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::NestedPolicies
Jan Ciesko edited this page Mar 11, 2020
·
3 revisions
Header File: Kokkos_Core.hpp
Usage:
parallel_for(TeamThreadRange(team,begin,end), [=] (int i) {});
parallel_for(ThreadVectorRange(team,begin,end), [=] (int i) {});
single(PerTeam(team), [=] () {});
single(PerThread(team), [=] () {});
Nested policies can be used for nested parallel patterns. In contrast to global policies, the public interface for nested policies is implemented as functions, in order to enable implicit templating on the execution space type via the team handle.
Impl::TeamThreadRangeBoundariesStruct TeamThreadRange(TeamMemberType team, IndexType count);
Impl::TeamThreadRangeBoundariesStruct TeamThreadRange(TeamMemberType team, IndexType begin, IndexType end);
Impl::ThreadVectorRangeBoundariesStruct ThreadVectorRange(TeamMemberType team, IndexType count);
Impl::ThreadVectorRangeBoundariesStruct ThreadVectorRange(TeamMemberType team, IndexType begin, IndexType end);
Impl::ThreadSingleStruct PerTeam(TeamMemberType team);
Impl::VectorSingleStruct PerThread(TeamMemberType team);
-
Splits the index range
Impl::TeamThreadRangeBoundariesStruct TeamThreadRange(TeamMemberType team, IndexType count);
0
tocount-1
over the threads of the team. This call is potentially a synchronization point for the team, and thus must meet the requirements ofteam_barrier
.-
team
: object meeting the requirements of TeamHandle -
count
: index range length.
-
-
Splits the index range
Impl::TeamThreadRangeBoundariesStruct TeamThreadRange(TeamMemberType team, IndexType begin, IndexType end);
begin
toend-1
over the threads of the team. This call is potentially a synchronization point for the team, and thus must meet the requirements ofteam_barrier
.-
team
: object meeting the requirements of TeamHandle -
begin
: start index. -
end
: end index.
-
-
Splits the index range
Impl::ThreadVectorRangeBoundariesStruct ThreadVectorRange(TeamMemberType team, IndexType count);
0
tocount-1
over the vector lanes of the calling thread. It is not legal to call this function inside of a vector level loop.-
team
: object meeting the requirements of TeamHandle -
count
: index range length.
-
-
Splits the index range
Impl::ThreadVectorRangeBoundariesStruct ThreadVectorRange(TeamMemberType team, IndexType begin, IndexType end);
begin
toend-1
over the vector lanes of the calling thread. It is not legal to call this function inside of a vector level loop.-
team
: object meeting the requirements of TeamHandle -
begin
: start index. -
end
: end index.
-
-
When used in conjunction with the
Impl::ThreadSingleStruct PerTeam(TeamMemberType team);
single
pattern restricts execution to a single vector lane in the calling team. While not a synchronization event, this call must be encountered by the entire team, and thus meet the calling requirements ofteam_barrier
.-
team
: object meeting the requirements of TeamHandle
-
-
When used in conjunction with the
Impl::VectorSingleStruct PerThread(TeamMemberType team);
single
pattern restricts execution to a single vector lane in the calling thread. It is not legal to call this function inside of a vector level loop.-
team
: object meeting the requirements of TeamHandle
-
typedef TeamPolicy<>::member_type team_handle;
parallel_for(TeamPolicy<>(N,AUTO,4), KOKKOS_LAMBDA (const team_handle& team) {
int n = team.league_rank();
parallel_for(TeamThreadRange(team,M), [&] (const int& i) {
int thread_sum;
parallel_reduce(ThreadVectorRange(team,K), [&] (const int& j, int& lsum) {
//...
},thread_sum);
single(PerThread(team), [&] () {
A(n,i) += thread_sum;
});
});
team.team_barrier();
int team_sum;
parallel_reduce(TeamThreadRange(team,M), [&] (const int& i, int& lsum) {
lsum += A(n,i);
},team_sum);
single(PerTeam(team),[&] () {
A_rowsum(n) += team_sum;
});
});
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