Bug 4462 – core.cpuid: Need way to get total number of sockets/physical CPUs

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-07-14T12:33:00Z
Last change time
2011-08-12T20:47:06Z
Assigned to
sean
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2010-07-14T12:33:35Z
Test Program: import core.cpuid, std.stdio; void main() { writeln("Cores: ", coresPerCPU, " Threads: ", threadsPerCPU); } This prints the following on the machine in question: Cores: 1 Threads: 2 cat /proc/cpuinfo on same machine: processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7321.79 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 4 siblings : 2 core id : 4 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7314.82 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 3 siblings : 2 core id : 3 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.15 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 7 siblings : 2 core id : 7 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.01 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.01 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 4 siblings : 2 core id : 4 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.07 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 3 siblings : 2 core id : 3 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.13 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) MP CPU 3.66GHz stepping : 1 cpu MHz : 3657.825 cache size : 1024 KB physical id : 7 siblings : 2 core id : 7 cpu cores : 1 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl est tm2 cid cx16 xtpr bogomips : 7315.03 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management:
Comment #1 by russel — 2011-02-27T05:51:06Z
OK this bug has been open for 7 months and no action. Surely this is no an urgent blocking bug. Note also Issue 5612 which shows that the code is broken with 64-bit processors as well as multiple processors. Can cpuid.d be separated out so that we can work on it?
Comment #2 by clugdbug — 2011-02-27T06:52:01Z
(In reply to comment #0) > Test Program: > > import core.cpuid, std.stdio; > > void main() { > writeln("Cores: ", coresPerCPU, " Threads: ", threadsPerCPU); > } > > This prints the following on the machine in question: > > Cores: 1 Threads: 2 > > cat /proc/cpuinfo on same machine: > > processor : 0 > cpu cores : 1 > processor : 1 > cpu cores : 1 > processor : 2 > cpu cores : 1 That isn't enough information to demonstrate a bug. proc/cpuinfo reports 8 processors, each with one core each. Thus, I would expect coresPerCPU to be 1. Can you please give a valid test case? (Seems as though you'll need to display the number of processors).
Comment #3 by clugdbug — 2011-02-27T13:59:51Z
To clarify: core.cpuid does NOT provide the number of CPUs in the system. Hence, it does not give the total number of available cores. core.cpuid gives the number of cores in each CPU, and the number of hyperthreads in each core. This means that it has sufficient information to do cache blocking correctly. The total number of physical CPUs is required only when distributing work between cores (you never need to know it when scheduling within a core). Determining this is OS-dependent, and is actually pretty useless unless you also have some way of controlling the processor affinity, as well. Although this is stuff we will definitely need, it's quite a different situation from bugs in the existing code. Are there any cases where the reported values are actually wrong? Or is this a feature request for the number of physical CPUs?
Comment #4 by dsimcha — 2011-02-27T14:15:37Z
(In reply to comment #3) > To clarify: core.cpuid does NOT provide the number of CPUs in the system. > Hence, it does not give the total number of available cores. > ... > Are there any cases where the reported values are actually wrong? Or is this a > feature request for the number of physical CPUs? This is definitely an enhancement request then. As far as I can tell, the cores per CPU stuff is actually right (I think). It's just that I vaguely remember you stating the opposite at one point, that coresPerCPU actually is a misnomer and gives the total number of cores across all CPUs.
Comment #5 by dsimcha — 2011-08-12T20:47:06Z
std.parallelism.totalCPUs addresses this.