<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Measuring FLOPS on intel i7 Skylake CPU using PCM in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114337#M6081</link>
    <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;How can I use PCM to measure FLOPS of part of my program?&amp;nbsp;&lt;SPAN style="font-size: 1em;"&gt;I'm trying to specify custom events as bellow:&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:cpp;"&gt;PCM::CustomCoreEventDescription events[NB_EVENTS];
double values[NB_EVENTS+1];
events[1].event_number = 0x10;
events[1].umask_value  = 0x01;
events[0].event_number = 0x10;
events[0].umask_value  = 0x80;
events[2].event_number = 0x10;
events[2].umask_value  = 0x10;
events[3].event_number = 0x11;
events[3].umask_value  = 0x02;

PCM * m = PCM::getInstance();
m-&amp;gt;disableJKTWorkaround();
m-&amp;gt;resetPMU();
if (m-&amp;gt;program(PCM::CUSTOM_CORE_EVENTS,&amp;amp;events) != PCM::Success)  return;

SystemCounterState before_sstate = getSystemCounterState();
compute(h, n, k, A, B, C);
SystemCounterState after_sstate = getSystemCounterState();

for ( int i=0; i &amp;lt; NB_EVENTS; i++ ) {
        uint64 value = getNumberOfCustomEvents(i, pcm_before, pcm_after);
        values[i+1] = (double) value;
        printf("Event %0d: 0x%04x0x%04x: %lld\n", i+1, events&lt;I&gt;.event_number, events&lt;I&gt;.umask_value, value);
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This results in:&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;Event 1: 0x00100x0080: 0&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 2: 0x00100x0001: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 3: 0x00100x0010: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 4: 0x00110x0002: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;Is there something wrong with the way I'm setting the events? or is it the masks? I can't find a clear documentation of the events number and masks for floating point operations on Skylake (I'm using intel i7 6700HQ)&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 16:48:59 GMT</pubDate>
    <dc:creator>Huda_I_</dc:creator>
    <dc:date>2017-03-08T16:48:59Z</dc:date>
    <item>
      <title>Measuring FLOPS on intel i7 Skylake CPU using PCM</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114337#M6081</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;How can I use PCM to measure FLOPS of part of my program?&amp;nbsp;&lt;SPAN style="font-size: 1em;"&gt;I'm trying to specify custom events as bellow:&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:cpp;"&gt;PCM::CustomCoreEventDescription events[NB_EVENTS];
double values[NB_EVENTS+1];
events[1].event_number = 0x10;
events[1].umask_value  = 0x01;
events[0].event_number = 0x10;
events[0].umask_value  = 0x80;
events[2].event_number = 0x10;
events[2].umask_value  = 0x10;
events[3].event_number = 0x11;
events[3].umask_value  = 0x02;

PCM * m = PCM::getInstance();
m-&amp;gt;disableJKTWorkaround();
m-&amp;gt;resetPMU();
if (m-&amp;gt;program(PCM::CUSTOM_CORE_EVENTS,&amp;amp;events) != PCM::Success)  return;

SystemCounterState before_sstate = getSystemCounterState();
compute(h, n, k, A, B, C);
SystemCounterState after_sstate = getSystemCounterState();

for ( int i=0; i &amp;lt; NB_EVENTS; i++ ) {
        uint64 value = getNumberOfCustomEvents(i, pcm_before, pcm_after);
        values[i+1] = (double) value;
        printf("Event %0d: 0x%04x0x%04x: %lld\n", i+1, events&lt;I&gt;.event_number, events&lt;I&gt;.umask_value, value);
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This results in:&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;Event 1: 0x00100x0080: 0&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 2: 0x00100x0001: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 3: 0x00100x0010: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 4: 0x00110x0002: 0&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;Is there something wrong with the way I'm setting the events? or is it the masks? I can't find a clear documentation of the events number and masks for floating point operations on Skylake (I'm using intel i7 6700HQ)&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 16:48:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114337#M6081</guid>
      <dc:creator>Huda_I_</dc:creator>
      <dc:date>2017-03-08T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114338#M6082</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you can use &lt;A href="https://github.com/opcm/pcm"&gt;pmu-query.py&lt;/A&gt;&amp;nbsp;python script to search/query available events on your processor. You can use the event/umask in your code or in PCM pcm-core.x utility as a command line parameter to monitor the events of interest.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Roman&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 08:41:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114338#M6082</guid>
      <dc:creator>Roman_D_Intel</dc:creator>
      <dc:date>2017-03-09T08:41:40Z</dc:date>
    </item>
    <item>
      <title>It looks like you are trying</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114339#M6083</link>
      <description>&lt;P&gt;It looks like you are trying to use the old performance counter events 0x10 and 0x11 that were disabled starting with Haswell.&amp;nbsp; As you can see, you are still allowed to program these event numbers, but they always return zeros.&lt;/P&gt;

&lt;P&gt;New FP performance counters were added starting with Broadwell.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For Skylake these are documented at &lt;A href="https://download.01.org/perfmon/SKL/Skylake_core_V24.json" target="_blank"&gt;https://download.01.org/perfmon/SKL/Skylake_core_V24.json&lt;/A&gt;, with additional information on how to scale the results at &lt;A href="https://download.01.org/perfmon/SKL/Skylake_FP_ARITH_INST_V24.json" target="_blank"&gt;https://download.01.org/perfmon/SKL/Skylake_FP_ARITH_INST_V24.json&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 15:59:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114339#M6083</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2017-03-09T15:59:40Z</dc:date>
    </item>
    <item>
      <title>Thank you for you replies!</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114340#M6084</link>
      <description>&lt;P&gt;Thank you for you replies!&lt;/P&gt;

&lt;P&gt;I've updated the events and masks numbers. Unfortunately, I still can't interpret the results. For example:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;PCM::CustomCoreEventDescription events[NB_EVENTS];
double values[NB_EVENTS+1];
// FP_ARITH_INST_RETIRED.SCALAR_DOUBLE
events[0].event_number = 0xC7;
events[0].umask_value  = 0x01;
// FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE
events[1].event_number = 0xC7;
events[1].umask_value  = 0x04;
// FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE
events[2].event_number = 0xC7;
events[2].umask_value  = 0x10;

PCM * m = PCM::getInstance();
m-&amp;gt;disableJKTWorkaround();
m-&amp;gt;resetPMU();
PCM::ErrorCode status = m-&amp;gt;program(PCM::CUSTOM_CORE_EVENTS, events);

double aa=1,bb=2;
SystemCounterState before_sstate = getSystemCounterState();
aa = aa + bb;
SystemCounterState after_sstate = getSystemCounterState();

for ( int i=0; i &amp;lt; NB_EVENTS; i++ ) {
        uint64 value = getNumberOfCustomEvents(i, before_sstate, after_sstate);
        printf("Event %0d: 0x%04x0x%04x: %lld\n", i+1, events&lt;I&gt;.event_number, events&lt;I&gt;.umask_value, value);
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;The output:&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 1: 0x00c70x0001: 4609&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 2: 0x00c70x0004: 2236&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 0, 0);"&gt;&lt;SPAN style="font-variant-ligatures: no-common-ligatures"&gt;Event 3: 0x00c70x0010: 42&lt;/SPAN&gt;&lt;/P&gt;

&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV&gt;Cleary this doesn't&amp;nbsp; reflect the number in FLOPs of (aa=aa+bb;)&lt;/DIV&gt;

&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 09 Mar 2017 16:47:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114340#M6084</guid>
      <dc:creator>Huda_I_</dc:creator>
      <dc:date>2017-03-09T16:47:04Z</dc:date>
    </item>
    <item>
      <title>I am not sure how many FLOPS</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114341#M6085</link>
      <description>&lt;P&gt;I am not sure how many FLOPS you were expecting, but it is typically a good idea to have a loop with a controllable number of FLOPS so that you can look at expected vs reported values....&amp;nbsp;&lt;/P&gt;

&lt;P&gt;In a recent test, I used a version of the STREAM benchmark that I expected to generate slightly over 50.5 billion counts, and "perf stat" reported 50.875 billion counts using the 0x37 counters programmed with the "raw" events interface.&amp;nbsp;&amp;nbsp; I have not tested on a wide variety of systems or with all supported instruction sets, but the hardware counting looks accurate so far.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 21:46:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114341#M6085</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2017-03-09T21:46:44Z</dc:date>
    </item>
    <item>
      <title>I'm just measuring (a=a+b)</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114342#M6086</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I'm just measuring (a=a+b) where a and b are just double numbers, as in below:&lt;/SPAN&gt;&lt;/P&gt;

&lt;DIV class="line alt2" style="color: rgb(96, 96, 96); margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; background-image: none !important; background-color: rgb(248, 248, 248) !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;"&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV class="line alt2" style="color: rgb(96, 96, 96); margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; background-image: none !important; background-color: rgb(248, 248, 248) !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; min-height: auto !important;"&gt;
	&lt;TABLE style="border-collapse: collapse !important; border: 0px !important; font-size: 1em !important; margin-top: 0px !important; margin-bottom: 0px !important; width: auto !important; vertical-align: baseline !important; outline: 0px !important; background-image: none !important; float: none !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; line-height: 1.1em !important; min-height: auto !important;"&gt;
		&lt;TBODY style="border: 0px !important; outline: 0px !important; background-image: none !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-size: 1em !important; min-height: auto !important;"&gt;&lt;/TBODY&gt;
	&lt;/TABLE&gt;
&lt;/DIV&gt;

&lt;PRE class="brush:cpp;"&gt;double aa=1,bb=2;
SystemCounterState before_sstate = getSystemCounterState();
aa = aa + bb;
SystemCounterState after_sstate = getSystemCounterState();
&lt;/PRE&gt;

&lt;P&gt;and hence, I'm expecting much smaller counts than what I'm getting (shown in my previous post)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:37:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114342#M6086</guid>
      <dc:creator>Huda_I_</dc:creator>
      <dc:date>2017-03-10T01:37:40Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114343#M6087</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;getSystemCounterState collects statistics from all cores on the system, not just your code. PCM is a &lt;STRONG&gt;processor-centric&lt;/STRONG&gt; API (no mapping to user thread). Though you can limit collection to a certain logical core (&lt;A href="https://intel-pcm-api-documentation.github.io/classPCM.html#a4ed1c64e3cb00c76851e3373a1fa54a3"&gt;getCoreCounterState&lt;/A&gt;), then you need to pin your thread to this logical core (i.e. with &lt;A href="http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html" style="color: rgb(102, 0, 153); cursor: pointer; text-decoration: underline;"&gt;pthread_setaffinity_np&lt;/A&gt;&amp;nbsp;call or run your program from taskset utility on Linux), but this also does not guarantee that OS will not interrupt your program and schedule something else on this logical core during the measurement. Other aspect is that the PCM API itself might have some FP computation inside that adds up to the measured statistics.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Following the John's advice you can significantly increase the amount of computation in the measurement region to minimize the relative side-effects.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Roman&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:16:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Measuring-FLOPS-on-intel-i7-Skylake-CPU-using-PCM/m-p/1114343#M6087</guid>
      <dc:creator>Roman_D_Intel</dc:creator>
      <dc:date>2017-03-10T08:16:51Z</dc:date>
    </item>
  </channel>
</rss>

