ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
const.h
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2009-2012 Matthias Kretz <kretz@kde.org>
4 
5  Vc is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of
8  the License, or (at your option) any later version.
9 
10  Vc is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with Vc. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef VC_SSE_CONST_H
21 #define VC_SSE_CONST_H
22 
23 #include "const_data.h"
24 #include "vector.h"
25 #include "macros.h"
26 
27 namespace ROOT {
28 namespace Vc
29 {
30 namespace SSE
31 {
32  template<typename T> class Vector;
33 
34  template<typename _T> struct Const
35  {
36  typedef Vector<_T> V;
37  typedef typename V::EntryType T;
38  typedef typename V::Mask M;
39  enum Constants { Stride = 16 / sizeof(T) };
40 
47 
48  static Vc_ALWAYS_INLINE Vc_CONST V cosCoeff(int i) { return load(&c_trig<T>::data[( 8 + i) * Stride]); }
49  static Vc_ALWAYS_INLINE Vc_CONST V sinCoeff(int i) { return load(&c_trig<T>::data[(14 + i) * Stride]); }
50  static Vc_ALWAYS_INLINE Vc_CONST V atanP(int i) { return load(&c_trig<T>::data[(24 + i) * Stride]); }
51  static Vc_ALWAYS_INLINE Vc_CONST V atanQ(int i) { return load(&c_trig<T>::data[(29 + i) * Stride]); }
58  static Vc_ALWAYS_INLINE Vc_CONST V _pi() { return load(&c_trig<T>::data[23 * Stride]); }
59  static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff0(int i) { return load(&c_trig<T>::data[(40 + i) * Stride]); }
60  static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff1(int i) { return load(&c_trig<T>::data[(45 + i) * Stride]); }
61  static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff2(int i) { return load(&c_trig<T>::data[(49 + i) * Stride]); }
62  static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff3(int i) { return load(&c_trig<T>::data[(55 + i) * Stride]); }
65 
66  static Vc_ALWAYS_INLINE Vc_CONST M exponentMask() { return M(load(c_log<T>::d(1)).data()); }
67  static Vc_ALWAYS_INLINE Vc_CONST V _1_2() { return load(c_log<T>::d(18)); }
68  static Vc_ALWAYS_INLINE Vc_CONST V _1_sqrt2() { return load(c_log<T>::d(15)); }
69  static Vc_ALWAYS_INLINE Vc_CONST V P(int i) { return load(c_log<T>::d(2 + i)); }
70  static Vc_ALWAYS_INLINE Vc_CONST V Q(int i) { return load(c_log<T>::d(8 + i)); }
71  static Vc_ALWAYS_INLINE Vc_CONST V min() { return load(c_log<T>::d(14)); }
74  static Vc_ALWAYS_INLINE Vc_CONST V neginf() { return load(c_log<T>::d(13)); }
75  static Vc_ALWAYS_INLINE Vc_CONST V log10_e() { return load(c_log<T>::d(19)); }
76  static Vc_ALWAYS_INLINE Vc_CONST V log2_e() { return load(c_log<T>::d(20)); }
77 
79  static Vc_ALWAYS_INLINE_L Vc_CONST_L V highMask(int bits) Vc_ALWAYS_INLINE_R Vc_CONST_R;
80  private:
81  static Vc_ALWAYS_INLINE_L Vc_CONST_L V load(const T *mem) Vc_ALWAYS_INLINE_R Vc_CONST_R;
82  };
83  template<typename T> Vc_ALWAYS_INLINE Vc_CONST Vector<T> Const<T>::load(const T *mem) { return V(mem); }
84  template<> Vc_ALWAYS_INLINE Vc_CONST sfloat_v Const<Vc::sfloat>::load(const float *mem) { return M256::dup(float_v(mem).data()); }
85 
86  template<> Vc_ALWAYS_INLINE Vc_CONST Vector<float> Const<float>::highMask() { return Vector<float>(reinterpret_cast<const float *>(&c_general::highMaskFloat)); }
87  template<> Vc_ALWAYS_INLINE Vc_CONST Vector<double> Const<double>::highMask() { return Vector<double>(reinterpret_cast<const double *>(&c_general::highMaskDouble)); }
88  template<> Vc_ALWAYS_INLINE Vc_CONST Vector<float> Const<float>::highMask(int bits) { return _mm_castsi128_ps(_mm_slli_epi32(_mm_setallone_si128(), bits)); }
89  template<> Vc_ALWAYS_INLINE Vc_CONST Vector<double> Const<double>::highMask(int bits) { return _mm_castsi128_pd(_mm_slli_epi64(_mm_setallone_si128(), bits)); }
91  return M256::dup(Const<float>::highMask(bits).data());
92  }
94  return M256::dup(Const<float>::P(i).data());
95  }
97  return M256::dup(Const<float>::Q(i).data());
98  }
100  return M256::dup(Const<float>::exponentMask().data());
101  }
102 } // namespace SSE
103 } // namespace Vc
104 } // namespace ROOT
105 
106 #include "undomacros.h"
107 
108 #endif // VC_SSE_CONST_H
static Vc_ALWAYS_INLINE Vc_CONST V _pi_4_hi()
Definition: const.h:42
static Vc_ALWAYS_INLINE Vc_CONST V _4_pi()
Definition: const.h:56
static Vc_ALWAYS_INLINE Vc_CONST V P(int i)
Definition: const.h:69
VectorTraits< T >::EntryType EntryType
Definition: vector.h:156
static Vc_ALWAYS_INLINE Vc_CONST V log2_e()
Definition: const.h:76
static Vc_ALWAYS_INLINE Vc_CONST V log10_e()
Definition: const.h:75
Small helper to encapsulate whether to return the value pointed to by the iterator or its address...
#define Vc_CONST_L
Definition: macros.h:134
static Vc_ALWAYS_INLINE Vc_CONST V Q(int i)
Definition: const.h:70
static Vc_ALWAYS_INLINE Vc_CONST V _16()
Definition: const.h:46
static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff3(int i)
Definition: const.h:62
static Vc_ALWAYS_INLINE Vc_CONST V lossThreshold()
Definition: const.h:55
static Vc_ALWAYS_INLINE Vc_CONST V min()
Definition: const.h:71
static Vc_ALWAYS_INLINE Vc_CONST V _pi_2()
Definition: const.h:57
static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff2(int i)
Definition: const.h:61
static Vc_ALWAYS_INLINE_L Vc_CONST_L V load(const T *mem) Vc_ALWAYS_INLINE_R Vc_CONST_R
Definition: const.h:83
static Vc_ALWAYS_INLINE Vc_CONST V atanP(int i)
Definition: const.h:50
static Vc_INTRINSIC __m128i Vc_CONST _mm_setallone_si128()
Definition: intrinsics.h:82
static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff0(int i)
Definition: const.h:59
static Vc_ALWAYS_INLINE Vc_CONST V neginf()
Definition: const.h:74
Vector< _T > V
Definition: const.h:36
static Vc_ALWAYS_INLINE Vc_CONST V ln2_large()
Definition: const.h:73
V::EntryType T
Definition: const.h:37
static Vc_ALWAYS_INLINE Vc_CONST V _1_sqrt2()
Definition: const.h:68
#define Vc_ALWAYS_INLINE_R
Definition: macros.h:132
static Vc_ALWAYS_INLINE Vc_CONST V smallAsinInput()
Definition: const.h:63
static Vc_ALWAYS_INLINE_L Vc_CONST_L V highMask() Vc_ALWAYS_INLINE_R Vc_CONST_R
static Vc_ALWAYS_INLINE Vc_CONST V atanThrsHi()
Definition: const.h:52
static Vc_ALWAYS_INLINE Vc_CONST V _pi_4_rem1()
Definition: const.h:43
#define Vc_CONST
Definition: macros.h:133
static Vc_ALWAYS_INLINE Vc_CONST V ln2_small()
Definition: const.h:72
static Vc_ALWAYS_INLINE Vc_CONST V largeAsinInput()
Definition: const.h:64
static Vc_ALWAYS_INLINE Vc_CONST V asinCoeff1(int i)
Definition: const.h:60
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
static Vc_ALWAYS_INLINE Vc_CONST V atanThrsLo()
Definition: const.h:53
static Vc_ALWAYS_INLINE Vc_CONST V cosCoeff(int i)
Definition: const.h:48
static Vc_ALWAYS_INLINE Vc_CONST M exponentMask()
Definition: const.h:66
static Vc_ALWAYS_INLINE Vc_CONST V _pi()
Definition: const.h:58
#define Vc_CONST_R
Definition: macros.h:135
#define Vc_ALWAYS_INLINE_L
Definition: macros.h:131
static Vc_ALWAYS_INLINE Vc_CONST V sinCoeff(int i)
Definition: const.h:49
static Vc_ALWAYS_INLINE Vc_CONST V atanQ(int i)
Definition: const.h:51
#define SSE
Definition: global.h:84
static Vc_ALWAYS_INLINE Vc_CONST V _1_2()
Definition: const.h:67
static Vc_ALWAYS_INLINE Vc_CONST V _1_16()
Definition: const.h:45
static Vc_INTRINSIC Vc_CONST M256 dup(_M128 a)
Definition: types.h:69
static Vc_ALWAYS_INLINE Vc_CONST V _pi_4()
Definition: const.h:41
static Vc_ALWAYS_INLINE Vc_CONST V _pi_2_rem()
Definition: const.h:54
static Vc_ALWAYS_INLINE Vc_CONST V _pi_4_rem2()
Definition: const.h:44
Vector< float > float_v
Definition: vector.h:481