<?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: How to get number of logical cores on Windows in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892293#M3849</link>
    <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/429282"&gt;anandakumaryg&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;BR /&gt;Hi pvonkaenel,&lt;BR /&gt;  Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;sysInfo.dwNumberOfProcessors returns number of logical processor not physical processor count. ProcCtrl::IsIntel() is identifying the processor as Intel.&lt;BR /&gt;&lt;BR /&gt; Could you suggest a simple way to get the physical processor count.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;I'm afraid that if ProcCtrl::NumLogicalProcs() is not returning the number of cores per die, then I'm not sure. Although, if you have the IPP library available, you could replace the call to ProcCtrl::NumLogicalProcs() with ippGetNumCoresOnDie().&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;</description>
    <pubDate>Tue, 26 May 2009 11:53:24 GMT</pubDate>
    <dc:creator>pvonkaenel</dc:creator>
    <dc:date>2009-05-26T11:53:24Z</dc:date>
    <item>
      <title>How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892278#M3834</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Does anybody know how to get number of logical processors on windows?&lt;/P&gt;
&lt;P&gt;I tried command GetSystemInfo(), but it gives number of physical processors.&lt;/P&gt;
&lt;P&gt;and GetLogicalProcessorInfo() is supported 2003 SP3 onwards.&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;BharatiPingale&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 06:52:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892278#M3834</guid>
      <dc:creator>bharatipingale</dc:creator>
      <dc:date>2008-12-02T06:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892279#M3835</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/188503/detecting-the-number-of-processors" target="_blank"&gt;http://stackoverflow.com/questions/188503/detecting-the-number-of-processors&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Should work on all versions of Windows with threading support, including some which didn't have adequate support for HyperThreading.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 13:27:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892279#M3835</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-12-02T13:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892280#M3836</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/331758"&gt;bharatipingale&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Does anybody know how to get number of logical processors on windows?&lt;/P&gt;
&lt;P&gt;I tried command GetSystemInfo(), but it gives number of physical processors.&lt;/P&gt;
&lt;P&gt;and GetLogicalProcessorInfo() is supported 2003 SP3 onwards.&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;I believe that GetSystemInfo() must return number of LOGICAL processors (i.e. HT processor -&amp;gt; 2 processors).&lt;/P&gt;
&lt;P&gt;Unfortunately I am unable to check this right now. Are you sure that it returns number of physical procesors (i.e. HT processor -&amp;gt; 1 processor)?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 14:38:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892280#M3836</guid>
      <dc:creator>Dmitry_Vyukov</dc:creator>
      <dc:date>2008-12-02T14:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892281#M3837</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/347331"&gt;Dmitriy Vyukov&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;I believe that GetSystemInfo() must return number of LOGICAL processors (i.e. HT processor -&amp;gt; 2 processors).&lt;/P&gt;
&lt;P&gt;Unfortunately I am unable to check this right now. Are you sure that it returns number of physical procesors (i.e. HT processor -&amp;gt; 1 processor)?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;If this helps GetSystemInfo does return the number of logical processors on all my systems.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2008 08:09:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892281#M3837</guid>
      <dc:creator>Emmanuel_W_</dc:creator>
      <dc:date>2008-12-05T08:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892282#M3838</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/188503/detecting-the-number-of-processors" target="_blank"&gt;http://stackoverflow.com/questions/188503/detecting-the-number-of-processors&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Should work on all versions of Windows with threading support, including some which didn't have adequate support for HyperThreading.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;If you just want the number of logical processors (currently booted/in-use by Windows), using GetSystemInfo will work. If you need to know more about the topology (packages, cores, HyperThreading), the "official" method can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration"&gt;http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Be wary of other implementations that use cpuid directly. (Using OS-provided info&lt;/P&gt;
&lt;P&gt;i should&lt;/P&gt;
&lt;P&gt;be ok).&lt;/P&gt;
&lt;P&gt;- Eric&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2008 20:23:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892282#M3838</guid>
      <dc:creator>Eric_P_Intel</dc:creator>
      <dc:date>2008-12-10T20:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892283#M3839</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/334321"&gt;Eric Palmer (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;&lt;BR /&gt;If you just want the number of logical processors (currently booted/in-use by Windows), using GetSystemInfo will work. If you need to know more about the topology (packages, cores, HyperThreading), the "official" method can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration"&gt;http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Be wary of other implementations that use cpuid directly. (Using OS-provided info&lt;/P&gt;
&lt;P&gt;i should&lt;/P&gt;
&lt;P&gt;be ok).&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;One must understand that this way is not "how to do in on &lt;STRONG&gt;Windows&lt;/STRONG&gt;", it's "how to do it on &lt;STRONG&gt;x86&lt;/STRONG&gt;". This won't work for Itanium. So, if one's system is otherwise portable to all Windows hardware, after employing such thick it will become x86 specific.&lt;/P&gt;
&lt;P&gt;For Linux it is a much more serious problem, because Linux also supports SPARC, PPC, ARM, etc.&lt;/P&gt;
&lt;P&gt;However the good news about CPUID is that it will work both on Windows and Linux (while you are on x86, and figure out how to transform asm/intrinsic syntax).&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2008 15:34:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892283#M3839</guid>
      <dc:creator>Dmitry_Vyukov</dc:creator>
      <dc:date>2008-12-24T15:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892284#M3840</link>
      <description>Hi bharatipingale,&lt;BR /&gt;&lt;BR /&gt;I don't know which programming language you are using. However, here are some tips for three programming languages:&lt;BR /&gt;&lt;BR /&gt;Java:&lt;BR /&gt;Runtime.getRuntime().availableProcessors();&lt;BR /&gt;&lt;BR /&gt;C#:&lt;BR /&gt;Environment.ProcessorCount;&lt;BR /&gt;&lt;BR /&gt;Visual Basic:&lt;BR /&gt;Environment.ProcessorCount&lt;BR /&gt;&lt;BR /&gt;These return the number of logical cores on Windows and in other operating systems.&lt;BR /&gt;For example, if you run these lines on a computer with a quad-core Core i7 supporting Hyper-Threading, it will return 8.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Gastn Hillar&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Mar 2009 01:03:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892284#M3840</guid>
      <dc:creator>gaston-hillar</dc:creator>
      <dc:date>2009-03-12T01:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892285#M3841</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/347331"&gt;Dmitriy Vyukov&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;I believe that GetSystemInfo() must return number of LOGICAL processors (i.e. HT processor -&amp;gt; 2 processors).&lt;/P&gt;
&lt;P&gt;Unfortunately I am unable to check this right now. Are you sure that it returns number of physical procesors (i.e. HT processor -&amp;gt; 1 processor)?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;I agree: I think GetSystemInfo() does return the number of logical processors. I wrote some code a few years ago to return various pieces of processor information which may help. As has already been mentioned, this code is x86 specific:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[cpp]//****************************************************************************
// FUNCTION: ProcCtrl::IsIntel()
// ACTION: Returns true if this is an Intel processor, otherwise false.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
bool ProcCtrl::IsIntel()
{
	unsigned int reg[5];
	char *stamp;

	// Make sure this is an Intel Processor
	__asm {
		mov eax, 00h
		cpuid
		mov reg[0], eax
		mov reg[4], ebx
		mov reg[8], edx
		mov reg[12], ecx
	}
	stamp = (char*)[1];
	stamp[12] = '&amp;#0;';
	if (strcmp("GenuineIntel", stamp) == 0)
		return true;

	return false;
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumProcs()
// ACTION: Return the total number of processors recognized by the OS.  If
//         hyper-threading is enabled, then a single physical processor will
//         be identified as multiple processors.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumProcs()
{
	// Get the total number of processoes in the computer
	SYSTEM_INFO sysInfo;
	GetSystemInfo(&amp;amp;sysInfo);
	return sysInfo.dwNumberOfProcessors;
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumPhysicalProcs()
// ACTION: Returns the number of physical processors in the computer.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumPhysicalProcs()
{
	// Get the number of logical processors per physical processor: this is
	// &amp;gt;1 if hyper-threading is enabled.
	I32 numLogicalProcs = NumLogicalProcs();

	// Get the total number of processoes on the system and devide it by
	// the number of logical processors per physical processor.
	return (NumProcs() / numLogicalProcs);
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumLogicalProcs()
// ACTION: Return the number of logical processors per physical processor.
//         This will be &amp;gt;1 if hyper-threading is enabled.  Note that this does
//         not return the total number of processors, just the number of logical
//         processors per physical processor.  Call NumProcs() to get the
//         total number of processors.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumLogicalProcs()
{
	// If this is not an Intel processor, there is no need to check further
	if (IsIntel() == false)
		return 1;

	// Determine if hyper-threading is available and enabled.  If it is, then
	// probe the number of logical processors.
	U32 regEdx, regEbx;
 	__asm {
		mov eax, 01h
		cpuid
		mov regEdx, edx
		mov regEbx, ebx
	}
	if (regEdx &amp;amp; BIT(28))
		return (regEbx &amp;amp; 0xff0000) &amp;gt;&amp;gt; 16;

	return 1;
}

[/cpp]&lt;/PRE&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Mar 2009 11:05:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892285#M3841</guid>
      <dc:creator>pvonkaenel</dc:creator>
      <dc:date>2009-03-12T11:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892286#M3842</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Intel C++ is supposed to support standard C++ OpenMP syntax at the next major release, allowing use of omp_get_num_procs in a num_threads specification:&lt;BR /&gt;&lt;BR /&gt;#ifdef _OPENMP&lt;BR /&gt;#include &lt;OMP.H&gt;&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;........&lt;BR /&gt;&lt;BR /&gt;#pragma omp parallel for num_threads(min(4,omp_get_num_procs()))&lt;BR /&gt;&lt;BR /&gt;For now, you can write it out, C style. The Fortran equivalent to the above works, even in (linux) gfortran now.&lt;BR /&gt;&lt;BR /&gt;I'm not very excited about the recommendations to use non-standard C++ syntax with processor and compiler dependent asm.&lt;BR /&gt;&lt;/OMP.H&gt;</description>
      <pubDate>Thu, 12 Mar 2009 13:09:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892286#M3842</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-03-12T13:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892287#M3843</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; I'm not very excited about the recommendations to use non-standard C++ syntax with processor and compiler dependent asm.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Non-standard C++ syntax or non-standard C++ functions and extensions, what's the difference? Results is exactly the same - non-portable code. Is it possible to get standard way to get number of processors from the language which does not support multi-threading? All bets are on C++09, when ICC will support C++09 threading extensions? So that we will be able to use std::thread::hardware_concurrency().&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 06:46:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892287#M3843</guid>
      <dc:creator>Dmitry_Vyukov</dc:creator>
      <dc:date>2009-03-13T06:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892288#M3844</link>
      <description>&lt;DIV style="margin:0px;"&gt;Hi bharatipingale,&lt;BR /&gt;&lt;BR /&gt;This post &lt;A title="http://software.intel.com/en-us/articles/hyper-threading-technology-multi-core-and-mobile-intel-pentium-processor-m-toolbox/" href="http://software.intel.com/en-us/articles/hyper-threading-technology-multi-core-and-mobile-intel-pentium-processor-m-toolbox/"&gt;http://software.intel.com/en-us/articles/hyper-threading-technology-multi-core-and-mobile-intel-pentium-processor-m-toolbox/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
can also help you. It uses C++ and a library to detect logical and physical cores.&lt;BR /&gt;&lt;BR /&gt;I think you have a lot of options to work with!&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Gastn</description>
      <pubDate>Mon, 16 Mar 2009 19:36:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892288#M3844</guid>
      <dc:creator>gaston-hillar</dc:creator>
      <dc:date>2009-03-16T19:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892289#M3845</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/414649"&gt;pvonkaenel&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;I agree: I think GetSystemInfo() does return the number of logical processors. I wrote some code a few years ago to return various pieces of processor information which may help. As has already been mentioned, this code is x86 specific:&lt;BR /&gt;&lt;BR /&gt;
&lt;/EM&gt;&lt;PRE&gt;&lt;EM&gt;[cpp]//****************************************************************************
// FUNCTION: ProcCtrl::IsIntel()
// ACTION: Returns true if this is an Intel processor, otherwise false.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
bool ProcCtrl::IsIntel()
{
	unsigned int reg[5];
	char *stamp;

	// Make sure this is an Intel Processor
	__asm {
		mov eax, 00h
		cpuid
		mov reg[0], eax
		mov reg[4], ebx
		mov reg[8], edx
		mov reg[12], ecx
	}
	stamp = (char*)[1];
	stamp[12] = '&amp;#0;';
	if (strcmp("GenuineIntel", stamp) == 0)
		return true;

	return false;
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumProcs()
// ACTION: Return the total number of processors recognized by the OS.  If
//         hyper-threading is enabled, then a single physical processor will
//         be identified as multiple processors.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumProcs()
{
	// Get the total number of processoes in the computer
	SYSTEM_INFO sysInfo;
	GetSystemInfo(&amp;amp;sysInfo);
	return sysInfo.dwNumberOfProcessors;
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumPhysicalProcs()
// ACTION: Returns the number of physical processors in the computer.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumPhysicalProcs()
{
	// Get the number of logical processors per physical processor: this is
	// &amp;gt;1 if hyper-threading is enabled.
	I32 numLogicalProcs = NumLogicalProcs();

	// Get the total number of processoes on the system and devide it by
	// the number of logical processors per physical processor.
	return (NumProcs() / numLogicalProcs);
}

//****************************************************************************
// FUNCTION: ProcCtrl::NumLogicalProcs()
// ACTION: Return the number of logical processors per physical processor.
//         This will be &amp;gt;1 if hyper-threading is enabled.  Note that this does
//         not return the total number of processors, just the number of logical
//         processors per physical processor.  Call NumProcs() to get the
//         total number of processors.
// EXPORT: Public
// HISTORY:
//  Date       Author              Description
// 10/25/2004   Peter von Kaenel    created
//****************************************************************************
I32 ProcCtrl::NumLogicalProcs()
{
	// If this is not an Intel processor, there is no need to check further
	if (IsIntel() == false)
		return 1;

	// Determine if hyper-threading is available and enabled.  If it is, then
	// probe the number of logical processors.
	U32 regEdx, regEbx;
 	__asm {
		mov eax, 01h
		cpuid
		mov regEdx, edx
		mov regEbx, ebx
	}
	if (regEdx &amp;amp; BIT(28))
		return (regEbx &amp;amp; 0xff0000) &amp;gt;&amp;gt; 16;

	return 1;
}

[/cpp]&lt;/EM&gt;&lt;/PRE&gt;
&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;</description>
      <pubDate>Fri, 22 May 2009 09:17:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892289#M3845</guid>
      <dc:creator>anandakumaryg</dc:creator>
      <dc:date>2009-05-22T09:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892290#M3846</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/429282"&gt;anandakumaryg&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;I have tried the above sample to get the number of processor available in my PC. Now I have two processor with 8 cores per processor. My problem is m_dwNumberofprocessor and logical processor are same, so when i divide the numberofprocessor/logicalprocessor, I am getting 1. But I should get 2. &lt;BR /&gt;&lt;BR /&gt;I followedd the logic given above.&lt;BR /&gt;&lt;BR /&gt;Please help me out to solve this issue.</description>
      <pubDate>Fri, 22 May 2009 09:22:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892290#M3846</guid>
      <dc:creator>anandakumaryg</dc:creator>
      <dc:date>2009-05-22T09:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892291#M3847</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/429282"&gt;anandakumaryg&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;BR /&gt;I have tried the above sample to get the number of processor available in my PC. Now I have two processor with 8 cores per processor. My problem is m_dwNumberofprocessor and logical processor are same, so when i divide the numberofprocessor/logicalprocessor, I am getting 1. But I should get 2. &lt;BR /&gt;&lt;BR /&gt;I followedd the logic given above.&lt;BR /&gt;&lt;BR /&gt;Please help me out to solve this issue.&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;I'm afraid I no longer have a multi-die computer to test this out on, but let's see what we can figure out. What exactly is being returned in sysInfo.dwNumberOfProcessors? Also, what is ProcCtrl::NumLogicalProcs() returning? I'm wondering if ProcCtrl::IsIntel() is not identifying your machine as an Intel based machine.&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;</description>
      <pubDate>Fri, 22 May 2009 10:57:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892291#M3847</guid>
      <dc:creator>pvonkaenel</dc:creator>
      <dc:date>2009-05-22T10:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892292#M3848</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/414649"&gt;pvonkaenel&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;I'm afraid I no longer have a multi-die computer to test this out on, but let's see what we can figure out. What exactly is being returned in sysInfo.dwNumberOfProcessors? Also, what is ProcCtrl::NumLogicalProcs() returning? I'm wondering if ProcCtrl::IsIntel() is not identifying your machine as an Intel based machine.&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Hi pvonkaenel,&lt;BR /&gt;  Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;sysInfo.dwNumberOfProcessors returns number of logical processor not physical processor count. ProcCtrl::IsIntel() is identifying the processor as Intel.&lt;BR /&gt;&lt;BR /&gt; Could you suggest a simple way to get the physical processor count.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 May 2009 05:05:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892292#M3848</guid>
      <dc:creator>anandakumaryg</dc:creator>
      <dc:date>2009-05-25T05:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get number of logical cores on Windows</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892293#M3849</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/429282"&gt;anandakumaryg&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;BR /&gt;Hi pvonkaenel,&lt;BR /&gt;  Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;sysInfo.dwNumberOfProcessors returns number of logical processor not physical processor count. ProcCtrl::IsIntel() is identifying the processor as Intel.&lt;BR /&gt;&lt;BR /&gt; Could you suggest a simple way to get the physical processor count.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;I'm afraid that if ProcCtrl::NumLogicalProcs() is not returning the number of cores per die, then I'm not sure. Although, if you have the IPP library available, you could replace the call to ProcCtrl::NumLogicalProcs() with ippGetNumCoresOnDie().&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;</description>
      <pubDate>Tue, 26 May 2009 11:53:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/How-to-get-number-of-logical-cores-on-Windows/m-p/892293#M3849</guid>
      <dc:creator>pvonkaenel</dc:creator>
      <dc:date>2009-05-26T11:53:24Z</dc:date>
    </item>
  </channel>
</rss>

