Skip to content

Commit

Permalink
added benchmark on neon
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolm committed Jan 29, 2024
1 parent c1257fc commit 87298cb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ int benchmark(approximation_function function, const char* name)

output = _mm256_cvtss_f32(result);
#else
float32x4_t step = vdupq_n_f32(FLT_EPSILON);
float32x4_t input = vld1q_f32(init_array);
float32x4_t result = vdupq_n_f32(0.f);

start = stm_now();

for(uint32_t i=0; i<NUM_ITERATIONS; ++i)
{
result = vaddq_f32(result, function(input));
input = vaddq_f32(input, step);
}

output = vgetq_lane_f32(result, 0);
#endif

printf(".%s: %3.3f ms \n", name, stm_ms(stm_since(start)));
Expand Down Expand Up @@ -73,7 +85,16 @@ int main(int argc, char * argv[])
output += benchmark(mm256_log_ps, "mm256_log_ps");
output += benchmark(mm256_log2_ps, "mm256_log2_ps");
#else

output += benchmark(vacosq_f32, "vacosq_f32");
output += benchmark(vasinq_f32, "vasinq_f32");
output += benchmark(vatanq_f32, "vatanq_f32");
output += benchmark(vcbrtq_f32, "vcbrtq_f32");
output += benchmark(vcosq_f32, "vcosq_f32");
output += benchmark(vsinq_f32, "vsinq_f32");
output += benchmark(vexpq_f32, "vexpq_f32");
output += benchmark(vexp2q_f32, "vexp2q_f32");
output += benchmark(vlogq_f32, "vlogq_f32");
output += benchmark(vlog2q_f32, "vlog2q_f32");
#endif

printf("\n%d\n", output);
Expand Down

0 comments on commit 87298cb

Please sign in to comment.