IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SubPack.h
Go to the documentation of this file.
1 // SubPack.h:
3 // -----------------
4 //
17 
18 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SUBPACK_H__
19 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SUBPACK_H__
20 
28 
29 #include <boost/type_traits/is_same.hpp>
30 #include <boost/utility/enable_if.hpp>
31 
32 namespace ipsdk {
33 namespace simd {
34 namespace detail {
35 
38 
44 template <eInstructionSet::domain instructionSet,
45  typename TIn1,
46  typename TIn2,
47  typename Enable=void>
48 struct SubPack
49 {
50 };
51 
53 
54 // substraction of 2 packs of same type
55 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
56 struct SubPack<instructionSet, TIn1, TIn2,
57  typename boost::enable_if_c<boost::is_same<TIn1, TIn2>::value>::type>
58 {
59  static
60  IPSDK_FORCEINLINE
62  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
63  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
64  {
65  return BinaryPackOp<instructionSet, TIn1,
66  SubReg<instructionSet, TIn1> >::act(in1, in2);
67  }
68 
69  static
70  IPSDK_FORCEINLINE
71  void
72  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
73  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
75  {
76  BinaryPackOp<instructionSet, TIn1,
77  SubReg<instructionSet, TIn1> >::act(in1, in2, out);
78  }
79 };
80 
81 // substraction of 2 packs of different types; TIn1 is greater than TIn2
82 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
83 struct SubPack<instructionSet, TIn1, TIn2,
84  typename boost::enable_if_c<!boost::is_same<TIn1, TIn2>::value
85  && boost::is_same<TIn1, typename PromotedType<TIn1, TIn2>::Type>::value
86  >::type>
87 {
88  static
89  IPSDK_FORCEINLINE
90  typename IS2Pack<instructionSet, TIn1>::Type
91  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
92  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
93  {
94  typename IS2Pack<instructionSet, TIn1>::Type in2Promoted =
95  cast<instructionSet, TIn2, TIn1>(in2);
96  return BinaryPackOp<instructionSet, TIn1,
97  SubReg<instructionSet, TIn1> >::act(in1, in2Promoted);
98  }
99 
100  static
101  IPSDK_FORCEINLINE
102  void
103  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
104  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
105  typename IS2Pack<instructionSet, TIn1>::Type& out)
106  {
107  typename IS2Pack<instructionSet, TIn1>::Type in2Promoted;
108  cast<instructionSet, TIn2, TIn1>(in2, in2Promoted);
109  BinaryPackOp<instructionSet, TIn1,
110  SubReg<instructionSet, TIn1> >::act(in1, in2Promoted, out);
111  }
112 };
113 
114 // substraction of 2 packs of different types; TIn2 is greater than TIn1
115 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
116 struct SubPack<instructionSet, TIn1, TIn2,
117  typename boost::enable_if_c<!boost::is_same<TIn1, TIn2>::value
118  && !boost::is_same<TIn1, typename PromotedType<TIn1, TIn2>::Type>::value
119  >::type>
120 {
121  static
122  IPSDK_FORCEINLINE
123  typename IS2Pack<instructionSet, TIn2>::Type
124  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
125  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
126  {
127  return SubPack<instructionSet, TIn2, TIn1>::act(in2, in1);
128  }
129 
130  static
131  IPSDK_FORCEINLINE
132  void
133  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
134  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
135  typename IS2Pack<instructionSet, TIn2>::Type& out)
136  {
137  SubPack<instructionSet, TIn2, TIn1>::act(in2, in1, out);
138  }
139 };
140 
144 
145 } // end of namespace detail
146 } // end of namespace simd
147 } // end of namespace ipsdk
148 
149 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SUBPACK_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
cast function; casts a Pack<instructionSet, TIn> to a Pack<instructionSet, TOut>
Definition: SubReg.h:39
Definition: SubPack.h:48
Definition: DataItemNodeHdrMacrosDetails.h:48
BasePack class; defines a set of scalars (for instruction set "standard") or registers (for all other...
defines template structures PromotedType<T1, T2> and PromotedType3<T1, T2, T3>; their attribute Type ...
Predefined types associated to instruction set management.
Definition of import/export macro for library.
Definition: BinaryPackOp.h:31
Definition: IS2Pack.h:34