1313#include < string>
1414#include < vector>
1515#include < iostream>
16- #include < cmath>
1716#include " xsimd/xsimd.hpp"
1817
1918namespace xsimd
2019{
2120 template <class T >
2221 std::string batch_name ();
2322
24- template <> inline std::string batch_name<batch<float , 4 >>() { return " sse float" ; }
25- template <> inline std::string batch_name<batch<double , 2 >>() { return " sse double" ; }
23+ template <> inline std::string batch_name<batch<float , 4 >>() { return " sse/neon float" ; }
24+ template <> inline std::string batch_name<batch<double , 2 >>() { return " sse/neon double" ; }
2625 template <> inline std::string batch_name<batch<float , 8 >>() { return " avx float" ; }
2726 template <> inline std::string batch_name<batch<double , 4 >>() { return " avx double" ; }
2827
@@ -213,66 +212,75 @@ namespace xsimd
213212 void run_benchmark_1op (F f, OS & out, std::size_t size, std::size_t iter, init_method init = init_method::classic)
214213 {
215214 bench_vector<float > f_lhs, f_rhs, f_res;
216- // bench_vector<double> d_lhs, d_rhs, d_res;
215+ bench_vector<double > d_lhs, d_rhs, d_res;
217216
218217 switch (init)
219218 {
220219 case init_method::classic:
221220 init_benchmark (f_lhs, f_rhs, f_res, size);
222- // init_benchmark(d_lhs, d_rhs, d_res, size);
221+ init_benchmark (d_lhs, d_rhs, d_res, size);
223222 break ;
224223 case init_method::arctrigo:
225224 init_benchmark_arctrigo (f_lhs, f_rhs, f_res, size);
226- // init_benchmark_arctrigo(d_lhs, d_rhs, d_res, size);
225+ init_benchmark_arctrigo (d_lhs, d_rhs, d_res, size);
227226 break ;
228227 default :
229228 init_benchmark (f_lhs, f_rhs, f_res, size);
230- // init_benchmark(d_lhs, d_rhs, d_res, size);
229+ init_benchmark (d_lhs, d_rhs, d_res, size);
231230 break ;
232231 }
233232
234-
235233 duration_type t_float_scalar = benchmark_scalar (f, f_lhs, f_res, iter);
236- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
237- // duration_type t_float_sse = benchmark_simd<batch<float, 4>>(f, f_lhs, f_res, iter);
238- // duration_type t_float_sse_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_lhs, f_res, iter);
239- // #endif
240- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
241- // duration_type t_float_avx = benchmark_simd<batch<float, 8 >>(f, f_lhs, f_res , iter);
242- // duration_type t_float_avx_u = benchmark_simd_unrolled<batch<float, 8 >>(f, f_lhs, f_res , iter);
243- // #endif
244- // duration_type t_double_scalar = benchmark_scalar(f, d_lhs, d_res, iter);
245- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
246- // duration_type t_double_sse = benchmark_simd <batch<double, 2 >>(f, d_lhs, d_res , iter);
247- // duration_type t_double_sse_u = benchmark_simd_unrolled <batch<double, 2 >>(f, d_lhs, d_res, iter);
248- // #endif
249- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
250- // duration_type t_double_avx = benchmark_simd<batch<double, 4>>(f, d_lhs, d_res, iter);
251- // duration_type t_double_avx_u = benchmark_simd_unrolled <batch<double , 4>>(f, d_lhs, d_res , iter);
252- // #endif
253-
254- duration_type t_double_avx = benchmark_simd <batch<float , 4 >>(f, f_lhs, f_res , iter);
255- duration_type t_double_avx_u = benchmark_simd_unrolled<batch< float , 4 >>(f, f_lhs, f_res, iter);
256-
257- out << " =======================" << std::endl;
234+ duration_type t_double_scalar = benchmark_scalar (f, d_lhs, d_res, iter);
235+
236+ # if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
237+ duration_type t_float_sse = benchmark_simd<batch< float , 4 >>(f, f_lhs, f_res, iter);
238+ duration_type t_float_sse_u = benchmark_simd_unrolled<batch< float , 4 >>(f, f_lhs, f_res, iter);
239+ duration_type t_double_sse = benchmark_simd<batch<double , 2 >>(f, d_lhs, d_res , iter);
240+ duration_type t_double_sse_u = benchmark_simd_unrolled<batch<double , 2 >>(f, d_lhs, d_res , iter);
241+ #endif
242+ # if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
243+ duration_type t_float_avx = benchmark_simd<batch< float , 8 >>(f, f_lhs, f_res, iter);
244+ duration_type t_float_avx_u = benchmark_simd_unrolled <batch<float , 8 >>(f, f_lhs, f_res , iter);
245+ duration_type t_double_avx = benchmark_simd <batch<double , 4 >>(f, d_lhs, d_res, iter);
246+ duration_type t_double_avx_u = benchmark_simd_unrolled<batch< double , 4 >>(f, d_lhs, d_res, iter);
247+ # endif
248+ # if defined(XSIMD_ARM_INSTR_SET)
249+ duration_type t_float_neon = benchmark_simd <batch<float , 4 >>(f, f_lhs, f_res , iter);
250+ duration_type t_float_neon_u = benchmark_simd_unrolled<batch< float , 4 >>(f, f_lhs, f_res, iter);
251+ duration_type t_double_neon = benchmark_simd<batch< double , 2 >>(f, d_lhs, d_res, iter);
252+ duration_type t_double_neon_u = benchmark_simd_unrolled <batch<double , 2 >>(f, d_lhs, d_res , iter);
253+ # endif
254+
255+ out << " ============================ " << std::endl;
258256 out << f.name () << std::endl;
259- out << " scalar float : " << t_float_scalar.count () << " ms" << std::endl;
260- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
261- // out << "sse float : " << t_float_sse.count() << "ms" << std::endl;
262- // out << "sse float unr : " << t_float_sse_u.count() << "ms" << std::endl;
263- // #endif
264- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
265- // out << "avx float : " << t_float_avx.count() << "ms" << std::endl;
266- // out << "avx float unr : " << t_float_avx_u.count() << "ms" << std::endl;
267- // #endif
268- // out << "scalar double : " << t_double_scalar.count() << "ms" << std::endl;
269- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
270- // out << "sse double : " << t_double_sse.count() << "ms" << std::endl;
271- // out << "sse double unr: " << t_double_sse_u.count() << "ms" << std::endl;
272- // #endif
273- out << " avx float : " << t_double_avx.count () << " ms" << std::endl;
274- out << " avx float unr: " << t_double_avx_u.count () << " ms" << std::endl;
275- out << " =======================" << std::endl;
257+ out << " scalar float : " << t_float_scalar.count () << " ms" << std::endl;
258+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
259+ out << " sse float : " << t_float_sse.count () << " ms" << std::endl;
260+ out << " sse float unr : " << t_float_sse_u.count () << " ms" << std::endl;
261+ #endif
262+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
263+ out << " avx float : " << t_float_avx.count () << " ms" << std::endl;
264+ out << " avx float unr : " << t_float_avx_u.count () << " ms" << std::endl;
265+ #endif
266+ #if defined(XSIMD_ARM_INSTR_SET)
267+ out << " neon float : " << t_float_neon.count () << " ms" << std::endl;
268+ out << " neon float unr : " << t_float_neon_u.count () << " ms" << std::endl;
269+ #endif
270+ out << " scalar double : " << t_double_scalar.count () << " ms" << std::endl;
271+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
272+ out << " sse double : " << t_double_sse.count () << " ms" << std::endl;
273+ out << " sse double unr : " << t_double_sse_u.count () << " ms" << std::endl;
274+ #endif
275+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
276+ out << " avx double : " << t_double_avx.count () << " ms" << std::endl;
277+ out << " avx double unr : " << t_double_avx_u.count () << " ms" << std::endl;
278+ #endif
279+ #if defined(XSIMD_ARM_INSTR_SET)
280+ out << " neon double : " << t_double_neon.count () << " ms" << std::endl;
281+ out << " neon double unr: " << t_double_neon_u.count () << " ms" << std::endl;
282+ #endif
283+ out << " ============================" << std::endl;
276284 }
277285
278286 template <class F , class OS >
@@ -285,48 +293,59 @@ namespace xsimd
285293 init_benchmark (d_lhs, d_rhs, d_res, size);
286294
287295 duration_type t_float_scalar = benchmark_scalar (f, f_lhs, f_rhs, f_res, iter);
288- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
289- // duration_type t_float_sse = benchmark_simd<batch<float, 4>>(f, f_lhs, f_rhs, f_res, iter);
290- // duration_type t_float_sse_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_lhs, f_rhs, f_res, iter);
291- // #endif
292- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
293- // duration_type t_float_avx = benchmark_simd<batch<float, 8>>(f, f_lhs, f_rhs, f_res, iter);
294- // duration_type t_float_avx_u = benchmark_simd_unrolled<batch<float, 8>>(f, f_lhs, f_rhs, f_res, iter);
295- // #endif
296- // duration_type t_double_scalar = benchmark_scalar(f, d_lhs, d_rhs, d_res, iter);
297- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
298- // duration_type t_double_sse = benchmark_simd<batch<double, 2>>(f, d_lhs, d_rhs, d_res, iter);
299- // duration_type t_double_sse_u = benchmark_simd_unrolled<batch<double, 2>>(f, d_lhs, d_rhs, d_res, iter);
300- // #endif
301- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
302- // duration_type t_double_avx = benchmark_simd<batch<double, 4>>(f, d_lhs, d_rhs, d_res, iter);
303- // duration_type t_double_avx_u = benchmark_simd_unrolled<batch<double, 4>>(f, d_lhs, d_rhs, d_res, iter);
304- // #endif
305- duration_type t_double_avx = benchmark_simd<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
306- duration_type t_double_avx_u = benchmark_simd_unrolled<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
307-
308-
309- out << " =======================" << std::endl;
296+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
297+ duration_type t_float_sse = benchmark_simd<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
298+ duration_type t_float_sse_u = benchmark_simd_unrolled<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
299+ #endif
300+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
301+ duration_type t_float_avx = benchmark_simd<batch<float , 8 >>(f, f_lhs, f_rhs, f_res, iter);
302+ duration_type t_float_avx_u = benchmark_simd_unrolled<batch<float , 8 >>(f, f_lhs, f_rhs, f_res, iter);
303+ #endif
304+ duration_type t_double_scalar = benchmark_scalar (f, d_lhs, d_rhs, d_res, iter);
305+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
306+ duration_type t_double_sse = benchmark_simd<batch<double , 2 >>(f, d_lhs, d_rhs, d_res, iter);
307+ duration_type t_double_sse_u = benchmark_simd_unrolled<batch<double , 2 >>(f, d_lhs, d_rhs, d_res, iter);
308+ #endif
309+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
310+ duration_type t_double_avx = benchmark_simd<batch<double , 4 >>(f, d_lhs, d_rhs, d_res, iter);
311+ duration_type t_double_avx_u = benchmark_simd_unrolled<batch<double , 4 >>(f, d_lhs, d_rhs, d_res, iter);
312+ #endif
313+ #if defined(XSIMD_ARM_INSTR_SET)
314+ duration_type t_float_neon = benchmark_simd<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
315+ duration_type t_float_neon_u = benchmark_simd_unrolled<batch<float , 4 >>(f, f_lhs, f_rhs, f_res, iter);
316+ duration_type t_double_neon = benchmark_simd<batch<double , 2 >>(f, d_lhs, d_rhs, d_res, iter);
317+ duration_type t_double_neon_u = benchmark_simd_unrolled<batch<double , 2 >>(f, d_lhs, d_rhs, d_res, iter);
318+ #endif
319+
320+ out << " ============================" << std::endl;
310321 out << f.name () << std::endl;
311- out << " scalar float : " << t_float_scalar.count () << " ms" << std::endl;
312- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
313- // out << "sse float : " << t_float_sse.count() << "ms" << std::endl;
314- // out << "sse float unr : " << t_float_sse_u.count() << "ms" << std::endl;
315- // #endif
316- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
317- // out << "avx float : " << t_float_avx.count() << "ms" << std::endl;
318- // out << "avx float unr : " << t_float_avx_u.count() << "ms" << std::endl;
319- // #endif
320- // out << "scalar double : " << t_double_scalar.count() << "ms" << std::endl;
321- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
322- // out << "sse double : " << t_double_sse.count() << "ms" << std::endl;
323- // out << "sse double unr: " << t_double_sse_u.count() << "ms" << std::endl;
324- // #endif
325- // #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
326- out << " avx double : " << t_double_avx.count () << " ms" << std::endl;
327- out << " avx double unr: " << t_double_avx_u.count () << " ms" << std::endl;
328- // #endif
329- out << " =======================" << std::endl;
322+ out << " scalar float : " << t_float_scalar.count () << " ms" << std::endl;
323+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
324+ out << " sse float : " << t_float_sse.count () << " ms" << std::endl;
325+ out << " sse float unr : " << t_float_sse_u.count () << " ms" << std::endl;
326+ #endif
327+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
328+ out << " avx float : " << t_float_avx.count () << " ms" << std::endl;
329+ out << " avx float unr : " << t_float_avx_u.count () << " ms" << std::endl;
330+ #endif
331+ #if defined(XSIMD_ARM_INSTR_SET)
332+ out << " neon float : " << t_float_neon.count () << " ms" << std::endl;
333+ out << " neon float unr : " << t_float_neon_u.count () << " ms" << std::endl;
334+ #endif
335+ out << " scalar double : " << t_double_scalar.count () << " ms" << std::endl;
336+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
337+ out << " sse double : " << t_double_sse.count () << " ms" << std::endl;
338+ out << " sse double unr : " << t_double_sse_u.count () << " ms" << std::endl;
339+ #endif
340+ #if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
341+ out << " avx double : " << t_double_avx.count () << " ms" << std::endl;
342+ out << " avx double unr : " << t_double_avx_u.count () << " ms" << std::endl;
343+ #endif
344+ #if defined(XSIMD_ARM_INSTR_SET)
345+ out << " neon double : " << t_double_neon.count () << " ms" << std::endl;
346+ out << " neon double unr: " << t_double_neon_u.count () << " ms" << std::endl;
347+ #endif
348+ out << " ============================" << std::endl;
330349 }
331350
332351#define DEFINE_OP_FUNCTOR_2OP (OP, NAME )\
@@ -370,24 +389,24 @@ DEFINE_FUNCTOR_1OP(asin);
370389DEFINE_FUNCTOR_1OP (acos);
371390DEFINE_FUNCTOR_1OP (atan);
372391
373- // DEFINE_FUNCTOR_1OP(sinh);
374- // DEFINE_FUNCTOR_1OP(cosh);
375- // DEFINE_FUNCTOR_1OP(tanh);
376- // DEFINE_FUNCTOR_1OP(asinh);
377- // DEFINE_FUNCTOR_1OP(acosh);
378- // DEFINE_FUNCTOR_1OP(atanh);
379-
380- // DEFINE_FUNCTOR_2OP(pow);
381- // DEFINE_FUNCTOR_1OP(sqrt);
382- // DEFINE_FUNCTOR_1OP(cbrt);
383- // DEFINE_FUNCTOR_2OP(hypot);
384-
385- // DEFINE_FUNCTOR_1OP(ceil);
386- // DEFINE_FUNCTOR_1OP(floor);
387- // DEFINE_FUNCTOR_1OP(trunc);
388- // DEFINE_FUNCTOR_1OP(round);
389- // DEFINE_FUNCTOR_1OP(nearbyint);
390- // DEFINE_FUNCTOR_1OP(rint);
392+ DEFINE_FUNCTOR_1OP (sinh);
393+ DEFINE_FUNCTOR_1OP (cosh);
394+ DEFINE_FUNCTOR_1OP (tanh);
395+ DEFINE_FUNCTOR_1OP (asinh);
396+ DEFINE_FUNCTOR_1OP (acosh);
397+ DEFINE_FUNCTOR_1OP (atanh);
398+
399+ DEFINE_FUNCTOR_2OP (pow);
400+ DEFINE_FUNCTOR_1OP (sqrt);
401+ DEFINE_FUNCTOR_1OP (cbrt);
402+ DEFINE_FUNCTOR_2OP (hypot);
403+
404+ DEFINE_FUNCTOR_1OP (ceil);
405+ DEFINE_FUNCTOR_1OP (floor);
406+ DEFINE_FUNCTOR_1OP (trunc);
407+ DEFINE_FUNCTOR_1OP (round);
408+ DEFINE_FUNCTOR_1OP (nearbyint);
409+ DEFINE_FUNCTOR_1OP (rint);
391410
392411}
393412
0 commit comments