I am using MKL, version 10.2.3 Product Build 20091130 on a Intel 64 Linux machine. My system is a dual core system but using Intel Hyper Threading, it appears that four processors are available. The problem is that when I run my code on this machine, MKL parts always use only two cores, and the two other processors are always idle. The core that I run to initialize MKL is as below:
Hyperthreading can improve throughput if there exist CPU resources that are underutilized without hyperthreading enabled. However, if you try to push the same calculation through all threads in a dual-core CPU with four hyperthreads instead of two, hyperthreading can actually slow down your program. Hyperthreading is not a technique that can materialize, from thin air, non-existent pipelines, internal register files and execution units.
Hi Dan,mesei4 is absolutely right with his answer.and these are my 2 cents into this thread: yes can push MKL to run with 1 thread by calling omp_set_num_threads(1) or mkl_set_num_threads(1) routines. Please reember for this case, that mkl_set_num_threads() does have precedence over omp_set_num_threads().
In the reference, the recommendation KMP_AFFINITY=granularity=fine,compact,1,0 must assume a BIOS in which even-odd pairs of logicals (e.g. 0,1) share the same core. This is not always the way it's done, although it seems common lately for single and dual socket platforms. I was surprised again how important these settings are when HyperThreading is enabled, even on a current single socket platform which has this expected assignment of logicals, where KMP_AFFINITY=compact,1 is correct, but must be specified, along with corresponding NUM_THREADS.
Hi, my 2 cents in addition to the previous comments.
Yes, it's correct that MKL hardly benefits form Heper-Threading, but if you want (just to compare) you may force MKL to use 4 threads:
The point is that if mkl_dynamic is 1, than MKL will reduce the number of threads down to 2 (a number of physical cores) due to perfromance considerations. And if mkl_dynamic is diasabled than MKL [theoretically] doesn't permitted to make it.