-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPWR083.cpp
More file actions
37 lines (28 loc) · 1.08 KB
/
PWR083.cpp
File metadata and controls
37 lines (28 loc) · 1.08 KB
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
#include "Benchmark.h"
// Forward-declare the functions to benchmark
extern "C" {
void update_simulation_state_by_fixed_amount(const int *n, double *state);
void update_simulation_state_by_fixed_amount_improved(const int *n,
double *state);
}
constexpr int N = 1024 * 1024;
#if OCB_ENABLE_Fortran
static void FortranExampleBench(benchmark::State &state) {
auto array = OpenCatalog::CreateRandomVector<double>(N);
for (auto _ : state) {
update_simulation_state_by_fixed_amount(&N, array.data());
benchmark::DoNotOptimize(array);
}
}
static void FortranImprovedBench(benchmark::State &state) {
auto array = OpenCatalog::CreateRandomVector<double>(N);
for (auto _ : state) {
update_simulation_state_by_fixed_amount_improved(&N, array.data());
benchmark::DoNotOptimize(array);
}
}
// The improved benchmark prevents the runtime bug, while not incurring in any
// performance penalty
OC_BENCHMARK("PWR083 Fortran Example", FortranExampleBench);
OC_BENCHMARK("PWR083 Fortran Improved", FortranImprovedBench);
#endif