-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPWR070.cpp
More file actions
38 lines (29 loc) · 1.05 KB
/
PWR070.cpp
File metadata and controls
38 lines (29 loc) · 1.05 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
38
#include "Benchmark.h"
// Forward-declare the functions to benchmark
extern "C" {
void clamp_data_points_f(int n, double *X, int min_value, int max_value);
void clamp_data_points_improved_f(int n, double *X, int min_value,
int max_value);
}
// Size adjusted to fit execution on micro-seconds
constexpr int N = 1024 * 1024;
constexpr double MIN_VALUE = 2.71;
constexpr double MAX_VALUE = 3.14;
#if OCB_ENABLE_Fortran
static void FortranExampleBench(benchmark::State &state) {
auto X = OpenCatalog::CreateRandomVector<double>(N);
for (auto _ : state) {
clamp_data_points_f(N, X.data(), MIN_VALUE, MAX_VALUE);
benchmark::DoNotOptimize(X);
}
}
static void FortranImprovedBench(benchmark::State &state) {
auto X = OpenCatalog::CreateRandomVector<double>(N);
for (auto _ : state) {
clamp_data_points_improved_f(N, X.data(), MIN_VALUE, MAX_VALUE);
benchmark::DoNotOptimize(X);
}
}
OC_BENCHMARK("PWR070 Fortran Example", FortranExampleBench);
OC_BENCHMARK("PWR070 Fortran Improved", FortranImprovedBench);
#endif