Skip to content

Commit b905f3b

Browse files
committed
Bench for exps
1 parent 9d41c18 commit b905f3b

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

.idea/misc.xml

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp/bench/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ target_link_libraries(bench-naive src-lib benchmark::benchmark)
2525
add_executable(bench-hl-filter hl-filter.cpp)
2626
target_link_libraries(bench-hl-filter src-lib benchmark::benchmark_main)
2727

28+
add_executable(bench-exps exps.cpp)
29+
target_link_libraries(bench-exps src-lib benchmark::benchmark_main)
30+
2831
if (ENABLE_CILK)
2932
add_executable(bench-fftw-cilk fftw-cilk.cpp)
3033
target_link_libraries(bench-fftw-cilk fftw-cpp benchmark::benchmark fftw3_threads)

cpp/bench/exps.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "Exponentials.hpp"
2+
3+
#include "benchmark-util.hpp"
4+
#include <iostream>
5+
6+
using namespace ahr;
7+
template <typename Exp> static void BM_ExpKXKY(benchmark::State &state) {
8+
Dim const X = state.range(0);
9+
Dim const Y = state.range(1);
10+
11+
Grid grid{1, X, Y};
12+
Real dt = 1.0;
13+
HyperCoefficients hyper = HyperCoefficients::calculate(dt, grid);
14+
15+
Exp exp{grid};
16+
exp.update(hyper, dt);
17+
18+
for (auto _ : state) {
19+
grid.for_each_kxky([&](Dim kx, Dim ky) { benchmark::DoNotOptimize(exp(kx, ky)); });
20+
}
21+
}
22+
23+
BENCHMARK_WMIN(BM_ExpKXKY<exp::Eta>)
24+
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
25+
->Unit(benchmark::kMillisecond);
26+
BENCHMARK_WMIN(BM_ExpKXKY<exp::Nu>)
27+
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
28+
->Unit(benchmark::kMillisecond);
29+
BENCHMARK_WMIN(BM_ExpKXKY<exp::NuG>)
30+
->ArgsProduct({{2048, 4096, 8192}, {2048, 4096, 8192}})
31+
->Unit(benchmark::kMillisecond);

0 commit comments

Comments
 (0)