IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
MulPack.h
Go to the documentation of this file.
1 // MulPack.h:
3 // -----------------
4 //
17 
18 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_MULPACK_H__
19 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_MULPACK_H__
20 
29 
30 #include <boost/type_traits/is_same.hpp>
31 #include <boost/utility/enable_if.hpp>
32 
33 namespace ipsdk {
34 namespace simd {
35 namespace detail {
36 
39 
45 template <eInstructionSet::domain instructionSet,
46  typename TIn1,
47  typename TIn2,
48  typename Enable=void>
49 struct MulPack
50 {
51 };
52 
54 
55 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
56 struct MulPack<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  MulReg<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, MulReg<instructionSet, TIn1> >::act(
77  in1, in2, out);
78  }
79 };
80 
81 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
82 struct MulPack<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  MulReg<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, MulReg<instructionSet, TIn1> >::act(
109  in1, in2Promoted, out);
110  }
111 };
112 
113 template <eInstructionSet::domain instructionSet, typename TIn1, typename TIn2>
114 struct MulPack<instructionSet, TIn1, TIn2,
115  typename boost::enable_if_c<!boost::is_same<TIn1, TIn2>::value
116  && !boost::is_same<TIn1, typename PromotedType<TIn1, TIn2>::Type>::value
117  >::type>
118 {
119  static
120  IPSDK_FORCEINLINE
121  typename IS2Pack<instructionSet, TIn2>::Type
122  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
123  const typename IS2Pack<instructionSet, TIn2>::Type& in2)
124  {
125  return MulPack<instructionSet, TIn2, TIn1>::act(in2, in1);
126  }
127 
128  static
129  IPSDK_FORCEINLINE
130  void
131  act(const typename IS2Pack<instructionSet, TIn1>::Type& in1,
132  const typename IS2Pack<instructionSet, TIn2>::Type& in2,
133  typename IS2Pack<instructionSet, TIn2>::Type& out)
134  {
135  MulPack<instructionSet, TIn2, TIn1>::act(in2, in1, out);
136  }
137 };
138 
142 
143 } // end of namespace detail
144 } // end of namespace simd
145 } // end of namespace ipsdk
146 
147 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_MULPACK_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: MulPack.h:49
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.
Definition: MulReg.h:39
Definition: BinaryPackOp.h:31
Definition: IS2Pack.h:34