ROOT  6.06/09
Reference Guide
vectortuple.h
Go to the documentation of this file.
1 /* This file is part of the Vc library. {{{
2 
3  Copyright (C) 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_COMMON_VECTORTUPLE_H
21 #define VC_COMMON_VECTORTUPLE_H
22 
23 #include "macros.h"
24 
25 namespace ROOT {
26 namespace Vc
27 {
28 namespace Common
29 {
30 
31 template<size_t StructSize, typename V> struct InterleavedMemoryReadAccess;
32 
33 template<int Length, typename V> struct VectorTuple;
34 template<typename V> struct VectorTuple<2, V>
35 {
36  typedef typename V::EntryType T;
37  typedef V &VC_RESTRICT Reference;
38  Reference l, r;
39 
40  Vc_ALWAYS_INLINE VectorTuple(Reference a, Reference b)
41  : l(a), r(b)
42  {
43  }
44 
46  {
47  return VectorTuple<3, V>(*this, a);
48  }
49 
51  {
52  return VectorTuple<3, const V>(*this, a);
53  }
54 
55  template<size_t StructSize>
57  {
58  VC_STATIC_ASSERT(2 <= StructSize, You_are_trying_to_extract_more_data_from_the_struct_than_it_has);
59  access.deinterleave(l, r);
60  }
61 };
62 
63 template<typename V> struct VectorTuple<2, const V>
64 {
65  typedef typename V::EntryType T;
66  typedef const V &VC_RESTRICT Reference;
67  Reference l, r;
68 
69  Vc_ALWAYS_INLINE VectorTuple(Reference a, Reference b)
70  : l(a), r(b)
71  {
72  }
73 
75  {
76  return VectorTuple<3, const V>(*this, a);
77  }
78 };
79 
80 #define _VC_VECTORTUPLE_SPECIALIZATION(LENGTH, parameters) \
81 template<typename V> struct VectorTuple<LENGTH, V> \
82 { \
83  typedef typename V::EntryType T; \
84  typedef V &VC_RESTRICT Reference; \
85  const VectorTuple<LENGTH - 1, V> &l; \
86  Reference r; \
87  \
88  Vc_ALWAYS_INLINE VectorTuple(const VectorTuple<LENGTH - 1, V> &tuple, Reference a) \
89  : l(tuple), r(a) \
90  { \
91  } \
92  \
93  Vc_ALWAYS_INLINE VectorTuple<LENGTH + 1, V> operator,(V &a) const \
94  { \
95  return VectorTuple<LENGTH + 1, V>(*this, a); \
96  } \
97  \
98  template<size_t StructSize> \
99  Vc_ALWAYS_INLINE void operator=(const InterleavedMemoryReadAccess<StructSize, V> &access) const \
100  { \
101  VC_STATIC_ASSERT(LENGTH <= StructSize, You_are_trying_to_extract_more_data_from_the_struct_than_it_has); \
102  access.deinterleave parameters; \
103  } \
104 }; \
105 template<typename V> struct VectorTuple<LENGTH, const V> \
106 { \
107  typedef typename V::EntryType T; \
108  typedef const V &VC_RESTRICT Reference; \
109  const VectorTuple<LENGTH - 1, const V> &l; \
110  Reference r; \
111  \
112  Vc_ALWAYS_INLINE VectorTuple(const VectorTuple<LENGTH - 1, const V> &tuple, Reference a) \
113  : l(tuple), r(a) \
114  { \
115  } \
116  \
117  Vc_ALWAYS_INLINE VectorTuple<LENGTH + 1, const V> operator,(const V &a) const \
118  { \
119  return VectorTuple<LENGTH + 1, const V>(*this, a); \
120  } \
121 }
122 _VC_VECTORTUPLE_SPECIALIZATION(3, (l.l, l.r, r));
123 _VC_VECTORTUPLE_SPECIALIZATION(4, (l.l.l, l.l.r, l.r, r));
124 _VC_VECTORTUPLE_SPECIALIZATION(5, (l.l.l.l, l.l.l.r, l.l.r, l.r, r));
125 _VC_VECTORTUPLE_SPECIALIZATION(6, (l.l.l.l.l, l.l.l.l.r, l.l.l.r, l.l.r, l.r, r));
126 _VC_VECTORTUPLE_SPECIALIZATION(7, (l.l.l.l.l.l, l.l.l.l.l.r, l.l.l.l.r, l.l.l.r, l.l.r, l.r, r));
127 _VC_VECTORTUPLE_SPECIALIZATION(8, (l.l.l.l.l.l.l, l.l.l.l.l.l.r, l.l.l.l.l.r, l.l.l.l.r, l.l.l.r, l.l.r, l.r, r));
128 // VC_STATIC_ASSERT(false, You_are_gathering_too_many_vectors__This_is_not_implemented);
129 
130 } // namespace Common
131 
132 #ifdef VC_IMPL_Scalar
133 namespace Scalar
134 #elif defined VC_IMPL_SSE
135 namespace SSE
136 #elif defined VC_IMPL_AVX
137 namespace AVX
138 #endif
139 {
140 
141 template<typename T>
142 Vc_ALWAYS_INLINE Common::VectorTuple<2, Vc::Vector<T> > operator,(Vc::Vector<T> &a, Vc::Vector<T> &b)
143 {
144  return Common::VectorTuple<2, Vc::Vector<T> >(a, b);
145 }
146 
147 template<typename T>
148 Vc_ALWAYS_INLINE Common::VectorTuple<2, const Vc::Vector<T> > operator,(const Vc::Vector<T> &a, const Vc::Vector<T> &b)
149 {
150  return Common::VectorTuple<2, const Vc::Vector<T> >(a, b);
151 }
152 
153 } // namespace Scalar/SSE/AVX
154 
155 } // namespace Vc
156 } // namespace ROOT
157 
158 #include "undomacros.h"
159 
160 #endif // VC_COMMON_VECTORTUPLE_H
Vc_ALWAYS_INLINE VectorTuple< 3, const V > operator,(const V &a) const
Definition: vectortuple.h:50
Vc_ALWAYS_INLINE VectorTuple(Reference a, Reference b)
Definition: vectortuple.h:69
Vc_ALWAYS_INLINE VectorTuple(Reference a, Reference b)
Definition: vectortuple.h:40
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Vc_ALWAYS_INLINE VectorTuple< 3, V > operator,(V &a) const
Definition: vectortuple.h:45
Vc_ALWAYS_INLINE void operator=(const InterleavedMemoryReadAccess< StructSize, V > &access) const
Definition: vectortuple.h:56
_VC_VECTORTUPLE_SPECIALIZATION(3,(l.l, l.r, r))
TArc * a
Definition: textangle.C:12
Vc_ALWAYS_INLINE VectorTuple< 3, const V > operator,(const V &a) const
Definition: vectortuple.h:74
#define AVX
Definition: global.h:90
ROOT::R::TRInterface & r
Definition: Object.C:4
#define Scalar
Definition: global.h:83
TLine * l
Definition: textangle.C:4
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
#define VC_RESTRICT
Definition: macros.h:145
#define SSE
Definition: global.h:84
#define VC_STATIC_ASSERT(cond, msg)
Definition: macros.h:246
Definition: casts.h:28