From 06ddf9a62fd6e991dfcf0bd2abe0941b960cb2bb Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 16 Oct 2015 13:45:31 -0400 Subject: Reformat source code with clang-format Note: If you have an existing checkout with modifications, then you should: (1) save your current state on a branch (2) run clang-format on this branch (3) compare this branch to a fresh checkout of the clang-formatted master Since both your branch and master have been formatted with clang-format, this will lead to a very small diff, avoiding spurious changes due to formatting differences. --- bench.cc | 274 ++--- example.cc | 14 +- example_float.cc | 14 +- floatbuiltins.h | 464 ++++---- floatprops.h | 571 +++++----- floattypes.h | 316 +++--- instantiations.cc | 239 ++-- interp.cc | 26 +- loop.cc | 250 ++--- mathfuncs.h | 2 +- mathfuncs_asin.h | 363 +++--- mathfuncs_asinh.h | 53 +- mathfuncs_base.h | 243 ++-- mathfuncs_convert.h | 358 +++--- mathfuncs_exp.h | 237 ++-- mathfuncs_fabs.h | 305 +++-- mathfuncs_int.h | 243 ++-- mathfuncs_log.h | 137 ++- mathfuncs_pow.h | 43 +- mathfuncs_rcp.h | 117 +- mathfuncs_sin.h | 419 ++++--- mathfuncs_sinh.h | 37 +- mathfuncs_sqrt.h | 124 +- selftest.cc | 1741 ++++++++++++++-------------- vec_altivec_float4.h | 1139 +++++++++---------- vec_avx_double4.h | 1359 ++++++++++------------ vec_avx_float8.h | 1395 +++++++++++------------ vec_avx_fp16_16.h | 1171 +++++++++---------- vec_avx_fp8_32.h | 1249 +++++++++------------ vec_base.h | 1179 +++++++++---------- vec_builtin.h | 2619 ++++++++++++++++++++----------------------- vec_mask.h | 121 +- vec_mic_double8.h | 1236 ++++++++++---------- vec_neon_float2.h | 1085 ++++++++---------- vec_neon_float4.h | 1131 +++++++++---------- vec_pseudo.h | 3052 ++++++++++++++++++++++++-------------------------- vec_qpx_double4.h | 1399 +++++++++++------------ vec_sse_double1.h | 1002 ++++++++--------- vec_sse_double2.h | 1237 +++++++++----------- vec_sse_float1.h | 998 ++++++++--------- vec_sse_float4.h | 1286 ++++++++++----------- vec_test.h | 2690 +++++++++++++++++++++----------------------- vec_vsx_double2.h | 1215 +++++++++----------- vecmathlib.h | 248 ++-- 44 files changed, 15431 insertions(+), 17970 deletions(-) diff --git a/bench.cc b/bench.cc index e795985..ac3eb46 100644 --- a/bench.cc +++ b/bench.cc @@ -16,47 +16,38 @@ using namespace std; using namespace vecmathlib; - - #ifndef __has_builtin -# define __has_builtin(x) 0 // Compatibility with non-clang compilers +#define __has_builtin(x) 0 // Compatibility with non-clang compilers #endif - - typedef unsigned long long ticks; -inline ticks getticks() -{ +inline ticks getticks() { #if __has_builtin(__builtin_readcyclecounter) return __builtin_readcyclecounter(); #elif defined __x86_64__ ticks a, d; - asm volatile("rdtsc" : "=a" (a), "=d" (d)); + asm volatile("rdtsc" : "=a"(a), "=d"(d)); return a | (d << 32); #elif defined __powerpc__ unsigned int tbl, tbu, tbu1; do { - asm volatile("mftbu %0": "=r"(tbu)); - asm volatile("mftb %0": "=r"(tbl)); - asm volatile("mftbu %0": "=r"(tbu1)); + asm volatile("mftbu %0" : "=r"(tbu)); + asm volatile("mftb %0" : "=r"(tbl)); + asm volatile("mftbu %0" : "=r"(tbu1)); } while (tbu != tbu1); return ((unsigned long long)tbu << 32) | tbl; #else timeval tv; gettimeofday(&tv, NULL); return 1000000ULL * tv.tv_sec + tv.tv_usec; - // timespec ts; - // clock_gettime(CLOCK_REALTIME, &ts); - // return 1000000000ULL * ts.tv_sec + ts.tv_nsec; +// timespec ts; +// clock_gettime(CLOCK_REALTIME, &ts); +// return 1000000000ULL * ts.tv_sec + ts.tv_nsec; #endif } -inline double elapsed(ticks t1, ticks t0) -{ - return t1-t0; -} +inline double elapsed(ticks t1, ticks t0) { return t1 - t0; } -double get_sys_time() -{ +double get_sys_time() { timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + 1.0e-6 * tv.tv_usec; @@ -65,8 +56,7 @@ double get_sys_time() // return ts.tv_sec + 1.0e-9 * ts.tv_nsec; } -double measure_tick() -{ +double measure_tick() { ticks const rstart = getticks(); double const wstart = get_sys_time(); while (get_sys_time() - wstart < 0.1) { @@ -74,124 +64,103 @@ double measure_tick() } ticks const rend = getticks(); double const wend = get_sys_time(); - assert(wend-wstart >= 0.09); + assert(wend - wstart >= 0.09); return (wend - wstart) / elapsed(rend, rstart); } - - double global_result = 0.0; -template -void save_result(realvec_t result) -{ - for (int i=0; i void save_result(realvec_t result) { + for (int i = 0; i < realvec_t::size; ++i) { global_result += result[i]; } // Check global accumulator to prevent optimisation - if (! vml_std::isfinite(global_result)) { + if (!vml_std::isfinite(global_result)) { cout << "\n" << "WARNING: Global accumulator is not finite\n"; } } +template inline T nop(T x) { return x; } +template inline T fneg(T x) { return -x; } -template inline T nop(T x) { return x; } - -template inline T fneg(T x) { return -x; } +template inline T fadd(T x, T y) { return x + y; } +template inline T fsub(T x, T y) { return x - y; } +template inline T fmul(T x, T y) { return x * y; } +template inline T fdiv(T x, T y) { return x / y; } -template inline T fadd(T x, T y) { return x+y; } -template inline T fsub(T x, T y) { return x-y; } -template inline T fmul(T x, T y) { return x*y; } -template inline T fdiv(T x, T y) { return x/y; } - -template inline T frexp0(T x) -{ +template inline T frexp0(T x) { typename T::intvec_t ir; return frexp(x, &ir); } -template inline typename T::intvec_t frexp1(T x) -{ +template inline typename T::intvec_t frexp1(T x) { typename T::intvec_t ir; frexp(x, &ir); return ir; } -template inline T ldexps(T x, T y) -{ +template inline T ldexps(T x, T y) { typename T::intvec_t iy = convert_int(y); return ldexp(x, iy[0]); } -template inline T ldexpv(T x, T y) -{ +template inline T ldexpv(T x, T y) { typename T::intvec_t iy = convert_int(y); return ldexp(x, iy); } - - -#define DECLARE_FUNCTOR(FUNC, XMIN, XMAX) \ - template \ - struct functor_##FUNC { \ - static typename T::real_t get_xmin() { return XMIN; } \ - static typename T::real_t get_xmax() { return XMAX; } \ - static const char* name() { return #FUNC; } \ - T operator()(T x) { \ - return FUNC(x); \ - } \ +#define DECLARE_FUNCTOR(FUNC, XMIN, XMAX) \ + template struct functor_##FUNC { \ + static typename T::real_t get_xmin() { return XMIN; } \ + static typename T::real_t get_xmax() { return XMAX; } \ + static const char *name() { return #FUNC; } \ + T operator()(T x) { return FUNC(x); } \ } -#define DECLARE_BFUNCTOR(FUNC, XMIN, XMAX) \ - template \ - struct functor_##FUNC { \ - static typename T::real_t get_xmin() { return XMIN; } \ - static typename T::real_t get_xmax() { return XMAX; } \ - static const char* name() { return #FUNC; } \ - T operator()(T x) { \ - typename T::boolvec_t res = FUNC(x); \ - return convert_float(convert_int(res)); \ - } \ +#define DECLARE_BFUNCTOR(FUNC, XMIN, XMAX) \ + template struct functor_##FUNC { \ + static typename T::real_t get_xmin() { return XMIN; } \ + static typename T::real_t get_xmax() { return XMAX; } \ + static const char *name() { return #FUNC; } \ + T operator()(T x) { \ + typename T::boolvec_t res = FUNC(x); \ + return convert_float(convert_int(res)); \ + } \ } -#define DECLARE_IFUNCTOR(FUNC, XMIN, XMAX) \ - template \ - struct functor_##FUNC { \ - static typename T::real_t get_xmin() { return XMIN; } \ - static typename T::real_t get_xmax() { return XMAX; } \ - static const char* name() { return #FUNC; } \ - T operator()(T x) { \ - typename T::intvec_t res = FUNC(x); \ - return convert_float(res); \ - } \ +#define DECLARE_IFUNCTOR(FUNC, XMIN, XMAX) \ + template struct functor_##FUNC { \ + static typename T::real_t get_xmin() { return XMIN; } \ + static typename T::real_t get_xmax() { return XMAX; } \ + static const char *name() { return #FUNC; } \ + T operator()(T x) { \ + typename T::intvec_t res = FUNC(x); \ + return convert_float(res); \ + } \ } -#define DECLARE_FUNCTOR2(FUNC, XMIN, XMAX, YOFFSET) \ - template \ - struct functor_##FUNC { \ - static typename T::real_t get_xmin() { return XMIN; } \ - static typename T::real_t get_xmax() { return XMAX; } \ - static const char* name() { return #FUNC; } \ - T operator()(T x) { \ - const typename T::real_t yoffset = YOFFSET; \ - return FUNC(x, x + T(yoffset)); \ - } \ +#define DECLARE_FUNCTOR2(FUNC, XMIN, XMAX, YOFFSET) \ + template struct functor_##FUNC { \ + static typename T::real_t get_xmin() { return XMIN; } \ + static typename T::real_t get_xmax() { return XMAX; } \ + static const char *name() { return #FUNC; } \ + T operator()(T x) { \ + const typename T::real_t yoffset = YOFFSET; \ + return FUNC(x, x + T(yoffset)); \ + } \ } -#define DECLARE_FUNCTOR3(FUNC, XMIN, XMAX, YOFFSET, ZOFFSET) \ - template \ - struct functor_##FUNC { \ - static typename T::real_t get_xmin() { return XMIN; } \ - static typename T::real_t get_xmax() { return XMAX; } \ - static const char* name() { return #FUNC; } \ - T operator()(T x) { \ - const typename T::real_t yoffset = YOFFSET; \ - const typename T::real_t zoffset = ZOFFSET; \ - return FUNC(x, x + T(yoffset), x + T(zoffset)); \ - } \ +#define DECLARE_FUNCTOR3(FUNC, XMIN, XMAX, YOFFSET, ZOFFSET) \ + template struct functor_##FUNC { \ + static typename T::real_t get_xmin() { return XMIN; } \ + static typename T::real_t get_xmax() { return XMAX; } \ + static const char *name() { return #FUNC; } \ + T operator()(T x) { \ + const typename T::real_t yoffset = YOFFSET; \ + const typename T::real_t zoffset = ZOFFSET; \ + return FUNC(x, x + T(yoffset), x + T(zoffset)); \ + } \ } - - DECLARE_FUNCTOR(nop, 0.0, 1.0); DECLARE_FUNCTOR(fneg, 0.0, 1.0); @@ -252,137 +221,127 @@ DECLARE_FUNCTOR(tan, 0.0, 1.0); DECLARE_FUNCTOR(tanh, -1.0, +1.0); DECLARE_FUNCTOR(trunc, -1.0, +1.0); - - -template class func_t> -double run_bench() -{ +template class func_t> +double run_bench() { const int numiters = 1000000; - + typedef typename realvec_t::real_t real_t; const real_t xmin = func_t::get_xmin(); const real_t xmax = func_t::get_xmax(); realvec_t x0, dx; - for (int i=0; i func; t0 = getticks(); x = y = x0; - for (int n=0; n class func_t> -void bench_type_func() -{ - cout << " " - << setw(-5) << func_t::name() << " " - << setw(18) << realvec_t::name() << ": " << flush; +template class func_t> +void bench_type_func() { + cout << " " << setw(-5) << func_t::name() << " " << setw(18) + << realvec_t::name() << ": " << flush; double const cycles = run_bench(); cout << cycles << " cycles\n" << flush; } -template class func_t> -void bench_func() -{ +template