IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
ToBoolPack.h
Go to the documentation of this file.
1 // ToBoolPack.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_TOBOOLPACK_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_TOBOOLPACK_H__
17 
23 
24 namespace ipsdk {
25 namespace simd {
26 namespace detail {
27 
30 
31 template <>
33 {
34  static IPSDK_FORCEINLINE
37  {
39  assign<eInstructionSet::eIS_Avx2>(zero, 0);
40  assign<eInstructionSet::eIS_Avx2>(one, 1);
41 
44  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
45  cast<eInstructionSet::eIS_Avx2>(nez, out);
46  bitwiseAnd<eInstructionSet::eIS_Avx2>(out, one, out);
47  return out;
48 
49  }
50 
51  static IPSDK_FORCEINLINE
52  void
55  {
57  assign<eInstructionSet::eIS_Avx2>(zero, 0);
58  assign<eInstructionSet::eIS_Avx2>(one, 1);
60  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
61  cast<eInstructionSet::eIS_Avx2>(nez, out);
62  bitwiseAnd<eInstructionSet::eIS_Avx2>(out, one, out);
63  }
64 
65  static IPSDK_FORCEINLINE
66  void
69  {
71  cast<eInstructionSet::eIS_Avx2>(inMask, in);
72  act(in, out);
73  }
74 };
75 
76 template <>
78 {
79  static IPSDK_FORCEINLINE
82  {
84  assign<eInstructionSet::eIS_Avx2>(zero, 0);
85  assign<eInstructionSet::eIS_Avx2>(one, 1);
86 
89  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
90  cast<eInstructionSet::eIS_Avx2>(nez, packInt8);
91  bitwiseAnd<eInstructionSet::eIS_Avx2>(packInt8, one, packInt8);
93  cast<eInstructionSet::eIS_Avx2>(packInt8, out);
94  return out;
95  }
96 
97  static IPSDK_FORCEINLINE
98  void
101  {
103  assign<eInstructionSet::eIS_Avx2>(zero, 0);
104  assign<eInstructionSet::eIS_Avx2>(one, 1);
107  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
108  cast<eInstructionSet::eIS_Avx2>(nez, packInt8);
109  bitwiseAnd<eInstructionSet::eIS_Avx2>(packInt8, one, packInt8);
110 
111  cast<eInstructionSet::eIS_Avx2>(packInt8, out);
112  }
113 
114  static IPSDK_FORCEINLINE
115  void
118  {
120  cast<eInstructionSet::eIS_Avx2>(inMask, in);
121  act(in, out);
122  }
123 };
124 
125 template <typename T>
127  typename boost::enable_if_c<
128  boost::is_integral<T>::value && sizeof(T) != 1>::type>
129 {
130  static IPSDK_FORCEINLINE
132  act(const BasePack<ePackType::ePT_Avx, T>& in)
133  {
136  assign<eInstructionSet::eIS_Avx2>(zero, 0);
137  assign<eInstructionSet::eIS_Avx2>(one, 1);
138 
141  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
142  cast<eInstructionSet::eIS_Avx2>(nez, packT);
143  bitwiseAnd<eInstructionSet::eIS_Avx2>(packT, one, packT);
144  return cast<eInstructionSet::eIS_Avx2, ipUInt8>(packT);
145  }
146 
147  static IPSDK_FORCEINLINE
148  void
149  act(const BasePack<ePackType::ePT_Avx, T>& in,
151  {
154  assign<eInstructionSet::eIS_Avx2>(zero, 0);
155  assign<eInstructionSet::eIS_Avx2>(one, 1);
156 
159  isNotEqual<eInstructionSet::eIS_Avx2>(in, zero, nez);
160  cast<eInstructionSet::eIS_Avx2>(nez, packT);
161  bitwiseAnd<eInstructionSet::eIS_Avx2>(packT, one, packT);
162 
163  cast<eInstructionSet::eIS_Avx2>(packT, out);
164  }
165 
166  static IPSDK_FORCEINLINE
167  void
168  act(const BaseMaskPack<ePackType::ePT_Avx, T>& inMask,
170  {
172  cast<eInstructionSet::eIS_Avx2>(inMask, in);
173  act(in, out);
174  }
175 };
176 
177 template <>
179 {
180  static IPSDK_FORCEINLINE
183  {
185  inCvt._val[0] = _mm256_castps_si256(in._val[0]);
186  inCvt._val[1] = _mm256_castps_si256(in._val[1]);
187  inCvt._val[2] = _mm256_castps_si256(in._val[2]);
188  inCvt._val[3] = _mm256_castps_si256(in._val[3]);
189 
191  }
192 
193  static IPSDK_FORCEINLINE
194  void
197  {
199  inCvt._val[0] = _mm256_castps_si256(in._val[0]);
200  inCvt._val[1] = _mm256_castps_si256(in._val[1]);
201  inCvt._val[2] = _mm256_castps_si256(in._val[2]);
202  inCvt._val[3] = _mm256_castps_si256(in._val[3]);
203 
205  }
206 
207  static IPSDK_FORCEINLINE
208  void
211  {
213  cast<eInstructionSet::eIS_Avx2>(inMask, in);
214  act(in, out);
215  }
216 };
217 
220 
221 } // end of namespace detail
222 } // end of namespace simd
223 } // end of namespace ipsdk
224 
225 #endif // __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_TOBOOLPACK_H__
int8_t ipInt8
Base types definition.
Definition: BaseTypes.h:48
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
structure containing set of masks for vectorized operations
Definition: BaseMaskPackDecl.h:29
Predefined types for Avx instruction set management.
uint8_t ipUInt8
Base types definition.
Definition: BaseTypes.h:49
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Advanced Vector Extensions 2.
Definition: InstructionSetTypes.h:48
Definition: ToBoolPack.h:30
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