Optimal number of threads for compute-intensive task on server with Hyperthreading

central-processing-unithyperthreadingintelthreads

When running a compute-intensive task on a server with an Intel i7 quad-core processor with Hyperthreading, is it ideal to run eight threads (for the eight virtual cores), or only four (for the four physical cores)? Each thread achieves consistent 100% utilization of a virtual core.

Best Answer

8 threads would be ideal, assuming there's no significant additional overhead in result combining or anything like that. With only four threads, any execution units that couldn't be saturated by the single thread per virtual core would be wasted. With eight threads, they can be used.

Note that this only applies to the unrealistic assumption that each thread can saturate a core. Also, it might not apply if the division of the processor cache resources negatively impacted performance. Some tasks have performance that "falls off a cliff" at a certain cache size. If your cliff is between the full cache size of the physical core and half that cache size, then four threads might be better.