1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 Intel Corporation.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the configuration of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #include <immintrin.h>
41
42 #ifndef __AVX512F__
43 # error "There doesn't seem to be AVX-512 support in this compiler"
44 #endif
45 #ifndef WANT_AVX512
46 # error ".pro file must define WANT_AVX512 macro to the AVX-512 feature to be tested"
47 #endif
48
49 // The following checks if __AVXx__ is defined, where x is the value in
50 // WANT_AVX512
51 #define HAS2(x) __AVX512 ## x ## __
52 #define HAS(x) HAS2(x)
53 #if !HAS(WANT_AVX512)
54 # error "Feature not supported"
55 #endif
56
main(int,char ** argv)57 int main(int, char**argv)
58 {
59 /* AVX512 Foundation */
60 __m512i i;
61 __m512d d;
62 __m512 f;
63 __mmask16 m = ~1;
64 i = _mm512_maskz_loadu_epi32(0, argv);
65 d = _mm512_loadu_pd((double *)argv + 64);
66 f = _mm512_loadu_ps((float *)argv + 128);
67
68 // some intrinsic that GCC forgot until GCC 8
69 i = _mm512_maskz_set1_epi32(m, '?');
70 _mm512_mask_cvtepi32_storeu_epi8(argv, m, i);
71
72 #ifdef WANT_AVX512ER
73 /* AVX512 Exponential and Reciprocal */
74 f = _mm512_exp2a23_round_ps(f, 8);
75 #endif
76 #ifdef WANT_AVX512CD
77 /* AVX512 Conflict Detection */
78 i = _mm512_maskz_conflict_epi32(m, i);
79 #endif
80 #ifdef WANT_AVX512PF
81 /* AVX512 Prefetch */
82 _mm512_mask_prefetch_i64scatter_pd(argv, 0xf, i, 2, 2);
83 #endif
84 #ifdef WANT_AVX512DQ
85 /* AVX512 Doubleword and Quadword support */
86 m = _mm512_movepi32_mask(i);
87 #endif
88 #ifdef WANT_AVX512BW
89 /* AVX512 Byte and Word support */
90 i = _mm512_mask_loadu_epi8(i, m, argv - 8);
91 _mm512_mask_cvtepi16_storeu_epi8(argv + 8, m, i);
92 #endif
93 #ifdef WANT_AVX512VL
94 /* AVX512 Vector Length */
95 __m256i i2 = _mm256_maskz_loadu_epi32(0, argv);
96 _mm256_mask_storeu_epi32(argv + 1, m, i2);
97 #endif
98 #ifdef WANT_AVX512IFMA
99 /* AVX512 Integer Fused Multiply-Add */
100 i = _mm512_madd52lo_epu64(i, i, i);
101 #endif
102 #ifdef WANT_AVX512VBMI
103 /* AVX512 Vector Byte Manipulation Instructions */
104 i = _mm512_permutexvar_epi8(i, i);
105 #endif
106
107 _mm512_mask_storeu_epi64(argv, m, i);
108 _mm512_mask_storeu_ps(argv + 64, m, f);
109 _mm512_mask_storeu_pd(argv + 128, m, d);
110 return 0;
111 }
112