Skip to content

Commit

Permalink
Merge pull request #99 from kokkos/disallow-invalid-plan
Browse files Browse the repository at this point in the history
Disallow invalid plan
  • Loading branch information
yasahi-hpc authored May 13, 2024
2 parents 892a320 + d11dd4e commit 0edcf54
Show file tree
Hide file tree
Showing 3 changed files with 368 additions and 30 deletions.
45 changes: 28 additions & 17 deletions fft/src/KokkosFFT_Plans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,20 @@ class Plan {
ExecutionSpace, typename OutViewType::memory_space>::accessible,
"Plan::Plan: execution_space cannot access data in OutViewType");

if (std::is_floating_point<in_value_type>::value &&
m_direction != KokkosFFT::Direction::forward) {
throw std::runtime_error(
"Plan::Plan: real to complex transform is constrcuted with backward "
"direction.");
}

if (std::is_floating_point<out_value_type>::value &&
m_direction != KokkosFFT::Direction::backward) {
throw std::runtime_error(
"Plan::Plan: complex to real transform is constrcuted with forward "
"direction.");
}

shape_type<1> s = {0};
if (n) {
std::size_t _n = n.value();
Expand Down Expand Up @@ -256,6 +270,20 @@ class Plan {
ExecutionSpace, typename OutViewType::memory_space>::accessible,
"Plan::Plan: execution_space cannot access data in OutViewType");

if (std::is_floating_point<in_value_type>::value &&
m_direction != KokkosFFT::Direction::forward) {
throw std::runtime_error(
"Plan::Plan: real to complex transform is constrcuted with backward "
"direction.");
}

if (std::is_floating_point<out_value_type>::value &&
m_direction != KokkosFFT::Direction::backward) {
throw std::runtime_error(
"Plan::Plan: complex to real transform is constrcuted with forward "
"direction.");
}

bool is_C2R = is_complex<in_value_type>::value &&
std::is_floating_point<out_value_type>::value;

Expand Down Expand Up @@ -306,23 +334,6 @@ class Plan {
"Plan::good: OutViewType for plan and "
"execution are not identical.");

using in_value_type = typename InViewType2::non_const_value_type;
using out_value_type = typename OutViewType2::non_const_value_type;

if (std::is_floating_point<in_value_type>::value &&
m_direction != KokkosFFT::Direction::forward) {
throw std::runtime_error(
"Plan::good: real to complex transform is constrcuted with backward "
"direction.");
}

if (std::is_floating_point<out_value_type>::value &&
m_direction != KokkosFFT::Direction::backward) {
throw std::runtime_error(
"Plan::good: complex to real transform is constrcuted with forward "
"direction.");
}

auto in_extents = KokkosFFT::Impl::extract_extents(in);
auto out_extents = KokkosFFT::Impl::extract_extents(out);
if (in_extents != m_in_extents) {
Expand Down
Loading

0 comments on commit 0edcf54

Please sign in to comment.