Skip to content

Commit

Permalink
fftw_lock: share lock and init between float/double
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwer committed Sep 10, 2024
1 parent 1e2c047 commit 8594b65
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/finufft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ namespace finufft {
namespace common {

#ifndef FINUFFT_USE_DUCC0
// Technically global state...
// Needs to be static to avoid name collision with SINGLE/DOUBLE
static std::mutex fftw_lock;
// The only global state in finufft. Inline ensures variables shared between float/double
inline std::mutex fftw_lock;
inline bool did_fftw_init = false;

class FFTWLockGuard {
public:
Expand Down Expand Up @@ -692,7 +692,6 @@ int FINUFFT_MAKEPLAN(int type, int dim, BIGINT *n_modes, int iflag, int ntrans,
// Now place FFTW initialization in a lock, courtesy of OMP. Makes FINUFFT
// thread-safe (can be called inside OMP)
{
static bool did_fftw_init = false; // the only global state of FINUFFT
FFTWLockGuard lock(p->opts.fftw_lock_fun, p->opts.fftw_unlock_fun,
p->opts.fftw_lock_data);
if (!did_fftw_init) {
Expand Down

0 comments on commit 8594b65

Please sign in to comment.