simd-reduce

SIMD reduce implementation and benchmark
git clone git://git.rr3.xyz/simd-reduce
Log | Files | Refs

main.c (552B)


      1 #include <rcx/all.h>
      2 #include <rcx/bench.h>
      3 
      4 #include "func.h"
      5 
      6 u64 in[32];
      7 volatile u128 out;
      8 
      9 #define BENCHMARK(f) \
     10 	void \
     11 	benchmark_##f(u64 N) { \
     12 		r_bench_start(); \
     13 		for (u64 n = 0; n < N; n++) \
     14 			out = f(in); \
     15 		r_bench_stop(); \
     16 	}
     17 
     18 BENCHMARK(reduce_scalar1024)
     19 BENCHMARK(reduce_scalar2048)
     20 BENCHMARK(reduce_avx1024)
     21 BENCHMARK(reduce_avx2048)
     22 
     23 int
     24 main(void) {
     25 	r_bench(benchmark_reduce_scalar1024, 3000);
     26 	r_bench(benchmark_reduce_scalar2048, 3000);
     27 	r_bench(benchmark_reduce_avx1024, 3000);
     28 	r_bench(benchmark_reduce_avx2048, 3000);
     29 }