digitalmars.D.bugs - [Issue 15299] New: gibberish CPU/processor/thread information
- via Digitalmars-d-bugs (62/62) Nov 06 2015 https://issues.dlang.org/show_bug.cgi?id=15299
https://issues.dlang.org/show_bug.cgi?id=15299 Issue ID: 15299 Summary: gibberish CPU/processor/thread information Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: 2krnk gmx.net For parallel computations I like to know the number of physical cores the computer system provides. For one, computation speed does not (significantly) increase if using more parallel threads than there are cores. Also, for longer running computations I like to keep one core free so that the system stays responsive. Unfortunately, the D libraries don't tell me want I need to know directly, but only in an obfuscated way - or rather, by means of optimistic second guessing. So there is an enhancement request hidden here. However, I filed it as a bug because the information I do get is highly misleading, if not to say plain wrong. My computer system has (i7-2600): 1 processor 4 physical cores 8 logical cores ( i.e. hyperthreading feature available) This is just using nomenclature most people can agree upon their meaning. Now this is what the D library functions tell me about my system (windows): std.parallelism.totalCPUs = 8 core.cpuid.coresPerCPU = 4 core.cpuid.threadsPerCPU = 8 core.cpuid.hyperThreading = true Only core.cpuid.hyperThreading is unambiguously correct. The rest is ... the horrors! Naturally, it is debatable what should be understood under the term "CPU". Most people and vendors mean what it used to mean before multi-processor architectures came up: the whole (multi-)processor chip that sits in one socket. AFAIK, technically speaking a CPU would refer to one physical core. a) If CPU == processor, the correct info would be std.parallelism.totalCPUs = 1 core.cpuid.coresPerCPU = 4 core.cpuid.threadsPerCPU = 8 Apparently this is not what the library functions report, mainly due to std.parallelism. Also: I have no way to test if the core.cpuid answer would be still correct on a multi-socket/multi-processor system... b) If CPU == physical cores, the correct info would be std.parallelism.totalCPUs = 4 core.cpuid.coresPerCPU = 1 core.cpuid.threadsPerCPU = 2 Now this is at total mismatch to the actual answers from the D libraries. And, of course, in this scenario "coresPerCPU" makes no sense as it will always be 1. However, the docs to std.parallelism indicate that this is the official D-meaning of "CPU" (totalCPUs): "total number of CPU cores available". Summary: (1) Neither interpretation (a) nor (b) provides the correct information. Seems like a simple inconsistency between std.parallelism and core.cpuid in combination with bad documentation. (2) This kind of information is irrelevant to the user anyway. Relevant information would be: (a) total number of physical cores and (b) number of logical cores or hyperthreading yes/no --
Nov 06 2015