Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A TeamPolicy example featuring Kokkos::single #580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/source/API/core/policies/TeamPolicy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,21 @@ Examples
TeamPolicy<Schedule<Dynamic>, OpenMP> policy_3(N,AUTO,8);
TeamPolicy<IndexType<int>, Schedule<Dynamic>> policy_4(N,1,4);
TeamPolicy<OpenMP> policy_5(OpenMP(), N, AUTO);
.. code-block:: cpp
using team_handle = TeamPolicy<>::member_type;
parallel_for(TeamPolicy<>(N,AUTO), 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();
Comment on lines +189 to +192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this add anything in clarity for th example?

Suggested change
parallel_for(TeamThreadRange(team,M), [&] (const int& i) {
A(n,i) = B(n) + i;
});
team.team_barrier();

Maybe add a comment explaining that this is computing the sum over each row in a matrix stored as a rank-2 View?

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;
});
});
Loading