This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
StdPartioningOps
Francesco Rizzi edited this page Feb 8, 2022
·
1 revision
Header File: Kokkos_Core.hpp
All algorithms are currently in the Kokkos::Experimental
namespace.
template <class ExecutionSpace, class InputIterator, class PredicateType>
InputIterator is_partitioned(const ExecutionSpace& exespace, (1)
InputIterator first, InputIterator last,
PredicateType pred);
template <class ExecutionSpace, class InputIterator, class PredicateType>
InputIterator is_partitioned(const std::string& label, const ExecutionSpace& exespace, (2)
InputIterator first, InputIterator last,
PredicateType pred);
template <class ExecutionSpace, class DataType, class... Properties, class PredicateType>
auto is_partitioned(const ExecutionSpace& exespace,
const ::Kokkos::View<DataType, Properties...>& view, (3)
PredicateType pred);
template <class ExecutionSpace, class DataType, class... Properties, class PredicateType>
auto is_partitioned(const std::string& label, const ExecutionSpace& exespace,
const ::Kokkos::View<DataType, Properties...>& view, (4)
PredicateType pred);
Returns true
if all elements in [first, last)
satisfying the predicate pred
appear before all elements that don't, or if [first, last)
is empty.
Overload set: (1,2) accept iterators; (3,4) accepting views
-
exespace
,label
,first
,last
,view
,pred
: same requirements asfind_if
(TODO: link) -
label
:- for 1, the default string is:
Kokkos::is_partitioned_iterator_api_default
- for 3, the default string is:
Kokkos::is_partitioned_view_api_default
- for 1, the default string is:
-
true
: if range is partitioned according topred
or if range is empty -
false
: otherwise
namespace KE = Kokkos::Experimental;
template<class ValueType>
struct IsNegative
{
KOKKOS_INLINE_FUNCTION
bool operator()(const ValueType & operand) const {
constexpr auto zero = static_cast<ValueType>(0);
return (operand < zero);
}
};
using view_type = Kokkos::View<int*>;
view_type a("a", 15);
// fill a somehow
auto exespace = Kokkos::DefaultExecutionSpace;
const auto res = KE::is_partitioned(exespace, KE::cbegin(a), KE::cend(a), IsNegative<int>());
// note that we used {cbegin, cend} here, because checking if the view
// is partitioned does not need to have write access to the view's elements.
// We could have also used {begin, end}, but if we know that we only
// need read access, it is good practice to ensure const-correctness.
// ...
Home:
- Introduction
- Machine Model
- Programming Model
- Compiling
- Initialization
- View
- Parallel Dispatch
- Hierarchical Parallelism
- Custom Reductions
- Atomic Operations
- Subviews
- Interoperability
- Kokkos and Virtual Functions
- Initialization and Finalization
- View
- Data Parallelism
- Execution Policies
- Spaces
- Task Parallelism
- Utilities
- STL Compatibility
- Numerics
- Detection Idiom