OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
team.cpp
1#include <Kokkos_Core.hpp>
2#include <cstdio>
3
4
5
6int main(int argc, char* argv[]) {
7 Kokkos::initialize(argc, argv);
8
9 printf("LayoutRight\n");
10
11 {
12
13
14
16
17 using Kokkos::TeamPolicy;
18 using Kokkos::parallel_for;
19
20 typedef TeamPolicy<Kokkos::OpenMP>::member_type member_type;
21 // Create an instance of the policy
22 int team_sz = 1;
23 int sz = 512;
24 TeamPolicy<Kokkos::OpenMP> policy (sz*sz, team_sz);
25 // Launch a kernel
26
27 Kokkos::fence();
28 Kokkos::Timer timer;
29
30 parallel_for (policy, KOKKOS_LAMBDA (member_type team_member) {
31 // Calculate a global thread id
32 int k = team_member.league_rank () * team_member.team_size () +
33 team_member.team_rank ();
34 // Calculate the sum of the global thread ids of this team
35 team_member.team_barrier();
36 team_member.team_barrier();
37 team_member.team_barrier();
38 team_member.team_barrier();
39 team_member.team_barrier();
40 team_member.team_barrier();
41
42 team_member.team_barrier();
43 team_member.team_barrier();
44 team_member.team_barrier();
45 team_member.team_barrier();
46 team_member.team_barrier();
47 team_member.team_barrier();
48
49 team_member.team_barrier();
50 team_member.team_barrier();
51 team_member.team_barrier();
52 team_member.team_barrier();
53 team_member.team_barrier();
54 team_member.team_barrier();
55
56 team_member.team_barrier();
57 team_member.team_barrier();
58 team_member.team_barrier();
59 team_member.team_barrier();
60 team_member.team_barrier();
61 team_member.team_barrier();
62
63 // Atomically add the value to a global value
64 });
65
66 Kokkos::fence();
67 double time = timer.seconds();
68 std::cout << "TIME: " << time / (sz*sz*team_sz*24) * 1e9 << " ns" << std::endl;
69
71
72 }
73 printf("LayoutLeft\n");
74
75 Kokkos::finalize();
76}
77
Class for cpu time benchmarking.
Definition timer.hpp:28