-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_parallel_for.cpp
58 lines (48 loc) · 1.85 KB
/
benchmark_parallel_for.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <Kokkos_Core.hpp>
#include <benchmark/benchmark.h>
#include <brak/wrapper_array.hpp>
#include <brak/wrapper_subview.hpp>
void benchmark_set_wrapper_subview(benchmark::State &state) {
Kokkos::View<int ******> data{"data", 30, 30, 30, 30, 30, 30};
brak::WrapperSubview dataWrapper{data};
while (state.KeepRunning()) {
Kokkos::parallel_for(
"benchmark_set_wrapper_subview",
Kokkos::MDRangePolicy({0, 0, 0, 0, 0, 0}, {30, 30, 30, 30, 30, 30}),
KOKKOS_LAMBDA(int const i, int const j, int const k, int const l,
int const m, int const n) {
dataWrapper[i][j][k][l][m][n] = i + j + k + l + m + n;
});
Kokkos::fence();
}
}
BENCHMARK(benchmark_set_wrapper_subview);
void benchmark_set_wrapper_array(benchmark::State &state) {
Kokkos::View<int ******> data{"data", 30, 30, 30, 30, 30, 30};
brak::WrapperArray dataWrapper{data};
while (state.KeepRunning()) {
Kokkos::parallel_for(
"benchmark_set_wrapper_array",
Kokkos::MDRangePolicy({0, 0, 0, 0, 0, 0}, {30, 30, 30, 30, 30, 30}),
KOKKOS_LAMBDA(int const i, int const j, int const k, int const l,
int const m, int const n) {
dataWrapper[i][j][k][l][m][n] = i + j + k + l + m + n;
});
Kokkos::fence();
}
}
BENCHMARK(benchmark_set_wrapper_array);
void benchmark_set_view(benchmark::State &state) {
Kokkos::View<int ******> data{"data", 30, 30, 30, 30, 30, 30};
while (state.KeepRunning()) {
Kokkos::parallel_for(
"benchmark_set_view",
Kokkos::MDRangePolicy({0, 0, 0, 0, 0, 0}, {30, 30, 30, 30, 30, 30}),
KOKKOS_LAMBDA(int const i, int const j, int const k, int const l,
int const m, int const n) {
data(i, j, k, l, m, n) = i + j + k + l + m + n;
});
Kokkos::fence();
}
}
BENCHMARK(benchmark_set_view);