Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Jul 29, 2024
1 parent edbd483 commit 07282b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
10 changes: 5 additions & 5 deletions common/src/KokkosFFT_Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ auto get_shift(const ViewType& inout, axis_type<DIM> _axes, int direction = 1) {

// Assert if the elements are overlapped
constexpr int rank = ViewType::rank();
check_precondition(!KokkosFFT::Impl::has_duplicate_values(axes),
"axes are overlapped");
check_precondition(
KOKKOSFFT_EXPECTS(!KokkosFFT::Impl::has_duplicate_values(axes),
"Axes overlap");
KOKKOSFFT_EXPECTS(
!KokkosFFT::Impl::is_out_of_range_value_included(axes, rank),
"axes include out of range index."
"axes should be in the range of [-rank, rank-1].");
"Axes include an out-of-range index."
"Axes must be in the range of [-rank, rank-1].");

axis_type<rank> shift = {0};
for (int i = 0; i < static_cast<int>(DIM); i++) {
Expand Down
22 changes: 10 additions & 12 deletions common/src/KokkosFFT_layouts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ auto get_extents(const InViewType& in, const OutViewType& out,
if (is_real_v<in_value_type>) {
// Then R2C
if (is_complex_v<out_value_type>) {
if (_out_extents.at(inner_most_axis) !=
_in_extents.at(inner_most_axis) / 2 + 1) {
throw std::runtime_error(
"For R2C, the output extent of transform should be input extent / "
"2 + 1");
}
KOKKOSFFT_EXPECTS(
_out_extents.at(inner_most_axis) ==
_in_extents.at(inner_most_axis) / 2 + 1,
"For R2C, the 'output extent' of transform must be equal to "
"'input extent'/2 + 1");
} else {
throw std::runtime_error(
"If the input type is real, the output type should be complex");
Expand All @@ -82,12 +81,11 @@ auto get_extents(const InViewType& in, const OutViewType& out,
if (is_real_v<out_value_type>) {
// Then C2R
if (is_complex_v<in_value_type>) {
if (_in_extents.at(inner_most_axis) !=
_out_extents.at(inner_most_axis) / 2 + 1) {
throw std::runtime_error(
"For C2R, the input extent of transform should be output extent / "
"2 + 1");
}
KOKKOSFFT_EXPECTS(
_in_extents.at(inner_most_axis) ==
_out_extents.at(inner_most_axis) / 2 + 1,
"For C2R, the 'input extent' of transform must be equal to "
"'output extent' / 2 + 1");
} else {
throw std::runtime_error(
"If the output type is real, the input type should be complex");
Expand Down
14 changes: 6 additions & 8 deletions common/src/KokkosFFT_padding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ auto get_modified_shape(const InViewType in, const OutViewType /* out */,
}

// Assert if the elements are overlapped
if (KokkosFFT::Impl::has_duplicate_values(positive_axes)) {
throw std::runtime_error("get_modified_shape: axes are overlapped.");
}
if (KokkosFFT::Impl::is_out_of_range_value_included(positive_axes, rank)) {
throw std::runtime_error(
"get_modified_shape: axes include out of range index."
"axes should be in the range of [-rank, rank-1].");
}
KOKKOSFFT_EXPECTS(!KokkosFFT::Impl::has_duplicate_values(positive_axes),
"Axes overlap");
KOKKOSFFT_EXPECTS(
!KokkosFFT::Impl::is_out_of_range_value_included(positive_axes, rank),
"Axes include an out-of-range index."
"Axes must be in the range of [-rank, rank-1].");

using full_shape_type = shape_type<rank>;
full_shape_type modified_shape;
Expand Down
17 changes: 6 additions & 11 deletions common/src/KokkosFFT_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,21 @@ inline void check_precondition(const bool expression,
}
throw std::runtime_error(ss.str());
}
inline void check_precondition(const bool expression, const std::string& msg,
const char* file_name, int line,
const char* function_name) {
std::stringstream ss("file: ");
ss << file_name << '(' << line << ") `" << function_name << "`: " << msg
<< '\n';
if (!expression) {
throw std::runtime_error(ss.str());
}
}
#endif

template <typename ViewType>
auto convert_negative_axis(ViewType, int _axis = -1) {
static_assert(Kokkos::is_view<ViewType>::value,
"convert_negative_axis: ViewType is not a Kokkos::View.");
int rank = static_cast<int>(ViewType::rank());
<<<<<<< HEAD
if (_axis < -rank || _axis >= rank) {
throw std::runtime_error("axis should be in [-rank, rank-1]");
}
=======

KOKKOSFFT_EXPECTS(_axis >= -rank && _axis < rank,
"Axis must be in [-rank, rank-1]");
>>>>>>> a786585 (improve assertion)

int axis = _axis < 0 ? rank + _axis : _axis;
return axis;
Expand Down

0 comments on commit 07282b9

Please sign in to comment.