-
Notifications
You must be signed in to change notification settings - Fork 165
/
app_benchmark.cpp
140 lines (83 loc) · 4.96 KB
/
app_benchmark.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <app/benchmark/app_benchmark.h>
#include <mcal_benchmark.h>
#include <mcal_cpu.h>
namespace app { namespace benchmark {
using port_type = mcal::benchmark::benchmark_port_type;
void task_init();
void task_func();
} // namespace benchmark
} // namespace app
auto app::benchmark::task_init() -> void
{
// Set the benchmark port pin direction to output.
port_type::set_direction_output();
}
auto app::benchmark::task_func() -> void
{
// Set the benchmark port pin level to high.
port_type::set_pin_high();
// Run the benchmark (if enabled via compiler switch).
#if (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_NONE))
const bool result_is_ok = app::benchmark::run_none();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_COMPLEX))
const bool result_is_ok = app::benchmark::run_complex();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_CRC))
const bool result_is_ok = app::benchmark::run_crc();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_FAST_MATH))
const bool result_is_ok = app::benchmark::run_fast_math();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_FILTER))
const bool result_is_ok = app::benchmark::run_filter();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_FIXED_POINT))
const bool result_is_ok = app::benchmark::run_fixed_point();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_FLOAT))
const bool result_is_ok = app::benchmark::run_float();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_WIDE_INTEGER))
const bool result_is_ok = app::benchmark::run_wide_integer();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_PI_SPIGOT))
const bool result_is_ok = app::benchmark::run_pi_spigot();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_PI_SPIGOT_SINGLE))
const bool result_is_ok = app::benchmark::run_pi_spigot_single();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_HASH))
const bool result_is_ok = app::benchmark::run_hash();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_WIDE_DECIMAL))
const bool result_is_ok = app::benchmark::run_wide_decimal();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_TRAPEZOID_INTEGRAL))
const bool result_is_ok = app::benchmark::run_trapezoid_integral();
#elif (defined(APP_BENCHMARK_TYPE) && ((APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_PI_AGM) || (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_PI_AGM_100)))
const bool result_is_ok = app::benchmark::run_pi_agm();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_BOOST_MATH_CBRT_TGAMMA))
const bool result_is_ok = app::benchmark::run_boost_math_cbrt_tgamma();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_CNL_SCALED_INTEGER))
const bool result_is_ok = app::benchmark::run_cnl_scaled_integer();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_SOFT_DOUBLE_H2F1))
const bool result_is_ok = app::benchmark::run_soft_double_h2f1();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_BOOST_MULTIPRECISION_CBRT))
const bool result_is_ok = app::benchmark::run_boost_multiprecision_cbrt();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_BOOST_MATH_CYL_BESSEL_J))
const bool result_is_ok = app::benchmark::run_boost_math_cbrt_cyl_bessel_j();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_HASH_SHA256))
const bool result_is_ok = app::benchmark::run_hash_sha256();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_ECC_GENERIC_ECC))
const bool result_is_ok = app::benchmark::run_ecc_generic_ecc();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_NON_STD_DECIMAL))
const bool result_is_ok = app::benchmark::run_non_std_decimal();
#elif (defined(APP_BENCHMARK_TYPE) && (APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_BOOST_CRYPT_HASHER))
const bool result_is_ok = app::benchmark::run_boost_crypt_hasher();
#endif
// Set the benchmark port pin level to low.
port_type::set_pin_low();
if(!result_is_ok)
{
// Purposefully crash the system (watchdog) if the benchmark fails.
for(;;)
{
mcal::cpu::nop();
}
}
}