# Number of user threads

Customer application can be parallelized by using the following techniques:

1. You do not create threads in your application but specify the parallel mode within the FFT module of Intel MKL. See Intel MKL User's Guide for more information on how to do this. See also Example “Using Intel MKL Internal Threading Mode”.

2. You create threads in the application yourself and have each thread perform all stages of FFT implementation, including descriptor initialization, FFT computation, and descriptor deallocation. In this case, each descriptor is used only within its corresponding thread. It is recommended to set single-threaded mode for Intel MKL. See Example “Using Parallel Mode with Multiple Descriptors Initialized in a Parallel Region”.

3. You create threads in the application yourself after initializing all FFT descriptors. This implies that threading is employed for parallel FFT computation only, and the descriptors are released upon return from the parallel region. In this case, each descriptor is used only within its corresponding thread. It is obligatory to explicitly set the single-threaded mode for Intel MKL, otherwise, the actual number of threads may differ from one, because the `DftiCommitDescriptor` function is not in a parallel region. See Example “Using Parallel Mode with Multiple Descriptors Initialized in One Thread”.

4. You create threads in the application yourself after initializing the only FFT descriptor. This implies that threading is employed for parallel FFT computation only, and the descriptor is released upon return from the parallel region. In this case, each thread uses the same descriptor. See Example “Using Parallel Mode with a Common Descriptor”.

In cases "a", "b", and "c", listed above, set the parameter `DFTI_NUMBER_OF_USER_THREADS` to 1 (its default value), since each particular descriptor instance is used only in a single thread.

In case "d", you must use the DftiSetValue() function to set the `DFTI_NUMBER_OF_USER_THREADS` to the actual number of FFT computation threads, because multiple threads will be using the same descriptor. If this setting is not done, your program will work incorrectly or fail, since the descriptor contains individual data for each thread.

### Warning

- It is not recommended to simultaneously parallelize your program and employ the Intel MKL internal threading because this will slow down the performance. Note that in case "d" above, FFT computation is automatically initiated in a single-threading mode.

- You must not change the number of threads after the DftiCommitDescriptor() function completed FFT initialization.

Parent topic: Configuration Settings