-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_access.cpp
54 lines (40 loc) · 1.54 KB
/
benchmark_access.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
#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 ********, Kokkos::DefaultHostExecutionSpace::memory_space>
data{"data", 2, 2, 2, 2, 2, 2, 2, 2};
brak::WrapperSubview dataWrapper{data};
while (state.KeepRunning()) {
dataWrapper[1][1][1][1][1][1][1][1] = 10;
}
}
BENCHMARK(benchmark_set_wrapper_subview);
void benchmark_set_wrapper_array(benchmark::State &state) {
Kokkos::View<int ********, Kokkos::DefaultHostExecutionSpace::memory_space>
data{"data", 2, 2, 2, 2, 2, 2, 2, 2};
brak::WrapperArray dataWrapper{data};
while (state.KeepRunning()) {
dataWrapper[1][1][1][1][1][1][1][1] = 10;
}
}
BENCHMARK(benchmark_set_wrapper_array);
void benchmark_set_view(benchmark::State &state) {
Kokkos::View<int ********, Kokkos::DefaultHostExecutionSpace::memory_space>
data{"data", 2, 2, 2, 2, 2, 2, 2, 2};
while (state.KeepRunning()) {
data(1, 1, 1, 1, 1, 1, 1, 1) = 10;
}
}
BENCHMARK(benchmark_set_view);
void benchmark_set_view_unmanaged(benchmark::State &state) {
Kokkos::View<int ********, Kokkos::DefaultHostExecutionSpace::memory_space>
data{"data", 2, 2, 2, 2, 2, 2, 2, 2};
Kokkos::View<int ********, Kokkos::DefaultHostExecutionSpace::memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
dataUnmanaged(data);
while (state.KeepRunning()) {
dataUnmanaged(1, 1, 1, 1, 1, 1, 1, 1) = 10;
}
}
BENCHMARK(benchmark_set_view_unmanaged);