From e1cccb2ec8507933d79e4f869b20269d49beb7e0 Mon Sep 17 00:00:00 2001 From: yasahi-hpc <57478230+yasahi-hpc@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:26:00 +0200 Subject: [PATCH] Use if constexpr for compile time if conditional (#174) Co-authored-by: Yuuichi Asahi --- common/src/KokkosFFT_layouts.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/KokkosFFT_layouts.hpp b/common/src/KokkosFFT_layouts.hpp index 305e1309..4dbeae37 100644 --- a/common/src/KokkosFFT_layouts.hpp +++ b/common/src/KokkosFFT_layouts.hpp @@ -30,8 +30,10 @@ auto get_extents(const InViewType& in, const OutViewType& out, "input axes are not valid for the view"); constexpr std::size_t rank = InViewType::rank; - int inner_most_axis = - std::is_same_v ? 0 : (rank - 1); + [[maybe_unused]] int inner_most_axis = + std::is_same_v + ? 0 + : (rank - 1); // index map after transpose over axis auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(in, axes); @@ -61,7 +63,7 @@ auto get_extents(const InViewType& in, const OutViewType& out, static_assert(!(is_real_v && is_real_v), "get_extents: real to real transform is not supported"); - if (is_real_v) { + if constexpr (is_real_v) { // Then R2C KOKKOSFFT_THROW_IF( _out_extents.at(inner_most_axis) != @@ -70,7 +72,7 @@ auto get_extents(const InViewType& in, const OutViewType& out, "'input extent'/2 + 1"); } - if (is_real_v) { + if constexpr (is_real_v) { // Then C2R KOKKOSFFT_THROW_IF( _in_extents.at(inner_most_axis) != @@ -79,7 +81,7 @@ auto get_extents(const InViewType& in, const OutViewType& out, "'output extent' / 2 + 1"); } - if (std::is_same_v) { + if constexpr (std::is_same_v) { std::reverse(_in_extents.begin(), _in_extents.end()); std::reverse(_out_extents.begin(), _out_extents.end()); std::reverse(_fft_extents.begin(), _fft_extents.end());