I spent this morning trying to find out how to determine which processor id is the hyper-threaded core, but without luck.
I wish to find out this information and use set_affinity()
to bind a process to hyper-threaded thread or non-hyper-threaded thread to profile its performance.
You can use WMI's Win32_processor class to get this information. The class has a property NumberOfCores that tells you how many cores the processor has. The NumberOfLogicalProcessors will tell you how many logical processors. If it is higher than the cores then hyperthreading is enabled.
From the System Utilities screen, select System Configuration > BIOS/Platform Configuration (RBSU) > Processor Options > Intel (R) Hyperthreading Options. Select a setting. Save your setting.
The way to tell how may cores you have is to look for "cpu cores" in your /proc/cpuinfo file. This line will show up for each virtual processor. If the number of cores shown is less than the number of virtual processors, your system is multi-threading.
I discovered the simply trick to do what I need.
cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list
If the first number is equal to the CPU number (0 in this example) then it's a real core, if not it is a hyperthreading core.
Real core example:
# cat /sys/devices/system/cpu/cpu1/topology/thread_siblings_list
1,13
Hyperthreading core example
# cat /sys/devices/system/cpu/cpu13/topology/thread_siblings_list
1,13
The output of the second example is exactly the same as the first one. However we are checking cpu13
, and the first number is 1
, so CPU 13 this is an hyperthreading core.
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