- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Read this informative post: should hyperthreading be used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
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

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page