From e8aa2ec3980bcc7050b8ae0b2a33d0d48fbf2dcf Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Tue, 7 Jan 2025 16:43:43 +0900 Subject: [PATCH] remove cleanup threads for safety --- fft/src/KokkosFFT_FFTW_Types.hpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/fft/src/KokkosFFT_FFTW_Types.hpp b/fft/src/KokkosFFT_FFTW_Types.hpp index 0481d2b1..a8ed6c00 100644 --- a/fft/src/KokkosFFT_FFTW_Types.hpp +++ b/fft/src/KokkosFFT_FFTW_Types.hpp @@ -60,26 +60,6 @@ struct fftw_transform_type, Kokkos::complex> { static constexpr FFTWTransformType type() { return m_type; }; }; -/// \brief A class that wraps fftw_init_threads and fftw_cleanup_threads -template -struct ScopedFFTWThreads { - ScopedFFTWThreads() { - if constexpr (std::is_same_v) { - fftwf_init_threads(); - } else { - fftw_init_threads(); - } - } - - ~ScopedFFTWThreads() noexcept { - if constexpr (std::is_same_v) { - fftwf_cleanup_threads(); - } else { - fftw_cleanup_threads(); - } - } -}; - /// \brief A class that wraps fftw_plan and fftwf_plan for RAII template struct ScopedFFTWPlan { @@ -143,16 +123,15 @@ struct ScopedFFTWPlan { private: void init_threads([[maybe_unused]] const ExecutionSpace &exec_space) { #if defined(KOKKOS_ENABLE_OPENMP) || defined(KOKKOS_ENABLE_THREADS) - static std::mutex mtx; - std::lock_guard lock(mtx); - static ScopedFFTWThreads fftw_threads; if constexpr (std::is_same_v) { int nthreads = exec_space.concurrency(); if constexpr (std::is_same_v) { + fftwf_init_threads(); fftwf_plan_with_nthreads(nthreads); } else { + fftw_init_threads(); fftw_plan_with_nthreads(nthreads); } }