IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
AddReg.h
Go to the documentation of this file.
1 // AddReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_ADDREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_ADDREG_H__
17 
20 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/AddReg.h>
23 
24 namespace ipsdk {
25 namespace simd {
26 namespace detail {
27 
30 
33 template <typename T>
35  typename boost::enable_if_c<boost::is_integral<T>::value
36  && sizeof(T) == 1>::type>
37 {
38  static
39  IPSDK_FORCEINLINE
40  typename Sse2Type<T>::Type
41  act(const typename Sse2Type<T>::Type& in1,
42  const typename Sse2Type<T>::Type& in2)
43  {
44  return _mm_add_epi8(in1, in2);
45  }
46 
47  static
48  IPSDK_FORCEINLINE
49  void
50  act(const typename Sse2Type<T>::Type& in1,
51  const typename Sse2Type<T>::Type& in2,
52  typename Sse2Type<T>::Type& out)
53  {
54  out = _mm_add_epi8(in1, in2);
55  }
56 };
57 
60 template <typename T>
62  typename boost::enable_if_c<boost::is_integral<T>::value
63  && sizeof(T) == 2>::type>
64 {
65  static
66  IPSDK_FORCEINLINE
67  typename Sse2Type<T>::Type
68  act(const typename Sse2Type<T>::Type& in1,
69  const typename Sse2Type<T>::Type& in2)
70  {
71  return _mm_add_epi16(in1, in2);
72  }
73 
74  static
75  IPSDK_FORCEINLINE
76  void
77  act(const typename Sse2Type<T>::Type& in1,
78  const typename Sse2Type<T>::Type& in2,
79  typename Sse2Type<T>::Type& out)
80  {
81  out = _mm_add_epi16(in1, in2);
82  }
83 };
84 
87 template <typename T>
89  typename boost::enable_if_c<boost::is_integral<T>::value
90  && sizeof(T) == 4>::type>
91 {
92  static
93  IPSDK_FORCEINLINE
94  typename Sse2Type<T>::Type
95  act(const typename Sse2Type<T>::Type& in1,
96  const typename Sse2Type<T>::Type& in2)
97  {
98  return _mm_add_epi32(in1, in2);
99  }
100 
101  static
102  IPSDK_FORCEINLINE
103  void
104  act(const typename Sse2Type<T>::Type& in1,
105  const typename Sse2Type<T>::Type& in2,
106  typename Sse2Type<T>::Type& out)
107  {
108  out = _mm_add_epi32(in1, in2);
109  }
110 };
111 
114 template <typename T>
116  typename boost::enable_if_c<boost::is_integral<T>::value
117  && sizeof(T) == 8>::type>
118 {
119  static
120  IPSDK_FORCEINLINE
121  typename Sse2Type<T>::Type
122  act(const typename Sse2Type<T>::Type& in1,
123  const typename Sse2Type<T>::Type& in2)
124  {
125  return _mm_add_epi64(in1, in2);
126  }
127 
128  static
129  IPSDK_FORCEINLINE
130  void
131  act(const typename Sse2Type<T>::Type& in1,
132  const typename Sse2Type<T>::Type& in2,
133  typename Sse2Type<T>::Type& out)
134  {
135  out = _mm_add_epi64(in1, in2);
136  }
137 };
138 
141 template <>
143 {
144  static
145  IPSDK_FORCEINLINE
147  act(const Sse2Type<ipReal32>::Type& in1,
148  const Sse2Type<ipReal32>::Type& in2)
149  {
150  return _mm_add_ps(in1, in2);
151  }
152 
153  static
154  IPSDK_FORCEINLINE
155  void
156  act(const Sse2Type<ipReal32>::Type& in1,
157  const Sse2Type<ipReal32>::Type& in2,
159  {
160  out = _mm_add_ps(in1, in2);
161  }
162 };
163 
166 template <>
168 {
169  static
170  IPSDK_FORCEINLINE
172  act(const Sse2Type<ipReal64>::Type& in1,
173  const Sse2Type<ipReal64>::Type& in2)
174  {
175  return _mm_add_pd(in1, in2);
176  }
177 
178  static
179  IPSDK_FORCEINLINE
180  void
181  act(const Sse2Type<ipReal64>::Type& in1,
182  const Sse2Type<ipReal64>::Type& in2,
184  {
185  out =_mm_add_pd(in1, in2);
186  }
187 };
188 
191 
192 } // end of namespace detail
193 } // end of namespace simd
194 } // end of namespace ipsdk
195 
196 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_ADDREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Predefined types for Sse2 instruction set management.
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
Streaming SIMD Extensions 2.
Definition: InstructionSetTypes.h:36
structure used to retrieve SSE2 type associated to a base type
Definition: Sse2Types.h:32
float ipReal32
Base types definition.
Definition: BaseTypes.h:56