PandaRoot
PndCAVector.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 ALIHLTVECTOR_H
18 #define ALIHLTVECTOR_H
19 
20 #include "PndCADef.h"
21 #include "PndCAMath.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 #ifndef ENABLE_LARRABEE
48 // template<> inline Vc::int_v Abs <Vc::int_v >( const Vc::int_v &x ) { return Vc::abs( x ); }
49 // SPECIALIZATION( int_v )
50 // SPECIALIZATION( uint_v )
51 #endif // ENABLE_LARRABEE
52 #undef SPECIALIZATION
53 #define SPECIALIZATION(T) \
54  template <> \
55  inline T Min<T>(const T &x, const T &y) \
56  { \
57  return Vc::min(x, y); \
58  } \
59  template <> \
60  inline T Max<T>(const T &x, const T &y) \
61  { \
62  return Vc::max(x, y); \
63  } \
64  template <> \
65  inline T Sqrt<T>(const T &x) \
66  { \
67  return Vc::sqrt(x); \
68  } \
69  template <> \
70  inline T Abs<T>(const T &x) \
71  { \
72  return Vc::abs(x); \
73  } \
74  template <> \
75  inline T Log<T>(const T &x) \
76  { \
77  return Vc::log(x); \
78  } \
79  template <> \
80  inline T Reciprocal<T>(const T &x) \
81  { \
82  return Vc::reciprocal(x); \
83  } \
84  template <> \
85  inline T Round<T>(const T &x) \
86  { \
87  return Vc::round(x); \
88  } \
89  template <> \
90  inline T RSqrt<T>(const T &x) \
91  { \
92  return Vc::rsqrt(x); \
93  } \
94  template <> \
95  struct FiniteReturnTypeHelper<T> { \
96  typedef T::Mask R; \
97  }; \
98  template <> \
99  inline FiniteReturnTypeHelper<T>::R Finite<T>(const T &x) \
100  { \
101  return Vc::isfinite(x); \
102  } \
103  template <> \
104  inline T ATan2<T>(const T &x, const T &y) \
105  { \
106  return Vc::atan2(x, y); \
107  } \
108  template <> \
109  inline T ASin<T>(const T &x) \
110  { \
111  return Vc::asin(x); \
112  } \
113  template <> \
114  inline T Sin<T>(const T &x) \
115  { \
116  return Vc::sin(x); \
117  } \
118  template <> \
119  inline T Cos<T>(const T &x) \
120  { \
121  return Vc::cos(x); \
122  }
123 
124 // SPECIALIZATION( float_v )
125 #if VC_IMPL_SSE
126 SPECIALIZATION(float_v)
127 #endif // VC_IMPL_SSE
128 SPECIALIZATION(double_v)
129 #undef SPECIALIZATION
130 
131 #ifdef USE_TBB
132 static void AtomicMax(unsigned int volatile *addr, uint_v val)
133 {
134  for (int i = 0; i < uint_v::Size; ++i) {
135  AtomicMax(&addr[i], val[i]);
136  }
137 }
138 #endif // USE_TBB
139 } // namespace CAMath
140 
141 #endif // ALIHLTVECTOR_H
#define SPECIALIZATION(T)
Definition: PndCAVector.h:53
__m128 v
Definition: P4_F32vec4.h:3
unsigned int i
Definition: P4_F32vec4.h:21
static uint_m validHitIndexes(const uint_v &v)
Definition: PndCAVector.h:23