Max.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_MAX_H_
36 #define _BLAZE_MATH_SIMD_MAX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // 8-BIT INTEGRAL SIMD TYPES
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
66 BLAZE_ALWAYS_INLINE const SIMDint8 max( const SIMDint8& a, const SIMDint8& b ) noexcept
67 #if BLAZE_AVX512BW_MODE
68 {
69  return _mm512_max_epi8( (~a).value, (~b).value );
70 }
71 #elif BLAZE_AVX2_MODE
72 {
73  return _mm256_max_epi8( (~a).value, (~b).value );
74 }
75 #elif BLAZE_SSE4_MODE
76 {
77  return _mm_max_epi8( (~a).value, (~b).value );
78 }
79 #else
80 = delete;
81 #endif
82 //*************************************************************************************************
83 
84 
85 //*************************************************************************************************
95 BLAZE_ALWAYS_INLINE const SIMDuint8 max( const SIMDuint8& a, const SIMDuint8& b ) noexcept
96 #if BLAZE_AVX512BW_MODE
97 {
98  return _mm512_max_epu8( (~a).value, (~b).value );
99 }
100 #elif BLAZE_AVX2_MODE
101 {
102  return _mm256_max_epu8( (~a).value, (~b).value );
103 }
104 #elif BLAZE_SSE2_MODE
105 {
106  return _mm_max_epu8( (~a).value, (~b).value );
107 }
108 #else
109 = delete;
110 #endif
111 //*************************************************************************************************
112 
113 
114 
115 
116 //=================================================================================================
117 //
118 // 16-BIT INTEGRAL SIMD TYPES
119 //
120 //=================================================================================================
121 
122 //*************************************************************************************************
132 BLAZE_ALWAYS_INLINE const SIMDint16 max( const SIMDint16& a, const SIMDint16& b ) noexcept
133 #if BLAZE_AVX512BW_MODE
134 {
135  return _mm512_max_epi16( (~a).value, (~b).value );
136 }
137 #elif BLAZE_AVX2_MODE
138 {
139  return _mm256_max_epi16( (~a).value, (~b).value );
140 }
141 #elif BLAZE_SSE2_MODE
142 {
143  return _mm_max_epi16( (~a).value, (~b).value );
144 }
145 #else
146 = delete;
147 #endif
148 //*************************************************************************************************
149 
150 
151 //*************************************************************************************************
161 BLAZE_ALWAYS_INLINE const SIMDuint16 max( const SIMDuint16& a, const SIMDuint16& b ) noexcept
162 #if BLAZE_AVX512BW_MODE
163 {
164  return _mm512_max_epu16( (~a).value, (~b).value );
165 }
166 #elif BLAZE_AVX2_MODE
167 {
168  return _mm256_max_epu16( (~a).value, (~b).value );
169 }
170 #elif BLAZE_SSE4_MODE
171 {
172  return _mm_max_epu16( (~a).value, (~b).value );
173 }
174 #else
175 = delete;
176 #endif
177 //*************************************************************************************************
178 
179 
180 
181 
182 //=================================================================================================
183 //
184 // 32-BIT INTEGRAL SIMD TYPES
185 //
186 //=================================================================================================
187 
188 //*************************************************************************************************
198 BLAZE_ALWAYS_INLINE const SIMDint32 max( const SIMDint32& a, const SIMDint32& b ) noexcept
199 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
200 {
201  return _mm512_max_epi32( (~a).value, (~b).value );
202 }
203 #elif BLAZE_AVX2_MODE
204 {
205  return _mm256_max_epi32( (~a).value, (~b).value );
206 }
207 #elif BLAZE_SSE4_MODE
208 {
209  return _mm_max_epi32( (~a).value, (~b).value );
210 }
211 #else
212 = delete;
213 #endif
214 //*************************************************************************************************
215 
216 
217 //*************************************************************************************************
227 BLAZE_ALWAYS_INLINE const SIMDuint32 max( const SIMDuint32& a, const SIMDuint32& b ) noexcept
228 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
229 {
230  return _mm512_max_epu32( (~a).value, (~b).value );
231 }
232 #elif BLAZE_AVX2_MODE
233 {
234  return _mm256_max_epu32( (~a).value, (~b).value );
235 }
236 #elif BLAZE_SSE4_MODE
237 {
238  return _mm_max_epu32( (~a).value, (~b).value );
239 }
240 #else
241 = delete;
242 #endif
243 //*************************************************************************************************
244 
245 
246 
247 
248 //=================================================================================================
249 //
250 // 32-BIT FLOATING POINT SIMD TYPES
251 //
252 //=================================================================================================
253 
254 //*************************************************************************************************
264 template< typename T1 // Type of the left-hand side operand
265  , typename T2 > // Type of the right-hand side operand
266 BLAZE_ALWAYS_INLINE const SIMDfloat
267  max( const SIMDf32<T1>& a, const SIMDf32<T2>& b ) noexcept
268 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
269 {
270  return _mm512_max_ps( (~a).eval().value, (~b).eval().value );
271 }
272 #elif BLAZE_AVX_MODE
273 {
274  return _mm256_max_ps( (~a).eval().value, (~b).eval().value );
275 }
276 #elif BLAZE_SSE_MODE
277 {
278  return _mm_max_ps( (~a).eval().value, (~b).eval().value );
279 }
280 #else
281 = delete;
282 #endif
283 //*************************************************************************************************
284 
285 
286 
287 
288 //=================================================================================================
289 //
290 // 64-BIT FLOATING POINT SIMD TYPES
291 //
292 //=================================================================================================
293 
294 //*************************************************************************************************
304 template< typename T1 // Type of the left-hand side operand
305  , typename T2 > // Type of the right-hand side operand
306 BLAZE_ALWAYS_INLINE const SIMDdouble
307  max( const SIMDf64<T1>& a, const SIMDf64<T2>& b ) noexcept
308 #if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
309 {
310  return _mm512_max_pd( (~a).eval().value, (~b).eval().value );
311 }
312 #elif BLAZE_AVX_MODE
313 {
314  return _mm256_max_pd( (~a).eval().value, (~b).eval().value );
315 }
316 #elif BLAZE_SSE2_MODE
317 {
318  return _mm_max_pd( (~a).eval().value, (~b).eval().value );
319 }
320 #else
321 = delete;
322 #endif
323 //*************************************************************************************************
324 
325 } // namespace blaze
326 
327 #endif
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:786
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
Header file for the basic SIMD types.
System settings for the SSE mode.
System settings for the inline keywords.