Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

Switching between threaded and non-threaded libraries

$
0
0

Hello,

I have an application that uses Intel's MKL libraries. In some sections of this application calls to MKL are made in parallel areas. In these areas, I want to use the sequential version of the MKL libraries; at times I am not in a parallel area in my application, so I would like to use the threadedversion of the MKL libraries here.

I understand I can only link my application with either the threaded or the sequential libraries. Given that I need to use the threaded version in certain places, I assume I must link with the threaded version. I set my environment variables OMP_NUM_THREADS and MKL_NUM_THREADS to 1. My understanding is that I should be able to call mkl_set_num_threads(n), where "n" is either 1 - in areas where I want to use MKL in sequential mode - or ">1", in threaded MKL calls.

But if I bring the Windows task manager I notice that calling mkl_set_num_threads(1) when I'm using the threaded version of the MKL library still starts many threads. If I use the sequential version, on the other hand, this is not a problem. It appears that mkl_set_num_threads does not have the effect I expected.

If I run my application entirely in sequential mode, then even if I call mkl_set_num_threads(1) I still see multiple threads running when MKL is being called. Since I know the threading is not coming from my application, it must be from MKL.

Is there a way to force MKL to run in sequential mode - even if I'm linking with the threaded MKL library?

Thanks.


Viewing all articles
Browse latest Browse all 3005

Trending Articles