Add sinf/cosf/sincosf benchmark

Similar to expf/exp2f, this patch add two benchmarks for sinf, cosf, and
sincosf: one which measures thoughput as default and one which measures
latency.

The input in 512 random value divided in 8 ranges:

  1. 0.0 <= x < 0.1
  2. 0.1 <= x < 0.7
  3. 0.7 <= x < 3.1
  4. -3.1 <= x < 3.1
  5. 3.3 <= x < 33.3
  6. 100.0 <= x < 1000.0
  7. 1e6 <= x < 1e32
  8. 1e32 < x < FLT_MAX

Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I92bc2f1fac911c573c5122911d08ca590311578a
This commit is contained in:
Adhemerval Zanella 2018-06-08 11:18:32 -03:00
parent ff5a353112
commit 7871ca1075
3 changed files with 4252 additions and 1 deletions

View file

@ -476,7 +476,8 @@ std::map<std::string, args_vector_t> GetShorthand() {
// that can be created with the current property area size.
{"NUM_PROPS", args_vector_t{ {1}, {4}, {16}, {64}, {128}, {256}, {512} }},
{"MATH_COMMON", args_vector_t{ {0}, {1}, {2}, {3} }}
{"MATH_COMMON", args_vector_t{ {0}, {1}, {2}, {3} }},
{"MATH_SINCOS_COMMON", args_vector_t{ {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} }},
};
args_vector_t args_onebuf;

View file

@ -348,3 +348,97 @@ static void BM_math_log2f_speccpu2017_latency(benchmark::State& state) {
}
}
BIONIC_BENCHMARK(BM_math_log2f_speccpu2017_latency);
// Four ranges of values are checked:
// * 0.0 <= x < 0.1
// * 0.1 <= x < 0.7
// * 0.7 <= x < 3.1
// * -3.1 <= x < 3.1
// * 3.3 <= x < 33.3
// * 100.0 <= x < 1000.0
// * 1e6 <= x < 1e32
// * 1e32 < x < FLT_MAX
#include "sincosf_input.cpp"
static void BM_math_sinf(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
f = sinf(*cin);
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_sinf, "MATH_SINCOS_COMMON");
static void BM_math_sinf_latency(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
f = sinf(f * zero + *cin);
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_sinf_latency, "MATH_SINCOS_COMMON");
static void BM_math_cosf(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
f = cosf(*cin);
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_cosf, "MATH_SINCOS_COMMON");
static void BM_math_cosf_latency(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
f = cosf(f * zero + *cin);
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_cosf_latency, "MATH_SINCOS_COMMON");
static void BM_math_sincosf(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
float s, c;
sincosf(*cin, &s, &c);
f += s;
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_sincosf, "MATH_SINCOS_COMMON");
static void BM_math_sincosf_latency(benchmark::State& state) {
auto range = sincosf_input[state.range(0)];
auto cin = range.values.cbegin();
f = 0.0;
for (auto _ : state) {
float s, c;
sincosf(f * zero + *cin, &s, &c);
f += s;
if (++cin == range.values.cend())
cin = range.values.cbegin();
}
state.SetLabel(range.label);
}
BIONIC_BENCHMARK_WITH_ARG(BM_math_sincosf_latency, "MATH_SINCOS_COMMON");

4156
benchmarks/sincosf_input.cpp Normal file

File diff suppressed because it is too large Load diff