From 72fe1c8df6a7a71d78d3089aae9f5fd06d15d90b Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 8 Aug 2018 13:36:14 -0300 Subject: [PATCH] Add pow benchmark As for exp/exp2 benchmark, this patch add two benchmark for pow: one which measures thoughput and one which measures latency. The input data is the same as powf. Test: ran 32-bit and 64-bit x86 tests on host Change-Id: I04335fac9e76fb3f39935323dacf6b7be6a6f917 --- benchmarks/math_benchmark.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp index 7d258f7ee..c3f14c8f7 100644 --- a/benchmarks/math_benchmark.cpp +++ b/benchmarks/math_benchmark.cpp @@ -331,6 +331,9 @@ BIONIC_BENCHMARK(BM_math_exp2_speccpu2017_latency); #include "powf_input.cpp" +static const std::vector> pow_input + (powf_input.begin(), powf_input.end()); + static void BM_math_powf_speccpu2006(benchmark::State& state) { f = 0.0; auto cin = powf_input.cbegin(); @@ -353,6 +356,28 @@ static void BM_math_powf_speccpu2017_latency(benchmark::State& state) { } BIONIC_BENCHMARK(BM_math_powf_speccpu2017_latency); +static void BM_math_pow_speccpu2006(benchmark::State& state) { + d = 0.0; + auto cin = pow_input.cbegin(); + for (auto _ : state) { + f = pow(cin->first, cin->second); + if (++cin == pow_input.cend()) + cin = pow_input.cbegin(); + } +} +BIONIC_BENCHMARK(BM_math_pow_speccpu2006); + +static void BM_math_pow_speccpu2017_latency(benchmark::State& state) { + d = 0.0; + auto cin = pow_input.cbegin(); + for (auto _ : state) { + d = powf(d * zero + cin->first, cin->second); + if (++cin == pow_input.cend()) + cin = pow_input.cbegin(); + } +} +BIONIC_BENCHMARK(BM_math_pow_speccpu2017_latency); + #include "logf_input.cpp" static const std::vector log_input (logf_input.begin(),