Thread overview
[Issue 6038] New: core.cpuid reports unexpected values for threadsPerCPU and hyperThreading
May 19, 2011
kai@redstar.de
May 19, 2011
Vladimir Panteleev
May 20, 2011
kai@redstar.de
May 20, 2011
kai@redstar.de
May 20, 2011
Vladimir Panteleev
May 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6038

           Summary: core.cpuid reports unexpected values for threadsPerCPU
                    and hyperThreading
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: kai@redstar.de


--- Comment #0 from kai@redstar.de 2011-05-19 13:04:57 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6038


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com


--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-05-19 16:54:41 PDT ---
Fix for i7: https://github.com/D-Programming-Language/druntime/pull/18

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6038



--- Comment #2 from kai@redstar.de 2011-05-20 09:02:02 PDT ---
Created an attachment (id=986)
Use level type instead of level number

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6038



--- Comment #3 from kai@redstar.de 2011-05-20 09:02:39 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6038



--- Comment #4 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-05-20 09:41:40 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6038


Alex Rønne Petersen <alex@lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex@lycus.org
         Resolution|                            |FIXED


--- Comment #5 from Alex Rønne Petersen <alex@lycus.org> 2012-10-10 03:27:58 CEST ---
Closing since the pull request was merged (and other comments speculation still
:).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------