IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SignedUnsignedOpReg.h
Go to the documentation of this file.
1 // SignedUnsignedOpReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_SIGNEDUNSIGNEDOPREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_SIGNEDUNSIGNEDOPREG_H__
17 
20 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/SignedUnsignedOpReg.h>
24 #include <IPSDKUtil/InstructionSet/Comparison/detail/AVX512/IsGreaterReg.h>
33 
34 namespace ipsdk {
35 namespace simd {
36 namespace detail {
37 
40 
43 template<typename T>
45  T, /* signed */ false>
46 {
47  typedef typename Avx512Type<T>::Type result_type;
48 
49  static IPSDK_FORCEINLINE
50  result_type act(const typename Avx512Type<T>::Type& x,
51  const typename Avx512Type<T>::Type& y)
52  {
54  }
55 
56  static IPSDK_FORCEINLINE
57  void act(const typename Avx512Type<T>::Type& x,
58  const typename Avx512Type<T>::Type& y,
59  result_type& out)
60  {
62  }
63 };
64 
67 template<typename T>
69  T, /* signed */ true>
70 {
71  typedef typename boost::make_unsigned<T>::type unsigned_type;
72  typedef typename Avx512Type<unsigned_type>::Type result_type;
73 
74  static IPSDK_FORCEINLINE
75  result_type act(const typename Avx512Type<T>::Type& x,
76  const typename Avx512Type<T>::Type& y)
77  {
78  const typename Avx512Type<T>::Type zero =
80 
81  const typename Avx512MaskType<T>::Type yNeg =
83 
84  const typename Avx512MaskType<T>::Type xNeg =
86 
87  typename Avx512Type<T>::Type regFromYNeg;
89  typename Avx512Type<T>::Type regFromXNeg;
91 
92  const typename Avx512Type<T>::Type yNegAndXNotNeg =
94 
95 
96  const typename Avx512Type<T>::Type one =
98 
100  yNegAndXNotNeg,
101 
102  // avoid the nasty two's complement case for y == min()
103  // return result_type(x) + result_type(-(y+1)) + 1;
106  x,
109  one),
110 
111  // return result_type(x - y);
113  //return SubReg<eInstructionSet::eIS_Avx2, unsigned_type>::act(x, y);
114  }
115 
116  static IPSDK_FORCEINLINE
117  void act(const typename Avx512Type<T>::Type& x,
118  const typename Avx512Type<T>::Type& y,
119  result_type& out)
120  {
121  const typename Avx512Type<T>::Type zero =
123 
124  const typename Avx512Type<T>::Type one =
126 
127  typename Avx512Type<T>::Type yNeg;
129 
130  typename Avx512Type<T>::Type xNeg;
132 
133  typename Avx512Type<T>::Type yNegAndXNotNeg;
134  BitwiseAndNotReg<eInstructionSet::eIS_Avx512, T>::act(yNeg, xNeg, yNegAndXNotNeg);
135 
136  typename Avx512Type<T>::Type a_t;
137  typename Avx512Type<unsigned_type>::Type a, b;
138 
141  cast<eInstructionSet::eIS_Avx512, T, unsigned_type>(a_t, a);
144 
146 
148  yNegAndXNotNeg, a, b, out);
149  }
150 };
151 
154 template<typename T1, typename T2>
156  T1, T2, /* signed */ false>
157 {
158  typedef typename Avx512Type<T2>::Type result_type;
159 
160  static IPSDK_FORCEINLINE
161  result_type act(const typename Avx512Type<T1>::Type& x,
162  const typename Avx512Type<T2>::Type& y)
163  {
165  }
166 
167  static IPSDK_FORCEINLINE
168  void act(const typename Avx512Type<T1>::Type& x,
169  const typename Avx512Type<T2>::Type& y,
170  result_type& out)
171  {
173  }
174 };
175 
178 template<typename T1, typename T2>
180  T1, T2, /* signed */ true>
181 {
182  typedef typename Avx512Type<T2>::Type result_type;
183 
184  static IPSDK_FORCEINLINE
185  result_type act(const typename Avx512Type<T1>::Type& x,
186  const typename Avx512Type<T2>::Type& y)
187  {
188  const typename Avx512Type<T1>::Type zero =
190 
191  const typename Avx512Type<T2>::Type one =
193 
194  const typename Avx512Type<T1>::Type yNeg =
196 
197  const typename Avx512Type<T1>::Type minusYPlusOne =
200 
201  const typename Avx512Type<T1>::Type xGtThnMinusYPlusOne =
203 
204  const typename Avx512Type<T1>::Type yNegAndXGtThnMinusYPlusOne =
206  yNeg, xGtThnMinusYPlusOne);
207 
208 
210  yNegAndXGtThnMinusYPlusOne,
211 
212  // avoid the nasty two's complement edge case for y == min()
213  // return T2(x - T1(-(y+1)) - 1);
216  x, minusYPlusOne),
217  one),
218  // return T2(x) + y;
220  //return AddReg<eInstructionSet::eIS_Avx2, T2>::act(x, y);
221  }
222 
223  static IPSDK_FORCEINLINE
224  void act(const typename Avx512Type<T1>::Type& x,
225  const typename Avx512Type<T2>::Type& y,
226  result_type& out)
227  {
228  const typename Avx512Type<T1>::Type zero =
230 
231  const typename Avx512Type<T2>::Type one =
233 
234  typename Avx512Type<T1>::Type yNeg;
236 
237  typename Avx512Type<T2>::Type minusYPlusOne_t2;
238  AddReg<eInstructionSet::eIS_Avx512, T2>::act(y, one, minusYPlusOne_t2);
239  UnaryMinusReg<eInstructionSet::eIS_Avx512, T2>::act(minusYPlusOne_t2, minusYPlusOne_t2);
240 
241  typename Avx512Type<T1>::Type minusYPlusOne;
242  cast<eInstructionSet::eIS_Avx512, T2, T1>(minusYPlusOne_t2, minusYPlusOne);
243 
244  typename Avx512Type<T1>::Type xGtThnMinusYPlusOne;
245  IsGreaterReg<eInstructionSet::eIS_Avx512, T1>::act(x, minusYPlusOne, xGtThnMinusYPlusOne);
246 
247  typename Avx512Type<T1>::Type yNegAndXGtThnMinusYPlusOne;
249  yNeg, xGtThnMinusYPlusOne, yNegAndXGtThnMinusYPlusOne);
250 
251  typename Avx512Type<T1>::Type a;
254 
255  typename Avx512Type<T2>::Type b;
258  yNegAndXGtThnMinusYPlusOne, a, b, out);
259  }
260 };
261 
264 
265 } // end of namespace detail
266 } // end of namespace simd
267 } // end of namespace ipsdk
268 
269 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX512_ADDREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: BitwiseAndNotReg.h:30
specialization of ipsdk::simd::detail::UnaryMinusReg structure for AVX512 instruction set ...
Definition: SubReg.h:39
Definition: SignedUnsignedOpReg.h:69
Definition: IsGreaterRegDecl.h:30
(including fundation and byte and word instructions)
Definition: InstructionSetTypes.h:51
Definition: CastReg.h:30
Definition: BitwiseSelectReg.h:30
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Predefined types for Avx512 instruction set management.
specialization of ipsdk::simd::detail::SubReg structure for AVX512 instruction set ...
Definition: Avx512MaskTypes.h:36
Predefined types associated to instruction set management.
Definition of import/export macro for library.
template structure which is specialized to implement the arithmetic addition on 2 scalars or 2 regist...
Definition: AddReg.h:37
Definition: UnaryMinusReg.h:40
specialization of ipsdk::simd::detail::AddReg structure for AVX512 instruction set ...
Definition: IsLessRegDecl.h:30
Definition: SignedUnsignedOpReg.h:51
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
structure used to retrieve AVX512 type associated to a base type
Definition: Avx512Types.h:36