Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:58

0001 
0002 #ifndef SIPM_SIPMHELPERS_H
0003 #define SIPM_SIPMHELPERS_H
0004 
0005 #include <cmath>
0006 #ifdef __AVX2__
0007 #include <immintrin.h>
0008 #endif
0009 
0010 namespace sipm {
0011 namespace math {
0012 #ifdef __AVX2__
0013 inline float rec(const float x) {
0014   float y;
0015   __m128 __x = _mm_load_ss(&x);
0016   __x = _mm_rcp_ss(__x);
0017   _mm_store_ss(&y, __x);
0018   return y;
0019 }
0020 #else
0021 inline float rec(const float x) { return 1 / x; }
0022 #endif
0023 
0024 #ifdef __AVX2__
0025 inline float sqrt(const float x) {
0026   float y;
0027   __m128 __x = _mm_load_ss(&x);
0028   __x = _mm_rsqrt_ss(__x);
0029   __x = _mm_rcp_ss(__x);
0030   _mm_store_ss(&y, __x);
0031   return y;
0032 }
0033 #else
0034 inline float sqrt(const float x) { return sqrt(x); }
0035 #endif
0036 
0037 template <typename T> struct pair {
0038   T first, second;
0039   pair(T x, T y) : first(x), second(y) {}
0040   pair() = default;
0041 };
0042 } // namespace math
0043 } // namespace sipm
0044 #endif /* SIPM_SIPMHELPERS_H */