IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IfElsePack.h
1 // IfElsePack.h:
3 // -----------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_COMMON_IFELSEPACK_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_COMMON_IFELSEPACK_H__
17 
23 
24 #include <boost/mpl/not_equal_to.hpp>
25 #include <boost/mpl/sizeof.hpp>
26 
27 namespace ipsdk {
28 namespace simd {
29 namespace detail {
30 
33 
34 template <eInstructionSet::domain instructionSet, typename T>
35 struct IfElsePack<
36  instructionSet,
37  T,
38  typename boost::enable_if<
39  typename boost::mpl::and_<
40  typename boost::mpl::not_equal_to<
41  boost::mpl::int_<instructionSet>,
42  boost::mpl::int_<eInstructionSet::eIS_Standard>
43  >::type,
44  typename boost::mpl::equal_to<
45  boost::mpl::sizeof_<T>,
46  boost::mpl::int_<1>
47  >::type
48  >::type
49  >::type
50 > {
51  static IPSDK_FORCEINLINE
56  {
59  mask._val[0], in1._val[0], in2._val[0]);
60  return out;
61  }
62 
63  static IPSDK_FORCEINLINE
64  void
69  {
71  mask._val[0], in1._val[0], in2._val[0], out._val[0]);
72  }
73 };
74 
75 template <eInstructionSet::domain instructionSet, typename T>
76 struct IfElsePack<
77  instructionSet,
78  T,
79  typename boost::enable_if<
80  typename boost::mpl::and_<
81  typename boost::mpl::not_equal_to<
82  boost::mpl::int_<instructionSet>,
83  boost::mpl::int_<eInstructionSet::eIS_Standard>
84  >::type,
85  typename boost::mpl::equal_to<
86  boost::mpl::sizeof_<T>,
87  boost::mpl::int_<2>
88  >::type
89  >::type
90  >::type
91 > {
92 
93  static IPSDK_FORCEINLINE
98  {
100  out._val[0] = IfElseReg<instructionSet, T>::act(
101  mask._val[0], in1._val[0], in2._val[0]);
102  out._val[1] = IfElseReg<instructionSet, T>::act(
103  mask._val[1], in1._val[1], in2._val[1]);
104  return out;
105  }
106 
107  static IPSDK_FORCEINLINE
108  void
113  {
115  mask._val[0], in1._val[0], in2._val[0], out._val[0]);
117  mask._val[1], in1._val[1], in2._val[1], out._val[1]);
118  }
119 };
120 
121 template <eInstructionSet::domain instructionSet, typename T>
122 struct IfElsePack<
123  instructionSet,
124  T,
125  typename boost::enable_if<
126  typename boost::mpl::and_<
127  typename boost::mpl::not_equal_to<
128  boost::mpl::int_<instructionSet>,
129  boost::mpl::int_<eInstructionSet::eIS_Standard>
130  >::type,
131  typename boost::mpl::equal_to<
132  boost::mpl::sizeof_<T>,
133  boost::mpl::int_<4>
134  >::type
135  >::type
136  >::type
137 > {
138 
139  static IPSDK_FORCEINLINE
144  {
146  out._val[0] = IfElseReg<instructionSet, T>::act(
147  mask._val[0], in1._val[0], in2._val[0]);
148  out._val[1] = IfElseReg<instructionSet, T>::act(
149  mask._val[1], in1._val[1], in2._val[1]);
150  out._val[2] = IfElseReg<instructionSet, T>::act(
151  mask._val[2], in1._val[2], in2._val[2]);
152  out._val[3] = IfElseReg<instructionSet, T>::act(
153  mask._val[3], in1._val[3], in2._val[3]);
154  return out;
155  }
156 
157  static IPSDK_FORCEINLINE
158  void
163  {
165  mask._val[0], in1._val[0], in2._val[0], out._val[0]);
167  mask._val[1], in1._val[1], in2._val[1], out._val[1]);
169  mask._val[2], in1._val[2], in2._val[2], out._val[2]);
171  mask._val[3], in1._val[3], in2._val[3], out._val[3]);
172  }
173 };
174 
175 template <eInstructionSet::domain instructionSet, typename T>
176 struct IfElsePack<
177  instructionSet,
178  T,
179  typename boost::enable_if<
180  typename boost::mpl::and_<
181  typename boost::mpl::not_equal_to<
182  boost::mpl::int_<instructionSet>,
183  boost::mpl::int_<eInstructionSet::eIS_Standard>
184  >::type,
185  typename boost::mpl::equal_to<
186  boost::mpl::sizeof_<T>,
187  boost::mpl::int_<8>
188  >::type
189  >::type
190  >::type
191 > {
192 
193  static IPSDK_FORCEINLINE
198  {
200  out._val[0] = IfElseReg<instructionSet, T>::act(
201  mask._val[0], in1._val[0], in2._val[0]);
202  out._val[1] = IfElseReg<instructionSet, T>::act(
203  mask._val[1], in1._val[1], in2._val[1]);
204  out._val[2] = IfElseReg<instructionSet, T>::act(
205  mask._val[2], in1._val[2], in2._val[2]);
206  out._val[3] = IfElseReg<instructionSet, T>::act(
207  mask._val[3], in1._val[3], in2._val[3]);
208  out._val[4] = IfElseReg<instructionSet, T>::act(
209  mask._val[4], in1._val[4], in2._val[4]);
210  out._val[5] = IfElseReg<instructionSet, T>::act(
211  mask._val[5], in1._val[5], in2._val[5]);
212  out._val[6] = IfElseReg<instructionSet, T>::act(
213  mask._val[6], in1._val[6], in2._val[6]);
214  out._val[7] = IfElseReg<instructionSet, T>::act(
215  mask._val[7], in1._val[7], in2._val[7]);
216  return out;
217  }
218 
219  static IPSDK_FORCEINLINE
220  void
225  {
227  mask._val[0], in1._val[0], in2._val[0], out._val[0]);
229  mask._val[1], in1._val[1], in2._val[1], out._val[1]);
231  mask._val[2], in1._val[2], in2._val[2], out._val[2]);
233  mask._val[3], in1._val[3], in2._val[3], out._val[3]);
235  mask._val[4], in1._val[4], in2._val[4], out._val[4]);
237  mask._val[5], in1._val[5], in2._val[5], out._val[5]);
239  mask._val[6], in1._val[6], in2._val[6], out._val[6]);
241  mask._val[7], in1._val[7], in2._val[7], out._val[7]);
242  }
243 };
246 
247 } // end of namespace detail
248 } // end of namespace simd
249 } // end of namespace ipsdk
250 
251 #endif // __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_COMMON_IFELSEPACK_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
structure containing set of masks for vectorized operations
Definition: BaseMaskPackDecl.h:29
BaseMaskPack class; defines a set of masks; the number of masks in this set depends on the type of th...
Definition: DataItemNodeHdrMacrosDetails.h:48
BasePack class; defines a set of scalars (for instruction set "standard") or registers (for all other...
Definition: PackTypes.h:56
Definition of import/export macro for library.
Definition: IfElseReg.h:33
Definition: IfElsePack.h:30
structure containing intrinsic registers used to store vectorized data
Definition: BasePackDecl.h:29