diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-08-08 11:02:26 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-08-08 18:04:48 -0300 |
commit | 56f4511c39589a6ac6957675e9d2feb212dfb708 (patch) | |
tree | 6c8657bb174b6188c335cb9a6273504299019fe4 /benchmarks | |
parent | 099835ad2a7c35ab9f2825b66d18742c7fcbd9be (diff) | |
download | android_bionic-56f4511c39589a6ac6957675e9d2feb212dfb708.tar.gz android_bionic-56f4511c39589a6ac6957675e9d2feb212dfb708.tar.bz2 android_bionic-56f4511c39589a6ac6957675e9d2feb212dfb708.zip |
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
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/math_benchmark.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp index 8c758ac67..7d258f7ee 100644 --- a/benchmarks/math_benchmark.cpp +++ b/benchmarks/math_benchmark.cpp @@ -355,6 +355,9 @@ BIONIC_BENCHMARK(BM_math_powf_speccpu2017_latency); #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 @@ static void BM_math_logf_speccpu2017_latency(benchmark::State& state) { } 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 @@ static void BM_math_log2f_speccpu2017(benchmark::State& state) { } 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(); |