CMS 3D CMS Logo

SIMDVec.h
Go to the documentation of this file.
1 #ifndef DataFormat_Math_SIMDVec_H
2 #define DataFormat_Math_SIMDVec_H
3 //
4 // For sustenaibility prefer the use of hte implementation based on the extended vector syntax
5 // supported by gcc and clang on all architectures
6 //
7 //
8 #if (defined(__CLING__) || defined(__MIC__) || defined(__NVCC__)) || (__BIGGEST_ALIGNMENT__ < 16)
9 #elif defined(__INTEL_COMPILER)
10 // intel compiler does not support the extended vector syntax
11 #define USE_SSEVECT
12 #elif defined(__GNUC__) || defined(__clang__)
13 #if defined(__x86_64__) && defined(__SSE__) && defined(CMS_PREFER_SSEVECT)
14 #define USE_SSEVECT
15 #else
16 #define USE_EXTVECT
17 #endif
18 #endif
19 
20 // to be moved elsewhere
21 namespace mathSSE {
22  //
23  template <typename T>
24  inline bool samesign(T rh, T lh);
25 
26  template <>
27  inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<int>(int rh, int lh) {
28  int const mask = 0x80000000;
29  return ((rh ^ lh) & mask) == 0;
30  }
31 
32  template <>
33  inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<long long>(long long rh, long long lh) {
34  long long const mask = 0x8000000000000000LL;
35  return ((rh ^ lh) & mask) == 0;
36  }
37 
38  template <>
39  inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<float>(float rh, float lh) {
40  union {
41  int i;
42  float f;
43  } a, b;
44  a.f = rh;
45  b.f = lh;
46  return samesign<int>(a.i, b.i);
47  }
48 
49  template <>
50  inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<double>(double rh, double lh) {
51  union {
52  long long i;
53  double f;
54  } a, b;
55  a.f = rh;
56  b.f = lh;
57  return samesign<long long>(a.i, b.i);
58  }
59 } // namespace mathSSE
60 
61 #if defined(USE_EXTVECT)
63 #elif defined(USE_SSEVECT)
64 #if !defined(CMS_PREFER_SSEVECT) || !defined(__INTEL_COMPILER)
65 #warning "using SSEVECT even if not requirested?????"
66 #endif
69 #endif
70 
71 #endif //
Definition: AVXVec.h:6
bool int lh
Definition: SIMDVec.h:27
struct mathSSE::Rot3 __attribute__
return samesign< long long >(a.i, b.i)
return samesign< int >(a.i, b.i)
double b
Definition: hdecay.h:120
a f
Definition: SIMDVec.h:44
bool samesign(T rh, T lh)
double a
Definition: hdecay.h:121
long double T