Skip to content

Commit

Permalink
SpaceAwareAccessor: fix issues (no-unique-address, is_empty)
Browse files Browse the repository at this point in the history
CI serviced these. Also turn off tests if mdspan is not enabled
  • Loading branch information
crtrott committed Jun 18, 2024
1 parent 34db518 commit f29c746
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
21 changes: 18 additions & 3 deletions core/src/View/MDSpan/Kokkos_MDSpan_Accessor.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//@HEADER
// ************************************************************************
//
Expand Down Expand Up @@ -88,7 +87,15 @@ struct SpaceAwareAccessor {
}

private:
[[no_unique_address]] NestedAccessor nested_acc;
// We either compile with our custom mdspan impl
// in which case we discover inside it whether no_unique_address
// works, or we use C++23 in which case it better be available
#ifdef _MDSPAN_NO_UNIQUE_ADDRESS
_MDSPAN_NO_UNIQUE_ADDRESS
#else
[[no_unique_address]]
#endif
NestedAccessor nested_acc;
template <class, class>
friend struct SpaceAwareAccessor;
};
Expand Down Expand Up @@ -135,7 +142,15 @@ struct SpaceAwareAccessor<AnonymousSpace, NestedAccessor> {
}

private:
[[no_unique_address]] NestedAccessor nested_acc;
// We either compile with our custom mdspan impl
// in which case we discover inside it whether no_unique_address
// works, or we use C++23 in which case it better be available
#ifdef _MDSPAN_NO_UNIQUE_ADDRESS
_MDSPAN_NO_UNIQUE_ADDRESS
#else
[[no_unique_address]]
#endif
NestedAccessor nested_acc;
template <class, class>
friend struct SpaceAwareAccessor;
};
Expand Down
10 changes: 7 additions & 3 deletions core/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,16 @@ foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;OpenMPTarget;OpenACC;HIP;SYCL)
Reductions
Reductions_DeviceView
SharedAlloc
SpaceAwareAccessorAccessViolation
SpaceAwareAccessor
Swap
)
IF (NOT Kokkos_ENABLE_IMPL_MDSPAN)
LIST(REMOVE_ITEM ${Tag}_TESTNAMES1B MDSpanConversion)
LIST(REMOVE_ITEM ${Tag}_TESTNAMES1B
MDSpanConversion
SpaceAwareAccessorAccessViolation
SpaceAwareAccessor
)
ENDIF()
foreach(Name IN LISTS ${Tag}_TESTNAMES1B)
set(file ${dir}/Test${Tag}_${Name}.cpp)
Expand All @@ -231,8 +237,6 @@ foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;OpenMPTarget;OpenACC;HIP;SYCL)

SET(${Tag}_SOURCES2A)
foreach(Name
SpaceAwareAccessorAccessViolation
SpaceAwareAccessor
TeamBasic
TeamCombinedReducers
TeamMDRange
Expand Down
2 changes: 2 additions & 0 deletions core/unit_test/TestSpaceAwareAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ void test_space_aware_accessor() {
static_assert(std::is_same_v<typename acc_t::offset_policy, acc_t>);
static_assert(
std::is_same_v<typename acc_t::memory_space, memory_space_t>);
#ifndef _WIN32
static_assert(std::is_empty_v<acc_t>);
#endif
},
errors);
ASSERT_EQ(errors, 0);
Expand Down

0 comments on commit f29c746

Please sign in to comment.