This quote is from the FFTW Manual:
[...] Third, before creating a plan that you want to parallelize, you should call:
void fftw_plan_with_nthreads(int nthreads);
The nthreads argument indicates the number of threads you want FFTW to use (or actually, the maximum number). [...]
With OpenMP, to configure FFTW to use all of the currently running OpenMP threads (set by omp_set_num_threads(nthreads) or by the
OMP_NUM_THREADS
environment variable), you can do:fftw_plan_with_nthreads(omp_get_num_threads()
).
I think the last command is wrong. It should be fftw_plan_with_nthreads(omp_get_max_threads())
. omp_get_num_threads()
will return the current number of threads. But that is probably 1
because one is creating the fftw_plan on one thread. omp_get_num_threads()
will not return the value of OMP_NUM_THREADS
and is not the inverse of omp_set_num_threads(nthreads)
.
Am I right or do I misunderstand either the FFTW or OpenMP API?