Skip to content

Commit

Permalink
Introduce Kokkos::Profiling::Region to profile tpl calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Nov 28, 2024
1 parent 18d113f commit c7897fd
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 3 deletions.
19 changes: 18 additions & 1 deletion fft/src/KokkosFFT_Cuda_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftCreate failed");
Expand All @@ -53,6 +55,8 @@ 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 @@ -78,6 +82,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_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftCreate failed");
Expand All @@ -96,6 +102,8 @@ 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 @@ -121,6 +129,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_cufft]");

plan = std::make_unique<PlanType>();
cufftResult cufft_rt = cufftCreate(&(*plan));
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftCreate failed");
Expand All @@ -141,6 +151,8 @@ 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 @@ -170,7 +182,9 @@ 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;
const int rank = fft_rank;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_cufft]");
const int rank = fft_rank;
constexpr auto type =
KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down Expand Up @@ -198,6 +212,7 @@ 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 @@ -206,7 +221,9 @@ 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]");
cufftDestroy(*plan);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
12 changes: 12 additions & 0 deletions fft/src/KokkosFFT_Cuda_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,54 @@ 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]");
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]");
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]");
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]");
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]");
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]");
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: 18 additions & 1 deletion fft/src/KokkosFFT_HIP_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftCreate failed");
Expand All @@ -53,6 +55,8 @@ 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 @@ -78,6 +82,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]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftCreate failed");
Expand All @@ -96,6 +102,8 @@ 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 @@ -121,6 +129,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]");

plan = std::make_unique<PlanType>();
hipfftResult hipfft_rt = hipfftCreate(&(*plan));
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftCreate failed");
Expand All @@ -141,6 +151,8 @@ 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 @@ -170,7 +182,9 @@ 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;
const int rank = fft_rank;

Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_hipfft]");
const int rank = fft_rank;
constexpr auto type =
KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down Expand Up @@ -198,6 +212,7 @@ 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 @@ -206,7 +221,9 @@ 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]");
hipfftDestroy(*plan);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
12 changes: 12 additions & 0 deletions fft/src/KokkosFFT_HIP_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,54 @@ 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]");
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]");
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]");
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]");
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]");
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]");
hipfftResult hipfft_rt = hipfftExecZ2Z(plan, idata, odata, direction);
Kokkos::Profiling::popRegion();
KOKKOSFFT_THROW_IF(hipfft_rt != HIPFFT_SUCCESS, "hipfftExecZ2Z failed");
}
} // namespace Impl
Expand Down
8 changes: 7 additions & 1 deletion fft/src/KokkosFFT_Host_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ 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;
const int rank = fft_rank;

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

const int rank = fft_rank;
init_threads<ExecutionSpace,
KokkosFFT::Impl::base_floating_point_type<in_value_type>>(
exec_space);
Expand Down Expand Up @@ -109,18 +111,22 @@ 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]");
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
12 changes: 12 additions & 0 deletions fft/src/KokkosFFT_Host_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,49 @@ 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]");
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]");
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]");
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]");
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]");
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]");
fftw_execute_dft(plan, idata, odata);
Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
9 changes: 9 additions & 0 deletions fft/src/KokkosFFT_ROCM_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ 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_rocfft]");

constexpr auto type =
KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down Expand Up @@ -198,6 +201,8 @@ auto create_plan(const ExecutionSpace& exec_space,
KOKKOSFFT_THROW_IF(status != rocfft_status_success,
"rocfft_plan_description_destroy failed");

Kokkos::Profiling::popRegion();

return fft_size;
}

Expand All @@ -206,8 +211,12 @@ template <typename ExecutionSpace, typename PlanType, typename InfoType,
std::nullptr_t> = nullptr>
void destroy_plan_and_info(std::unique_ptr<PlanType>& plan,
InfoType& execution_info) {
Kokkos::Profiling::pushRegion("KokkosFFT::create_plan[TPL_rocfft]");

rocfft_execution_info_destroy(execution_info);
rocfft_plan_destroy(*plan);

Kokkos::Profiling::popRegion();
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
Loading

0 comments on commit c7897fd

Please sign in to comment.