Expectations: From issue 4462 I got the definitions:
coresPerCPU = number of logical cores in a (physical) CPU
threadsPerCPU = number of hyperthreads in each core (name is misleading)
My Core i7 Q820 has 4 physical cores in the CPU and each core can handle 2 hyperthreads. From core.cpuid, I get the following results:
threadsPerCPU = 2
coresPerCPU = 8
hyperThreading = false
I would expect hyperThreading = true in this case.
Contrast this with my Core2 T7600 which is a dualcore CPU with no hyperthreading. core.cpuid reports:
threadsPerCPU = 2
coresPerCPU = 2
hyperThreading = false
I would expect threadsPerCPU = 1 in this case.
Comment #1 by dlang-bugzilla — 2011-05-19T16:54:41Z
Created attachment 986
Use level type instead of level number
Comment #3 by kai — 2011-05-20T09:02:39Z
With the fix, I get the right numbers. Thanks.
(Now, threadsPerCPU() returns the total number of logical thread in the CPU. With this interpretation, the numbers for the
Core Duo2 are ok, too.)
In an attempt to fix it by myself, I read the latest Instruction Set Manual from Intel. From my understanding,
there is no hardcoded relationship between the level number (bits [7:0] in ECX) and the level type (bits [15:8] in ECX).
E.g. returning the number of cores for level number 0 and the number of threads per core for level number 1 would also
match the specification.
The attached patch uses the level type instead of the level number to fix this.
Comment #4 by dlang-bugzilla — 2011-05-20T09:41:40Z
I noticed that myself, but from reading the docs, I believe that the type will always correspond to the level, so the returned type is simply informative. I guess we won't know for sure until we see a CPU which implements this but acts differently than the i7.
Comment #5 by alex — 2012-10-09T18:27:58Z
Closing since the pull request was merged (and other comments speculation still :).