www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6038] New: core.cpuid reports unexpected values for threadsPerCPU and hyperThreading

reply d-bugmail puremagic.com writes:
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



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
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6038


Vladimir Panteleev <thecybershadow gmail.com> changed:

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



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 19 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6038




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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6038




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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6038




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: -------
May 20 2011
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 09 2012