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
Kokkos::parallel_scan
Christian Trott edited this page Jul 17, 2020
·
4 revisions
Header File: Kokkos_Core.hpp
Kokkos::parallel_scan( name, policy, functor, result );
Kokkos::parallel_scan( name, policy, functor );
Kokkos::parallel_scan( policy, functor, result);
Kokkos::parallel_scan( policy, functor );
Dispatches parallel work defined by functor
according to the ExecutionPolicy policy
and perform a pre (inclusive) or post (exclusive) scan of the contributions
provided by the work items. The optional label name
is used by profiling and debugging tools. If provided, the final result is placed in result.
template <class ExecPolicy, class FunctorType>
Kokkos::parallel_scan(const std::string& name,
const ExecPolicy& policy,
const FunctorType& functor);
template <class ExecPolicy, class FunctorType>
Kokkos::parallel_scan(const ExecPolicy& policy,
const FunctorType& functor);
template <class ExecPolicy, class FunctorType, class ReturnType>
Kokkos::parallel_scan(const std::string& name,
const ExecPolicy& policy,
const FunctorType& functor,
ReturnType& return_value);
template <class ExecPolicy, class FunctorType, class ReturnType>
Kokkos::parallel_scan(const ExecPolicy& policy,
const FunctorType& functor,
ReturnType& return_value);
template <class ExecPolicy, class FunctorType, class ReturnType>
Kokkos::parallel_scan(const std::string& name,
const ExecPolicy& policy,
const FunctorType& functor,
ReturnType& return_value);
-
name
: A user provided string which is used in profiling and debugging tools via the Kokkos Profiling Hooks. - ExecPolicy: An ExecutionPolicy which defines iteration space and other execution properties. Valid policies are:
-
IntegerType
: defines a 1D iteration range, starting from 0 and going to a count. - RangePolicy: defines a 1D iteration range.
-
ThreadVectorRange: defines a 1D iteration range to be executed through vector parallelization dividing the threads within a team. Only valid inside a parallel region executed through a
TeamPolicy
or aTaskTeam
.
-
- FunctorType: A valid functor with (at minimum) an
operator()
with a matching signature for theExecPolicy
combined with the reduced type. - ReturnType: a POD type with
operator +=
andoperator =
, or aKokkos::View
.
- The
functor
has a member function of the formoperator() (const HandleType& handle, ReturnType& value, const bool final) const
oroperator() (const WorkTag, const HandleType& handle, ReturnType& value, const bool final) const
- The
WorkTag
free form of the operator is used ifExecPolicy
is anIntegerType
orExecPolicy::work_tag
isvoid
. -
HandleType
is anIntegerType
ifExecPolicy
is anIntegerType
else it isExecPolicy::member_type
.
- The
- The type
ReturnType
of thefunctor
operator must be compatible with theReturnType
of the parallel_scan and must match the arguments of theinit
andjoin
functions of the functor. - the functor must define FunctorType::value_type the same as ReturnType
- Neither concurrency nor order of execution are guaranteed.
- The
ReturnType
content will be overwritten, i.e. the value does not need to be initialized to the reduction-neutral element. - The input value to the operator may contain a partial result, Kokkos may only combine the thread local contributions in the end. The operator should modify the input value according to the desired scan operation.
#include<Kokkos_Core.hpp>
#include<cstdio>
int main(int argc, char* argv[]) {
Kokkos::initialize(argc,argv);
int N = atoi(argv[1]);
double result;
ScanFunctor f;
Kokkos::parallel_scan("Loop1", N, f, result);
printf("Result: %i %lf\n",N,result);
Kokkos::finalize();
}
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