Getting # Physical CPUs

Don nospam at nospam.com
Wed Jul 14 12:11:05 PDT 2010


dsimcha wrote:
> == Quote from Don (nospam at nospam.com)'s article
>> dsimcha wrote:
>>> When I do parallel programming in D, it's nice to have a sane default for the
>>> number of threads.  The ideal number is the number of cores that can see the
>>> current address space.  core.cpuid provides coresPerCPU, but it doesn't appear
>>> to provide nPhysialCPUs or something similar, which would allow the total
>>> number of physical CPUs in the system to be determined.  Is there any easy way
>>> to determine this in D2?
>> coresPerCPU is a misnomer. It's actually the total number of cores. Will
>> fix.
> 
> Ok, then maybe this is a bug and belongs in bugzilla.  Here's a little  test
> program I wrote:

[snip]
Thanks, that's definitely a bug. The code in core.cpuid has not been 
tested on the most recent CPUs (Intel added a totally new method) and 
their documentation is quite convoluted. It's hard to get it right 
without an actual machine.


More information about the Digitalmars-d mailing list