IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
MaskCastReg.h
Go to the documentation of this file.
1 // MaskCastReg.h:
3 // ------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX512_MASKCASTREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX512_MASKCASTREG_H__
17 
23 
24 #include <boost/mpl/and.hpp>
25 #include <boost/mpl/equal_to.hpp>
26 #include <boost/mpl/int.hpp>
27 #include <boost/mpl/not.hpp>
28 #include <boost/mpl/or.hpp>
29 #include <boost/mpl/sizeof.hpp>
30 #include <boost/type_traits/is_signed.hpp>
31 
32 namespace ipsdk {
33 namespace simd {
34 namespace detail {
35 
38 
41 template <typename TIn, typename TOut>
42 struct MaskCastReg<
44  TIn,
45  TOut,
46  typename boost::enable_if<
47  typename boost::mpl::equal_to<
48  boost::mpl::sizeof_<TIn>,
49  boost::mpl::sizeof_<TOut>
50  >::type
51  >::type
52 >
53 {
54  static IPSDK_FORCEINLINE
55  void act(const typename RegMaskType<eInstructionSet::eIS_Avx512, TIn>::Type& in,
57  {
58  out = in;
59  }
60 };
61 
64 template <typename TIn, typename TOut>
65 struct MaskCastReg<
67  TIn,
68  TOut,
69  typename boost::enable_if<
70  typename boost::mpl::and_<
71  typename boost::mpl::equal_to<
72  boost::mpl::sizeof_<TIn>,
73  boost::mpl::int_<1>
74  >::type,
75  typename boost::mpl::equal_to<
76  boost::mpl::sizeof_<TOut>,
77  boost::mpl::int_<2>
78  >::type
79  >::type
80  >::type
81 >
82 {
83  static IPSDK_FORCEINLINE
84  void act(
88  {
89  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
90  out1 = static_cast<RegMaskOut>((in & 0xFFFFFFFF00000000) >> 32);
91  out0 = static_cast<RegMaskOut>(in & 0x00000000FFFFFFFF);
92  }
93 };
94 
97 template <typename TIn, typename TOut>
98 struct MaskCastReg<
100  TIn,
101  TOut,
102  typename boost::enable_if<
103  typename boost::mpl::and_<
104  typename boost::mpl::equal_to<
105  boost::mpl::sizeof_<TIn>,
106  boost::mpl::int_<1>
107  >::type,
108  typename boost::mpl::equal_to<
109  boost::mpl::sizeof_<TOut>,
110  boost::mpl::int_<4>
111  >::type
112  >::type
113  >::type
114 >
115 {
116  static IPSDK_FORCEINLINE
117  void act(
123  {
124  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
125  out3 = static_cast<RegMaskOut>((in & 0xFFFF000000000000) >> 48);
126  out2 = static_cast<RegMaskOut>((in & 0x0000FFFF00000000) >> 32);
127  out1 = static_cast<RegMaskOut>((in & 0x00000000FFFF0000) >> 16);
128  out0 = static_cast<RegMaskOut>(in & 0x000000000000FFFF);
129  }
130 };
131 
134 template <typename TIn, typename TOut>
135 struct MaskCastReg<
137  TIn,
138  TOut,
139  typename boost::enable_if<
140  typename boost::mpl::and_<
141  typename boost::mpl::equal_to<
142  boost::mpl::sizeof_<TIn>,
143  boost::mpl::int_<1>
144  >::type,
145  typename boost::mpl::equal_to<
146  boost::mpl::sizeof_<TOut>,
147  boost::mpl::int_<8>
148  >::type
149  >::type
150  >::type
151 >
152 {
153  static IPSDK_FORCEINLINE
154  void act(
164  {
165  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
166  out7 = static_cast<RegMaskOut>((in & 0xFF00000000000000) >> 56);
167  out6 = static_cast<RegMaskOut>((in & 0x00FF000000000000) >> 48);
168  out5 = static_cast<RegMaskOut>((in & 0x0000FF0000000000) >> 40);
169  out4 = static_cast<RegMaskOut>((in & 0x000000FF00000000) >> 32);
170  out3 = static_cast<RegMaskOut>((in & 0x00000000FF000000) >> 24);
171  out2 = static_cast<RegMaskOut>((in & 0x0000000000FF0000) >> 16);
172  out1 = static_cast<RegMaskOut>((in & 0x000000000000FF00) >> 8);
173  out0 = static_cast<RegMaskOut>(in & 0x00000000000000FF);
174  }
175 };
176 
179 template <typename TIn, typename TOut>
180 struct MaskCastReg<
182  TIn,
183  TOut,
184  typename boost::enable_if<
185  typename boost::mpl::and_<
186  typename boost::mpl::equal_to<
187  boost::mpl::sizeof_<TIn>,
188  boost::mpl::int_<2>
189  >::type,
190  typename boost::mpl::equal_to<
191  boost::mpl::sizeof_<TOut>,
192  boost::mpl::int_<4>
193  >::type
194  >::type
195  >::type
196 >
197 {
198  static IPSDK_FORCEINLINE
199  void act(
203  {
204  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
205  out1 = static_cast<RegMaskOut>((in & 0xFFFF0000) >> 16);
206  out0 = static_cast<RegMaskOut>(in & 0x0000FFFF);
207  }
208 };
209 
212 template <typename TIn, typename TOut>
213 struct MaskCastReg<
215  TIn,
216  TOut,
217  typename boost::enable_if<
218  typename boost::mpl::and_<
219  typename boost::mpl::equal_to<
220  boost::mpl::sizeof_<TIn>,
221  boost::mpl::int_<2>
222  >::type,
223  typename boost::mpl::equal_to<
224  boost::mpl::sizeof_<TOut>,
225  boost::mpl::int_<8>
226  >::type
227  >::type
228  >::type
229 >
230 {
231  static IPSDK_FORCEINLINE
232  void act(
238  {
239  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
240  out3 = static_cast<RegMaskOut>((in & 0xFF000000) >> 24);
241  out2 = static_cast<RegMaskOut>((in & 0x00FF0000) >> 16);
242  out1 = static_cast<RegMaskOut>((in & 0x0000FF00) >> 8);
243  out0 = static_cast<RegMaskOut>(in & 0x000000FF);
244  }
245 };
246 
249 template <typename TIn, typename TOut>
250 struct MaskCastReg<
252  TIn,
253  TOut,
254  typename boost::enable_if<
255  typename boost::mpl::and_<
256  typename boost::mpl::equal_to<
257  boost::mpl::sizeof_<TIn>,
258  boost::mpl::int_<4>
259  >::type,
260  typename boost::mpl::equal_to<
261  boost::mpl::sizeof_<TOut>,
262  boost::mpl::int_<8>
263  >::type
264  >::type
265  >::type
266 >
267 {
268  static IPSDK_FORCEINLINE
269  void act(
273  {
274  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type RegMaskOut;
275  out1 = static_cast<RegMaskOut>((in & 0xFF00) >> 8);
276  out0 = static_cast<RegMaskOut>(in & 0x00FF);
277  }
278 };
279 
282 template <typename TIn, typename TOut>
283 struct MaskCastReg<
285  TIn,
286  TOut,
287  typename boost::enable_if<
288  typename boost::mpl::and_<
289  typename boost::mpl::equal_to<
290  boost::mpl::sizeof_<TIn>,
291  boost::mpl::int_<2>
292  >::type,
293  typename boost::mpl::equal_to<
294  boost::mpl::sizeof_<TOut>,
295  boost::mpl::int_<1>
296  >::type
297  >::type
298  >::type
299 >
300 {
301  static IPSDK_FORCEINLINE
302  void act(
306  {
307  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
308  out = (static_cast<OutRegMaskType>(in1) << 32) | static_cast<OutRegMaskType>(in0);
309  }
310 };
311 
314 template <typename TIn, typename TOut>
315 struct MaskCastReg<
317  TIn,
318  TOut,
319  typename boost::enable_if<
320  typename boost::mpl::and_<
321  typename boost::mpl::equal_to<
322  boost::mpl::sizeof_<TIn>,
323  boost::mpl::int_<4>
324  >::type,
325  typename boost::mpl::equal_to<
326  boost::mpl::sizeof_<TOut>,
327  boost::mpl::int_<2>
328  >::type
329  >::type
330  >::type
331 >
332 {
333  static IPSDK_FORCEINLINE
334  void act(
338  {
339  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
340  out = (static_cast<OutRegMaskType>(in1) << 16) | static_cast<OutRegMaskType>(in0);
341  }
342 };
343 
346 template <typename TIn, typename TOut>
347 struct MaskCastReg<
349  TIn,
350  TOut,
351  typename boost::enable_if<
352  typename boost::mpl::and_<
353  typename boost::mpl::equal_to<
354  boost::mpl::sizeof_<TIn>,
355  boost::mpl::int_<4>
356  >::type,
357  typename boost::mpl::equal_to<
358  boost::mpl::sizeof_<TOut>,
359  boost::mpl::int_<1>
360  >::type
361  >::type
362  >::type
363 >
364 {
365  static IPSDK_FORCEINLINE
366  void act(
372  {
373  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
374  out = (static_cast<OutRegMaskType>(in3) << 48) | (static_cast<OutRegMaskType>(in2) << 32) | (static_cast<OutRegMaskType>(in1) << 16) | static_cast<OutRegMaskType>(in0);
375  }
376 };
377 
380 template <typename TIn, typename TOut>
381 struct MaskCastReg<
383  TIn,
384  TOut,
385  typename boost::enable_if<
386  typename boost::mpl::and_<
387  typename boost::mpl::equal_to<
388  boost::mpl::sizeof_<TIn>,
389  boost::mpl::int_<8>
390  >::type,
391  typename boost::mpl::equal_to<
392  boost::mpl::sizeof_<TOut>,
393  boost::mpl::int_<4>
394  >::type
395  >::type
396  >::type
397 >
398 {
399  static IPSDK_FORCEINLINE
400  void act(
404  {
405  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
406  out = (static_cast<OutRegMaskType>(in1) << 8) | static_cast<OutRegMaskType>(in0);
407  }
408 };
409 
412 template <typename TIn, typename TOut>
413 struct MaskCastReg<
415  TIn,
416  TOut,
417  typename boost::enable_if<
418  typename boost::mpl::and_<
419  typename boost::mpl::equal_to<
420  boost::mpl::sizeof_<TIn>,
421  boost::mpl::int_<8>
422  >::type,
423  typename boost::mpl::equal_to<
424  boost::mpl::sizeof_<TOut>,
425  boost::mpl::int_<2>
426  >::type
427  >::type
428  >::type
429 >
430 {
431  static IPSDK_FORCEINLINE
432  void act(
438  {
439  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
440  out = (static_cast<OutRegMaskType>(in3) << 24) | (static_cast<OutRegMaskType>(in2) << 16) | (static_cast<OutRegMaskType>(in1) << 8) | static_cast<OutRegMaskType>(in0);
441  }
442 };
443 
446 template <typename TIn, typename TOut>
447 struct MaskCastReg<
449  TIn,
450  TOut,
451  typename boost::enable_if<
452  typename boost::mpl::and_<
453  typename boost::mpl::equal_to<
454  boost::mpl::sizeof_<TIn>,
455  boost::mpl::int_<8>
456  >::type,
457  typename boost::mpl::equal_to<
458  boost::mpl::sizeof_<TOut>,
459  boost::mpl::int_<1>
460  >::type
461  >::type
462  >::type
463 >
464 {
465  static IPSDK_FORCEINLINE
466  void act(
476  {
477  typedef typename RegMaskType<eInstructionSet::eIS_Avx512, TOut>::Type OutRegMaskType;
478  out = (static_cast<OutRegMaskType>(in7) << 56) | (static_cast<OutRegMaskType>(in6) << 48) | (static_cast<OutRegMaskType>(in5) << 40) | (static_cast<OutRegMaskType>(in4) << 32) |
479  (static_cast<OutRegMaskType>(in3) << 24) | (static_cast<OutRegMaskType>(in2) << 16) | (static_cast<OutRegMaskType>(in1) << 8) | static_cast<OutRegMaskType>(in0);
480  }
481 };
482 
485 
486 } // end of namespace detail
487 } // end of namespace simd
488 } // end of namespace ipsdk
489 
490 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX512_MASKCASTREG_H__
Definition: MaskCastReg.h:30
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
(including fundation and byte and word instructions)
Definition: InstructionSetTypes.h:51
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
RegMaskType class.
Definition of import/export macro for library.
Definition: RegMaskType.h:29