<?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 how to get accurate number of cores/threads using cpuid on Core in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813503#M1079</link>
    <description>&lt;P&gt;Welcome!&lt;/P&gt;&lt;P&gt;CPUID.4.EAX[31:26] is in fact the *maximum* number of APIC IDs for the package's cores.&lt;/P&gt;You will need to enumerate all APIC IDs, split them into package/core/logical bitfields, and count how many unique 'core' values there are.&lt;BR /&gt;Code to do this may be found at &lt;A href="http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/arch/x86_x64/topology.cpp" target="_blank"&gt;http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/arch/x86_x64/topology.cpp&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As to the EAX=0xB failure, __cpuid may be rejecting 'InfoType' it doesn't know about. I would recommend another means of accessing CPUID, particularly because it doesn't seem possible to set ECX otherwise (how are you doing that?).&lt;BR /&gt;&lt;BR /&gt;HTH+HAND&lt;BR /&gt;</description>
    <pubDate>Fri, 01 Oct 2010 21:21:11 GMT</pubDate>
    <dc:creator>janwassenberg</dc:creator>
    <dc:date>2010-10-01T21:21:11Z</dc:date>
    <item>
      <title>how to get accurate number of cores/threads using cpuid on Core i7</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813502#M1078</link>
      <description>All the literature to which I've been exposed indicates that I can ascertain the number of cores on a package using:&lt;BR /&gt;&lt;BR /&gt;CPUID.4.EAX[31:26]+1&lt;BR /&gt;&lt;BR /&gt;and I have had great results on a broad spectrum of processors on which I've run my code.&lt;BR /&gt;&lt;BR /&gt;But when I run the same code on my Core i7 820QM (which has 4 cores according to &lt;A href="http://ark.intel.com/Product.aspx?id=43124" target="_blank"&gt;http://ark.intel.com/Product.aspx?id=43124&lt;/A&gt; ), it indicates that there are 8 cores, not 4.&lt;BR /&gt;&lt;BR /&gt;Similarly, the processor is supposed to have 8 total threads (per the same spec page linked above), but when I use the recommended cpuid call:&lt;BR /&gt;&lt;BR /&gt;CPUID.1.EBX[23:16]&lt;BR /&gt;&lt;BR /&gt;I get 16 threads instead of 8.&lt;BR /&gt;&lt;BR /&gt;I'd heard that it was possible to infer similar information using CPUID.0Bh (thus accessing the x2apic processor topology functions), and while CPUID.0.EAX does yield "11", I also found reference that one could check if CPUID.1.ECX[21] to see if x2apic was enabled, but on my processor that bit is 0. Sure enough, calls to CPUID.0Bh with any value of ECX have EAX=0x0 and EBX=0x0.&lt;BR /&gt;&lt;BR /&gt;Anyone know why I'm getting inconsistent results here?&lt;BR /&gt;&lt;BR /&gt;I'm running the software on 64-bit Windows 7, using the __cpuid function from &lt;INTRIN.H&gt; in Visual Studio 2008, e.g,:&lt;BR /&gt;&lt;BR /&gt;// retrieve number of APIC IDs for the package ("cores")&lt;BR /&gt;int CPUInfo[4];&lt;BR /&gt;__cpuid(CPUInfo, 4);&lt;BR /&gt;return ((CPUInfo[0] &amp;amp; 0xfc000000) &amp;gt;&amp;gt; 26) + 1;&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;/INTRIN.H&gt;</description>
      <pubDate>Fri, 01 Oct 2010 19:43:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813502#M1078</guid>
      <dc:creator>erikcz</dc:creator>
      <dc:date>2010-10-01T19:43:05Z</dc:date>
    </item>
    <item>
      <title>how to get accurate number of cores/threads using cpuid on Core</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813503#M1079</link>
      <description>&lt;P&gt;Welcome!&lt;/P&gt;&lt;P&gt;CPUID.4.EAX[31:26] is in fact the *maximum* number of APIC IDs for the package's cores.&lt;/P&gt;You will need to enumerate all APIC IDs, split them into package/core/logical bitfields, and count how many unique 'core' values there are.&lt;BR /&gt;Code to do this may be found at &lt;A href="http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/arch/x86_x64/topology.cpp" target="_blank"&gt;http://trac.wildfiregames.com/browser/ps/trunk/source/lib/sysdep/arch/x86_x64/topology.cpp&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As to the EAX=0xB failure, __cpuid may be rejecting 'InfoType' it doesn't know about. I would recommend another means of accessing CPUID, particularly because it doesn't seem possible to set ECX otherwise (how are you doing that?).&lt;BR /&gt;&lt;BR /&gt;HTH+HAND&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Oct 2010 21:21:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813503#M1079</guid>
      <dc:creator>janwassenberg</dc:creator>
      <dc:date>2010-10-01T21:21:11Z</dc:date>
    </item>
    <item>
      <title>how to get accurate number of cores/threads using cpuid on Core</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813504#M1080</link>
      <description>thanks, I'll take a look at the code and see.&lt;BR /&gt;&lt;BR /&gt;As for passing ECX values, I'm using Microsoft's version __fastcall calling convention and passing my InfoType value as an argument to the method.</description>
      <pubDate>Sat, 02 Oct 2010 17:14:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813504#M1080</guid>
      <dc:creator>erikcz</dc:creator>
      <dc:date>2010-10-02T17:14:43Z</dc:date>
    </item>
    <item>
      <title>how to get accurate number of cores/threads using cpuid on Core</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813505#M1081</link>
      <description>Ah. Some of the CPUID functions (0x4, 0xB) require the ECX register to be initialized with an additional index. This usage does not seem to be supported by __cpuid.</description>
      <pubDate>Sun, 03 Oct 2010 09:29:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/how-to-get-accurate-number-of-cores-threads-using-cpuid-on-Core/m-p/813505#M1081</guid>
      <dc:creator>janwassenberg</dc:creator>
      <dc:date>2010-10-03T09:29:37Z</dc:date>
    </item>
  </channel>
</rss>

