Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

MKL and multithreaded FFTs

rarob
Beginner
586 Views
Greetings all,
I've got a couple of questions regarding multithreaded code doing FFTs from the IMKL. Our package
traditionally has been single threaded, but there is some growing interest in making it multithreaded. It looked like the examples given in the Reference Manual for IMKL V10 (I've got an eval license right now) assume the use
of the Intel Compilers. We also use gcc/g++, so we can't *require* features that aren't supported in both compilers.
Would the following scenario be 'safe', both with IMKL V10 as well as V9 or V8 (assume code is C++):

singleton class responsible for managing all descriptors, with mutex lock to prevent concurrent access to
the list of descriptors
all threads call this class to check in or out a descriptor. If an 'idle' descriptor does not exist that matches the
request, one is created/commited. A descriptor would only be one-way, either forward or backward.
after use, the descriptor is checked-in and the reference counter decremented
descriptors would be freed at program exit, or by an explicit call to a release method.


Thanks...

Rob

0 Kudos
1 Reply
Dmitry_B_Intel
Employee
586 Views

Hi Rob,

Youseem to use DFT descriptors in your own threads, unclear whether you want DFT be threaded internally or not. If you want DFT be sequential within your threads (i.e. no nested parallelism), you have the followingoptions:use mkl_sequential threading layer, set MKL_NUM_THREADS=1 or OMP_NUM_THREADS=1 in the environment,set MKL_DOMAIN_NUM_THREADS=FFT:1 in the environment,call MKL_Domain_Set_Max_Threads(MKL_FFT,1) before creating a descriptor,set OpenMP max number of threads to 1 during descriptor creation (set before create, reset after commit). The latter option should work on MKL 8.+, while the others appeared later.

If, however,you want to use one descriptor in different threads simultaneously, you should be careful: you should know the number of sharing threads beforehand and use DFTI_NUM_USER_THREADS accordingly for the shared descriptor.

If you use mkl_sequential, then youwill not be dependent on Intel OpenMP runtime library.

Dima

0 Kudos
Reply