From f22a23ab5eacc009c2650473c4dafbbe77e02266 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Sat, 27 Jan 2024 19:13:30 +0900 Subject: [PATCH 1/3] Use Kokkos Array inside parallel for --- common/src/KokkosFFT_transpose.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/KokkosFFT_transpose.hpp b/common/src/KokkosFFT_transpose.hpp index 772d0a6d..44658dea 100644 --- a/common/src/KokkosFFT_transpose.hpp +++ b/common/src/KokkosFFT_transpose.hpp @@ -165,23 +165,25 @@ void _transpose(const ExecutionSpace& exec_space, InViewType& in, auto [_n0, _n1, _n2] = out_extents; out = OutViewType("out", _n0, _n1, _n2); } + + Kokkos::Array map = {_map[0], _map[1], _map[2]}; Kokkos::parallel_for( range, KOKKOS_LAMBDA(int i0, int i1, int i2) { int _i0 = i0, _i1 = i1, _i2 = i2; - if (_map[0] == 0 && _map[1] == 2 && _map[2] == 1) { + if (map[0] == 0 && map[1] == 2 && map[2] == 1) { _i1 = i2; _i2 = i1; - } else if (_map[0] == 1 && _map[1] == 0 && _map[2] == 2) { + } else if (map[0] == 1 && map[1] == 0 && map[2] == 2) { _i0 = i1; _i1 = i0; - } else if (_map[0] == 1 && _map[1] == 2 && _map[2] == 0) { + } else if (map[0] == 1 && map[1] == 2 && map[2] == 0) { _i0 = i1; _i1 = i2; _i2 = i0; - } else if (_map[0] == 2 && _map[1] == 1 && _map[2] == 0) { + } else if (map[0] == 2 && map[1] == 1 && map[2] == 0) { _i0 = i2; _i2 = i0; - } else if (_map[0] == 2 && _map[1] == 0 && _map[2] == 1) { + } else if (map[0] == 2 && map[1] == 0 && map[2] == 1) { _i0 = i2; _i1 = i0; _i2 = i1; From 5f16deecee7f68e79cae22ab376a4f5a80c62349 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Sat, 27 Jan 2024 19:14:17 +0900 Subject: [PATCH 2/3] add [[maybe_unused]] to suppress warnings from nvcc --- common/src/KokkosFFT_layouts.hpp | 6 +++--- common/src/KokkosFFT_normalization.hpp | 2 +- common/src/KokkosFFT_utils.hpp | 2 +- fft/src/KokkosFFT_Helpers.hpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/src/KokkosFFT_layouts.hpp b/common/src/KokkosFFT_layouts.hpp index aea31d8c..e9d48662 100644 --- a/common/src/KokkosFFT_layouts.hpp +++ b/common/src/KokkosFFT_layouts.hpp @@ -24,7 +24,7 @@ auto get_extents(InViewType& in, OutViewType& out, axis_type _axes) { auto [map, map_inv] = KokkosFFT::Impl::get_map_axes(in, _axes); constexpr std::size_t rank = InViewType::rank; - int inner_most_axis = + [[maybe_unused]] int inner_most_axis = std::is_same_v ? 0 : rank - 1; @@ -95,7 +95,7 @@ auto get_extents_batched(InViewType& in, OutViewType& out, "or equal to 1."); constexpr std::size_t rank = InViewType::rank; - int inner_most_axis = + [[maybe_unused]] int inner_most_axis = std::is_same_v ? 0 : (rank - 1); @@ -155,7 +155,7 @@ auto get_extents_batched(InViewType& in, OutViewType& out, 1, std::multiplies<>()); int fft_size = std::accumulate(fft_extents.begin(), fft_extents.end(), 1, std::multiplies<>()); - int howmany = total_fft_size / fft_size; + [[maybe_unused]] int howmany = total_fft_size / fft_size; return std::tuple, std::vector, std::vector, int>( {in_extents, out_extents, fft_extents, howmany}); diff --git a/common/src/KokkosFFT_normalization.hpp b/common/src/KokkosFFT_normalization.hpp index 28a90024..e2a08f98 100644 --- a/common/src/KokkosFFT_normalization.hpp +++ b/common/src/KokkosFFT_normalization.hpp @@ -25,7 +25,7 @@ auto _coefficients(const ViewType& inout, Direction direction, using value_type = KokkosFFT::Impl::real_type_t; value_type coef = 1; - bool to_normalize = false; + [[maybe_unused]] bool to_normalize = false; switch (normalization) { case Normalization::FORWARD: diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index e80b0d3c..b44fc110 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -69,7 +69,7 @@ auto convert_negative_shift(const ViewType& view, int _shift, int _axis) { "convert_negative_shift: ViewType is not a Kokkos::View."); int axis = convert_negative_axis(view, _axis); int extent = view.extent(axis); - int shift0 = 0, shift1 = 0, shift2 = extent / 2; + [[maybe_unused]] int shift0 = 0, shift1 = 0, shift2 = extent / 2; if (_shift < 0) { shift0 = -_shift + extent % 2; // add 1 for odd case diff --git a/fft/src/KokkosFFT_Helpers.hpp b/fft/src/KokkosFFT_Helpers.hpp index 39fc982c..8eba5de5 100644 --- a/fft/src/KokkosFFT_Helpers.hpp +++ b/fft/src/KokkosFFT_Helpers.hpp @@ -71,8 +71,8 @@ void _roll(const ExecutionSpace& exec_space, ViewType& inout, int n0 = inout.extent(0), n1 = inout.extent(1); ViewType tmp("tmp", n0, n1); - int len0 = (n0 - 1) / 2 + 1; - int len1 = (n1 - 1) / 2 + 1; + [[maybe_unused]] int len0 = (n0 - 1) / 2 + 1; + [[maybe_unused]] int len1 = (n1 - 1) / 2 + 1; using range_type = Kokkos::MDRangePolicy< ExecutionSpace, From 7266906213f5fbffb21ce6fb62e7564d7ab70994 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Sat, 27 Jan 2024 19:16:38 +0900 Subject: [PATCH 3/3] formatting --- common/src/KokkosFFT_layouts.hpp | 2 +- common/src/KokkosFFT_normalization.hpp | 2 +- common/src/KokkosFFT_utils.hpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/KokkosFFT_layouts.hpp b/common/src/KokkosFFT_layouts.hpp index e9d48662..01c41c1e 100644 --- a/common/src/KokkosFFT_layouts.hpp +++ b/common/src/KokkosFFT_layouts.hpp @@ -155,7 +155,7 @@ auto get_extents_batched(InViewType& in, OutViewType& out, 1, std::multiplies<>()); int fft_size = std::accumulate(fft_extents.begin(), fft_extents.end(), 1, std::multiplies<>()); - [[maybe_unused]] int howmany = total_fft_size / fft_size; + [[maybe_unused]] int howmany = total_fft_size / fft_size; return std::tuple, std::vector, std::vector, int>( {in_extents, out_extents, fft_extents, howmany}); diff --git a/common/src/KokkosFFT_normalization.hpp b/common/src/KokkosFFT_normalization.hpp index e2a08f98..47614a98 100644 --- a/common/src/KokkosFFT_normalization.hpp +++ b/common/src/KokkosFFT_normalization.hpp @@ -24,7 +24,7 @@ auto _coefficients(const ViewType& inout, Direction direction, Normalization normalization, std::size_t fft_size) { using value_type = KokkosFFT::Impl::real_type_t; - value_type coef = 1; + value_type coef = 1; [[maybe_unused]] bool to_normalize = false; switch (normalization) { diff --git a/common/src/KokkosFFT_utils.hpp b/common/src/KokkosFFT_utils.hpp index b44fc110..0009479a 100644 --- a/common/src/KokkosFFT_utils.hpp +++ b/common/src/KokkosFFT_utils.hpp @@ -67,8 +67,8 @@ template auto convert_negative_shift(const ViewType& view, int _shift, int _axis) { static_assert(Kokkos::is_view::value, "convert_negative_shift: ViewType is not a Kokkos::View."); - int axis = convert_negative_axis(view, _axis); - int extent = view.extent(axis); + int axis = convert_negative_axis(view, _axis); + int extent = view.extent(axis); [[maybe_unused]] int shift0 = 0, shift1 = 0, shift2 = extent / 2; if (_shift < 0) {