PandaRoot
PndFTSVector.h
Go to the documentation of this file.
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project *
3  * All rights reserved. *
4  * *
5  * Primary Authors: *
6  * Copyright 2009 Matthias Kretz <kretz@kde.org> *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
17 #ifndef PNDFTSVECTOR_H
18 #define PNDFTSVECTOR_H
19 
20 #include "PndFTSCADef.h"
21 #include "PndFTSCAMath.h"
22 
23 static inline uint_m validHitIndexes(const uint_v &v)
24 {
25  return static_cast<int_v>(v) >= int_v(Vc::Zero);
26 }
27 
28 namespace CAMath {
29 template <>
30 inline Vc::int_v Abs<Vc::int_v>(const Vc::int_v &x)
31 {
32  return Vc::abs(x);
33 }
34 #define SPECIALIZATION(T) \
35  template <> \
36  inline Vc::T Min<Vc::T>(const Vc::T &x, const Vc::T &y) \
37  { \
38  return Vc::min(x, y); \
39  } \
40  template <> \
41  inline Vc::T Max<Vc::T>(const Vc::T &x, const Vc::T &y) \
42  { \
43  return Vc::max(x, y); \
44  }
45 SPECIALIZATION(int_v)
46 SPECIALIZATION(uint_v)
47 #undef SPECIALIZATION
48 #define SPECIALIZATION(T) \
49  template <> \
50  inline T Min<T>(const T &x, const T &y) \
51  { \
52  return Vc::min(x, y); \
53  } \
54  template <> \
55  inline T Max<T>(const T &x, const T &y) \
56  { \
57  return Vc::max(x, y); \
58  } \
59  template <> \
60  inline T Sqrt<T>(const T &x) \
61  { \
62  return Vc::sqrt(x); \
63  } \
64  template <> \
65  inline T Abs<T>(const T &x) \
66  { \
67  return Vc::abs(x); \
68  } \
69  template <> \
70  inline T Log<T>(const T &x) \
71  { \
72  return Vc::log(x); \
73  } \
74  template <> \
75  inline T Reciprocal<T>(const T &x) \
76  { \
77  return Vc::reciprocal(x); \
78  } \
79  template <> \
80  inline T Round<T>(const T &x) \
81  { \
82  return Vc::round(x); \
83  } \
84  template <> \
85  inline T RSqrt<T>(const T &x) \
86  { \
87  return Vc::rsqrt(x); \
88  } \
89  template <> \
90  struct FiniteReturnTypeHelper<T> { \
91  typedef T::Mask R; \
92  }; \
93  template <> \
94  inline FiniteReturnTypeHelper<T>::R Finite<T>(const T &x) \
95  { \
96  return Vc::isfinite(x); \
97  } \
98  template <> \
99  inline T ATan2<T>(const T &x, const T &y) \
100  { \
101  return Vc::atan2(x, y); \
102  } \
103  template <> \
104  inline T ASin<T>(const T &x) \
105  { \
106  return Vc::asin(x); \
107  } \
108  template <> \
109  inline T Sin<T>(const T &x) \
110  { \
111  return Vc::sin(x); \
112  } \
113  template <> \
114  inline T Cos<T>(const T &x) \
115  { \
116  return Vc::cos(x); \
117  }
118 
119 SPECIALIZATION(float_v)
120 SPECIALIZATION(double_v)
121 #undef SPECIALIZATION
122 
123 #ifdef USE_TBB
124 static void AtomicMax(unsigned int volatile *addr, uint_v val)
125 {
126  for (int i = 0; i < uint_v::Size; ++i) {
127  AtomicMax(&addr[i], val[i]);
128  }
129 }
130 #endif // USE_TBB
131 } // namespace CAMath
132 
133 #endif // PNDFTSVECTOR_H
#define SPECIALIZATION(T)
Definition: PndFTSVector.h:48
__m128 v
Definition: P4_F32vec4.h:3
unsigned int i
Definition: P4_F32vec4.h:21
static uint_m validHitIndexes(const uint_v &v)
Definition: PndFTSVector.h:23