forked from kokkos/kokkos
-
Notifications
You must be signed in to change notification settings - Fork 0
Kokkos::TeamThreadRange
Christian Trott edited this page May 1, 2020
·
3 revisions
Header File: Kokkos_Core.hpp
Usage:
parallel_for(TeamThreadRange(team,range), [=] (int i) {...});
parallel_reduce(TeamThreadRange(team,begin,end),
[=] (int i, double& lsum) {...},sum);
TeamThreadRange is an execution policy which 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.
template<class TeamMemberType, class iType>
/* implementation defined */ T TeamThreadRange(const TeamMemberType& team, iType count);
template<class TeamMemberType, class iType1, class iType2>
/* implementation defined */ T TeamThreadRange(const TeamMemberType& team, iType1 begin, iType2 end);
-
template<class TeamMemberType, class iType> /* Implementation defined */ T TeamThreadRange(const TeamMemberType& team, iType count);
Splits the index range
0
tocount-1
over the threads of the team.-
Arguments
-
team
: a handle to the calling team execution context. -
count
: index range length.
-
-
Returns
- Implementation defined type.
-
Requirements
-
TeamMemberType
meets the requirements of TeamHandle -
std::is_integral<iType>::value
is true. - Every member thread of
team
must call the lexically same operation. I.e. it is not legal to have some threads call this function in one branch, and the other threads ofteam
call it in another branch. -
count >= 0
is true;
-
-
-
template<class TeamMemberType, class iType1, class iType2> /* Implementation defined */ T TeamThreadRange(const TeamMemberType& team, iType1 begin, iType2 end);
Splits the index range
begin
toend-1
over the threads of the team.-
Arguments
-
team
: a handle to the calling team execution context. -
begin
: index range begin. -
end
: index range end.
-
-
Returns
- Implementation defined type.
-
Requirements
-
TeamMemberType
meets the requirements of TeamHandle -
std::is_integral<iType1>::value
is true. -
std::is_integral<iType2>::value
is true. - Every member thread of
team
must call the lexically same operation. I.e. it is not legal to have some threads call this function in one branch, and the other threads ofteam
call it in another branch. -
end >= begin
is true;
-
-
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) {
A(n,i) = B(n) + i;
});
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