Skip to content

Commit 8b4780b

Browse files
committed
Add moment-like bench
1 parent b905f3b commit 8b4780b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

cpp/bench/exps.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <iostream>
55

66
using namespace ahr;
7+
using namespace ahr::exp;
78
template <typename Exp> static void BM_ExpKXKY(benchmark::State &state) {
89
Dim const X = state.range(0);
910
Dim const Y = state.range(1);
@@ -20,12 +21,34 @@ template <typename Exp> static void BM_ExpKXKY(benchmark::State &state) {
2021
}
2122
}
2223

23-
BENCHMARK_WMIN(BM_ExpKXKY<exp::Eta>)
24+
template <typename Exp> static void BM_ExpM(benchmark::State &state) {
25+
Dim const M = state.range(0);
26+
Dim const X = state.range(1);
27+
Dim const Y = state.range(2);
28+
29+
Grid grid{M, X, Y};
30+
Real dt = 1.0;
31+
HyperCoefficients hyper = HyperCoefficients::calculate(dt, grid);
32+
33+
Exp exp{grid};
34+
exp.update(hyper, dt);
35+
36+
for (auto _ : state) {
37+
for (Dim m = 0; m < M; ++m) {
38+
grid.for_each_kxky([&](Dim kx, Dim ky) { benchmark::DoNotOptimize(exp(m)); });
39+
}
40+
}
41+
}
42+
43+
BENCHMARK_WMIN(BM_ExpKXKY<Eta>)
2444
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
2545
->Unit(benchmark::kMillisecond);
26-
BENCHMARK_WMIN(BM_ExpKXKY<exp::Nu>)
46+
BENCHMARK_WMIN(BM_ExpKXKY<Nu>)
2747
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
2848
->Unit(benchmark::kMillisecond);
29-
BENCHMARK_WMIN(BM_ExpKXKY<exp::NuG>)
49+
BENCHMARK_WMIN(BM_ExpKXKY<NuG>)
3050
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
3151
->Unit(benchmark::kMillisecond);
52+
BENCHMARK_WMIN(BM_ExpM<GM>)
53+
->ArgsProduct({{2, 4, 10}, {2048, 4096}, {2048, 4096}})
54+
->Unit(benchmark::kMillisecond);

0 commit comments

Comments
 (0)