From f9b2bee3d24f9a6dc99f9c20b48f4646463680a0 Mon Sep 17 00:00:00 2001 From: Miroslav Stoyanov Date: Wed, 23 Oct 2024 14:56:35 -0400 Subject: [PATCH] added call to rocfft_setup() --- include/heffte_backend_rocm.h | 25 +++++++++++++++++++++++-- src/heffte_backend_rocm.hip.cpp | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/heffte_backend_rocm.h b/include/heffte_backend_rocm.h index 0787e94..a4906a9 100644 --- a/include/heffte_backend_rocm.h +++ b/include/heffte_backend_rocm.h @@ -180,6 +180,23 @@ namespace rocm { return 4 * (length-1); } }; + + /*! + * \ingroup heffterocm + * \brief Indicates whether the rocfft_setup() method has been called + */ + struct initialize { + //! \brief Static (global) variable indicating if rocfft_setup() has been called + static bool is_initialized; + //! \brief Make initialize + static void make() { + if (not is_initialized) { + rocfft_setup(); + is_initialized = true; + } + + } + }; } namespace backend{ @@ -549,7 +566,9 @@ class rocfft_executor : public executor_base{ total_size(box.count()), embed({0, 0}), worksize(compute_workspace_size()) - {} + { + rocm::initialize::make(); + } //! \brief Merges two FFTs into one. template rocfft_executor(hipStream_t active_stream, box3d const box, int dir1, int dir2) : @@ -740,7 +759,9 @@ class rocfft_executor_r2c : public executor_base{ rsize(box.count()), csize(box.r2c(dimension).count()), worksize(compute_workspace_size()) - {} + { + rocm::initialize::make(); + } //! \brief Forward transform, single precision. template diff --git a/src/heffte_backend_rocm.hip.cpp b/src/heffte_backend_rocm.hip.cpp index e2ff591..22bd2ef 100644 --- a/src/heffte_backend_rocm.hip.cpp +++ b/src/heffte_backend_rocm.hip.cpp @@ -34,6 +34,8 @@ void synchronize_default_stream(){ namespace rocm { +bool initialize::is_initialized = false; + /* * Launch with one thread per entry. *