From 0d234fbec6ffb1c40fdf06a8333c9d9f76fb2ef3 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Tue, 24 Sep 2024 20:57:05 +0900 Subject: [PATCH 1/3] Remove unused argument from exec_impl function --- fft/src/KokkosFFT_Transform.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/fft/src/KokkosFFT_Transform.hpp b/fft/src/KokkosFFT_Transform.hpp index 38fa12a6..a3224acb 100644 --- a/fft/src/KokkosFFT_Transform.hpp +++ b/fft/src/KokkosFFT_Transform.hpp @@ -70,7 +70,6 @@ void exec_impl( template void fft_exec_impl( const PlanType& plan, const InViewType& in, OutViewType& out, - // KokkosFFT::Direction direction, KokkosFFT::Normalization norm = KokkosFFT::Normalization::backward) { using ExecutionSpace = typename PlanType::execSpace; static_assert( From d6475116f762c887d37dd620f637a6e9c240d0ee Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Tue, 24 Sep 2024 21:01:53 +0900 Subject: [PATCH 2/3] update static assertions in create_plan for each backend --- fft/src/KokkosFFT_Cuda_plans.hpp | 55 +++++++++++++++++++++----------- fft/src/KokkosFFT_HIP_plans.hpp | 55 +++++++++++++++++++++----------- fft/src/KokkosFFT_Host_plans.hpp | 20 ++++++++---- fft/src/KokkosFFT_ROCM_plans.hpp | 16 ++++++---- fft/src/KokkosFFT_SYCL_plans.hpp | 15 +++++---- 5 files changed, 104 insertions(+), 57 deletions(-) diff --git a/fft/src/KokkosFFT_Cuda_plans.hpp b/fft/src/KokkosFFT_Cuda_plans.hpp index 3b532673..4b49ac44 100644 --- a/fft/src/KokkosFFT_Cuda_plans.hpp +++ b/fft/src/KokkosFFT_Cuda_plans.hpp @@ -22,10 +22,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<1> axes, shape_type<1> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -60,10 +64,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<2> axes, shape_type<2> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -98,10 +106,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<3> axes, shape_type<3> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -139,17 +151,22 @@ auto create_plan(const ExecutionSpace& exec_space, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type axes, shape_type s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); static_assert( InViewType::rank() >= fft_rank, "KokkosFFT::_create: Rank of View must be larger than Rank of FFT."); - const int rank = fft_rank; + + 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; constexpr auto type = KokkosFFT::Impl::transform_type::type(); diff --git a/fft/src/KokkosFFT_HIP_plans.hpp b/fft/src/KokkosFFT_HIP_plans.hpp index 3c781ec4..e2d0a294 100644 --- a/fft/src/KokkosFFT_HIP_plans.hpp +++ b/fft/src/KokkosFFT_HIP_plans.hpp @@ -22,10 +22,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<1> axes, shape_type<1> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -60,10 +64,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<2> axes, shape_type<2> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -98,10 +106,14 @@ auto create_plan(const ExecutionSpace& exec_space, std::unique_ptr& plan, const InViewType& in, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type<3> axes, shape_type<3> s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); using in_value_type = typename InViewType::non_const_value_type; using out_value_type = typename OutViewType::non_const_value_type; @@ -139,17 +151,22 @@ auto create_plan(const ExecutionSpace& exec_space, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type axes, shape_type s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); static_assert( InViewType::rank() >= fft_rank, "KokkosFFT::create_plan: Rank of View must be larger than Rank of FFT."); - const int rank = fft_rank; + + 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; constexpr auto type = KokkosFFT::Impl::transform_type::type(); diff --git a/fft/src/KokkosFFT_Host_plans.hpp b/fft/src/KokkosFFT_Host_plans.hpp index 44070993..e18aae8d 100644 --- a/fft/src/KokkosFFT_Host_plans.hpp +++ b/fft/src/KokkosFFT_Host_plans.hpp @@ -9,6 +9,7 @@ #include "KokkosFFT_default_types.hpp" #include "KokkosFFT_layouts.hpp" #include "KokkosFFT_traits.hpp" +#include "KokkosFFT_asserts.hpp" namespace KokkosFFT { namespace Impl { @@ -39,17 +40,22 @@ auto create_plan(const ExecutionSpace& exec_space, const OutViewType& out, BufferViewType&, InfoType&, [[maybe_unused]] Direction direction, axis_type axes, shape_type s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); static_assert( InViewType::rank() >= fft_rank, "KokkosFFT::create_plan: Rank of View must be larger than Rank of FFT."); - const int rank = fft_rank; + + 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; init_threads>( diff --git a/fft/src/KokkosFFT_ROCM_plans.hpp b/fft/src/KokkosFFT_ROCM_plans.hpp index fec5141d..d44a0512 100644 --- a/fft/src/KokkosFFT_ROCM_plans.hpp +++ b/fft/src/KokkosFFT_ROCM_plans.hpp @@ -92,17 +92,21 @@ auto create_plan(const ExecutionSpace& exec_space, const OutViewType& out, BufferViewType& buffer, InfoType& execution_info, Direction direction, axis_type axes, shape_type s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); static_assert( InViewType::rank() >= fft_rank, "KokkosFFT::create_plan: Rank of View must be larger than Rank of FFT."); + using in_value_type = typename InViewType::non_const_value_type; + using out_value_type = typename OutViewType::non_const_value_type; constexpr auto type = KokkosFFT::Impl::transform_type::type(); diff --git a/fft/src/KokkosFFT_SYCL_plans.hpp b/fft/src/KokkosFFT_SYCL_plans.hpp index 8e9fdcd6..3abbb2c5 100644 --- a/fft/src/KokkosFFT_SYCL_plans.hpp +++ b/fft/src/KokkosFFT_SYCL_plans.hpp @@ -9,6 +9,7 @@ #include #include "KokkosFFT_SYCL_types.hpp" #include "KokkosFFT_layouts.hpp" +#include "KokkosFFT_asserts.hpp" namespace KokkosFFT { namespace Impl { @@ -53,12 +54,14 @@ auto create_plan(const ExecutionSpace& exec_space, const OutViewType& out, BufferViewType&, InfoType&, Direction /*direction*/, axis_type axes, shape_type s) { - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: InViewType is not a Kokkos::View."); - static_assert(Kokkos::is_view::value, - "KokkosFFT::create_plan: OutViewType is not a Kokkos::View."); - using in_value_type = typename InViewType::non_const_value_type; - using out_value_type = typename OutViewType::non_const_value_type; + static_assert( + KokkosFFT::Impl::are_operatable_views_v, + "create_plan: InViewType and OutViewType must have the same base " + "floating point type (float/double), the same layout " + "(LayoutLeft/LayoutRight), " + "and the same rank. ExecutionSpace must be accessible to the data in " + "InViewType and OutViewType."); static_assert( InViewType::rank() >= fft_rank, From 6e7ad91151f196512aeceea0b61564d007cb6780 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Tue, 24 Sep 2024 21:05:45 +0900 Subject: [PATCH 3/3] fix: includes in KokkosFFT_*_plans.hpp --- fft/src/KokkosFFT_Cuda_plans.hpp | 1 + fft/src/KokkosFFT_HIP_plans.hpp | 1 + fft/src/KokkosFFT_Host_plans.hpp | 1 - fft/src/KokkosFFT_ROCM_plans.hpp | 1 + fft/src/KokkosFFT_SYCL_plans.hpp | 2 +- 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fft/src/KokkosFFT_Cuda_plans.hpp b/fft/src/KokkosFFT_Cuda_plans.hpp index 4b49ac44..3b84bed3 100644 --- a/fft/src/KokkosFFT_Cuda_plans.hpp +++ b/fft/src/KokkosFFT_Cuda_plans.hpp @@ -8,6 +8,7 @@ #include #include "KokkosFFT_Cuda_types.hpp" #include "KokkosFFT_layouts.hpp" +#include "KokkosFFT_traits.hpp" #include "KokkosFFT_asserts.hpp" namespace KokkosFFT { diff --git a/fft/src/KokkosFFT_HIP_plans.hpp b/fft/src/KokkosFFT_HIP_plans.hpp index e2d0a294..77cfe3e4 100644 --- a/fft/src/KokkosFFT_HIP_plans.hpp +++ b/fft/src/KokkosFFT_HIP_plans.hpp @@ -8,6 +8,7 @@ #include #include "KokkosFFT_HIP_types.hpp" #include "KokkosFFT_layouts.hpp" +#include "KokkosFFT_traits.hpp" #include "KokkosFFT_asserts.hpp" namespace KokkosFFT { diff --git a/fft/src/KokkosFFT_Host_plans.hpp b/fft/src/KokkosFFT_Host_plans.hpp index e18aae8d..a18c21bd 100644 --- a/fft/src/KokkosFFT_Host_plans.hpp +++ b/fft/src/KokkosFFT_Host_plans.hpp @@ -9,7 +9,6 @@ #include "KokkosFFT_default_types.hpp" #include "KokkosFFT_layouts.hpp" #include "KokkosFFT_traits.hpp" -#include "KokkosFFT_asserts.hpp" namespace KokkosFFT { namespace Impl { diff --git a/fft/src/KokkosFFT_ROCM_plans.hpp b/fft/src/KokkosFFT_ROCM_plans.hpp index d44a0512..e26cbd22 100644 --- a/fft/src/KokkosFFT_ROCM_plans.hpp +++ b/fft/src/KokkosFFT_ROCM_plans.hpp @@ -9,6 +9,7 @@ #include #include "KokkosFFT_ROCM_types.hpp" #include "KokkosFFT_layouts.hpp" +#include "KokkosFFT_traits.hpp" #include "KokkosFFT_asserts.hpp" namespace KokkosFFT { diff --git a/fft/src/KokkosFFT_SYCL_plans.hpp b/fft/src/KokkosFFT_SYCL_plans.hpp index 3abbb2c5..2c9b3a91 100644 --- a/fft/src/KokkosFFT_SYCL_plans.hpp +++ b/fft/src/KokkosFFT_SYCL_plans.hpp @@ -9,7 +9,7 @@ #include #include "KokkosFFT_SYCL_types.hpp" #include "KokkosFFT_layouts.hpp" -#include "KokkosFFT_asserts.hpp" +#include "KokkosFFT_traits.hpp" namespace KokkosFFT { namespace Impl {