diff --git a/patches/vectorclass/0001-Add-an-alternative-implementation-of-horizontal_add-.patch b/patches/vectorclass/0001-Add-an-alternative-implementation-of-horizontal_add-.patch new file mode 100644 index 0000000000000000000000000000000000000000..10f1cd949df56339c25682fb578343e16774ceef --- /dev/null +++ b/patches/vectorclass/0001-Add-an-alternative-implementation-of-horizontal_add-.patch @@ -0,0 +1,41 @@ +From d46b04686c44bea537773c99e5001482972a454a Mon Sep 17 00:00:00 2001 +From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> +Date: Thu, 12 Oct 2017 15:14:48 +0200 +Subject: [PATCH] Add an alternative implementation of horizontal_add for Vec8d + +--- + vectorf512.h | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/vectorf512.h b/vectorf512.h +index 0845d12..fb1a4d4 100644 +--- a/vectorf512.h ++++ b/vectorf512.h +@@ -1339,13 +1339,19 @@ static inline Vec8d if_mul (Vec8db const & f, Vec8d const & a, Vec8d const & b) + + + // General arithmetic functions, etc. ++extern __inline double ++__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) ++_mm512_cvtsd_f64 (__m512d __A) ++{ ++ return __A[0]; ++} + + // Horizontal add: Calculates the sum of all vector elements. +-static inline double horizontal_add (Vec8d const & a) { +-#if defined(__INTEL_COMPILER) +- return _mm512_reduce_add_pd(a); +-#else +- return horizontal_add(a.get_low() + a.get_high()); ++static inline double horizontal_add (Vec8d const & x) { ++ __m512d intermediate = _mm512_add_pd(x, _mm512_castsi512_pd(_mm512_alignr_epi64(_mm512_castpd_si512(x), _mm512_castpd_si512(x), 1)$ ++ intermediate = _mm512_add_pd(intermediate, _mm512_castsi512_pd(_mm512_alignr_epi64(_mm512_castpd_si512(intermediate), _mm512_castp$ ++ intermediate = _mm512_add_pd(intermediate, _mm512_castsi512_pd(_mm512_alignr_epi64(_mm512_castpd_si512(intermediate), _mm512_castp$ ++ return _mm512_cvtsd_f64(intermediate); + #endif + } + +-- +2.1.4 +