Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

threading problem in MKL

Dear all,

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:

procs=omp_get_num_procs();
omp_set_num_threads(procs);

mkl_set_num_threads(procs);
mkl_set_dynamic(1);



I would like to know, why the code doesn't use all processors when it is running. I also know that I can force it to use e.g. only one processor by setting number of omp processors to one as:

omp_set_num_threads(1);

if I am right! Any help would be appreciated.

Regards,

D.

0 Kudos
4 Replies
Highlighted
Black Belt
9 Views

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.

Read this informative post: should hyperthreading be used?
0 Kudos
Highlighted
Moderator
9 Views

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().
--Gennady
0 Kudos
Highlighted
Black Belt
9 Views

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.
0 Kudos
Highlighted
9 Views

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:
mkl_set_num_threads(4);
mkl_set_dynamic(0);
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.
Regards,
Konstantin
0 Kudos