IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsGreaterRegImpl.h
Go to the documentation of this file.
1 // IsGreaterRegImpl.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX2_ISGREATERREGIMPL_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX2_ISGREATERREGIMPL_H__
17 
22 
23 namespace ipsdk {
24 namespace simd {
25 namespace detail {
26 
29 
30 template <>
31 IPSDK_FORCEINLINE
32 RegMaskType<eInstructionSet::eIS_Avx2, ipInt8>::Type
33 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt8>::act(
34  const AvxType<ipInt8>::Type& in1,
35  const AvxType<ipInt8>::Type& in2)
36 {
37  return _mm256_cmpgt_epi8(in1, in2);
38 }
39 
40 template <>
41 IPSDK_FORCEINLINE
42 void
43 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt8>::act(
44  const AvxType<ipInt8>::Type& in1,
45  const AvxType<ipInt8>::Type& in2,
46  RegMaskType<eInstructionSet::eIS_Avx2, ipInt8>::Type& out)
47 {
48  out = _mm256_cmpgt_epi8(in1, in2);
49 }
50 
51 template <>
52 IPSDK_FORCEINLINE
53 RegMaskType<eInstructionSet::eIS_Avx2, ipUInt8>::Type
54 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(
55  const AvxType<ipUInt8>::Type& in1,
56  const AvxType<ipUInt8>::Type& in2)
57 {
58  const AvxType<ipUInt8>::Type& c =
59  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(0x80);
60  const AvxType<ipUInt8>::Type& in1Cvt =
61  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(in1, c);
62  const AvxType<ipUInt8>::Type& in2Cvt =
63  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(in2, c);
64 
65  return _mm256_cmpgt_epi8(in1Cvt, in2Cvt);
66 }
67 
68 template <>
69 IPSDK_FORCEINLINE
70 void
71 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(
72  const AvxType<ipUInt8>::Type& in1,
73  const AvxType<ipUInt8>::Type& in2,
74  RegMaskType<eInstructionSet::eIS_Avx2, ipUInt8>::Type& out)
75 {
76  AvxType<ipUInt8>::Type c;
77  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(c, 0x80);
78  AvxType<ipUInt8>::Type in1Cvt;
79  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(in1, c, in1Cvt);
80  AvxType<ipUInt8>::Type in2Cvt;
81  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(in2, c, in2Cvt);
82 
83  out = _mm256_cmpgt_epi8(in1Cvt, in2Cvt);
84 }
85 
86 template <>
87 IPSDK_FORCEINLINE
88 RegMaskType<eInstructionSet::eIS_Avx2, ipInt16>::Type
89 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt16>::act(
90  const AvxType<ipInt16>::Type& in1,
91  const AvxType<ipInt16>::Type& in2)
92 {
93  return _mm256_cmpgt_epi16(in1, in2);
94 }
95 
96 template <>
97 IPSDK_FORCEINLINE
98 void
99 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt16>::act(
100  const AvxType<ipInt16>::Type& in1,
101  const AvxType<ipInt16>::Type& in2,
102  RegMaskType<eInstructionSet::eIS_Avx2, ipInt16>::Type& out)
103 {
104  out = _mm256_cmpgt_epi16(in1, in2);
105 }
106 
107 template <>
108 IPSDK_FORCEINLINE
109 RegMaskType<eInstructionSet::eIS_Avx2, ipUInt16>::Type
110 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(
111  const AvxType<ipUInt16>::Type& in1,
112  const AvxType<ipUInt16>::Type& in2)
113 {
114  const AvxType<ipUInt16>::Type& c =
115  AssignReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(0x8000);
116  const AvxType<ipUInt16>::Type& in1Cvt =
117  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(in1, c);
118  const AvxType<ipUInt16>::Type& in2Cvt =
119  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(in2, c);
120 
121  return _mm256_cmpgt_epi16(in1Cvt, in2Cvt);
122 }
123 
124 template <>
125 IPSDK_FORCEINLINE
126 void
127 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(
128  const AvxType<ipUInt16>::Type& in1,
129  const AvxType<ipUInt16>::Type& in2,
130  RegMaskType<eInstructionSet::eIS_Avx2, ipUInt16>::Type& out)
131 {
132  AvxType<ipUInt16>::Type c;
133  AssignReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(c, 0x8000);
134  AvxType<ipUInt16>::Type in1Cvt;
135  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(in1, c, in1Cvt);
136  AvxType<ipUInt16>::Type in2Cvt;
137  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt16>::act(in2, c, in2Cvt);
138  out = _mm256_cmpgt_epi16(in1Cvt, in2Cvt);
139 }
140 
141 template <>
142 IPSDK_FORCEINLINE
143 RegMaskType<eInstructionSet::eIS_Avx2, ipInt32>::Type
144 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt32>::act(
145  const AvxType<ipInt32>::Type& in1,
146  const AvxType<ipInt32>::Type& in2)
147 {
148  return _mm256_cmpgt_epi32(in1, in2);
149 }
150 
151 template <>
152 IPSDK_FORCEINLINE
153 void
154 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt32>::act(
155  const AvxType<ipInt32>::Type& in1,
156  const AvxType<ipInt32>::Type& in2,
157  RegMaskType<eInstructionSet::eIS_Avx2, ipInt32>::Type& out)
158 {
159  out = _mm256_cmpgt_epi32(in1, in2);
160 }
161 
162 template <>
163 IPSDK_FORCEINLINE
164 RegMaskType<eInstructionSet::eIS_Avx2, ipUInt32>::Type
165 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(
166  const AvxType<ipUInt32>::Type& in1,
167  const AvxType<ipUInt32>::Type& in2)
168 {
169  const AvxType<ipUInt32>::Type& c =
170  AssignReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(0x80000000);
171  const AvxType<ipUInt32>::Type& in1Cvt =
172  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(in1, c);
173  const AvxType<ipUInt32>::Type& in2Cvt =
174  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(in2, c);
175 
176  return _mm256_cmpgt_epi32(in1Cvt, in2Cvt);
177 }
178 
179 template <>
180 IPSDK_FORCEINLINE
181 void
182 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(
183  const AvxType<ipUInt32>::Type& in1,
184  const AvxType<ipUInt32>::Type& in2,
185  RegMaskType<eInstructionSet::eIS_Avx2, ipUInt32>::Type& out)
186 {
187  AvxType<ipUInt32>::Type c;
188  AssignReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(c, 0x80000000);
189  AvxType<ipUInt32>::Type in1Cvt;
190  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(in1, c, in1Cvt);
191  AvxType<ipUInt32>::Type in2Cvt;
192  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt32>::act(in2, c, in2Cvt);
193 
194  out = _mm256_cmpgt_epi32(in1Cvt, in2Cvt);
195 }
196 
197 template <>
198 IPSDK_FORCEINLINE
199 RegMaskType<eInstructionSet::eIS_Avx2, ipInt64>::Type
200 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt64>::act(
201  const AvxType<ipInt64>::Type& in1,
202  const AvxType<ipInt64>::Type& in2)
203 {
204  return _mm256_cmpgt_epi64(in1, in2);
205 }
206 
207 
208 template <>
209 IPSDK_FORCEINLINE
210 void
211 IsGreaterReg<eInstructionSet::eIS_Avx2, ipInt64>::act(
212  const AvxType<ipInt64>::Type& in1,
213  const AvxType<ipInt64>::Type& in2,
214  RegMaskType<eInstructionSet::eIS_Avx2, ipInt64>::Type& out)
215 {
216  out = _mm256_cmpgt_epi64(in1, in2);
217 }
218 
219 template <>
220 IPSDK_FORCEINLINE
221 RegMaskType<eInstructionSet::eIS_Avx2, ipUInt64>::Type
222 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(
223  const AvxType<ipUInt64>::Type& in1,
224  const AvxType<ipUInt64>::Type& in2)
225 {
226  const AvxType<ipUInt64>::Type& c =
227  AssignReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(0x8000000000000000);
228  const AvxType<ipUInt64>::Type& in1Cvt =
229  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(in1, c);
230  const AvxType<ipUInt64>::Type& in2Cvt =
231  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(in2, c);
232 
233  return _mm256_cmpgt_epi64(in1Cvt, in2Cvt);
234 }
235 
236 template <>
237 IPSDK_FORCEINLINE
238 void
239 IsGreaterReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(
240  const AvxType<ipUInt64>::Type& in1,
241  const AvxType<ipUInt64>::Type& in2,
242  RegMaskType<eInstructionSet::eIS_Avx2, ipUInt64>::Type& out)
243 {
244  AvxType<ipUInt64>::Type c;
245  AssignReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(c, 0x8000000000000000);
246  AvxType<ipUInt64>::Type in1Cvt;
247  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(in1, c, in1Cvt);
248  AvxType<ipUInt64>::Type in2Cvt;
249  BitwiseXOrReg<eInstructionSet::eIS_Avx2, ipUInt64>::act(in2, c, in2Cvt);
250 
251  out = _mm256_cmpgt_epi64(in1Cvt, in2Cvt);
252 }
253 
254 template <>
255 IPSDK_FORCEINLINE
256 RegMaskType<eInstructionSet::eIS_Avx2, ipReal32>::Type
257 IsGreaterReg<eInstructionSet::eIS_Avx2, ipReal32>::act(
258  const AvxType<ipReal32>::Type& in1,
259  const AvxType<ipReal32>::Type& in2)
260 {
261  return IsGreaterReg<eInstructionSet::eIS_Avx, ipReal32>::act(in1, in2);
262 }
263 
264 template <>
265 IPSDK_FORCEINLINE
266 void
267 IsGreaterReg<eInstructionSet::eIS_Avx2, ipReal32>::act(
268  const AvxType<ipReal32>::Type& in1,
269  const AvxType<ipReal32>::Type& in2,
270  RegMaskType<eInstructionSet::eIS_Avx2, ipReal32>::Type& out)
271 {
272  IsGreaterReg<eInstructionSet::eIS_Avx, ipReal32>::act(in1, in2, out);
273 }
274 
275 template <>
276 IPSDK_FORCEINLINE
277 RegMaskType<eInstructionSet::eIS_Avx2, ipReal64>::Type
278 IsGreaterReg<eInstructionSet::eIS_Avx2, ipReal64>::act(
279  const AvxType<ipReal64>::Type& in1,
280  const AvxType<ipReal64>::Type& in2)
281 {
282  return IsGreaterReg<eInstructionSet::eIS_Avx, ipReal64>::act(in1, in2);
283 }
284 
285 template <>
286 IPSDK_FORCEINLINE
287 void
288 IsGreaterReg<eInstructionSet::eIS_Avx2, ipReal64>::act(
289  const AvxType<ipReal64>::Type& in1,
290  const AvxType<ipReal64>::Type& in2,
291  RegMaskType<eInstructionSet::eIS_Avx2, ipReal64>::Type& out)
292 {
293  IsGreaterReg<eInstructionSet::eIS_Avx, ipReal64>::act(in1, in2, out);
294 }
295 
298 
299 } // end of namespace detail
300 } // end of namespace simd
301 } // end of namespace ipsdk
302 
305 
306 #endif // __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX2_ISGREATERREGIMPL_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22