Skip to content

Commit

Permalink
Rename functions starting from under score (#115)
Browse files Browse the repository at this point in the history
* Rename:unuse under score in Plan functions

* Rename: unuse under score in Transform functions

* Rename: unuse under score in util functions

* Rename: unuse under score in helper functions

* update _get_shift to get_shift

* rename roll_impl and coefficients_impl

* Undo merging destroy_plan and destroy_info functions

---------

Co-authored-by: Yuuichi Asahi <[email protected]>
  • Loading branch information
yasahi-hpc and Yuuichi Asahi authored Jul 9, 2024
1 parent f49a2e8 commit 17e97f3
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 260 deletions.
61 changes: 30 additions & 31 deletions common/src/KokkosFFT_Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
namespace KokkosFFT {
namespace Impl {
template <typename ViewType, std::size_t DIM = 1>
auto _get_shift(const ViewType& inout, axis_type<DIM> _axes,
int direction = 1) {
auto get_shift(const ViewType& inout, axis_type<DIM> _axes, int direction = 1) {
static_assert(DIM > 0,
"_get_shift: Rank of shift axes must be "
"get_shift: Rank of shift axes must be "
"larger than or equal to 1.");

// Convert the input axes to be in the range of [0, rank-1]
Expand All @@ -39,10 +38,10 @@ auto _get_shift(const ViewType& inout, axis_type<DIM> _axes,
}

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, ViewType& inout, axis_type<1> shift,
axis_type<1>) {
// Last parameter is ignored but present for keeping the interface consistent
static_assert(ViewType::rank() == 1, "_roll: Rank of View must be 1.");
static_assert(ViewType::rank() == 1, "roll: Rank of View must be 1.");
std::size_t n0 = inout.extent(0);

ViewType tmp("tmp", n0);
Expand All @@ -69,10 +68,10 @@ void _roll(const ExecutionSpace& exec_space, ViewType& inout,
}

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, 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.");
static_assert(ViewType::rank() == DIM0, "roll: Rank of View must be 2.");
int n0 = inout.extent(0), n1 = inout.extent(1);

ViewType tmp("tmp", n0, n1);
Expand Down Expand Up @@ -130,43 +129,43 @@ void _roll(const ExecutionSpace& exec_space, ViewType& inout,
}

template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void _fftshift(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
void fftshift_impl(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
static_assert(Kokkos::is_view<ViewType>::value,
"_fftshift: ViewType is not a Kokkos::View.");
"fftshift_impl: ViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::is_layout_left_or_right_v<ViewType>,
"_fftshift: ViewType must be either LayoutLeft or LayoutRight.");
"fftshift_impl: ViewType must be either LayoutLeft or LayoutRight.");
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename ViewType::memory_space>::accessible,
"_fftshift: execution_space cannot access data in ViewType");
"fftshift_impl: execution_space cannot access data in ViewType");

static_assert(ViewType::rank() >= DIM,
"_fftshift: Rank of View must be larger thane "
"fftshift_impl: Rank of View must be larger thane "
"or equal to the Rank of shift axes.");
auto shift = _get_shift(inout, axes);
_roll(exec_space, inout, shift, 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(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
void ifftshift_impl(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
static_assert(Kokkos::is_view<ViewType>::value,
"_ifftshift: ViewType is not a Kokkos::View.");
"ifftshift_impl: ViewType is not a Kokkos::View.");
static_assert(
KokkosFFT::Impl::is_layout_left_or_right_v<ViewType>,
"_ifftshift: ViewType must be either LayoutLeft or LayoutRight.");
"ifftshift_impl: ViewType must be either LayoutLeft or LayoutRight.");
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename ViewType::memory_space>::accessible,
"_ifftshift: execution_space cannot access data in ViewType");
"ifftshift_impl: execution_space cannot access data in ViewType");

static_assert(ViewType::rank() >= DIM,
"_ifftshift: Rank of View must be larger "
"ifftshift_impl: Rank of View must be larger "
"thane or equal to the Rank of shift axes.");
auto shift = _get_shift(inout, axes, -1);
_roll(exec_space, inout, shift, axes);
auto shift = get_shift(inout, axes, -1);
roll(exec_space, inout, shift, axes);
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down Expand Up @@ -246,12 +245,12 @@ void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
std::optional<int> axes = std::nullopt) {
if (axes) {
axis_type<1> _axes{axes.value()};
KokkosFFT::Impl::_fftshift(exec_space, inout, _axes);
KokkosFFT::Impl::fftshift_impl(exec_space, inout, _axes);
} else {
constexpr std::size_t rank = ViewType::rank();
constexpr int start = -static_cast<int>(rank);
axis_type<rank> _axes = KokkosFFT::Impl::index_sequence<rank>(start);
KokkosFFT::Impl::_fftshift(exec_space, inout, _axes);
KokkosFFT::Impl::fftshift_impl(exec_space, inout, _axes);
}
}

Expand All @@ -263,7 +262,7 @@ void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void fftshift(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
KokkosFFT::Impl::_fftshift(exec_space, inout, axes);
KokkosFFT::Impl::fftshift_impl(exec_space, inout, axes);
}

/// \brief The inverse of fftshift
Expand All @@ -276,12 +275,12 @@ void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
std::optional<int> axes = std::nullopt) {
if (axes) {
axis_type<1> _axes{axes.value()};
KokkosFFT::Impl::_ifftshift(exec_space, inout, _axes);
KokkosFFT::Impl::ifftshift_impl(exec_space, inout, _axes);
} else {
constexpr std::size_t rank = ViewType::rank();
constexpr int start = -static_cast<int>(rank);
axis_type<rank> _axes = KokkosFFT::Impl::index_sequence<rank>(start);
KokkosFFT::Impl::_ifftshift(exec_space, inout, _axes);
KokkosFFT::Impl::ifftshift_impl(exec_space, inout, _axes);
}
}

Expand All @@ -293,7 +292,7 @@ void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
template <typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void ifftshift(const ExecutionSpace& exec_space, ViewType& inout,
axis_type<DIM> axes) {
KokkosFFT::Impl::_ifftshift(exec_space, inout, axes);
KokkosFFT::Impl::ifftshift_impl(exec_space, inout, axes);
}
} // namespace KokkosFFT

Expand Down
12 changes: 6 additions & 6 deletions common/src/KokkosFFT_normalization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace KokkosFFT {
namespace Impl {
template <typename ExecutionSpace, typename ViewType, typename T>
void _normalize(const ExecutionSpace& exec_space, ViewType& inout,
const T coef) {
void normalize_impl(const ExecutionSpace& exec_space, ViewType& inout,
const T coef) {
std::size_t size = inout.size();
auto* data = inout.data();

Expand All @@ -24,8 +24,8 @@ void _normalize(const ExecutionSpace& exec_space, ViewType& inout,
}

template <typename ViewType>
auto _coefficients(ViewType, Direction direction, Normalization normalization,
std::size_t fft_size) {
auto get_coefficients(ViewType, Direction direction,
Normalization normalization, std::size_t fft_size) {
using value_type =
KokkosFFT::Impl::real_type_t<typename ViewType::non_const_value_type>;
value_type coef = 1;
Expand Down Expand Up @@ -63,8 +63,8 @@ void normalize(const ExecutionSpace& exec_space, ViewType& inout,
Direction direction, Normalization normalization,
std::size_t fft_size) {
auto [coef, to_normalize] =
_coefficients(inout, direction, normalization, fft_size);
if (to_normalize) _normalize(exec_space, inout, coef);
get_coefficients(inout, direction, normalization, fft_size);
if (to_normalize) normalize_impl(exec_space, inout, coef);
}

inline auto swap_direction(Normalization normalization) {
Expand Down
38 changes: 18 additions & 20 deletions common/src/KokkosFFT_padding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ auto is_crop_or_pad_needed(const ViewType& view,
"is_crop_or_pad_needed: Rank of View must be equal to Rank "
"of extended shape.");

// [TO DO] Add a is_C2R arg. If is_C2R is true, then shape should be shape/2+1
constexpr int rank = static_cast<int>(ViewType::rank());

bool not_same = false;
bool not_same = false;
for (int i = 0; i < rank; i++) {
if (modified_shape.at(i) != view.extent(i)) {
not_same = true;
Expand All @@ -103,8 +101,8 @@ auto is_crop_or_pad_needed(const ViewType& view,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<1> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<1> s) {
auto _n0 = s.at(0);
out = OutViewType("out", _n0);

Expand All @@ -117,8 +115,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<2> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<2> s) {
constexpr std::size_t DIM = 2;

auto [_n0, _n1] = s;
Expand All @@ -143,8 +141,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<3> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<3> s) {
constexpr std::size_t DIM = 3;

auto [_n0, _n1, _n2] = s;
Expand Down Expand Up @@ -172,8 +170,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<4> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<4> s) {
constexpr std::size_t DIM = 4;

auto [_n0, _n1, _n2, _n3] = s;
Expand Down Expand Up @@ -202,8 +200,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<5> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<5> s) {
constexpr std::size_t DIM = 5;

auto [_n0, _n1, _n2, _n3, _n4] = s;
Expand Down Expand Up @@ -233,8 +231,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<6> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<6> s) {
constexpr std::size_t DIM = 6;

auto [_n0, _n1, _n2, _n3, _n4, _n5] = s;
Expand Down Expand Up @@ -266,8 +264,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<7> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<7> s) {
constexpr std::size_t DIM = 6;

auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6] = s;
Expand Down Expand Up @@ -302,8 +300,8 @@ void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
}

template <typename ExecutionSpace, typename InViewType, typename OutViewType>
void _crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<8> s) {
void crop_or_pad_impl(const ExecutionSpace& exec_space, const InViewType& in,
OutViewType& out, shape_type<8> s) {
constexpr std::size_t DIM = 6;

auto [_n0, _n1, _n2, _n3, _n4, _n5, _n6, _n7] = s;
Expand Down Expand Up @@ -351,7 +349,7 @@ void crop_or_pad(const ExecutionSpace& exec_space, const InViewType& in,
static_assert(OutViewType::rank() == DIM,
"crop_or_pad: Rank of View must be equal to Rank "
"of extended shape.");
_crop_or_pad(exec_space, in, out, s);
crop_or_pad_impl(exec_space, in, out, s);
}
} // namespace Impl
} // namespace KokkosFFT
Expand Down
Loading

0 comments on commit 17e97f3

Please sign in to comment.