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_AVX2_MASKCASTREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX2_MASKCASTREG_H__
17 
24 
25 #include <boost/mpl/and.hpp>
26 #include <boost/mpl/equal_to.hpp>
27 #include <boost/mpl/int.hpp>
28 #include <boost/mpl/not.hpp>
29 #include <boost/mpl/or.hpp>
30 #include <boost/mpl/sizeof.hpp>
31 #include <boost/type_traits/is_signed.hpp>
32 
33 namespace ipsdk {
34 namespace simd {
35 namespace detail {
36 
39 
42 template <typename TIn, typename TOut>
43 struct MaskCastReg<
45  TIn,
46  TOut,
47  typename boost::enable_if<
48  typename boost::mpl::or_<
49  typename boost::is_same<TIn, TOut>::type,
50  typename boost::mpl::and_<
51  typename boost::is_integral<TIn>::type,
52  typename boost::mpl::and_<
53  typename boost::is_integral<TOut>::type,
54  typename boost::mpl::equal_to<
55  boost::mpl::sizeof_<TIn>,
56  boost::mpl::sizeof_<TOut>
57  >::type
58  >::type
59  >::type
60  >::type
61  >::type
62 >
63 {
64  static IPSDK_FORCEINLINE
65  void act(const typename RegMaskType<eInstructionSet::eIS_Avx2, TIn>::Type& in,
67  {
68  out = in;
69  }
70 };
71 
74 template <typename TIn, typename TOut>
75 struct MaskCastReg<
77  TIn,
78  TOut,
79  typename boost::enable_if<
80  typename boost::mpl::and_<
81  typename boost::mpl::equal_to<
82  boost::mpl::sizeof_<TIn>,
83  boost::mpl::sizeof_<TOut>
84  >::type,
85  typename boost::mpl::or_<
86  typename boost::mpl::and_<
87  typename boost::mpl::not_<typename boost::is_integral<TIn>::type>::type,
88  typename boost::is_integral<TOut>::type
89  >::type,
90  typename boost::mpl::and_<
91  typename boost::mpl::not_<typename boost::is_integral<TOut>::type>::type,
92  typename boost::is_integral<TIn>::type
93  >::type
94  >::type
95  >::type
96  >::type
97 >
98 {
99  static IPSDK_FORCEINLINE
100  void act(
103  {
105  }
106 };
107 
110 template <typename TIn, typename TOut>
111 struct MaskCastReg<
113  TIn,
114  TOut,
115  typename boost::enable_if<
116  typename boost::mpl::and_<
117  typename boost::mpl::equal_to<
118  boost::mpl::sizeof_<TIn>,
119  boost::mpl::int_<1>
120  >::type,
121  typename boost::mpl::equal_to<
122  boost::mpl::sizeof_<TOut>,
123  boost::mpl::int_<2>
124  >::type
125  >::type
126  >::type
127 >
128 {
129  static IPSDK_FORCEINLINE
130  void act(
134  {
140  }
141 };
142 
145 template <typename TIn, typename TOut>
146 struct MaskCastReg<
148  TIn,
149  TOut,
150  typename boost::enable_if<
151  typename boost::mpl::and_<
152  typename boost::mpl::equal_to<
153  boost::mpl::sizeof_<TIn>,
154  boost::mpl::int_<1>
155  >::type,
156  typename boost::mpl::equal_to<
157  boost::mpl::sizeof_<TOut>,
158  boost::mpl::int_<4>
159  >::type
160  >::type
161  >::type
162 >
163 {
164  static IPSDK_FORCEINLINE
165  void act(
171  {
172  typedef typename UpperType<TIn>::Type T16;
177  }
178 };
179 
182 template <typename TIn, typename TOut>
183 struct MaskCastReg<
185  TIn,
186  TOut,
187  typename boost::enable_if<
188  typename boost::mpl::and_<
189  typename boost::mpl::equal_to<
190  boost::mpl::sizeof_<TIn>,
191  boost::mpl::int_<1>
192  >::type,
193  typename boost::mpl::equal_to<
194  boost::mpl::sizeof_<TOut>,
195  boost::mpl::int_<8>
196  >::type
197  >::type
198  >::type
199 >
200 {
201  static IPSDK_FORCEINLINE
202  void act(
212  {
213  typedef typename UpperType<TIn>::Type T16;
216 
217  typedef typename UpperType<T16>::Type T32;
218  typename RegMaskType<eInstructionSet::eIS_Avx2, T32>::Type in32_0, in32_1, in32_2, in32_3;
221 
226  }
227 };
228 
231 template <typename TIn, typename TOut>
232 struct MaskCastReg<
234  TIn,
235  TOut,
236  typename boost::enable_if<
237  typename boost::mpl::and_<
238  typename boost::mpl::equal_to<
239  boost::mpl::sizeof_<TIn>,
240  boost::mpl::int_<2>
241  >::type,
242  typename boost::mpl::equal_to<
243  boost::mpl::sizeof_<TOut>,
244  boost::mpl::int_<4>
245  >::type
246  >::type
247  >::type
248 >
249 {
250  static IPSDK_FORCEINLINE
251  void act(
255  {
261  }
262 };
263 
266 template <typename TIn, typename TOut>
267 struct MaskCastReg<
269  TIn,
270  TOut,
271  typename boost::enable_if<
272  typename boost::mpl::and_<
273  typename boost::mpl::equal_to<
274  boost::mpl::sizeof_<TIn>,
275  boost::mpl::int_<2>
276  >::type,
277  typename boost::mpl::equal_to<
278  boost::mpl::sizeof_<TOut>,
279  boost::mpl::int_<8>
280  >::type
281  >::type
282  >::type
283 >
284 {
285  static IPSDK_FORCEINLINE
286  void act(
292  {
293  typedef typename UpperType<TIn>::Type T32;
298  }
299 };
300 
303 template <typename TIn, typename TOut>
304 struct MaskCastReg<
306  TIn,
307  TOut,
308  typename boost::enable_if<
309  typename boost::mpl::and_<
310  typename boost::mpl::and_<
311  typename boost::mpl::equal_to<
312  boost::mpl::sizeof_<TIn>,
313  boost::mpl::int_<4>
314  >::type,
315  typename boost::is_integral<TIn>::type
316  >::type,
317  typename boost::mpl::equal_to<
318  boost::mpl::sizeof_<TOut>,
319  boost::mpl::int_<8>
320  >::type
321  >::type
322  >::type
323 >
324 {
325  static IPSDK_FORCEINLINE
326  void act(
330  {
336  }
337 };
338 
341 template <typename TOut>
342 struct MaskCastReg<
344  ipReal32,
345  TOut,
346  typename boost::enable_if<
347  typename boost::mpl::equal_to<
348  boost::mpl::sizeof_<TOut>,
349  boost::mpl::int_<8>
350  >::type
351  >::type
352 >
353 {
354  static IPSDK_FORCEINLINE
355  void act(
359  {
363  }
364 };
365 
368 template <typename TIn, typename TOut>
369 struct MaskCastReg<
371  TIn,
372  TOut,
373  typename boost::enable_if<
374  typename boost::mpl::and_<
375  typename boost::mpl::equal_to<
376  boost::mpl::sizeof_<TIn>,
377  boost::mpl::int_<2>
378  >::type,
379  typename boost::mpl::equal_to<
380  boost::mpl::sizeof_<TOut>,
381  boost::mpl::int_<1>
382  >::type
383  >::type
384  >::type
385 >
386 {
387  static IPSDK_FORCEINLINE
388  void act(
392  {
397  }
398 };
399 
402 template <typename TIn, typename TOut>
403 struct MaskCastReg<
405  TIn,
406  TOut,
407  typename boost::enable_if<
408  typename boost::mpl::and_<
409  typename boost::mpl::and_<
410  typename boost::mpl::equal_to<
411  boost::mpl::sizeof_<TIn>,
412  boost::mpl::int_<4>
413  >::type,
414  typename boost::is_integral<TIn>::type
415  >::type,
416  typename boost::mpl::equal_to<
417  boost::mpl::sizeof_<TOut>,
418  boost::mpl::int_<2>
419  >::type
420  >::type
421  >::type
422 >
423 {
424  static IPSDK_FORCEINLINE
425  void act(
429  {
434  }
435 };
436 
439 template <typename TOut>
440 struct MaskCastReg<
442  ipReal32,
443  TOut,
444  typename boost::enable_if<
445  typename boost::mpl::equal_to<
446  boost::mpl::sizeof_<TOut>,
447  boost::mpl::int_<2>
448  >::type
449  >::type
450 >
451 {
452  static IPSDK_FORCEINLINE
453  void act(
457  {
462  }
463 };
464 
467 template <typename TIn, typename TOut>
468 struct MaskCastReg<
470  TIn,
471  TOut,
472  typename boost::enable_if<
473  typename boost::mpl::and_<
474  typename boost::mpl::and_<
475  typename boost::mpl::equal_to<
476  boost::mpl::sizeof_<TIn>,
477  boost::mpl::int_<4>
478  >::type,
479  typename boost::is_integral<TIn>::type
480  >::type,
481  typename boost::mpl::equal_to<
482  boost::mpl::sizeof_<TOut>,
483  boost::mpl::int_<1>
484  >::type
485  >::type
486  >::type
487 >
488 {
489  static IPSDK_FORCEINLINE
490  void act(
496  {
501  }
502 };
503 
506 template <typename TOut>
507 struct MaskCastReg<
509  ipReal32,
510  TOut,
511  typename boost::enable_if<
512  typename boost::mpl::equal_to<
513  boost::mpl::sizeof_<TOut>,
514  boost::mpl::int_<1>
515  >::type
516  >::type
517 >
518 {
519  static IPSDK_FORCEINLINE
520  void act(
526  {
532  MaskCastReg<eInstructionSet::eIS_Avx2, ipUInt32, TOut>::act(inUI0, inUI1, inUI2, inUI3, out);
533  }
534 };
535 /*
538 template <typename TIn, typename TOut>
539 struct MaskCastReg<
540  eInstructionSet::eIS_Avx2,
541  TIn,
542  TOut,
543  typename boost::enable_if<
544  typename boost::mpl::and_<
545  typename boost::mpl::and_<
546  typename boost::mpl::equal_to<
547  boost::mpl::sizeof_<TIn>,
548  boost::mpl::int_<8>
549  >::type,
550  typename boost::is_integral<TIn>::type
551  >::type,
552  typename boost::mpl::and_<
553  typename boost::mpl::equal_to<
554  boost::mpl::sizeof_<TOut>,
555  boost::mpl::int_<4>
556  >::type,
557  typename boost::is_integral<TOut>::type
558  >::type
559  >::type
560  >::type
561 >
562 {
563  static IPSDK_FORCEINLINE
564  void act(
565  const typename RegMaskType<eInstructionSet::eIS_Avx2, TIn>::Type& in0,
566  const typename RegMaskType<eInstructionSet::eIS_Avx2, TIn>::Type& in1,
567  typename RegMaskType<eInstructionSet::eIS_Avx2, TOut>::Type& out)
568  {
569  typename RegType<eInstructionSet::eIS_Avx2, TOut>::Type zero;
570  AssignReg<eInstructionSet::eIS_Avx2, TOut>::act(zero, 0);
571  CastReg<eInstructionSet::eIS_Avx2, ipInt64, ipInt32>::act(in0, in1, out);
572  IsNotEqualReg<eInstructionSet::eIS_Avx2, TOut>::act(out, zero, out);
573  }
574 };*/
575 
578 template <typename TOut>
579 struct MaskCastReg<
581  ipReal64,
582  TOut,
583  typename boost::enable_if<
584  typename boost::mpl::and_<
585  typename boost::mpl::equal_to<
586  boost::mpl::sizeof_<TOut>,
587  boost::mpl::int_<4>
588  >::type,
589  typename boost::is_integral<TOut>::type
590  >::type
591  >::type
592 >
593 {
594  static IPSDK_FORCEINLINE
595  void act(
599  {
600  /*typename RegType<eInstructionSet::eIS_Avx2, ipInt64>::Type in0I, in1I;
601  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in0, in0I);
602  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in1, in1I);
603  MaskCastReg<eInstructionSet::eIS_Avx2, ipInt64, TOut>::act(in0I, in1I, out);*/
607  }
608 };
609 
612 template <>
614 {
615  static IPSDK_FORCEINLINE
616  void act(
620  {
622 
626  }
627 };
628 
631 template <typename TIn>
632 struct MaskCastReg<
634  TIn,
635  ipReal32,
636  typename boost::enable_if<
637  typename boost::mpl::and_<
638  typename boost::mpl::equal_to<
639  boost::mpl::sizeof_<TIn>,
640  boost::mpl::int_<8>
641  >::type,
642  typename boost::is_integral<TIn>::type
643  >::type
644  >::type
645 >
646 {
647  static IPSDK_FORCEINLINE
648  void act(
652  {
656  }
657 };
658 
661 template <typename TIn, typename TOut>
662 struct MaskCastReg<
664  TIn,
665  TOut,
666  typename boost::enable_if<
667  typename boost::mpl::and_<
668  typename boost::mpl::and_<
669  typename boost::mpl::equal_to<
670  boost::mpl::sizeof_<TIn>,
671  boost::mpl::int_<8>
672  >::type,
673  typename boost::is_integral<TIn>::type
674  >::type,
675  typename boost::mpl::and_<
676  typename boost::mpl::equal_to<
677  boost::mpl::sizeof_<TOut>,
678  boost::mpl::int_<2>
679  >::type,
680  typename boost::is_integral<TOut>::type
681  >::type
682  >::type
683  >::type
684 >
685 {
686  static IPSDK_FORCEINLINE
687  void act(
693  {
698  }
699 };
700 
703 template <typename TOut>
704 struct MaskCastReg<
706  ipReal64,
707  TOut,
708  typename boost::enable_if<
709  typename boost::mpl::and_<
710  typename boost::mpl::equal_to<
711  boost::mpl::sizeof_<TOut>,
712  boost::mpl::int_<2>
713  >::type,
714  typename boost::is_integral<TOut>::type
715  >::type
716  >::type
717 >
718 {
719  static IPSDK_FORCEINLINE
720  void act(
726  {
727 
728  /*RegMaskType<eInstructionSet::eIS_Avx2, ipInt64>::Type in0I, in1I, in2I, in3I;
729  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in0, in0I);
730  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in1, in1I);
731  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in2, in2I);
732  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in3, in3I);
733 
734  MaskCastReg<eInstructionSet::eIS_Avx2, ipInt64, TOut>::act(
735  in0I, in1I, in2I, in3I, out);*/
740  }
741 };
742 
745 template <typename TIn, typename TOut>
746 struct MaskCastReg<
748  TIn,
749  TOut,
750  typename boost::enable_if<
751  typename boost::mpl::and_<
752  typename boost::mpl::and_<
753  typename boost::mpl::equal_to<
754  boost::mpl::sizeof_<TIn>,
755  boost::mpl::int_<8>
756  >::type,
757  typename boost::is_integral<TIn>::type
758  >::type,
759  typename boost::mpl::and_<
760  typename boost::mpl::equal_to<
761  boost::mpl::sizeof_<TOut>,
762  boost::mpl::int_<1>
763  >::type,
764  typename boost::is_integral<TOut>::type
765  >::type
766  >::type
767  >::type
768 >
769 {
770  static IPSDK_FORCEINLINE
771  void act(
781  {
788  }
789 };
790 
793 template <typename TOut>
794 struct MaskCastReg<
796  ipReal64,
797  TOut,
798  typename boost::enable_if<
799  typename boost::mpl::and_<
800  typename boost::mpl::equal_to<
801  boost::mpl::sizeof_<TOut>,
802  boost::mpl::int_<1>
803  >::type,
804  typename boost::is_integral<TOut>::type
805  >::type
806  >::type
807 >
808 {
809  static IPSDK_FORCEINLINE
810  void act(
820  {
821 
822  /*RegMaskType<eInstructionSet::eIS_Avx2, ipInt64>::Type in0I, in1I, in2I, in3I,
823  in4I, in5I, in6I, in7I;
824  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in0, in0I);
825  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in1, in1I);
826  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in2, in2I);
827  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in3, in3I);
828  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in4, in4I);
829  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in5, in5I);
830  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in6, in6I);
831  BitwiseCastReg<eInstructionSet::eIS_Avx2, ipReal64, ipInt64>::act(in7, in7I);
832 
833  MaskCastReg<eInstructionSet::eIS_Avx2, ipInt64, TOut>::act(
834  in0I, in1I, in2I, in3I, in4I, in5I, in6I, in7I, out);*/
835  RegMaskType<eInstructionSet::eIS_Avx2, ipInt32>::Type out0I32, out1I32, out2I32, out3I32;
840  MaskCastReg<eInstructionSet::eIS_Avx2, ipInt32, ipInt8>::act(out0I32, out1I32, out2I32, out3I32, out);
841  }
842 };
845 
846 } // end of namespace detail
847 } // end of namespace simd
848 } // end of namespace ipsdk
849 
850 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX2_MASKCASTREG_H__
Definition: MaskCastReg.h:30
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: CastReg.h:30
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
template structure UpperType<typename T>; its typedef Type gives the type just upper to T...
Definition: UpperType.h:42
Advanced Vector Extensions 2.
Definition: InstructionSetTypes.h:48
RegMaskType class.
Definition of import/export macro for library.
Definition: IsNotEqualRegDecl.h:30
Definition: RegMaskType.h:29
Definition: BitwiseCastReg.h:29
Definition: RegType.h:29
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56