Skip to content

Commit

Permalink
unstdify config.hpp macros
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Nov 26, 2024
1 parent 771e3ca commit a66c160
Show file tree
Hide file tree
Showing 37 changed files with 287 additions and 279 deletions.
4 changes: 2 additions & 2 deletions compilation_tests/ctest_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// At least in the case of clang, that error is descriptive enough to see what's
// going on if we're careful with how we do things.

#if _MDSPAN_USE_CONSTEXPR_14
#if MDSPAN_USE_CONSTEXPR_14

// A nice marker in the compiler output. Also, use std::is_constant_evaluated if we have it
#if __cpp_lib_is_constant_evaluated > 201811
Expand Down Expand Up @@ -117,7 +117,7 @@ struct _____constexpr_assertion_failed_ {
#define constexpr_assert_greater_than(expr, ...) \
_____constexpr_assertion_failed_{#__VA_ARGS__}._expected_to_be_greater_than_(expr).but_actual_value_was_((__VA_ARGS__));

#endif // _MDSPAN_USE_CONSTEXPR_14
#endif // MDSPAN_USE_CONSTEXPR_14

// </editor-fold> end assert-like macros that don't break constexpr }}}1
//==============================================================================
Expand Down
16 changes: 8 additions & 8 deletions compilation_tests/ctest_compressed_pair_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct E3 {};
void instantiate_tests() {
//==============================================================================
// <editor-fold desc="compressed pair layout: 2 leaf elements"> {{{1
#ifdef _MDSPAN_COMPILER_MSVC
#ifdef MDSPAN_COMPILER_MSVC
test<CP<E0, E0>, 1, empty, non_standard_layout>();
test<CP<E0, E1>, 1, empty, standard_layout>();
#else
Expand All @@ -75,29 +75,29 @@ test<CP<int*, int*>, 2 * sizeof(int*), non_empty>();

//==============================================================================
// <editor-fold desc="compressed pair layout: 1 nested pair, 3 leaf element"> {{{1
#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
#if defined(MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
test<CP<E0, CP<E0, E0>>, 3, empty>(); // Emulation can't handle this correctly.
#endif
#ifdef _MDSPAN_COMPILER_MSVC
#ifdef MDSPAN_COMPILER_MSVC
test<CP<E0, CP<E1, E2>>, 2, empty>();
#else
test<CP<E0, CP<E1, E2>>, 1, empty>();
#endif
test<CP<E0, CP<E1, int*>>, sizeof(int*), non_empty>();
test<CP<E0, CP<int*, E2>>, sizeof(int*), non_empty>();
test<CP<E0, CP<int*, int*>>, 2 * sizeof(int*), non_empty>();
#ifdef _MDSPAN_COMPILER_MSVC
#ifdef MDSPAN_COMPILER_MSVC
test<CP<int*, CP<E1, E2>>, 2 * sizeof(int*), non_empty>();
#else
test<CP<int*, CP<E1, E2>>, sizeof(int*), non_empty>();
#endif
test<CP<int*, CP<E1, int*>>, 2 * sizeof(int*), non_empty>();
test<CP<int*, CP<int*, E2>>, 2 * sizeof(int*), non_empty>();
test<CP<int*, CP<int*, int*>>, 3 * sizeof(int*), non_empty>();
#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
#if defined(MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
test<CP<CP<E0, E0>, E0>, 3, empty>(); // Emulation can't handle this correctly.
#endif
#ifdef _MDSPAN_COMPILER_MSVC
#ifdef MDSPAN_COMPILER_MSVC
test<CP<CP<E0, E1>, E2>, 2, empty>();
test<CP<CP<E0, E1>, int*>, 2 * sizeof(int*), non_empty>();
#else
Expand All @@ -115,10 +115,10 @@ test<CP<CP<int*, int*>, int*>, 3 * sizeof(int*), non_empty>();

//==============================================================================
// <editor-fold desc="compressed pair layout: 2 nested pairs, 4 leaf element"> {{{1
#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
#if defined(MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
test<CP<CP<E0, E0>, CP<E0, E0>>, 4, empty>(); // Emulation can't handle this correctly.
#endif
#ifdef _MDSPAN_COMPILER_MSVC
#ifdef MDSPAN_COMPILER_MSVC
test<CP<CP<E0, E1>, CP<E2, E3>>, 3, empty>();
test<CP<CP<E0, E1>, CP<E2, int*>>, 2 * sizeof(int*), non_empty>();
test<CP<CP<E0, E1>, CP<int*, E3>>, 2 * sizeof(int*), non_empty>();
Expand Down
18 changes: 9 additions & 9 deletions compilation_tests/ctest_constexpr_dereference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


// Only works with newer constexpr
#if defined(_MDSPAN_USE_CONSTEXPR_14) && _MDSPAN_USE_CONSTEXPR_14
#if defined(MDSPAN_USE_CONSTEXPR_14) && MDSPAN_USE_CONSTEXPR_14

//==============================================================================

Expand All @@ -34,7 +34,7 @@ simple_static_sum_test_1(int add_to_row) {
int result = 0;
for(int col = 0; col < 3; ++col) {
for(int row = 0; row < 3; ++row) {
result += __MDSPAN_OP(s, row, col) * (row + add_to_row);
result += MDSPAN_OP(s, row, col) * (row + add_to_row);
}
}
return result;
Expand Down Expand Up @@ -87,7 +87,7 @@ simple_dynamic_sum_test_2(int add_to_row) {
int result = 0;
for(int col = 0; col < 3; ++col) {
for(int row = 0; row < 3; ++row) {
result += __MDSPAN_OP(s, row, col) * (row + add_to_row);
result += MDSPAN_OP(s, row, col) * (row + add_to_row);
}
}
return result;
Expand Down Expand Up @@ -120,7 +120,7 @@ simple_mixed_layout_left_sum_test_3(int add_to_row) {
int result = 0;
for(int col = 0; col < 3; ++col) {
for(int row = 0; row < 3; ++row) {
result += __MDSPAN_OP(s, row, col) * (row + add_to_row);
result += MDSPAN_OP(s, row, col) * (row + add_to_row);
}
}
return result;
Expand Down Expand Up @@ -150,8 +150,8 @@ multidimensional_single_element_stress_test_impl_2(
int data[] = { 42 };
auto s = mdspan_t(data);
auto s_dyn = dyn_mdspan_t(data, _repeated_ptrdiff_t<1, Idxs>...);
auto val = __MDSPAN_OP(s, _repeated_ptrdiff_t<0, Idxs>...);
auto val_dyn = __MDSPAN_OP(s_dyn, _repeated_ptrdiff_t<0, Idxs>...);
auto val = MDSPAN_OP(s, _repeated_ptrdiff_t<0, Idxs>...);
auto val_dyn = MDSPAN_OP(s_dyn, _repeated_ptrdiff_t<0, Idxs>...);
constexpr_assert_equal(42, val);
constexpr_assert_equal(42, val_dyn);
return val == 42 && val_dyn == 42;
Expand Down Expand Up @@ -205,13 +205,13 @@ stress_test_2d_single_element_stress_test_impl_2(
auto s12 = dyn_mdspan_t(data, Idx1, Idx2);
for(ptrdiff_t i = 0; i < Idx1; ++i) {
for(ptrdiff_t j = 0; j < Idx2; ++j) {
__MDSPAN_OP(s, i, j) = __MDSPAN_OP(s1, i, j) = __MDSPAN_OP(s2, i, j) = __MDSPAN_OP(s12, i, j) = 1;
MDSPAN_OP(s, i, j) = MDSPAN_OP(s1, i, j) = MDSPAN_OP(s2, i, j) = MDSPAN_OP(s12, i, j) = 1;
}
}
int result = 0;
for(ptrdiff_t i = 0; i < Idx1; ++i) {
for(ptrdiff_t j = 0; j < Idx2; ++j) {
result += __MDSPAN_OP(s, i, j) + __MDSPAN_OP(s1, i, j) + __MDSPAN_OP(s2, i, j) + __MDSPAN_OP(s12, i, j);
result += MDSPAN_OP(s, i, j) + MDSPAN_OP(s1, i, j) + MDSPAN_OP(s2, i, j) + MDSPAN_OP(s12, i, j);
}
}
result /= 4;
Expand Down Expand Up @@ -270,4 +270,4 @@ static bool _stress_2d_result =
#endif // MDSPAN_DISABLE_EXPENSIVE_COMPILATION_TESTS


#endif //defined(_MDSPAN_USE_CONSTEXPR_14) && _MDSPAN_USE_CONSTEXPR_14
#endif //defined(MDSPAN_USE_CONSTEXPR_14) && MDSPAN_USE_CONSTEXPR_14
4 changes: 2 additions & 2 deletions compilation_tests/ctest_constexpr_layouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


// Only works with newer constexpr
#if defined(_MDSPAN_USE_CONSTEXPR_14) && _MDSPAN_USE_CONSTEXPR_14
#if defined(MDSPAN_USE_CONSTEXPR_14) && MDSPAN_USE_CONSTEXPR_14

constexpr std::ptrdiff_t
layout_stride_simple(int i) {
Expand All @@ -36,4 +36,4 @@ MDSPAN_STATIC_TEST(
layout_stride_simple(1) == 1
);

#endif // _MDSPAN_USE_CONSTEXPR_14
#endif // MDSPAN_USE_CONSTEXPR_14
52 changes: 26 additions & 26 deletions compilation_tests/ctest_constexpr_submdspan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <mdspan/mdspan.hpp>

// Only works with newer constexpr
#if defined(_MDSPAN_USE_CONSTEXPR_14) && _MDSPAN_USE_CONSTEXPR_14
#if defined(MDSPAN_USE_CONSTEXPR_14) && MDSPAN_USE_CONSTEXPR_14

//==============================================================================
// <editor-fold desc="1D dynamic extent ptrdiff_t submdspan"> {{{1
Expand All @@ -31,7 +31,7 @@ dynamic_extent_1d() {
int result = 0;
for (size_t i = 0; i < s.extent(0); ++i) {
auto ss = Kokkos::submdspan(s, i);
result += __MDSPAN_OP0(ss);
result += MDSPAN_OP0(ss);
}
// 1 + 2 + 3 + 4 + 5
constexpr_assert_equal(15, result);
Expand All @@ -57,7 +57,7 @@ dynamic_extent_1d_all_slice() {
int result = 0;
auto ss = Kokkos::submdspan(s, Kokkos::full_extent);
for (size_t i = 0; i < s.extent(0); ++i) {
result += __MDSPAN_OP(ss, i);
result += MDSPAN_OP(ss, i);
}
// 1 + 2 + 3 + 4 + 5
constexpr_assert_equal(15, result);
Expand All @@ -82,7 +82,7 @@ dynamic_extent_1d_pair_full() {
int result = 0;
auto ss = Kokkos::submdspan(s, std::pair<std::ptrdiff_t, std::ptrdiff_t>{0, 5});
for (size_t i = 0; i < s.extent(0); ++i) {
result += __MDSPAN_OP(ss, i);
result += MDSPAN_OP(ss, i);
}
constexpr_assert_equal(15, result);
return result == 15;
Expand All @@ -101,14 +101,14 @@ dynamic_extent_1d_pair_each() {
for (size_t i = 0; i < s.extent(0); ++i) {
auto ss = Kokkos::submdspan(s,
std::pair<std::ptrdiff_t, std::ptrdiff_t>{i, i+1});
result += __MDSPAN_OP(ss, 0);
result += MDSPAN_OP(ss, 0);
}
constexpr_assert_equal(15, result);
return result == 15;
}

// MSVC ICE
#ifndef _MDSPAN_COMPILER_MSVC
#ifndef MDSPAN_COMPILER_MSVC
MDSPAN_STATIC_TEST(dynamic_extent_1d_pair_each<Kokkos::layout_left>());
MDSPAN_STATIC_TEST(dynamic_extent_1d_pair_each<Kokkos::layout_right>());
#endif
Expand All @@ -130,14 +130,14 @@ dynamic_extent_1d_all_three() {
int result = 0;
for (size_t i = 0; i < s.extent(0); ++i) {
auto ss = Kokkos::submdspan(s2, i);
result += __MDSPAN_OP0(ss);
result += MDSPAN_OP0(ss);
}
constexpr_assert_equal(15, result);
return result == 15;
}

// MSVC ICE
#ifndef _MDSPAN_COMPILER_MSVC
#ifndef MDSPAN_COMPILER_MSVC
MDSPAN_STATIC_TEST(dynamic_extent_1d_all_three<Kokkos::layout_left>());
MDSPAN_STATIC_TEST(dynamic_extent_1d_all_three<Kokkos::layout_right>());
#endif
Expand All @@ -156,7 +156,7 @@ dynamic_extent_2d_idx_idx() {
for(size_t row = 0; row < s.extent(0); ++row) {
for(size_t col = 0; col < s.extent(1); ++col) {
auto ss = Kokkos::submdspan(s, row, col);
result += __MDSPAN_OP0(ss);
result += MDSPAN_OP0(ss);
}
}
constexpr_assert_equal(21, result);
Expand All @@ -177,16 +177,16 @@ dynamic_extent_2d_idx_all_idx() {
auto srow = Kokkos::submdspan(s, row, Kokkos::full_extent);
for(size_t col = 0; col < s.extent(1); ++col) {
auto scol = Kokkos::submdspan(srow, col);
constexpr_assert_equal(__MDSPAN_OP0(scol), __MDSPAN_OP(srow, col));
result += __MDSPAN_OP0(scol);
constexpr_assert_equal(MDSPAN_OP0(scol), MDSPAN_OP(srow, col));
result += MDSPAN_OP0(scol);
}
}
constexpr_assert_equal(21, result);
return result == 21;
}

// MSVC ICE
#ifndef _MDSPAN_COMPILER_MSVC
#ifndef MDSPAN_COMPILER_MSVC
MDSPAN_STATIC_TEST(dynamic_extent_2d_idx_all_idx<Kokkos::layout_left>());
MDSPAN_STATIC_TEST(dynamic_extent_2d_idx_all_idx<Kokkos::layout_right>());
#endif
Expand All @@ -206,14 +206,14 @@ simple_static_submdspan_test_1(int add_to_row) {
auto scol = Kokkos::submdspan(s, Kokkos::full_extent, col);
for(int row = 0; row < 3; ++row) {
auto srow = Kokkos::submdspan(scol, row);
result += __MDSPAN_OP0(srow) * (row + add_to_row);
result += MDSPAN_OP0(srow) * (row + add_to_row);
}
}
return result;
}

// MSVC ICE
#if !defined(_MDSPAN_COMPILER_MSVC) && (!defined(__GNUC__) || (__GNUC__>=6 && __GNUC_MINOR__>=4))
#if !defined(MDSPAN_COMPILER_MSVC) && (!defined(__GNUC__) || (__GNUC__>=6 && __GNUC_MINOR__>=4))
MDSPAN_STATIC_TEST(
// 1 + 2 + 3 + 2*(4 + 5 + 6) + 3*(7 + 8 + 9) = 108
simple_static_submdspan_test_1(1) == 108
Expand Down Expand Up @@ -248,7 +248,7 @@ mixed_submdspan_left_test_2() {
auto scol = Kokkos::submdspan(s, Kokkos::full_extent, col);
for(int row = 0; row < 3; ++row) {
auto srow = Kokkos::submdspan(scol, row);
result += __MDSPAN_OP0(srow) * (row + 1);
result += MDSPAN_OP0(srow) * (row + 1);
}
}
// 1 + 2 + 3 + 2*(4 + 5 + 6) + 3*(7 + 8 + 9)= 108
Expand All @@ -257,7 +257,7 @@ mixed_submdspan_left_test_2() {
auto srow = Kokkos::submdspan(s, row, Kokkos::full_extent);
for(int col = 0; col < 5; ++col) {
auto scol = Kokkos::submdspan(srow, col);
result += __MDSPAN_OP0(scol) * (row + 1);
result += MDSPAN_OP0(scol) * (row + 1);
}
}
result /= 2;
Expand All @@ -267,7 +267,7 @@ mixed_submdspan_left_test_2() {
}

// MSVC ICE
#if !defined(_MDSPAN_COMPILER_MSVC) && (!defined(__GNUC__) || (__GNUC__>=6 && __GNUC_MINOR__>=4))
#if !defined(MDSPAN_COMPILER_MSVC) && (!defined(__GNUC__) || (__GNUC__>=6 && __GNUC_MINOR__>=4))
MDSPAN_STATIC_TEST(
// 2 * (1 + 2 + 3 + 2*(4 + 5 + 6) + 3*(7 + 8 + 9)) / 2 = 108
mixed_submdspan_left_test_2()
Expand All @@ -291,15 +291,15 @@ mixed_submdspan_test_3() {
auto scol = Kokkos::submdspan(s, Kokkos::full_extent, col);
for(int row = 0; row < 3; ++row) {
auto srow = Kokkos::submdspan(scol, row);
result += __MDSPAN_OP0(srow) * (row + 1);
result += MDSPAN_OP0(srow) * (row + 1);
}
}
constexpr_assert_equal(71, result);
for(int row = 0; row < 3; ++row) {
auto srow = Kokkos::submdspan(s, row, Kokkos::full_extent);
for(int col = 0; col < 5; ++col) {
auto scol = Kokkos::submdspan(srow, col);
result += __MDSPAN_OP0(scol) * (row + 1);
result += MDSPAN_OP0(scol) * (row + 1);
}
}
result /= 2;
Expand All @@ -309,7 +309,7 @@ mixed_submdspan_test_3() {
}

// MSVC ICE
#ifndef _MDSPAN_COMPILER_MSVC
#ifndef MDSPAN_COMPILER_MSVC
MDSPAN_STATIC_TEST(
mixed_submdspan_test_3<Kokkos::layout_right>()
);
Expand Down Expand Up @@ -340,19 +340,19 @@ submdspan_single_element_stress_test_impl_2(
auto ss_dyn = Kokkos::submdspan(s_dyn, _repeated_ptrdiff_t<0, Idxs>...);
auto ss_all = Kokkos::submdspan(s, _repeated_with_idxs_t<Kokkos::full_extent_t, Idxs>{}...);
auto ss_all_dyn = Kokkos::submdspan(s_dyn, _repeated_with_idxs_t<Kokkos::full_extent_t, Idxs>{}...);
auto val = __MDSPAN_OP(ss_all, (_repeated_ptrdiff_t<0, Idxs>...));
auto val_dyn = __MDSPAN_OP(ss_all_dyn, (_repeated_ptrdiff_t<0, Idxs>...));
auto val = MDSPAN_OP(ss_all, (_repeated_ptrdiff_t<0, Idxs>...));
auto val_dyn = MDSPAN_OP(ss_all_dyn, (_repeated_ptrdiff_t<0, Idxs>...));
auto ss_pair = Kokkos::submdspan(s, _repeated_with_idxs_t<std::pair<ptrdiff_t, ptrdiff_t>, Idxs>{0, 1}...);
auto ss_pair_dyn = Kokkos::submdspan(s_dyn, _repeated_with_idxs_t<std::pair<ptrdiff_t, ptrdiff_t>, Idxs>{0, 1}...);
auto val_pair = __MDSPAN_OP(ss_pair, (_repeated_ptrdiff_t<0, Idxs>...));
auto val_pair_dyn = __MDSPAN_OP(ss_pair_dyn, (_repeated_ptrdiff_t<0, Idxs>...));
auto val_pair = MDSPAN_OP(ss_pair, (_repeated_ptrdiff_t<0, Idxs>...));
auto val_pair_dyn = MDSPAN_OP(ss_pair_dyn, (_repeated_ptrdiff_t<0, Idxs>...));
constexpr_assert_equal(42, ss());
constexpr_assert_equal(42, ss_dyn());
constexpr_assert_equal(42, val);
constexpr_assert_equal(42, val_dyn);
constexpr_assert_equal(42, val_pair);
constexpr_assert_equal(42, val_pair_dyn);
return __MDSPAN_OP0(ss) == 42 && __MDSPAN_OP0(ss_dyn) == 42 && val == 42 && val_dyn == 42 && val_pair == 42 && val_pair_dyn == 42;
return MDSPAN_OP0(ss) == 42 && MDSPAN_OP0(ss_dyn) == 42 && val == 42 && val_dyn == 42 && val_pair == 42 && val_pair_dyn == 42;
}

template <class Layout, size_t... Sizes>
Expand Down Expand Up @@ -384,4 +384,4 @@ MDSPAN_STATIC_TEST(

#endif // MDSPAN_DISABLE_EXPENSIVE_COMPILATION_TESTS

#endif // defined(_MDSPAN_USE_CONSTEXPR_14) && _MDSPAN_USE_CONSTEXPR_14
#endif // defined(MDSPAN_USE_CONSTEXPR_14) && MDSPAN_USE_CONSTEXPR_14
4 changes: 2 additions & 2 deletions compilation_tests/ctest_mdarray_type_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <experimental/mdarray>
#include <complex>

#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20
#if defined(MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20
#include <concepts>
#endif

Expand All @@ -27,7 +27,7 @@ namespace KokkosEx = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESP
using E1 = Kokkos::extents<int32_t, Kokkos::dynamic_extent, 3>;
using M1 = KokkosEx::mdarray<float, E1, Kokkos::layout_left>;

#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20
#if defined(MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20
template<class T>
constexpr bool is_copyable = std::copyable<T>;
#else
Expand Down
4 changes: 2 additions & 2 deletions compilation_tests/ctest_no_unique_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ MDSPAN_STATIC_TEST(
sizeof(Kokkos::extents<size_t,45, Kokkos::dynamic_extent, 1>) == sizeof(ptrdiff_t)
);

#ifdef _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS
#ifdef MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS
MDSPAN_STATIC_TEST(
std::is_empty<Kokkos::extents<size_t,1, 2, 3>>::value
);
Expand All @@ -65,7 +65,7 @@ MDSPAN_STATIC_TEST(
>) == sizeof(size_t)
);

#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) && !defined(_MDSPAN_USE_FAKE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
#if defined(MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) && !defined(MDSPAN_USE_FAKE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
MDSPAN_STATIC_TEST(
std::is_empty<Kokkos::layout_right::template mapping<
Kokkos::extents<size_t,42, 123, 73>
Expand Down
Loading

0 comments on commit a66c160

Please sign in to comment.