Disable hyperthreads versus ProcessorAffinity changes?

I noticed that several of my multi-threaded calculations work faster if I disable hyperthreading in the BIOS.

I also found out that I can programmatically disable the (logical) CPU: s by changing the affinity of the processor to the current process, for example, as in C #:

// using System.Diagnostics; var current = Process.GetCurrentProcess(); var affinity = current.ProcessorAffinity.ToInt32(); current.ProcessorAffinity = new IntPtr(affinity & 0x5555); 

At least in terms of performance, disabling every second (logical) processor by changing the affinity for the processor has the same effect as completely disabling the hyperflow?

+7
source share
1 answer

You can try using the NUMA API or manually discover the CPU topology with the CPUID instruction ... But IMHO, the best solution makes some normal defaults and allows end users to configure streaming settings. If you do not have a specific hardware goal, there are fair possible scenarios for processing: logical or physical cores, hyperthreading or not, single or multi-component systems, cache and memory topology.

+2
source

All Articles