IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
ConditionalAddReg.h
Go to the documentation of this file.
1 // ConditionalAddReg.h:
3 // -------------------
4 //
13 
14 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_CONDITIONALADDREG_H__
15 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_CONDITIONALADDREG_H__
16 
18 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/ConditionalAddReg.h>
21 
22 #include "immintrin.h"
23 
24 namespace ipsdk {
25 namespace simd {
26 namespace detail {
27 
30 
33 template <typename T>
36  T,
37  typename boost::enable_if<
38  typename boost::mpl::and_<
39  typename boost::is_integral<T>::type,
40  typename boost::mpl::equal_to<
41  boost::mpl::sizeof_<T>,
42  boost::mpl::int_<1>
43  >::type
44  >::type
45  >::type
46 >
47 {
48  static IPSDK_FORCEINLINE
53  {
55  act(mask, in1, in2, out);
56  return out;
57  }
58 
59  static IPSDK_FORCEINLINE
63  const T& in2)
64  {
66  act(mask, in1, in2, out);
67  return out;
68  }
69 
70  static IPSDK_FORCEINLINE
71  void
76  {
77  out = _mm512_mask_add_epi8(in1, mask, in1, in2);
78  }
79 
80  static IPSDK_FORCEINLINE
81  void
84  const T& in2,
86  {
87  const typename RegType<eInstructionSet::eIS_Avx512, T>::Type regIn2 =
89  act(mask, in1, regIn2, out);
90  }
91 };
92 
95 template <typename T>
98  T,
99  typename boost::enable_if<
100  typename boost::mpl::and_<
101  typename boost::is_integral<T>::type,
102  typename boost::mpl::equal_to<
103  boost::mpl::sizeof_<T>,
104  boost::mpl::int_<2>
105  >::type
106  >::type
107  >::type
108 >
109 {
110  static IPSDK_FORCEINLINE
112  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
115  {
117  act(mask, in1, in2, out);
118  return out;
119  }
120 
121  static IPSDK_FORCEINLINE
123  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
125  const T& in2)
126  {
128  act(mask, in1, in2, out);
129  return out;
130  }
131 
132  static IPSDK_FORCEINLINE
133  void
134  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
138  {
139  out = _mm512_mask_add_epi16(in1, mask, in1, in2);
140  }
141 
142  static IPSDK_FORCEINLINE
143  void
144  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
146  const T& in2,
148  {
149  const typename RegType<eInstructionSet::eIS_Avx512, T>::Type regIn2 =
151  act(mask, in1, regIn2, out);
152  }
153 };
154 
157 template <typename T>
160  T,
161  typename boost::enable_if<
162  typename boost::mpl::and_<
163  typename boost::is_integral<T>::type,
164  typename boost::mpl::equal_to<
165  boost::mpl::sizeof_<T>,
166  boost::mpl::int_<4>
167  >::type
168  >::type
169  >::type
170 >
171 {
172  static IPSDK_FORCEINLINE
174  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
177  {
179  act(mask, in1, in2, out);
180  return out;
181  }
182 
183  static IPSDK_FORCEINLINE
185  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
187  const T& in2)
188  {
190  act(mask, in1, in2, out);
191  return out;
192  }
193 
194  static IPSDK_FORCEINLINE
195  void
196  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
200  {
201  out = _mm512_mask_add_epi32(in1, mask, in1, in2);
202  }
203 
204  static IPSDK_FORCEINLINE
205  void
206  act(const typename RegMaskType<eInstructionSet::eIS_Avx512, T>::Type& mask,
208  const T& in2,
210  {
211  const typename RegType<eInstructionSet::eIS_Avx512, T>::Type regIn2 =
213  act(mask, in1, regIn2, out);
214  }
215 };
216 
219 template <>
221 {
222  static IPSDK_FORCEINLINE
227  {
229  act(mask, in1, in2, out);
230  return out;
231  }
232 
233  static IPSDK_FORCEINLINE
237  const ipReal32& in2)
238  {
240  act(mask, in1, in2, out);
241  return out;
242  }
243 
244  static IPSDK_FORCEINLINE
245  void
250  {
251  out = _mm512_mask_add_ps(in1, mask, in1, in2);
252  }
253 
254  static IPSDK_FORCEINLINE
255  void
258  const ipReal32& in2,
260  {
263  act(mask, in1, regIn2, out);
264  }
265 };
266 
269 template <>
271 {
272  static IPSDK_FORCEINLINE
277  {
279  act(mask, in1, in2, out);
280  return out;
281  }
282 
283  static IPSDK_FORCEINLINE
287  const ipReal64& in2)
288  {
290  act(mask, in1, in2, out);
291  return out;
292  }
293 
294  static IPSDK_FORCEINLINE
295  void
300  {
301  out = _mm512_mask_add_pd(in1, mask, in1, in2);
302  }
303 
304  static IPSDK_FORCEINLINE
305  void
308  const ipReal64& in2,
310  {
313  act(mask, in1, regIn2, out);
314  }
315 };
318 
319 } // end of namespace detail
320 } // end of namespace simd
321 } // end of namespace ipsdk
322 
323 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_CONDITIONALADDREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
(including fundation and byte and word instructions)
Definition: InstructionSetTypes.h:51
RegType class.
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Definition: ConditionalAddReg.h:36
Definition of import/export macro for library.
Definition: RegMaskType.h:29
Definition: RegType.h:29
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56