I can already correctly detect the number of logical processors correctly on all three of these platforms.
To be able to detect the number of physical processors/cores correctly I'll have to detect if hyperthreading is supported AND active (or enabled if you prefer) and if so divide the number of logical processors by 2 to determine the number of physical processors.
Perphaps I should provide an example:
A quad core Intel CPU's with hyperthreading enabled has 4 physical cores, yet 8 logical processors (hyperthreading creates 4 more logical processors). So my current function would detect 8 instead of the desired 4.
My question therefore is if there is a way to detect whether hyperthreading is supported AND ENABLED?
If the number of logical processors is greater than physical processors (cores), then hyperthreading is enabled.
The main function of hyper-threading is to increase the number of independent instructions in the pipeline; it takes advantage of superscalar architecture, in which multiple instructions operate on separate data in parallel.
Use the hyptop command to obtain utilization data for threads while Linux runs with multithreading enabled. You can use the smt= and nosmt kernel parameters to control multithreading. By default, Linux in LPAR mode uses multithreading if it is provided by the hardware.
It's enabled by default, but it can be switched on and off from the BIOS environment by setting “Hyper-Threading Technology” to “Enable” or “Disable”. Note that Intel® Hyper-Threading Technology is only available on some enthusiast CPUs: see the full list here.
On Windows 2003 Server and Windows XP SP3 and later, you can determine this information using the GetLogicalProcessorInformation system call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With