Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/finufft/fftw_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@
#define FFTW_INIT FFTWIFY(init_threads)
#define FFTW_PLAN_TH FFTWIFY(plan_with_nthreads)
#define FFTW_CLEANUP_THREADS FFTWIFY(cleanup_threads)
#define FFTW_GET_NTHREADS FFTWIFY(planner_nthreads)
#define FFTW_PLAN_SF FFTWIFY(make_planner_thread_safe)
#else
// no OMP (no fftw{f}_threads or _omp), need dummy fftw threads calls...
#define FFTW_INIT()
#define FFTW_PLAN_TH(x)
#define FFTW_CLEANUP_THREADS()
#define FFTW_GET_NTHREADS()
#define FFTW_PLAN_SF()
#endif

#endif // FFTW_DEFS_H
3 changes: 3 additions & 0 deletions src/finufft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ int FINUFFT_MAKEPLAN(int type, int dim, BIGINT *n_modes, int iflag, int ntrans,
std::lock_guard<std::mutex> lock(fftw_lock);
if (!did_fftw_init) {
FFTW_INIT(); // setup FFTW global state; should only do once
FFTW_PLAN_SF();
did_fftw_init = true; // ensure other FINUFFT threads don't clash
}
}
Expand Down Expand Up @@ -760,10 +761,12 @@ int FINUFFT_MAKEPLAN(int type, int dim, BIGINT *n_modes, int iflag, int ntrans,
// set it just for our one plan and then revert to the user value.
// Unfortunately fftw_planner_nthreads wasn't introduced until fftw 3.3.9, and
// there isn't a convenient mechanism to probe the version
int prev_nthr_fft = FFTW_GET_NTHREADS();
FFTW_PLAN_TH(nthr_fft);
p->fftwPlan = FFTW_PLAN_MANY_DFT(dim, ns, p->batchSize, (FFTW_CPX *)p->fwBatch,
NULL, 1, p->nf, (FFTW_CPX *)p->fwBatch, NULL, 1,
p->nf, p->fftSign, p->opts.fftw);
FFTW_PLAN_TH(prev_nthr_fft);
}
if (p->opts.debug)
printf("[%s] FFTW plan (mode %d, nthr=%d):\t%.3g s\n", __func__, p->opts.fftw,
Expand Down