17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22 #ifndef KOKKOS_ACQUIRE_UNIQUE_TOKEN_IMPL_HPP
23 #define KOKKOS_ACQUIRE_UNIQUE_TOKEN_IMPL_HPP
25 #include <Kokkos_Core.hpp>
26 #include <Kokkos_UniqueToken.hpp>
28 namespace Experimental {
30 template <
typename TeamPolicy>
31 KOKKOS_FUNCTION AcquireTeamUniqueToken<TeamPolicy>::AcquireTeamUniqueToken(
32 AcquireTeamUniqueToken<TeamPolicy>::token_type t, team_member_type team)
33 : my_token(t), my_team_acquired_val(team.team_scratch(0)), my_team(team) {
34 Kokkos::single(Kokkos::PerTeam(my_team),
35 [&]() { my_team_acquired_val() = my_token.acquire(); });
36 my_team.team_barrier();
38 my_acquired_val = my_team_acquired_val();
41 template <
typename TeamPolicy>
42 KOKKOS_FUNCTION AcquireTeamUniqueToken<TeamPolicy>::~AcquireTeamUniqueToken() {
43 my_team.team_barrier();
44 Kokkos::single(Kokkos::PerTeam(my_team),
45 [&]() { my_token.release(my_acquired_val); });
46 my_team.team_barrier();
52 #endif // KOKKOS_UNIQUE_TOKEN_HPP