IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
AddPack.h
Go to the documentation of this file.
1 // AddPack.h:
3 // -----------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ADDPACK_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ADDPACK_H__
17 
23 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/AddReg.h>
26 
27 #include <boost/type_traits/is_same.hpp>
28 #include <boost/utility/enable_if.hpp>
29 
30 namespace ipsdk {
31 namespace simd {
32 namespace detail {
33 
36 
43 template <eInstructionSet::domain instructionSet,
44  typename TIn1,
45  typename TIn2,
46  typename Enable=void>
47 struct AddPack
48 {
49 };
50 
52 
53 // addition of 2 packs of same type
54 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
55 struct AddPack<instructionSet, TIn1, TIn2,
56  typename boost::enable_if_c<boost::is_same<TIn1, TIn2>::value>::type>
57 {
58  static
59  IPSDK_FORCEINLINE
61  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
62  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
63  {
64  return BinaryPackOp<instructionSet, TIn1,
65  AddReg<instructionSet, TIn1> >::act(in1, in2);
66  }
67 
68  static
69  IPSDK_FORCEINLINE
70  void
71  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
72  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
74  {
75  BinaryPackOp<instructionSet, TIn1, AddReg<instructionSet, TIn1> >::act(
76  in1, in2, out);
77  }
78 };
79 
80 // addition of 2 packs of different types; TIn1 is greater than TIn2
81 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
82 struct AddPack<instructionSet, TIn1, TIn2,
83  typename boost::enable_if_c<!boost::is_same<TIn1, TIn2>::value
84  && boost::is_same<TIn1, typename PromotedType<TIn1, TIn2>::Type>::value
85  >::type>
86 {
87  static
88  IPSDK_FORCEINLINE
89  typename IS2Pack<instructionSet, TIn1>::Type
90  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
91  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
92  {
93  typename IS2Pack<instructionSet, TIn1>::Type in2Promoted =
94  cast<instructionSet, TIn2, TIn1>(in2);
95  return BinaryPackOp<instructionSet, TIn1,
96  AddReg<instructionSet, TIn1> >::act(in1, in2Promoted);
97  }
98 
99  static
100  IPSDK_FORCEINLINE
101  void
102  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
103  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
104  typename IS2Pack<instructionSet, TIn1>::Type& out)
105  {
106  typename IS2Pack<instructionSet, TIn1>::Type in2Promoted;
107  cast<instructionSet, TIn2, TIn1>(in2, in2Promoted);
108  BinaryPackOp<instructionSet, TIn1, AddReg<instructionSet, TIn1> >::act(
109  in1, in2Promoted, out);
110  }
111 };
112 
113 // addition of 2 packs of different types; TIn2 is greater than TIn1
114 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
115 struct AddPack<instructionSet, TIn1, TIn2,
116  typename boost::enable_if_c<!boost::is_same<TIn1, TIn2>::value
117  && !boost::is_same<TIn1, typename PromotedType<TIn1, TIn2>::Type>::value
118  >::type>
119 {
120  static
121  IPSDK_FORCEINLINE
122  typename IS2Pack<instructionSet, TIn2>::Type
123  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
124  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
125  {
126  return AddPack<instructionSet, TIn2, TIn1>::act(in2, in1);
127  }
128 
129  static
130  IPSDK_FORCEINLINE
131  void
132  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
133  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
134  typename IS2Pack<instructionSet, TIn2>::Type& out)
135  {
136  AddPack<instructionSet, TIn2, TIn1>::act(in2, in1, out);
137  }
138 };
139 
141 
144 
145 } // end of namespace detail
146 } // end of namespace simd
147 } // end of namespace ipsdk
148 
149 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ADDPACK_H__
Definition: AddPack.h:47
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
cast function; casts a Pack<instructionSet, TIn> to a Pack<instructionSet, TOut>
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.
template structure which is specialized to implement the arithmetic addition on 2 scalars or 2 regist...
Definition: AddReg.h:37
Definition: BinaryPackOp.h:31
Definition: IS2Pack.h:34