Skip to content

Commit

Permalink
More fixes for cpp14 and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed May 23, 2024
1 parent dc0f4da commit fd0be5b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
13 changes: 9 additions & 4 deletions include/experimental/__p0009_bits/extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,17 +646,21 @@ check_upper_bound(InputIndexType user_index,
#endif
}

// Returning true to use AND fold instead of comma
// CPP14 mode doesn't like the use of void expressions
// with the way the _MDSPAN_FOLD_AND is set up
template<class InputIndex, class ExtentsIndexType>
MDSPAN_INLINE_FUNCTION
constexpr void
constexpr bool
check_one_index(InputIndex user_index,
ExtentsIndexType current_extent)
{
check_lower_bound(user_index, current_extent,
std::integral_constant<bool, std::is_signed<ExtentsIndexType>::value>{});
check_upper_bound(user_index, current_extent);
return true;
}

template<size_t ... RankIndices,
class ExtentsIndexType, size_t ... Exts,
class ... Indices>
Expand All @@ -666,7 +670,8 @@ check_all_indices_helper(std::index_sequence<RankIndices...>,
const extents<ExtentsIndexType, Exts...>& exts,
Indices... indices)
{
_MDSPAN_FOLD_COMMA(
// Suppress warning about statement has no effect
(void) _MDSPAN_FOLD_AND(
(check_one_index(indices, exts.extent(RankIndices)))
);
}
Expand All @@ -681,6 +686,6 @@ check_all_indices(const extents<ExtentsIndexType, Exts...>& exts,
check_all_indices_helper(std::make_index_sequence<sizeof...(Indices)>(),
exts, indices...);
}

} // namespace detail
} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE
5 changes: 4 additions & 1 deletion include/experimental/__p0009_bits/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ template <bool check = MDSPAN_IMPL_CHECK_PRECONDITION>
MDSPAN_FUNCTION constexpr void precondition(const char* cond, const char* file, unsigned line)
{
if (not check) { return; }

// in case the macro doesn't use the arguments for custom macros
(void) cond;
(void) file;
(void) line;
MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER(cond, file, line);
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_mdspan_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void test_mdspan_size(std::vector<char>& storage, Extents&& e)

TEST(TestMdspan, MdspanSizeReturnTypeAndPrecondition)
{
(void) test_info_;
std::vector<char> storage;

static_assert(std::numeric_limits<std::int8_t>::max() == 127, "max int8_t != 127");
Expand Down
27 changes: 25 additions & 2 deletions tests/test_submdspan_static_slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using IC = std::integral_constant<Integral, Value>;
template<class ExpectedOutputMdspan, class InputMdspan, class ... Slices>
void test_submdspan_static_slice(
typename InputMdspan::mapping_type input_mapping,
Slices&&... slices)
[[maybe_unused]] Slices&&... slices)
{
using input_type = InputMdspan;
std::vector<typename InputMdspan::value_type> storage(input_mapping.required_span_size());
Expand All @@ -44,20 +44,22 @@ void test_submdspan_static_slice(
template<class ExpectedOutputMdspan, class InputMdspan, class ... Slices>
void test_submdspan_static_slice(
typename InputMdspan::extents_type input_extents,
Slices&&... slices)
[[maybe_unused]] Slices&&... slices)
{
using input_mapping_type = typename InputMdspan::mapping_type;
input_mapping_type input_mapping(input_extents);
test_submdspan_static_slice<ExpectedOutputMdspan, InputMdspan>(input_mapping, std::forward<Slices>(slices)...);
}

TEST(TestMdspan, StaticAsserts) {
(void) test_info_;
static_assert(std::is_convertible<IC<std::size_t, 1>, std::size_t>::value, "Just a check.");
static_assert(std::is_convertible<IC<int32_t, 1>, std::size_t>::value, "Just a check.");
static_assert(std::is_convertible<IC<uint32_t, 1>, std::size_t>::value, "Just a check.");
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullFullIndex) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -84,6 +86,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullFullIndex) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullFullIndex) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -110,6 +113,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullFullIndex) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_FullFullIndex) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_right;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -136,6 +140,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_FullFullIndex) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_FullFullIndex) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_right;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -162,6 +167,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_FullFullIndex) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullIndexFull) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -188,6 +194,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullIndexFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullIndexFull) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand All @@ -214,6 +221,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullIndexFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullTupleFull) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_left;
Expand Down Expand Up @@ -251,6 +259,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_FullTupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullTupleFull) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_left;
Expand Down Expand Up @@ -288,6 +297,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_FullTupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_FullTupleFull) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_right;
Expand Down Expand Up @@ -325,6 +335,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_FullTupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_FullTupleFull) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_right;
Expand Down Expand Up @@ -362,6 +373,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_FullTupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_TupleFullTuple) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_left;
Expand Down Expand Up @@ -403,6 +415,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_iddd_TupleFullTuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_TupleFullTuple) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_left;
Expand Down Expand Up @@ -444,6 +457,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_i345_TupleFullTuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_TupleFullTuple) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::dextents<int, 3>;
using input_layout_type = Kokkos::layout_right;
Expand Down Expand Up @@ -485,6 +499,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_iddd_TupleFullTuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_TupleFullTuple) {
(void) test_info_;
using std::tuple;
using input_extents_type = Kokkos::extents<int, 3, 4, 5>;
using input_layout_type = Kokkos::layout_right;
Expand Down Expand Up @@ -529,6 +544,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_i345_TupleFullTuple) {
// it may help to comment out all the tests but the ones below.

TEST(TestMdspan, SubmdspanStaticSlice_Left_idd_FullTuple) {
(void) test_info_;
// tuple of two integral_constant is convertible to tuple of two size_t.
// Nevertheless, submdspan needs special handling to be able to compile
// with a tuple of two integral_constant as a slice specifier.
Expand Down Expand Up @@ -574,6 +590,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_idd_FullTuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_idd_FullTuple) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 2>;
using input_layout_type = Kokkos::layout_right;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -608,6 +625,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_idd_FullTuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_idd_TupleFull) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 2>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -642,6 +660,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_idd_TupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_idd_TupleFull) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 2>;
using input_layout_type = Kokkos::layout_right;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -676,6 +695,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Right_idd_TupleFull) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Stride_idd_TupleFull) {
(void) test_info_;
using input_extents_type = Kokkos::dextents<int, 2>;
using input_layout_type = Kokkos::layout_stride;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -715,6 +735,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Stride_idd_TupleFull) {
// Rank 1 tests

TEST(TestMdspan, SubmdspanStaticSlice_Left_id_Tuple) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, Kokkos::dynamic_extent>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -749,6 +770,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_id_Tuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Left_i5_Tuple) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, 5>;
using input_layout_type = Kokkos::layout_left;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down Expand Up @@ -783,6 +805,7 @@ TEST(TestMdspan, SubmdspanStaticSlice_Left_i5_Tuple) {
}

TEST(TestMdspan, SubmdspanStaticSlice_Right_id_Tuple) {
(void) test_info_;
using input_extents_type = Kokkos::extents<int, Kokkos::dynamic_extent>;
using input_layout_type = Kokkos::layout_right;
using input_mdspan_type = Kokkos::mdspan<float, input_extents_type, input_layout_type>;
Expand Down

0 comments on commit fd0be5b

Please sign in to comment.