Skip to content

Commit

Permalink
Allow user to work on const output View
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Sep 24, 2024
1 parent 9a6a7bb commit f47bce2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions common/src/KokkosFFT_transpose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ void prep_transpose_view(InViewType& in, OutViewType& out,
}
}

if (!is_out_view_ready) {
if constexpr (!OutViewType::memory_traits::is_unmanaged) {
KokkosFFT::Impl::create_view(out, "out", out_extents);
} else {
// try to reshape out if it currently has enough memory available
KokkosFFT::Impl::reshape_view(out, out_extents);
if constexpr (std::is_const_v<OutViewType>) {
KOKKOSFFT_THROW_IF(!is_out_view_ready,
"prep_transpose_view: OutViewType is const, but do not have the required extents");
} else {
if (!is_out_view_ready) {
if constexpr (!OutViewType::memory_traits::is_unmanaged) {
KokkosFFT::Impl::create_view(out, "out", out_extents);
} else {
// try to reshape out if it currently has enough memory available
KokkosFFT::Impl::reshape_view(out, out_extents);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions fft/unit_test/Test_Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,8 @@ void test_fft2_2dfft_2dview() {
Kokkos::View<Kokkos::complex<T>**, LayoutType, execution_space>;

ComplexView2DType x("x", n0, n1);
ComplexView2DType out("out", n0, n1), out1("out1", n0, n1),
out2("out2", n0, n1);
ComplexView2DType out("out", n0, n1);
const ComplexView2DType out1("out1", n0, n1), out2("out2", n0, n1);
ComplexView2DType out_b("out_b", n0, n1), out_o("out_o", n0, n1),
out_f("out_f", n0, n1);

Expand Down

0 comments on commit f47bce2

Please sign in to comment.