#ifndef NETGEN_CORE_SIMD_HPP #define NETGEN_CORE_SIMD_HPP /**************************************************************************/ /* File: simd.hpp */ /* Author: Joachim Schoeberl, Matthias Hochsteger */ /* Date: 25. Mar. 16 */ /**************************************************************************/ #include "ngcore_api.hpp" #include "simd_generic.hpp" #ifdef NETGEN_ARCH_AMD64 #ifndef __SSE__ #define __SSE__ #endif #include "simd_sse.hpp" #endif #ifdef __AVX__ #include "simd_avx.hpp" #endif #ifdef __AVX512F__ #include "simd_avx512.hpp" #endif namespace ngcore { #ifdef NETGEN_ARCH_AMD64 NETGEN_INLINE auto HSum (SIMD v1, SIMD v2, SIMD v3, SIMD v4) { SIMD hsum1 = my_mm_hadd_pd (v1.Data(), v2.Data()); SIMD hsum2 = my_mm_hadd_pd (v3.Data(), v4.Data()); return SIMD (hsum1, hsum2); } NETGEN_INLINE auto GetMaskFromBits( unsigned int i ) { return SIMD::GetMaskFromBits(i); } #endif NETGEN_INLINE void SIMDTranspose (SIMD a1, SIMD a2, SIMD a3, SIMD a4, SIMD & b1, SIMD & b2, SIMD & b3, SIMD & b4) { SIMD h1,h2,h3,h4; std::tie(h1,h2) = Unpack(a1,a2); std::tie(h3,h4) = Unpack(a3,a4); b1 = SIMD (h1.Lo(), h3.Lo()); b2 = SIMD (h2.Lo(), h4.Lo()); b3 = SIMD (h1.Hi(), h3.Hi()); b4 = SIMD (h2.Hi(), h4.Hi()); } template NETGEN_INLINE auto HSum (SIMD s1, SIMD s2) { return SIMD(HSum(s1), HSum(s2)); } template NETGEN_INLINE auto HSum (SIMD s1, SIMD s2, SIMD s3, SIMD s4 ) { return SIMD(HSum(s1), HSum(s2), HSum(s3), HSum(s4)); } } #endif // NETGEN_CORE_SIMD_HPP