Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

Ref for optimizing hyper threading cpu ?

New Contributor I
Dear Every One:

I have search reference ( article, blog, doc ..etc) about optimize for hyper threading.

it is seems hyper threading is as ordinary core by openmp.

I do not know what tool I could use for optimzing using HT.

Could everyone give me a start?

thank you.

0 Kudos
4 Replies
Honored Contributor III
Normally, it's most productive simply to treat HyperThreading as a level of multi-threading allowing a core to support more threads, similar to, but (in most cases) not as effectively, as more cores. I think this agrees with your comment.
For Intel OpenMP, if you set KMP_AFFINITY=verbose, along with any of the usual options, you will see that the logical threads on each core are treated as interchangeable. This is because they share cache to a greater extent even than pairs of cores on the same CPU do. This also implies that one of the conditions for HyperThreading to show an advantage is that the threads share data in cache, or at least don't have a combined footprint exceeding cache size.
During your searches, you should have seen the comments about how the hyperthreads on Xeon compete for several important resources, such as FPU. Then, in highly optimized code such as MKL, more effective use of FPU is achieved by making only 1 thread active per core.
0 Kudos
I agree with the fact that sometimes it's best to make only 1 thread per core. Therefore I would like to know how to detect if hyperthreading is enabled. If I can't do it with omp, maybe I can use a call to another library. @TimP, do you know how I can achieve that?
0 Kudos
Honored Contributor III
The documentation for several Intel software products, including MKL, OpenMP (KMP_AFFINITY), and MPI, deals with this, perhaps not in a fully satisfactory way. All of them rely on ability to do it under OpenMP (using functionality not specified in OpenMP standard), and on updated capabilities for each significant platform change.
Under linux (when the kernel is sufficiently up to date for the platform), you have facilities showing information about hyperthreading, as displayed e.g. in /proc/cpuinfo and by irqbalance -debug
0 Kudos
Honored Contributor III

Can you describe in greater detail the HT platforms you will be using, and the type of application?

This is one such threading toolkit that directly addresses this issue. I wrote it, so this may be a shameless example of self promotion. A few examples of the capability are:

Assume you have an integer-only parallel task (i.e. schedule all threads)

parallel_for(foo, iBegin, iEnd, arg1, arg2, ... argn);

Assume FP intensive task (i.e. you want one HT thread per core)

parallel_for(OneEachL1$, foo, iBegin, iEnd, arg1, arg2, ... argn);

Assume you have FP intensive task .AND. integer intensive task

[&](){ parallel_for(OneEachL1$, fooFP, iBegin, iEnd, arg1, arg2, ... argn); },
[&](){ parallel_for(OneEachL1$, fooInteger, iBegin, iEnd, arg1, arg2, ... argn); });

Jim Dempsey

0 Kudos