Skip to content

Commit

Permalink
update static assertions in create_plan for each backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Sep 24, 2024
1 parent 3a42d6e commit 43d70a2
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 57 deletions.
55 changes: 36 additions & 19 deletions fft/src/KokkosFFT_Cuda_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<1> axes, shape_type<1> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -60,10 +64,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<2> axes, shape_type<2> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -98,10 +106,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<3> axes, shape_type<3> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -139,17 +151,22 @@ auto create_plan(const ExecutionSpace& exec_space,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<fft_rank> axes,
shape_type<fft_rank> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::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<ExecutionSpace, InViewType,
OutViewType>,
"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<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down
55 changes: 36 additions & 19 deletions fft/src/KokkosFFT_HIP_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<1> axes, shape_type<1> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -60,10 +64,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<2> axes, shape_type<2> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -98,10 +106,14 @@ auto create_plan(const ExecutionSpace& exec_space,
std::unique_ptr<PlanType>& plan, const InViewType& in,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<3> axes, shape_type<3> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: OutViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::are_operatable_views_v<ExecutionSpace, InViewType,
OutViewType>,
"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;

Expand Down Expand Up @@ -139,17 +151,22 @@ auto create_plan(const ExecutionSpace& exec_space,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<fft_rank> axes,
shape_type<fft_rank> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::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<ExecutionSpace, InViewType,
OutViewType>,
"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<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down
20 changes: 13 additions & 7 deletions fft/src/KokkosFFT_Host_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -39,17 +40,22 @@ auto create_plan(const ExecutionSpace& exec_space,
const OutViewType& out, BufferViewType&, InfoType&,
[[maybe_unused]] Direction direction, axis_type<fft_rank> axes,
shape_type<fft_rank> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::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<ExecutionSpace, InViewType,
OutViewType>,
"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<ExecutionSpace,
KokkosFFT::Impl::base_floating_point_type<in_value_type>>(
Expand Down
16 changes: 10 additions & 6 deletions fft/src/KokkosFFT_ROCM_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,21 @@ auto create_plan(const ExecutionSpace& exec_space,
const OutViewType& out, BufferViewType& buffer,
InfoType& execution_info, Direction direction,
axis_type<fft_rank> axes, shape_type<fft_rank> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::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<ExecutionSpace, InViewType,
OutViewType>,
"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<ExecutionSpace, in_value_type,
out_value_type>::type();
Expand Down
15 changes: 9 additions & 6 deletions fft/src/KokkosFFT_SYCL_plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <algorithm>
#include "KokkosFFT_SYCL_types.hpp"
#include "KokkosFFT_layouts.hpp"
#include "KokkosFFT_asserts.hpp"

namespace KokkosFFT {
namespace Impl {
Expand Down Expand Up @@ -53,12 +54,14 @@ auto create_plan(const ExecutionSpace& exec_space,
const OutViewType& out, BufferViewType&, InfoType&,
Direction /*direction*/, axis_type<fft_rank> axes,
shape_type<fft_rank> s) {
static_assert(Kokkos::is_view<InViewType>::value,
"KokkosFFT::create_plan: InViewType is not a Kokkos::View.");
static_assert(Kokkos::is_view<InViewType>::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<ExecutionSpace, InViewType,
OutViewType>,
"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,
Expand Down

0 comments on commit 43d70a2

Please sign in to comment.