<?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 Re: TSC frequency computation in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/TSC-frequency-computation/m-p/1193435#M7554</link>
    <description>&lt;P&gt;The method based on CPUID is a new one and is probably not supported on a processor as old as Ivy Bridge?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have any CPUID dumps on Ivy Bridge systems, but you should certainly check the value returned in %eax by CPUID with an initial %eax value of 0x0. &amp;nbsp;This will be the maximum %eax value supported for "basic" CPUID information. &amp;nbsp; My systems before Skylake Xeon all have maximum values smaller than 0x15:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Westmere: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x0b&lt;/LI&gt;
&lt;LI&gt;Sandy Bridge: &amp;nbsp; 0x0d&lt;/LI&gt;
&lt;LI&gt;Haswell: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x0f&lt;/LI&gt;
&lt;LI&gt;Broadwell: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x14&lt;/LI&gt;
&lt;LI&gt;Skylake Xeon: &amp;nbsp; 0x16&lt;/LI&gt;
&lt;LI&gt;CascadeLake: &amp;nbsp; 0x16&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;On a Cascade Lake Xeon system, CPUID with %eax=0x15 returns&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;   0x00000015 0x00: eax=0x00000002 ebx=0x000000d8 ecx=0x00000000 edx=0x00000000
&lt;/LI-CODE&gt;
&lt;P&gt;So even these relatively new processors don't provide information about the "crystal clock frequency" in ECX. &amp;nbsp;The EBX and EAX values show a multiplier of 216/2. &amp;nbsp;Given the known TSC clock of 2700 MHz, these imply a "crystal clock frequency" of 25 MHz.&lt;/P&gt;
&lt;P&gt;On the same system, CPUID with EAX=0x16 returns:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;   0x00000016 0x00: eax=0x00000a8c ebx=0x00000fa0 ecx=0x00000064 edx=0x00000000&lt;/LI-CODE&gt;
&lt;P&gt;EAX gives the CPU base frequency in MHz: 0xa8c = 2700&lt;BR /&gt;EBX gives the maximum CPU frequency: 0xfa0 = 4000&lt;BR /&gt;ECX gives the "bus" frequency in MHz: 0x64 = 100&lt;/P&gt;
&lt;P&gt;Note that the "crystal" frequency and the "bus" frequency are not the same. &amp;nbsp;This is reflected in the behavior of the performance counters for Reference Cycles Not Halted. &amp;nbsp;In previous processors this counter would increment by the CPU multiplier ratio once every "tick" of the "base clock" -- i.e., increment by 27 every 10 nanoseconds (for a 100 MHz base clock). &amp;nbsp; On SKX/CLX, the Reference Cycles Not Halted now increments only once every "crystal clock" cycles -- e.g., with a 2700 MHz TSC and a 25 MHz "crystal clock", the counter increments by 108 every 40 ns.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 15:34:25 GMT</pubDate>
    <dc:creator>McCalpinJohn</dc:creator>
    <dc:date>2020-07-18T15:34:25Z</dc:date>
    <item>
      <title>TSC frequency computation</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/TSC-frequency-computation/m-p/1193432#M7553</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;To compute the average frequency, two counters are needed : IA32_APERF and IA32_MPERF&lt;/P&gt;
&lt;P&gt;According to Intel specifications Volume 3 section 14.5.5, the average frequency is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta ((IA32_APERF) / delta (IA32_MPERF)) * (TSC frequency)&lt;/P&gt;
&lt;P&gt;According to Volume 3, there are two methods to compute TSC frequency:&lt;/P&gt;
&lt;P&gt;1°) To compute "TSC frequency", we need to know the "nominal core crystal clock frequency":&lt;/P&gt;
&lt;P&gt;Section 18.7.3 (Volume 3 specifications Intel) says that Nominal TSC frequency is obtained from (CPUID.15H.ECX[31:0] * CPUID.15H.EBX[31:0] ) / (CPUID.15H.EAX[31:0])&lt;/P&gt;
&lt;P&gt;2°) To compute "TSC frequency", we can use MSR_PLATFORM_INFO[15&amp;nbsp;:8]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the first method (ivy bridge microarchitecture) : "TSC frequency" = ecx*(ebx/eax)&amp;nbsp;= 98889 Hz&lt;/P&gt;
&lt;P&gt;Indeed, the output of "cpuid -l0x15" is :&lt;/P&gt;
&lt;P&gt;eax = 00000007 (hexa)&lt;/P&gt;
&lt;P&gt;ebx = 00000340 (hexa)&lt;/P&gt;
&lt;P&gt;ecx = 00000340 (hexa)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the second method&lt;/P&gt;
&lt;P&gt;MSR_PLATFORM_INFO[15&amp;nbsp;:8]&amp;nbsp;= 20&lt;/P&gt;
&lt;P&gt;Indeed, the output of rdmsr 0xCE is :&lt;/P&gt;
&lt;P&gt;c10e4811400&lt;/P&gt;
&lt;P&gt;TSC frequency = 20 * 100 MHz&lt;/P&gt;
&lt;P&gt;TSC frequency = 2000 MHz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the second method, TSC frequency is much more higher (x 10 000) than its value computed with the first method&lt;/P&gt;
&lt;P&gt;What is the correct value?&lt;/P&gt;
&lt;P&gt;best regards&lt;/P&gt;
&lt;P&gt;joel penhoat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 13:45:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/TSC-frequency-computation/m-p/1193432#M7553</guid>
      <dc:creator>penhoat__joel</dc:creator>
      <dc:date>2020-07-18T13:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: TSC frequency computation</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/TSC-frequency-computation/m-p/1193435#M7554</link>
      <description>&lt;P&gt;The method based on CPUID is a new one and is probably not supported on a processor as old as Ivy Bridge?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have any CPUID dumps on Ivy Bridge systems, but you should certainly check the value returned in %eax by CPUID with an initial %eax value of 0x0. &amp;nbsp;This will be the maximum %eax value supported for "basic" CPUID information. &amp;nbsp; My systems before Skylake Xeon all have maximum values smaller than 0x15:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Westmere: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x0b&lt;/LI&gt;
&lt;LI&gt;Sandy Bridge: &amp;nbsp; 0x0d&lt;/LI&gt;
&lt;LI&gt;Haswell: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x0f&lt;/LI&gt;
&lt;LI&gt;Broadwell: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0x14&lt;/LI&gt;
&lt;LI&gt;Skylake Xeon: &amp;nbsp; 0x16&lt;/LI&gt;
&lt;LI&gt;CascadeLake: &amp;nbsp; 0x16&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;On a Cascade Lake Xeon system, CPUID with %eax=0x15 returns&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;   0x00000015 0x00: eax=0x00000002 ebx=0x000000d8 ecx=0x00000000 edx=0x00000000
&lt;/LI-CODE&gt;
&lt;P&gt;So even these relatively new processors don't provide information about the "crystal clock frequency" in ECX. &amp;nbsp;The EBX and EAX values show a multiplier of 216/2. &amp;nbsp;Given the known TSC clock of 2700 MHz, these imply a "crystal clock frequency" of 25 MHz.&lt;/P&gt;
&lt;P&gt;On the same system, CPUID with EAX=0x16 returns:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;   0x00000016 0x00: eax=0x00000a8c ebx=0x00000fa0 ecx=0x00000064 edx=0x00000000&lt;/LI-CODE&gt;
&lt;P&gt;EAX gives the CPU base frequency in MHz: 0xa8c = 2700&lt;BR /&gt;EBX gives the maximum CPU frequency: 0xfa0 = 4000&lt;BR /&gt;ECX gives the "bus" frequency in MHz: 0x64 = 100&lt;/P&gt;
&lt;P&gt;Note that the "crystal" frequency and the "bus" frequency are not the same. &amp;nbsp;This is reflected in the behavior of the performance counters for Reference Cycles Not Halted. &amp;nbsp;In previous processors this counter would increment by the CPU multiplier ratio once every "tick" of the "base clock" -- i.e., increment by 27 every 10 nanoseconds (for a 100 MHz base clock). &amp;nbsp; On SKX/CLX, the Reference Cycles Not Halted now increments only once every "crystal clock" cycles -- e.g., with a 2700 MHz TSC and a 25 MHz "crystal clock", the counter increments by 108 every 40 ns.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 15:34:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/TSC-frequency-computation/m-p/1193435#M7554</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2020-07-18T15:34:25Z</dc:date>
    </item>
  </channel>
</rss>

