IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SubReg.h
Go to the documentation of this file.
1 // SubReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_SUBREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_SUBREG_H__
17 
23 
24 #include <boost/type_traits/is_integral.hpp>
25 #include <boost/utility/enable_if.hpp>
26 
27 
28 namespace ipsdk {
29 namespace simd {
30 namespace detail {
31 
34 
37 template <typename T>
39  typename boost::enable_if_c<boost::is_integral<T>::value
40  && sizeof(T) == 1>::type>
41 {
42  static IPSDK_FORCEINLINE
43  typename Sse2Type<T>::Type
44  act(const typename Sse2Type<T>::Type& in1,
45  const typename Sse2Type<T>::Type& in2)
46  {
47  return _mm_sub_epi8(in1, in2);
48  }
49 
50  static IPSDK_FORCEINLINE
51  void
52  act(const typename Sse2Type<T>::Type& in1,
53  const typename Sse2Type<T>::Type& in2,
54  typename Sse2Type<T>::Type& out)
55  {
56  out = _mm_sub_epi8(in1, in2);
57  }
58 };
59 
62 template <typename T>
64  typename boost::enable_if_c<boost::is_integral<T>::value
65  && sizeof(T) == 2>::type>
66 {
67  static IPSDK_FORCEINLINE
68  typename Sse2Type<T>::Type
69  act(const typename Sse2Type<T>::Type& in1,
70  const typename Sse2Type<T>::Type& in2)
71  {
72  return _mm_sub_epi16(in1, in2);
73  }
74 
75  static 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_sub_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 IPSDK_FORCEINLINE
93  typename Sse2Type<T>::Type
94  act(const typename Sse2Type<T>::Type& in1,
95  const typename Sse2Type<T>::Type& in2)
96  {
97  return _mm_sub_epi32(in1, in2);
98  }
99 
100  static IPSDK_FORCEINLINE
101  void
102  act(const typename Sse2Type<T>::Type& in1,
103  const typename Sse2Type<T>::Type& in2,
104  typename Sse2Type<T>::Type& out)
105  {
106  out = _mm_sub_epi32(in1, in2);
107  }
108 };
109 
112 template <typename T>
114  typename boost::enable_if_c<boost::is_integral<T>::value
115  && sizeof(T) == 8>::type>
116 {
117  static IPSDK_FORCEINLINE
118  typename Sse2Type<T>::Type
119  act(const typename Sse2Type<T>::Type& in1,
120  const typename Sse2Type<T>::Type& in2)
121  {
122  return _mm_sub_epi64(in1, in2);
123  }
124 
125  static IPSDK_FORCEINLINE
126  void
127  act(const typename Sse2Type<T>::Type& in1,
128  const typename Sse2Type<T>::Type& in2,
129  typename Sse2Type<T>::Type& out)
130  {
131  out = _mm_sub_epi64(in1, in2);
132  }
133 };
134 
137 template <>
139 {
140  static IPSDK_FORCEINLINE
142  act(const Sse2Type<ipReal32>::Type& in1,
143  const Sse2Type<ipReal32>::Type& in2)
144  {
145  return _mm_sub_ps(in1, in2);
146  }
147 
148  static IPSDK_FORCEINLINE
149  void
150  act(const Sse2Type<ipReal32>::Type& in1,
151  const Sse2Type<ipReal32>::Type& in2,
153  {
154  out = _mm_sub_ps(in1, in2);
155  }
156 };
157 
160 template <>
162 {
163  static IPSDK_FORCEINLINE
165  act(const Sse2Type<ipReal64>::Type& in1,
166  const Sse2Type<ipReal64>::Type& in2)
167  {
168  return _mm_sub_pd(in1, in2);
169  }
170 
171  static IPSDK_FORCEINLINE
172  void
173  act(const Sse2Type<ipReal64>::Type& in1,
174  const Sse2Type<ipReal64>::Type& in2,
176  {
177  out = _mm_sub_pd(in1, in2);
178  }
179 };
180 
183 
184 } // end of namespace detail
185 } // end of namespace simd
186 } // end of namespace ipsdk
187 
188 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_SUBREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: SubReg.h:39
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.
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