0

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?

hanno
  • 6,401
  • 8
  • 48
  • 80
  • I think you misunderstand the OpenMP documentation, eg http://gcc.gnu.org/onlinedocs/libgomp/omp_005fget_005fnum_005fthreads.html. When called inside a parallel region the function returns the number of threads in the team. – High Performance Mark May 16 '12 at 21:48
  • But why would I create an fftw_plan in a parallel region? – hanno May 17 '12 at 00:32
  • 2
    That would only make sense if that function is to be called by a single thread inside the parallel region. Please, write an email to the FFTW team and tell them to correct the manual or to clarify it. – Hristo Iliev May 17 '12 at 07:18
  • Ahaa, now I see it. The manual says: "... to use all of the CURRENTLY RUNNING OpenMP threads..." So the function call is correct but you should only make it in a single thread, e.g. with the `single` or `master` directive. – Hristo Iliev May 17 '12 at 07:23
  • Ok. Thanks for the feedback. I wrote them an e-mail. – hanno May 17 '12 at 14:52

0 Answers0