IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsEqualRegImpl.h
Go to the documentation of this file.
1 // IsEqualRegImpl.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISEQUALREGIMPL_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISEQUALREGIMPL_H__
17 
19 
20 namespace ipsdk {
21 namespace simd {
22 namespace detail {
23 
26 
27 template <typename T>
28 IPSDK_FORCEINLINE
29 typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type
30 IsEqualReg<
32  T,
33  typename boost::enable_if<
34  typename boost::mpl::and_<
35  typename boost::is_integral<T>::type,
36  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<1> >::type
37  >::type
38  >::type
39 >::act(
40  const typename Sse2Type<T>::Type& in1,
41  const typename Sse2Type<T>::Type& in2)
42 {
43  return _mm_cmpeq_epi8(in1, in2);
44 }
45 
46 template <typename T>
47 IPSDK_FORCEINLINE
48 void
49 IsEqualReg<
51  T,
52  typename boost::enable_if<
53  typename boost::mpl::and_<
54  typename boost::is_integral<T>::type,
55  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<1> >::type
56  >::type
57  >::type
58 >::act(
59  const typename Sse2Type<T>::Type& in1,
60  const typename Sse2Type<T>::Type& in2,
61  typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type& out)
62 {
63  out = _mm_cmpeq_epi8(in1, in2);
64 }
65 
66 template <typename T>
67 IPSDK_FORCEINLINE
68 typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type
69 IsEqualReg<
71  T,
72  typename boost::enable_if<
73  typename boost::mpl::and_<
74  typename boost::is_integral<T>::type,
75  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<2> >::type
76  >::type
77  >::type
78 >::act(
79  const typename Sse2Type<T>::Type& in1,
80  const typename Sse2Type<T>::Type& in2)
81 {
82  return _mm_cmpeq_epi16(in1, in2);
83 }
84 
85 template <typename T>
86 IPSDK_FORCEINLINE
87 void
88 IsEqualReg<eInstructionSet::eIS_Sse2, T,
89  typename boost::enable_if<
90  typename boost::mpl::and_<
91  typename boost::is_integral<T>::type,
92  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<2> >::type
93  >::type
94  >::type
95 >::act(
96  const typename Sse2Type<T>::Type& in1,
97  const typename Sse2Type<T>::Type& in2,
98  typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type& out)
99 {
100  out = _mm_cmpeq_epi16(in1, in2);
101 }
102 
103 template <typename T>
104 IPSDK_FORCEINLINE
105 typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type
106 IsEqualReg<
108  T,
109  typename boost::enable_if<
110  typename boost::mpl::and_<
111  typename boost::is_integral<T>::type,
112  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::type
113  >::type
114  >::type
115 >::act(
116  const typename Sse2Type<T>::Type& in1,
117  const typename Sse2Type<T>::Type& in2)
118 {
119  return _mm_cmpeq_epi32(in1, in2);
120 }
121 
122 template <typename T>
123 IPSDK_FORCEINLINE
124 void
125 IsEqualReg<
127  T,
128  typename boost::enable_if<
129  typename boost::mpl::and_<
130  typename boost::is_integral<T>::type,
131  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::type
132  >::type
133  >::type
134 >::act(
135  const typename Sse2Type<T>::Type& in1,
136  const typename Sse2Type<T>::Type& in2,
137  typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type& out)
138 {
139  out = _mm_cmpeq_epi32(in1, in2);
140 }
141 
142 template <typename T>
143 IPSDK_FORCEINLINE
144 typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type
145 IsEqualReg<eInstructionSet::eIS_Sse2, T,
146  typename boost::enable_if<
147  typename boost::mpl::and_<
148  typename boost::is_integral<T>::type,
149  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<8 > >::type
150  >::type
151  >::type
152 >::act(
153  const typename Sse2Type<T>::Type& in1,
154  const typename Sse2Type<T>::Type& in2)
155 {
156  typedef typename Sse2Type<T>::Type RegT;
157  RegT eq_epi32 = _mm_cmpeq_epi32(in1, in2);
158  return _mm_and_si128(
159  _mm_shuffle_epi32(eq_epi32, _MM_SHUFFLE(3, 3, 1, 1)),
160  _mm_shuffle_epi32(eq_epi32, _MM_SHUFFLE(2, 2, 0, 0)));
161 }
162 
163 template <typename T>
164 IPSDK_FORCEINLINE
165 void
166 IsEqualReg<eInstructionSet::eIS_Sse2, T,
167  typename boost::enable_if<
168  typename boost::mpl::and_<
169  typename boost::is_integral<T>::type,
170  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<8 > >::type
171  >::type
172  >::type
173 >::act(
174  const typename Sse2Type<T>::Type& in1,
175  const typename Sse2Type<T>::Type& in2,
176  typename RegMaskType<eInstructionSet::eIS_Sse2, T>::Type& out)
177 {
178  typedef typename Sse2Type<T>::Type RegT;
179  RegT eq_epi32 = _mm_cmpeq_epi32(in1, in2);
180  out = _mm_and_si128(
181  _mm_shuffle_epi32(eq_epi32, _MM_SHUFFLE(3, 3, 1, 1)),
182  _mm_shuffle_epi32(eq_epi32, _MM_SHUFFLE(2, 2, 0, 0)));
183 }
184 
185 IPSDK_FORCEINLINE
186 RegMaskType<eInstructionSet::eIS_Sse2, ipReal32>::Type
187 IsEqualReg<eInstructionSet::eIS_Sse2, ipReal32>::act(
188  const Sse2Type<ipReal32>::Type& in1,
189  const Sse2Type<ipReal32>::Type& in2)
190 {
191  return _mm_cmpeq_ps(in1, in2);
192 }
193 
194 IPSDK_FORCEINLINE
195 void
196 IsEqualReg<eInstructionSet::eIS_Sse2, ipReal32>::act(
197  const Sse2Type<ipReal32>::Type& in1,
198  const Sse2Type<ipReal32>::Type& in2,
199  RegMaskType<eInstructionSet::eIS_Sse2, ipReal32>::Type& out)
200 {
201  out = _mm_cmpeq_ps(in1, in2);
202 }
203 
204 IPSDK_FORCEINLINE
205 RegMaskType<eInstructionSet::eIS_Sse2, ipReal64>::Type
206 IsEqualReg<eInstructionSet::eIS_Sse2, ipReal64>::act(
207  const Sse2Type<ipReal64>::Type& in1,
208  const Sse2Type<ipReal64>::Type& in2)
209 {
210  return _mm_cmpeq_pd(in1, in2);
211 }
212 
213 IPSDK_FORCEINLINE
214 void
215 IsEqualReg<eInstructionSet::eIS_Sse2, ipReal64>::act(
216  const Sse2Type<ipReal64>::Type& in1,
217  const Sse2Type<ipReal64>::Type& in2,
218  RegMaskType<eInstructionSet::eIS_Sse2, ipReal64>::Type& out)
219 {
220  out = _mm_cmpeq_pd(in1, in2);
221 }
222 
225 
226 } // end of namespace detail
227 } // end of namespace simd
228 } // end of namespace ipsdk
229 
230 #endif // __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISEQUALREGIMPL_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Streaming SIMD Extensions 2.
Definition: InstructionSetTypes.h:36