This repository was 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
TeamPolicyor aTaskTeam.
-
- FunctorType: A valid functor with (at minimum) an
operator()with a matching signature for theExecPolicycombined with the reduced type. - ReturnType: a POD type with
operator +=andoperator =, or aKokkos::View.
- The
functorhas a member function of the formoperator() (const HandleType& handle, ReturnType& value, const bool final) constoroperator() (const WorkTag, const HandleType& handle, ReturnType& value, const bool final) const- The
WorkTagfree form of the operator is used ifExecPolicyis anIntegerTypeorExecPolicy::work_tagisvoid. -
HandleTypeis anIntegerTypeifExecPolicyis anIntegerTypeelse it isExecPolicy::member_type.
- The
- The type
ReturnTypeof thefunctoroperator must be compatible with theReturnTypeof the parallel_scan and must match the arguments of theinitandjoinfunctions of the functor. - the functor must define FunctorType::value_type the same as ReturnType
- Neither concurrency nor order of execution are guaranteed.
- The
ReturnTypecontent 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