Add log and log2 benchmark
Similar to exp/exp2, this patch add two benchmarks for log and log2:
one which measures thoughput and one which measures latency.
The input data is based on logf/log2f one (reduced trace based on 2.8
billion samples extracted from specpu2017 521.wrf_r benchmark).
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I51a9e2960e45d5619585e685eaa7634cc7be901b
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index 8c758ac..7d258f7 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -355,6 +355,9 @@
#include "logf_input.cpp"
+static const std::vector<double> log_input (logf_input.begin(),
+ logf_input.end());
+
static void BM_math_logf_speccpu2017(benchmark::State& state) {
f = 0.0;
auto cin = logf_input.cbegin();
@@ -377,6 +380,28 @@
}
BIONIC_BENCHMARK(BM_math_logf_speccpu2017_latency);
+static void BM_math_log_speccpu2017(benchmark::State& state) {
+ d = 0.0;
+ auto cin = log_input.cbegin();
+ for (auto _ : state) {
+ d = log(*cin);
+ if (++cin == log_input.cend())
+ cin = log_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_log_speccpu2017);
+
+static void BM_math_log_speccpu2017_latency(benchmark::State& state) {
+ d = 0.0;
+ auto cin = log_input.cbegin();
+ for (auto _ : state) {
+ d = log(d * zerod + *cin);
+ if (++cin == log_input.cend())
+ cin = log_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_log_speccpu2017_latency);
+
static void BM_math_log2f_speccpu2017(benchmark::State& state) {
f = 0.0;
auto cin = logf_input.cbegin();
@@ -388,6 +413,28 @@
}
BIONIC_BENCHMARK(BM_math_log2f_speccpu2017);
+static void BM_math_log2_speccpu2017_latency(benchmark::State& state) {
+ d = 0.0;
+ auto cin = log_input.cbegin();
+ for (auto _ : state) {
+ d = log2(d * zerod + *cin);
+ if (++cin == log_input.cend())
+ cin = log_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_log2_speccpu2017_latency);
+
+static void BM_math_log2_speccpu2017(benchmark::State& state) {
+ d = 0.0;
+ auto cin = log_input.cbegin();
+ for (auto _ : state) {
+ d = log2(*cin);
+ if (++cin == log_input.cend())
+ cin = log_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_log2_speccpu2017);
+
static void BM_math_log2f_speccpu2017_latency(benchmark::State& state) {
f = 0.0;
auto cin = logf_input.cbegin();