Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass views by const& in fftshift #192

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions common/src/KokkosFFT_Helpers.hpp
tpadioleau marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ auto get_shift(const ViewType& inout, axis_type<DIM> axes, int direction = 1) {
}

template <typename ExecutionSpace, typename ViewType>
void roll(const ExecutionSpace& exec_space, ViewType& inout, axis_type<1> shift,
axis_type<1>) {
void roll(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<1> shift, axis_type<1>) {
tpadioleau marked this conversation as resolved.
Show resolved Hide resolved
// Last parameter is ignored but present for keeping the interface consistent
static_assert(ViewType::rank() == 1, "roll: Rank of View must be 1.");
int n0 = inout.extent_int(0);
Expand All @@ -67,13 +67,13 @@ void roll(const ExecutionSpace& exec_space, ViewType& inout, axis_type<1> shift,
}
});

inout = tmp;
Kokkos::deep_copy(inout, tmp);
}
}

template <typename ExecutionSpace, typename ViewType, std::size_t DIM1 = 1>
void roll(const ExecutionSpace& exec_space, ViewType& inout, axis_type<2> shift,
axis_type<DIM1> axes) {
void roll(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<2> shift, axis_type<DIM1> axes) {
constexpr int DIM0 = 2;
static_assert(ViewType::rank() == DIM0, "roll: Rank of View must be 2.");
int n0 = inout.extent_int(0), n1 = inout.extent_int(1);
Expand Down Expand Up @@ -128,18 +128,18 @@ void roll(const ExecutionSpace& exec_space, ViewType& inout, axis_type<2> shift,
}
});

inout = tmp;
Kokkos::deep_copy(inout, tmp);
}

template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void fftshift_impl(const ExecutionSpace& exec_space, ViewType& inout,
void fftshift_impl(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<DIM> axes) {
auto shift = get_shift(inout, axes);
roll(exec_space, inout, shift, axes);
}

template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void ifftshift_impl(const ExecutionSpace& exec_space, ViewType& inout,
void ifftshift_impl(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<DIM> axes) {
auto shift = get_shift(inout, axes, -1);
roll(exec_space, inout, shift, axes);
Expand Down Expand Up @@ -219,7 +219,7 @@ auto rfftfreq(const ExecutionSpace&, const std::size_t n,
/// \param axes [in] Axes over which to shift (default: nullopt, shifting over
/// all axes)
template <typename ExecutionSpace, typename ViewType>
void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
void fftshift(const ExecutionSpace& exec_space, const ViewType& inout,
std::optional<int> axes = std::nullopt) {
static_assert(KokkosFFT::Impl::is_operatable_view_v<ExecutionSpace, ViewType>,
"fftshift: View value type must be float, double, "
Expand All @@ -246,7 +246,7 @@ void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
/// \param inout [in,out] Spectrum
/// \param axes [in] Axes over which to shift
template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
void fftshift(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<DIM> axes) {
static_assert(KokkosFFT::Impl::is_operatable_view_v<ExecutionSpace, ViewType>,
"fftshift: View value type must be float, double, "
Expand All @@ -269,7 +269,7 @@ void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
/// \param axes [in] Axes over which to shift (default: nullopt, shifting over
/// all axes)
template <typename ExecutionSpace, typename ViewType>
void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
void ifftshift(const ExecutionSpace& exec_space, const ViewType& inout,
std::optional<int> axes = std::nullopt) {
static_assert(KokkosFFT::Impl::is_operatable_view_v<ExecutionSpace, ViewType>,
"ifftshift: View value type must be float, double, "
Expand All @@ -295,7 +295,7 @@ void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
/// \param inout [in,out] Spectrum
/// \param axes [in] Axes over which to shift
template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
void ifftshift(const ExecutionSpace& exec_space, const ViewType& inout,
axis_type<DIM> axes) {
static_assert(KokkosFFT::Impl::is_operatable_view_v<ExecutionSpace, ViewType>,
"ifftshift: View value type must be float, double, "
Expand Down
Loading