Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-02 05:09:31

0001 #ifndef DataFormat_Math_SIMDVec_H
0002 #define DataFormat_Math_SIMDVec_H
0003 //
0004 //  For sustenaibility prefer the use of hte implementation based on the extended vector syntax
0005 //  supported by gcc and clang on all architectures
0006 //
0007 //
0008 #if (defined(__CLING__) || defined(__MIC__) || defined(__NVCC__)) || (__BIGGEST_ALIGNMENT__ < 16)
0009 #elif defined(__INTEL_COMPILER)
0010 // intel compiler does not support the extended vector syntax
0011 #define USE_SSEVECT
0012 #elif defined(__GNUC__) || defined(__clang__)
0013 #if defined(__x86_64__) && defined(__SSE__) && defined(CMS_PREFER_SSEVECT)
0014 #define USE_SSEVECT
0015 #else
0016 #define USE_EXTVECT
0017 #endif
0018 #endif
0019 
0020 // to be moved elsewhere
0021 namespace mathSSE {
0022   //
0023   template <typename T>
0024   inline bool samesign(T rh, T lh);
0025 
0026   template <>
0027   inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<int>(int rh, int lh) {
0028     int const mask = 0x80000000;
0029     return ((rh ^ lh) & mask) == 0;
0030   }
0031 
0032   template <>
0033   inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<long long>(long long rh, long long lh) {
0034     long long const mask = 0x8000000000000000LL;
0035     return ((rh ^ lh) & mask) == 0;
0036   }
0037 
0038   template <>
0039   inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<float>(float rh, float lh) {
0040     union {
0041       int i;
0042       float f;
0043     } a, b;
0044     a.f = rh;
0045     b.f = lh;
0046     return samesign<int>(a.i, b.i);
0047   }
0048 
0049   template <>
0050   inline bool __attribute__((always_inline)) __attribute__((pure)) samesign<double>(double rh, double lh) {
0051     union {
0052       long long i;
0053       double f;
0054     } a, b;
0055     a.f = rh;
0056     b.f = lh;
0057     return samesign<long long>(a.i, b.i);
0058   }
0059 }  // namespace mathSSE
0060 
0061 #if defined(USE_EXTVECT)
0062 #include "DataFormats/Math/interface/ExtVec.h"
0063 #elif defined(USE_SSEVECT)
0064 #if !defined(CMS_PREFER_SSEVECT) || !defined(__INTEL_COMPILER)
0065 #warning "using SSEVECT even if not requirested?????"
0066 #endif
0067 #include "DataFormats/Math/interface/SSEVec.h"
0068 #include "DataFormats/Math/interface/SSERot.h"
0069 #endif
0070 
0071 #endif  //