Skip to content

Commit

Permalink
added call to rocfft_setup()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkstoyanov committed Oct 23, 2024
1 parent c93784f commit f9b2bee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 23 additions & 2 deletions include/heffte_backend_rocm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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<typename index>
rocfft_executor(hipStream_t active_stream, box3d<index> const box, int dir1, int dir2) :
Expand Down Expand Up @@ -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<typename precision_type>
Expand Down
2 changes: 2 additions & 0 deletions src/heffte_backend_rocm.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void synchronize_default_stream(){

namespace rocm {

bool initialize::is_initialized = false;

/*
* Launch with one thread per entry.
*
Expand Down

0 comments on commit f9b2bee

Please sign in to comment.