15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX2_SATURATEDCASTPACK_H__ 16 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX2_SATURATEDCASTPACK_H__ 31 template <
typename TIn,
typename TOut>
33 typename boost::enable_if_c<
34 boost::is_same<TIn, TOut>::value
38 static IPSDK_FORCEINLINE
45 static IPSDK_FORCEINLINE
54 template <
typename TIn,
typename TOut>
56 typename boost::enable_if_c<
57 boost::is_integral<TIn>::value &&
58 boost::is_integral<TOut>::value &&
59 boost::is_signed<TIn>::value==boost::is_signed<TOut>::value &&
60 sizeof(TIn)<sizeof(TOut)
64 static IPSDK_FORCEINLINE
72 static IPSDK_FORCEINLINE
81 template <
typename TIn,
typename TOut>
83 typename boost::enable_if_c<
84 boost::is_integral<TIn>::value &&
85 boost::is_integral<TOut>::value &&
86 boost::is_signed<TIn>::value &&
87 !boost::is_signed<TOut>::value &&
88 sizeof(TOut)>=sizeof(TIn)
92 static IPSDK_FORCEINLINE
101 simd::assign<eInstructionSet::eIS_Avx2>(zero, 0);
108 static IPSDK_FORCEINLINE
116 simd::assign<eInstructionSet::eIS_Avx2>(zero, 0);
118 simd::max<eInstructionSet::eIS_Avx2>(zero, in, clampedIn);
119 CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn, out);
123 template <
typename TIn,
typename TOut>
125 typename boost::enable_if_c<
126 boost::is_integral<TIn>::value &&
127 boost::is_integral<TOut>::value &&
128 !boost::is_signed<TIn>::value &&
129 boost::is_signed<TOut>::value &&
130 sizeof(TOut)<=sizeof(TIn)
134 static IPSDK_FORCEINLINE
135 BasePack<ePackType::ePT_Avx, TOut>
136 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
143 BasePack<ePackType::ePT_Avx, TIn> packMax;
144 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
145 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
146 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
147 BasePack<ePackType::ePT_Avx, TOut> out;
148 return CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn);
151 static IPSDK_FORCEINLINE
153 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
154 BasePack<ePackType::ePT_Avx, TOut>& out)
160 BasePack<ePackType::ePT_Avx, TIn> packMax;
161 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
162 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
163 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
164 CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn, out);
168 template <
typename TIn,
typename TOut>
170 typename boost::enable_if_c<
171 boost::is_integral<TIn>::value &&
172 boost::is_integral<TOut>::value &&
173 !boost::is_signed<TIn>::value &&
174 boost::is_signed<TOut>::value &&
175 (sizeof(TOut) > sizeof(TIn))
179 static IPSDK_FORCEINLINE
180 BasePack<ePackType::ePT_Avx, TOut>
181 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
183 BasePack<ePackType::ePT_Avx, TOut> out;
184 return CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(in);
187 static IPSDK_FORCEINLINE
189 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
190 BasePack<ePackType::ePT_Avx, TOut>& out)
192 return CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(in, out);
196 template <
typename TIn,
typename TOut>
198 typename boost::enable_if_c<
199 boost::is_integral<TIn>::value &&
200 boost::is_integral<TOut>::value &&
201 !boost::is_signed<TIn>::value &&
202 !boost::is_signed<TOut>::value &&
203 sizeof(TOut)<sizeof(TIn)
207 static IPSDK_FORCEINLINE
208 BasePack<ePackType::ePT_Avx, TOut>
209 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
216 BasePack<ePackType::ePT_Avx, TIn> packMax;
217 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
218 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
219 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
220 BasePack<ePackType::ePT_Avx, TOut> out;
221 return CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn);
224 static IPSDK_FORCEINLINE
226 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
227 BasePack<ePackType::ePT_Avx, TOut>& out)
232 BasePack<ePackType::ePT_Avx, TIn> packMax;
233 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
234 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
235 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
236 CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn, out);
240 template <
typename TIn,
typename TOut>
242 typename boost::enable_if_c<
243 boost::is_integral<TIn>::value &&
244 boost::is_integral<TOut>::value &&
245 boost::is_signed<TIn>::value &&
246 sizeof(TOut)<sizeof(TIn)
250 static IPSDK_FORCEINLINE
251 BasePack<ePackType::ePT_Avx, TOut>
252 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
261 BasePack<ePackType::ePT_Avx, TIn> packZero, packMax;
262 simd::assign<eInstructionSet::eIS_Avx2>(packZero, 0);
263 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
264 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
265 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
266 simd::max<eInstructionSet::eIS_Avx2>(packZero, clampedIn, clampedIn);
267 BasePack<ePackType::ePT_Avx, TOut> out;
268 return CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn);
271 static IPSDK_FORCEINLINE
273 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
274 BasePack<ePackType::ePT_Avx, TOut>& out)
282 BasePack<ePackType::ePT_Avx, TIn> packMin, packMax;
283 simd::assign<eInstructionSet::eIS_Avx2>(packMin, NumericLimits<TOut>::min());
284 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
285 BasePack<ePackType::ePT_Avx, TIn> clampedIn;
286 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
287 simd::max<eInstructionSet::eIS_Avx2>(packMin, clampedIn, clampedIn);
288 CastPack<eInstructionSet::eIS_Avx2, TIn, TOut>::act(clampedIn, out);
292 template <
typename TIn>
294 typename boost::enable_if_c<boost::is_integral<TIn>::value>::type>
296 static IPSDK_FORCEINLINE
297 BasePack<ePackType::ePT_Avx, ipReal32>
298 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
300 BasePack<ePackType::ePT_Avx, ipReal32> out;
301 return CastPack<eInstructionSet::eIS_Avx2, TIn, ipReal32>::act(in);
304 static IPSDK_FORCEINLINE
306 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
307 BasePack<ePackType::ePT_Avx, ipReal32>& out)
309 return CastPack<eInstructionSet::eIS_Avx2, TIn, ipReal32>::act(in, out);
313 template <
typename TOut>
315 typename boost::enable_if_c<boost::is_integral<TOut>::value>::type>
317 static IPSDK_FORCEINLINE
318 BasePack<ePackType::ePT_Avx, TOut>
319 act(
const BasePack<ePackType::ePT_Avx, ipReal32>& in)
329 BasePack<ePackType::ePT_Avx, ipReal64> clampedIn;
330 CastPack<eInstructionSet::eIS_Avx2, ipReal32, ipReal64>::act(in, clampedIn);
332 BasePack<ePackType::ePT_Avx, ipReal64> packMin, packMax;
333 simd::assign<eInstructionSet::eIS_Avx2>(packMin, NumericLimits<TOut>::min());
334 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
335 simd::min<eInstructionSet::eIS_Avx2>(packMax, clampedIn, clampedIn);
336 simd::max<eInstructionSet::eIS_Avx2>(packMin, clampedIn, clampedIn);
338 return CastPack<eInstructionSet::eIS_Avx2, ipReal64, TOut>::act(clampedIn);
341 static IPSDK_FORCEINLINE
343 act(
const BasePack<ePackType::ePT_Avx, ipReal32>& in,
344 BasePack<ePackType::ePT_Avx, TOut>& out)
352 BasePack<ePackType::ePT_Avx, ipReal64> clampedIn;
353 CastPack<eInstructionSet::eIS_Avx2, ipReal32, ipReal64>::act(in, clampedIn);
355 BasePack<ePackType::ePT_Avx, ipReal64> packMin, packMax;
356 simd::assign<eInstructionSet::eIS_Avx2>(packMin, NumericLimits<TOut>::min());
357 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
358 simd::min<eInstructionSet::eIS_Avx2>(packMax, clampedIn, clampedIn);
359 simd::max<eInstructionSet::eIS_Avx2>(packMin, clampedIn, clampedIn);
361 CastPack<eInstructionSet::eIS_Avx2, ipReal64, TOut>::act(clampedIn, out);
365 template <
typename TIn>
367 typename boost::enable_if_c<
368 !boost::is_same<TIn, ipReal64>::value
372 static IPSDK_FORCEINLINE
373 BasePack<ePackType::ePT_Avx, ipReal64>
374 act(
const BasePack<ePackType::ePT_Avx, TIn>& in)
376 BasePack<ePackType::ePT_Avx, ipReal64> out;
377 return CastPack<eInstructionSet::eIS_Avx2, TIn, ipReal64>::act(in);
380 static IPSDK_FORCEINLINE
382 act(
const BasePack<ePackType::ePT_Avx, TIn>& in,
383 BasePack<ePackType::ePT_Avx, ipReal64>& out)
385 return CastPack<eInstructionSet::eIS_Avx2, TIn, ipReal64>::act(in, out);
389 template <
typename TOut>
391 typename boost::enable_if_c<
392 !boost::is_same<ipReal64, TOut>::value
396 static IPSDK_FORCEINLINE
397 BasePack<ePackType::ePT_Avx, TOut>
398 act(
const BasePack<ePackType::ePT_Avx, ipReal64>& in)
400 BasePack<ePackType::ePT_Avx, ipReal64> clampedIn, packMin, packMax;
401 simd::assign<eInstructionSet::eIS_Avx2>(packMin, NumericLimits<TOut>::min());
402 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
403 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
404 simd::max<eInstructionSet::eIS_Avx2>(packMin, clampedIn, clampedIn);
406 BasePack<ePackType::ePT_Avx, TOut> out;
407 return CastPack<eInstructionSet::eIS_Avx2, ipReal64, TOut>::act(clampedIn);
410 static IPSDK_FORCEINLINE
412 act(
const BasePack<ePackType::ePT_Avx, ipReal64>& in,
413 BasePack<ePackType::ePT_Avx, TOut>& out)
415 BasePack<ePackType::ePT_Avx, ipReal64> clampedIn, packMin, packMax;
416 simd::assign<eInstructionSet::eIS_Avx2>(packMin, NumericLimits<TOut>::min());
417 simd::assign<eInstructionSet::eIS_Avx2>(packMax, NumericLimits<TOut>::max());
418 simd::min<eInstructionSet::eIS_Avx2>(packMax, in, clampedIn);
419 simd::max<eInstructionSet::eIS_Avx2>(packMin, clampedIn, clampedIn);
421 CastPack<eInstructionSet::eIS_Avx2, ipReal64, TOut>::act(clampedIn, out);
432 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX2_SATURATEDCASTPACK_H__ Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: CastPack.h:33
Definition: SaturatedCastPack.h:33
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
BasePack class; defines a set of scalars (for instruction set "standard") or registers (for all other...
IPSDK_FORCEINLINE PackT max(const PackT &in1, const PackT &in2)
returns the maximum of 2 packs
Definition: max.h:40
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Advanced Vector Extensions 2.
Definition: InstructionSetTypes.h:48
Definition of import/export macro for library.
float ipReal32
Base types definition.
Definition: BaseTypes.h:56
structure containing intrinsic registers used to store vectorized data
Definition: BasePackDecl.h:29