MKL Python Libraries won't use all 4 processors

MKL Python Libraries won't use all 4 processors

Hi, I use numpy for python that implements the MKL libraries in a lot of its linear algebra functions. I noticed that when i run my simulations, it doesn't use all 4 processors. Originally it only use 1 (it actually uses all 4, but only 25% of the system CPU power at any given time). I changed the environmental variable mkl_num_threads from 1 to 4, but now it only uses 50% of the total CPU cycles available. Actually if i set the number of threads to any value above 1 (tried 2, 3, 4, 6, and 8), it only uses 50% of the available cycles.

Any help would certainly be appreciated! 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Jordan

MKL may decide to use less threads than specified via env.var MKL_NUM_THREADS. You may tell it refrain from using less threads by setting env.var MKL_DYNAMIC=false.

That CPU meter shows 25% migrating from cpu to cpu suggests that operating system tries to balance the load on the cpus by migrating threads of your application from cpu to cpu as the time goes. If you thread with OpenMP, you can tell the OpenMP runtime library to affinitize the threads of your application, thereby preventing their migration. This is attained by setting env.var KMP_AFFINITY, for example KMP_AFFINITY=compact.

Description of the environment variables can be found in Intel Developer's Zone.



For more information on improving MKL performance using threading, please see this chapter in the User's Guide. The env-variables Dima mentioned in his reply can also be found in this chapter.


Leave a Comment

Please sign in to add a comment. Not a member? Join today