Skip to content

Commit

Permalink
use ScopedRegion instead of pushRegion/popRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Nov 28, 2024
1 parent c7897fd commit 945462f
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 130 deletions.
18 changes: 5 additions & 13 deletions fft/src/KokkosFFT_Cuda_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
Expand All @@ -55,8 +55,6 @@ auto create_plan(const ExecutionSpace& exec_space,
cufft_rt = cufftPlan1d(&(*plan), nx, type, howmany);
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftPlan1d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand All @@ -82,7 +80,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
Expand All @@ -102,8 +100,6 @@ auto create_plan(const ExecutionSpace& exec_space,
cufft_rt = cufftPlan2d(&(*plan), nx, ny, type);
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftPlan2d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand All @@ -129,7 +125,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
Expand All @@ -151,8 +147,6 @@ auto create_plan(const ExecutionSpace& exec_space,
cufft_rt = cufftPlan3d(&(*plan), nx, ny, nz, type);
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftPlan3d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand Down Expand Up @@ -183,7 +177,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_cufft]");
const int rank = fft_rank;
constexpr auto type =
KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
Expand Down Expand Up @@ -212,7 +206,6 @@ auto create_plan(const ExecutionSpace& exec_space,
out_extents.data(), ostride, odist, type, howmany);

KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftPlanMany failed");
Kokkos::Profiling::popRegion();

return fft_size;
}
Expand All @@ -221,9 +214,8 @@ template <typename ExecutionSpace, typename PlanType, typename InfoType,
std::enable_if_t<std::is_same_v<ExecutionSpace, Kokkos::Cuda>,
std::nullptr_t> = nullptr>
void destroy_plan_and_info(std::unique_ptr<PlanType>& plan, InfoType&) {
Kokkos::Profiling::pushRegion("KokkosFFT::destroy_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::destroy_plan[TPL_cufft]");
cufftDestroy(*plan);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
18 changes: 6 additions & 12 deletions fft/src/KokkosFFT_Cuda_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,48 @@ namespace Impl {
template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftReal* idata, cufftComplex* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecR2C(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecR2C failed");
}

template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftDoubleReal* idata,
cufftDoubleComplex* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecD2Z(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecD2Z failed");
}

template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftComplex* idata, cufftReal* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecC2R(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecC2R failed");
}

template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftDoubleComplex* idata,
cufftDoubleReal* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecZ2D(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecZ2D failed");
}

template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftComplex* idata,
cufftComplex* odata, int direction, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecC2C(plan, idata, odata, direction);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecC2C failed");
}

template <typename... Args>
inline void exec_plan(cufftHandle& plan, cufftDoubleComplex* idata,
cufftDoubleComplex* odata, int direction, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
cufftResult cufft_rt = cufftExecZ2Z(plan, idata, odata, direction);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftExecZ2Z failed");
}
} // namespace Impl
Expand Down
19 changes: 6 additions & 13 deletions fft/src/KokkosFFT_HIP_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_hipfft]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
Expand All @@ -55,8 +55,6 @@ auto create_plan(const ExecutionSpace& exec_space,
hipfft_rt = hipfftPlan1d(&(*plan), nx, type, howmany);
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftPlan1d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand All @@ -82,7 +80,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_hipfft]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
Expand All @@ -102,8 +100,6 @@ auto create_plan(const ExecutionSpace& exec_space,
hipfft_rt = hipfftPlan2d(&(*plan), nx, ny, type);
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftPlan2d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand All @@ -129,7 +125,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_hipfft]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
Expand All @@ -151,8 +147,6 @@ auto create_plan(const ExecutionSpace& exec_space,
hipfft_rt = hipfftPlan3d(&(*plan), nx, ny, nz, type);
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftPlan3d failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand Down Expand Up @@ -183,7 +177,8 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_hipfft]");

const int rank = fft_rank;
constexpr auto type =
KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
Expand Down Expand Up @@ -212,7 +207,6 @@ auto create_plan(const ExecutionSpace& exec_space,
out_extents.data(), ostride, odist, type, howmany);

KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftPlanMany failed");
Kokkos::Profiling::popRegion();

return fft_size;
}
Expand All @@ -221,9 +215,8 @@ template <typename ExecutionSpace, typename PlanType, typename InfoType,
std::enable_if_t<std::is_same_v<ExecutionSpace, Kokkos::HIP>,
std::nullptr_t> = nullptr>
void destroy_plan_and_info(std::unique_ptr<PlanType>& plan, InfoType&) {
Kokkos::Profiling::pushRegion("KokkosFFT::destroy_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::destroy_plan[TPL_hipfft]");
hipfftDestroy(*plan);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
18 changes: 6 additions & 12 deletions fft/src/KokkosFFT_HIP_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,48 @@ namespace Impl {
template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftReal* idata,
hipfftComplex* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_cufft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_cufft]");
hipfftResult hipfft_rt = hipfftExecR2C(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecR2C failed");
}

template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftDoubleReal* idata,
hipfftDoubleComplex* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_hipfft]");
hipfftResult hipfft_rt = hipfftExecD2Z(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecD2Z failed");
}

template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftComplex* idata,
hipfftReal* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_hipfft]");
hipfftResult hipfft_rt = hipfftExecC2R(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecC2R failed");
}

template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftDoubleComplex* idata,
hipfftDoubleReal* odata, int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_hipfft]");
hipfftResult hipfft_rt = hipfftExecZ2D(plan, idata, odata);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecZ2D failed");
}

template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftComplex* idata,
hipfftComplex* odata, int direction, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_hipfft]");
hipfftResult hipfft_rt = hipfftExecC2C(plan, idata, odata, direction);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecC2C failed");
}

template <typename... Args>
inline void exec_plan(hipfftHandle& plan, hipfftDoubleComplex* idata,
hipfftDoubleComplex* odata, int direction, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_hipfft]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_hipfft]");
hipfftResult hipfft_rt = hipfftExecZ2Z(plan, idata, odata, direction);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecZ2Z failed");
}
} // namespace Impl
Expand Down
7 changes: 2 additions & 5 deletions fft/src/KokkosFFT_Host_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ auto create_plan(const ExecutionSpace& exec_space,
using in_value_type = typename InViewType::non_const_value_type;
using out_value_type = typename OutViewType::non_const_value_type;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::create_plan[TPL_fftw]");

const int rank = fft_rank;
init_threads<ExecutionSpace,
Expand Down Expand Up @@ -111,22 +111,19 @@ auto create_plan(const ExecutionSpace& exec_space,
idist, odata, out_extents.data(), ostride, odist, sign, FFTW_ESTIMATE);
}

Kokkos::Profiling::popRegion();

return fft_size;
}

template <typename ExecutionSpace, typename PlanType, typename InfoType,
std::enable_if_t<is_AnyHostSpace_v<ExecutionSpace>, std::nullptr_t> =
nullptr>
void destroy_plan_and_info(std::unique_ptr<PlanType>& plan, InfoType&) {
Kokkos::Profiling::pushRegion("KokkosFFT::destroy_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::destroy_plan[TPL_fftw]");
if constexpr (std::is_same_v<PlanType, fftwf_plan>) {
fftwf_destroy_plan(*plan);
} else {
fftw_destroy_plan(*plan);
}
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
18 changes: 6 additions & 12 deletions fft/src/KokkosFFT_Host_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,43 @@ namespace Impl {
template <typename PlanType, typename... Args>
void exec_plan(PlanType& plan, float* idata, fftwf_complex* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftwf_execute_dft_r2c(plan, idata, odata);
Kokkos::Profiling::popRegion();
}

template <typename PlanType, typename... Args>
void exec_plan(PlanType& plan, double* idata, fftw_complex* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftw_execute_dft_r2c(plan, idata, odata);
Kokkos::Profiling::popRegion();
}

template <typename PlanType, typename... Args>
void exec_plan(PlanType& plan, fftwf_complex* idata, float* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftwf_execute_dft_c2r(plan, idata, odata);
Kokkos::Profiling::popRegion();
}

template <typename PlanType, typename... Args>
void exec_plan(PlanType& plan, fftw_complex* idata, double* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftw_execute_dft_c2r(plan, idata, odata);
Kokkos::Profiling::popRegion();
}

template <typename PlanType, typename... Args>
void exec_plan(PlanType& plan, fftwf_complex* idata, fftwf_complex* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftwf_execute_dft(plan, idata, odata);
Kokkos::Profiling::popRegion();
}

template <typename PlanType, typename... Args>
void exec_plan(PlanType plan, fftw_complex* idata, fftw_complex* odata,
int /*direction*/, Args...) {
Kokkos::Profiling::pushRegion("KokkosFFT::exec_plan[TPL_fftw]");
Kokkos::Profiling::ScopedRegion region("KokkosFFT::exec_plan[TPL_fftw]");
fftw_execute_dft(plan, idata, odata);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
Loading

0 comments on commit 945462f

Please sign in to comment.