Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Jul 17, 2023
1 parent 48ecaef commit 96922d9
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 305 deletions.
104 changes: 54 additions & 50 deletions algorithms/src/std_algorithms/Kokkos_AdjacentFind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@ namespace Experimental {
//

// overload set1
template <class ExecutionSpace, class IteratorType>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
IteratorType>
adjacent_find(const ExecutionSpace& ex, IteratorType first, IteratorType last) {
template <
typename ExecutionSpace, typename IteratorType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
IteratorType adjacent_find(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::adjacent_find_exespace_impl(
"Kokkos::adjacent_find_iterator_api_default", ex, first, last);
}

template <class ExecutionSpace, class IteratorType>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
IteratorType>
adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
template <
typename ExecutionSpace, typename IteratorType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
IteratorType adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::adjacent_find_exespace_impl(label, ex, first, last);
}

template <class ExecutionSpace, class DataType, class... Properties,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
typename ExecutionSpace, typename DataType, typename... Properties,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto adjacent_find(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Expand All @@ -55,9 +56,9 @@ auto adjacent_find(const ExecutionSpace& ex,
"Kokkos::adjacent_find_view_api_default", ex, KE::begin(v), KE::end(v));
}

template <class ExecutionSpace, class DataType, class... Properties,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
typename ExecutionSpace, typename DataType, typename... Properties,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Expand All @@ -66,27 +67,30 @@ auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
}

// overload set2
template <class ExecutionSpace, class IteratorType, class BinaryPredicateType>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
IteratorType>
adjacent_find(const ExecutionSpace& ex, IteratorType first, IteratorType last,
BinaryPredicateType pred) {
template <
typename ExecutionSpace, typename IteratorType,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
IteratorType adjacent_find(const ExecutionSpace& ex, IteratorType first,
IteratorType last, BinaryPredicateType pred) {
return Impl::adjacent_find_exespace_impl(
"Kokkos::adjacent_find_iterator_api_default", ex, first, last, pred);
}

template <class ExecutionSpace, class IteratorType, class BinaryPredicateType>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
IteratorType>
adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, BinaryPredicateType pred) {
template <
typename ExecutionSpace, typename IteratorType,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
IteratorType adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
BinaryPredicateType pred) {
return Impl::adjacent_find_exespace_impl(label, ex, first, last, pred);
}

template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicateType,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
typename ExecutionSpace, typename DataType, typename... Properties,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto adjacent_find(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
BinaryPredicateType pred) {
Expand All @@ -97,10 +101,10 @@ auto adjacent_find(const ExecutionSpace& ex,
pred);
}

template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicateType,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
typename ExecutionSpace, typename DataType, typename... Properties,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
BinaryPredicateType pred) {
Expand All @@ -117,17 +121,16 @@ auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
//

// overload set1
template <class TeamHandleType, class IteratorType>
KOKKOS_FUNCTION std::enable_if_t<
::Kokkos::is_team_handle<TeamHandleType>::value, IteratorType>
adjacent_find(const TeamHandleType& teamHandle, IteratorType first,
IteratorType last) {
template <typename TeamHandleType, typename IteratorType,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION IteratorType adjacent_find(const TeamHandleType& teamHandle,
IteratorType first,
IteratorType last) {
return Impl::adjacent_find_team_impl(teamHandle, first, last);
}

template <
class TeamHandleType, class DataType, class... Properties,
std::enable_if_t<::Kokkos::is_team_handle<TeamHandleType>::value, int> = 0>
template <typename TeamHandleType, typename DataType, typename... Properties,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION auto adjacent_find(
const TeamHandleType& teamHandle,
const ::Kokkos::View<DataType, Properties...>& v) {
Expand All @@ -137,18 +140,19 @@ KOKKOS_FUNCTION auto adjacent_find(
}

// overload set2
template <class TeamHandleType, class IteratorType, class BinaryPredicateType>
KOKKOS_FUNCTION std::enable_if_t<
::Kokkos::is_team_handle<TeamHandleType>::value, IteratorType>
adjacent_find(const TeamHandleType& teamHandle, IteratorType first,
IteratorType last, BinaryPredicateType pred) {
template <typename TeamHandleType, typename IteratorType,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION IteratorType adjacent_find(const TeamHandleType& teamHandle,
IteratorType first,
IteratorType last,
BinaryPredicateType pred) {
return Impl::adjacent_find_team_impl(teamHandle, first, last, pred);
}

template <
class TeamHandleType, class DataType, class... Properties,
class BinaryPredicateType,
std::enable_if_t<::Kokkos::is_team_handle<TeamHandleType>::value, int> = 0>
template <typename TeamHandleType, typename DataType, typename... Properties,
typename BinaryPredicateType,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION auto adjacent_find(
const TeamHandleType& teamHandle,
const ::Kokkos::View<DataType, Properties...>& v,
Expand Down
54 changes: 29 additions & 25 deletions algorithms/src/std_algorithms/Kokkos_Count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,31 @@ namespace Experimental {
//
// overload set accepting execution space
//
template <class ExecutionSpace, class IteratorType, class T>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
typename IteratorType::difference_type>
count(const ExecutionSpace& ex, IteratorType first, IteratorType last,
const T& value) {
template <
class ExecutionSpace, class IteratorType, class T,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
typename IteratorType::difference_type count(const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
const T& value) {
return Impl::count_exespace_impl("Kokkos::count_iterator_api_default", ex,
first, last, value);
}

template <class ExecutionSpace, class IteratorType, class T>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
typename IteratorType::difference_type>
count(const std::string& label, const ExecutionSpace& ex, IteratorType first,
IteratorType last, const T& value) {
template <
class ExecutionSpace, class IteratorType, class T,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
typename IteratorType::difference_type count(const std::string& label,
const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
const T& value) {
return Impl::count_exespace_impl(label, ex, first, last, value);
}

template <class ExecutionSpace, class DataType, class... Properties, class T,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
class ExecutionSpace, class DataType, class... Properties, class T,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto count(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Expand All @@ -55,9 +60,9 @@ auto count(const ExecutionSpace& ex,
KE::cbegin(v), KE::cend(v), value);
}

template <class ExecutionSpace, class DataType, class... Properties, class T,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
int> = 0>
template <
class ExecutionSpace, class DataType, class... Properties, class T,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto count(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Expand All @@ -73,18 +78,17 @@ auto count(const std::string& label, const ExecutionSpace& ex,
// since they cause issues on device because of the string allocation.
//

template <class TeamHandleType, class IteratorType, class T>
KOKKOS_FUNCTION
std::enable_if_t<::Kokkos::is_team_handle<TeamHandleType>::value,
typename IteratorType::difference_type>
count(const TeamHandleType& teamHandle, IteratorType first,
IteratorType last, const T& value) {
template <class TeamHandleType, class IteratorType, class T,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>

KOKKOS_FUNCTION typename IteratorType::difference_type count(
const TeamHandleType& teamHandle, IteratorType first, IteratorType last,
const T& value) {
return Impl::count_team_impl(teamHandle, first, last, value);
}

template <
class TeamHandleType, class DataType, class... Properties, class T,
std::enable_if_t<::Kokkos::is_team_handle<TeamHandleType>::value, int> = 0>
template <class TeamHandleType, class DataType, class... Properties, class T,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION auto count(const TeamHandleType& teamHandle,
const ::Kokkos::View<DataType, Properties...>& v,
const T& value) {
Expand Down
55 changes: 29 additions & 26 deletions algorithms/src/std_algorithms/Kokkos_CountIf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ namespace Experimental {
//
// overload set accepting execution space
//
template <class ExecutionSpace, class IteratorType, class Predicate>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
typename IteratorType::difference_type>
count_if(const ExecutionSpace& ex, IteratorType first, IteratorType last,
Predicate predicate) {
template <
class ExecutionSpace, class IteratorType, class Predicate,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
typename IteratorType::difference_type count_if(const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
Predicate predicate) {
return Impl::count_if_exespace_impl("Kokkos::count_if_iterator_api_default",
ex, first, last, std::move(predicate));
}

template <class ExecutionSpace, class IteratorType, class Predicate>
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value,
typename IteratorType::difference_type>
count_if(const std::string& label, const ExecutionSpace& ex, IteratorType first,
IteratorType last, Predicate predicate) {
template <
class ExecutionSpace, class IteratorType, class Predicate,
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
typename IteratorType::difference_type count_if(const std::string& label,
const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
Predicate predicate) {
return Impl::count_if_exespace_impl(label, ex, first, last,
std::move(predicate));
}

template <
class ExecutionSpace, class DataType, class... Properties, class Predicate,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value, int> =
0>
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto count_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Expand All @@ -61,8 +65,7 @@ auto count_if(const ExecutionSpace& ex,

template <
class ExecutionSpace, class DataType, class... Properties, class Predicate,
std::enable_if_t<::Kokkos::is_execution_space<ExecutionSpace>::value, int> =
0>
std::enable_if_t<Kokkos::is_execution_space_v<ExecutionSpace>, int> = 0>
auto count_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Expand All @@ -76,25 +79,25 @@ auto count_if(const std::string& label, const ExecutionSpace& ex,
//
// overload set accepting team handle
//
template <class ExecutionSpace, class IteratorType, class Predicate>
KOKKOS_FUNCTION
std::enable_if_t<::Kokkos::is_team_handle<ExecutionSpace>::value,
typename IteratorType::difference_type>
count_if(const ExecutionSpace& ex, IteratorType first, IteratorType last,
Predicate predicate) {
return Impl::count_if_team_impl(ex, first, last, std::move(predicate));
template <class TeamHandleType, class IteratorType, class Predicate,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION typename IteratorType::difference_type count_if(
const TeamHandleType& teamHandle, IteratorType first, IteratorType last,
Predicate predicate) {
return Impl::count_if_team_impl(teamHandle, first, last,
std::move(predicate));
}

template <
class ExecutionSpace, class DataType, class... Properties, class Predicate,
std::enable_if_t<::Kokkos::is_team_handle<ExecutionSpace>::value, int> = 0>
KOKKOS_FUNCTION auto count_if(const ExecutionSpace& ex,
template <class TeamHandleType, class DataType, class... Properties,
class Predicate,
std::enable_if_t<Kokkos::is_team_handle_v<TeamHandleType>, int> = 0>
KOKKOS_FUNCTION auto count_if(const TeamHandleType& teamHandle,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);

namespace KE = ::Kokkos::Experimental;
return Impl::count_if_team_impl(ex, KE::cbegin(v), KE::cend(v),
return Impl::count_if_team_impl(teamHandle, KE::cbegin(v), KE::cend(v),
std::move(predicate));
}

Expand Down

0 comments on commit 96922d9

Please sign in to comment.