[x265] [PATCH 2 of 2] pcm: print PCM statistics when csv is enabled and log level >= 3

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Fri May 8 12:05:35 CEST 2015


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1431078261 -19800
#      Fri May 08 15:14:21 2015 +0530
# Node ID 16fbf64badb142b32b6f9ac2b279120215b8af1d
# Parent  4203e7ac7d784a307d6d7174f69d96a86bc576c8
pcm: print PCM statistics when csv is enabled and log level >= 3

diff -r 4203e7ac7d78 -r 16fbf64badb1 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri May 08 11:22:28 2015 +0530
+++ b/source/encoder/encoder.cpp	Fri May 08 15:14:21 2015 +0530
@@ -237,7 +237,14 @@
                         fprintf(m_csvfpt, "RateFactor, ");
                     fprintf(m_csvfpt, "Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB),  List 0, List 1");
                     /* detailed performance statistics */
-                    fprintf(m_csvfpt, ", DecideWait (ms), Row0Wait (ms), Wall time (ms), Ref Wait Wall (ms), Total CTU time (ms), Stall Time (ms), Avg WPP, Row Blocks\n");
+                    fprintf(m_csvfpt, ", DecideWait (ms), Row0Wait (ms), Wall time (ms), Ref Wait Wall (ms), Total CTU time (ms), Stall Time (ms), Avg WPP, Row Blocks");
+#if ENABLE_PCM
+                    m_pcmInstance.init();
+                    if (!m_pcmInstance.status)
+                        fprintf(m_csvfpt, ", C0 (active) core residency, IPC, L3 Cache Hit Ratio, L2 Cache Hit Ratio\n");
+#else
+                    fprintf(m_csvfpt, "\n");
+#endif
                 }
                 else
                     fputs(summaryCSVHeader, m_csvfpt);
@@ -1447,6 +1454,10 @@
         else
             fputs(", 1", m_csvfpt);
         fprintf(m_csvfpt, ", %d", curEncoder->m_countRowBlocks);
+#if ENABLE_PCM
+        if (!m_pcmInstance.status)
+            m_pcmInstance.printCurState(m_csvfpt);
+#endif
         fprintf(m_csvfpt, "\n");
         fflush(stderr);
     }
@@ -1881,6 +1892,10 @@
     }
     else
         m_param->rc.qgSize = p->maxCUSize;
+#if ENABLE_PCM
+    if (!m_param->csvfn || m_param->logLevel < X265_LOG_FRAME)
+        x265_log(p, X265_LOG_WARNING, "PCM data collection enabled without detailed CSV logging option; will be ignored \n");
+#endif
 }
 
 void Encoder::allocAnalysis(x265_analysis_data* analysis)
diff -r 4203e7ac7d78 -r 16fbf64badb1 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Fri May 08 11:22:28 2015 +0530
+++ b/source/encoder/encoder.h	Fri May 08 15:14:21 2015 +0530
@@ -30,6 +30,10 @@
 #include "x265.h"
 #include "nal.h"
 
+#if ENABLE_PCM
+#include "profile/PCM/pcm.h"
+#endif
+
 struct x265_encoder {};
 
 namespace x265 {
@@ -105,6 +109,7 @@
     EncStats           m_analyzeI;
     EncStats           m_analyzeP;
     EncStats           m_analyzeB;
+    PCMStats           m_pcmInstance;
     FILE*              m_csvfpt;
     int64_t            m_encodeStartTime;
 
diff -r 4203e7ac7d78 -r 16fbf64badb1 source/profile/PCM/pcm.cpp
--- a/source/profile/PCM/pcm.cpp	Fri May 08 11:22:28 2015 +0530
+++ b/source/profile/PCM/pcm.cpp	Fri May 08 15:14:21 2015 +0530
@@ -19,4 +19,39 @@
  *
  * This program is also available under a commercial proprietary license.
  * For more information, contact us at license @ x265.com.
- *****************************************************************************/
\ No newline at end of file
+ *****************************************************************************/
+
+#include "pcm.h"
+
+namespace x265 {
+
+void PCMStats::init()
+{
+    pcm_instance = PCM::getInstance();
+    status = pcm_instance->program();
+    switch (status)
+    {
+    case PCM::Success:
+        break;
+    case PCM::MSRAccessDenied:
+        printf("Access to Intel(r) Performance Counter Monitor is denied (no MSR or PCI CFG space access)\n");
+    case PCM::PMUBusy:
+        printf("Access to Intel(r) Performance Counter Monitor is denied (Performance Monitoring Unit is occupied by other application)\n");
+    default:
+        printf("Access to Intel(r) Performance Counter Monitor is denied (Unknown error)\n");
+    }
+    if (!status)
+        beforeState = getSystemCounterState();
+}
+
+void PCMStats::printCurState(FILE* csv)
+{
+    afterState = getSystemCounterState();
+    fprintf(csv, ", %.3lf, %.3lf, %.3lf, %.3lf", getCoreCStateResidency(0, beforeState, afterState) * 100.0
+                                               , getCoreIPC(beforeState, afterState)
+                                               , getL3CacheHitRatio(beforeState, afterState)
+                                               , getL2CacheHitRatio(beforeState, afterState));
+    beforeState = afterState;
+}
+
+}
\ No newline at end of file
diff -r 4203e7ac7d78 -r 16fbf64badb1 source/profile/PCM/pcm.h
--- a/source/profile/PCM/pcm.h	Fri May 08 11:22:28 2015 +0530
+++ b/source/profile/PCM/pcm.h	Fri May 08 15:14:21 2015 +0530
@@ -26,4 +26,17 @@
 
 #include "cpucounters.h"
 
+namespace x265 {
+
+struct PCMStats
+{
+    PCM* pcm_instance;
+    PCM::ErrorCode status;
+    SystemCounterState beforeState;
+    SystemCounterState afterState;
+    void init();
+    void printCurState(FILE* csv);
+};
+
+}
 #endif
\ No newline at end of file


More information about the x265-devel mailing list