Skip to content

Commit

Permalink
team-level std algos: common code needed (kokkos#6199)
Browse files Browse the repository at this point in the history
* add common code needed for all team level

* remove unused include
  • Loading branch information
fnrizzi committed Jun 13, 2023
1 parent 63d695c commit 7cc2e45
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 21 deletions.
23 changes: 13 additions & 10 deletions algorithms/src/std_algorithms/impl/Kokkos_Constraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,18 @@ struct iterators_are_accessible_from<ExeSpace, Head, Tail...> {
iterators_are_accessible_from<ExeSpace, Tail...>::value;
};

template <class ExecutionSpace, class... IteratorTypes>
template <class ExecutionSpaceOrTeamHandleType, class... IteratorTypes>
KOKKOS_INLINE_FUNCTION constexpr void
static_assert_random_access_and_accessible(const ExecutionSpace& /* ex */,
IteratorTypes... /* iterators */) {
static_assert_random_access_and_accessible(
const ExecutionSpaceOrTeamHandleType& /* ex_or_th*/,
IteratorTypes... /* iterators */) {
static_assert(
are_random_access_iterators<IteratorTypes...>::value,
"Currently, Kokkos standard algorithms require random access iterators.");
static_assert(
iterators_are_accessible_from<ExecutionSpace, IteratorTypes...>::value,
"Incompatible view/iterator and execution space");
static_assert(iterators_are_accessible_from<
typename ExecutionSpaceOrTeamHandleType::execution_space,
IteratorTypes...>::value,
"Incompatible view/iterator and execution space");
}

//
Expand Down Expand Up @@ -182,10 +184,10 @@ struct not_openmptarget {
#endif
};

template <class ExecutionSpace>
template <class ExecutionSpaceOrTeamHandleType>
KOKKOS_INLINE_FUNCTION constexpr void static_assert_is_not_openmptarget(
const ExecutionSpace&) {
static_assert(not_openmptarget<ExecutionSpace>::value,
const ExecutionSpaceOrTeamHandleType& /*ex_or_th*/) {
static_assert(not_openmptarget<ExecutionSpaceOrTeamHandleType>::value,
"Currently, Kokkos standard algorithms do not support custom "
"comparators in OpenMPTarget");
}
Expand All @@ -194,7 +196,8 @@ KOKKOS_INLINE_FUNCTION constexpr void static_assert_is_not_openmptarget(
// valid range
//
template <class IteratorType>
void expect_valid_range(IteratorType first, IteratorType last) {
KOKKOS_INLINE_FUNCTION void expect_valid_range(IteratorType first,
IteratorType last) {
// this is a no-op for release
KOKKOS_EXPECTS(last >= first);
// avoid compiler complaining when KOKKOS_EXPECTS is no-op
Expand Down
6 changes: 6 additions & 0 deletions algorithms/unit_tests/TestStdAlgorithmsCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ std::string view_tag_to_string(StridedTwoTag) { return "stride2_view"; }

std::string view_tag_to_string(StridedThreeTag) { return "stride3_view"; }

std::string view_tag_to_string(StridedTwoRowsTag) { return "stride2rows_view"; }

std::string view_tag_to_string(StridedThreeRowsTag) {
return "stride3rows_view";
}

} // namespace stdalgos
} // namespace Test

0 comments on commit 7cc2e45

Please sign in to comment.