Debian Codegraph @

gcc/testsuite/gcc.target/i386/m512-check.h

raw
1 #include <immintrin.h>
2 #include "m256-check.h"
3
4 typedef union
5 {
6 __m512i x;
7 char a[64];
8 } union512i_b;
9
10 typedef union
11 {
12 __m512i x;
13 short a[32];
14 } union512i_w;
15
16 typedef union
17 {
18 __m512i x;
19 int a[16];
20 } union512i_d;
21
22 typedef union
23 {
24 __m512i x;
25 long long a[8];
26 } union512i_q;
27
28 typedef union
29 {
30 __m512 x;
31 float a[16];
32 } union512;
33
34 typedef union
35 {
36 __m512d x;
37 double a[8];
38 } union512d;
39
40 typedef union
41 {
42 __m512i x;
43 unsigned char a[64];
44 } union512i_ub;
45
46 typedef union
47 {
48 __m512i x;
49 unsigned short a[32];
50 } union512i_uw;
51
52 typedef union
53 {
54 __m512i x;
55 unsigned int a[16];
56 } union512i_ud;
57
58 typedef union
59 {
60 __m512i x;
61 unsigned long long a[8];
62 } union512i_uq;
63
64 typedef union
65 {
66 __m512h x;
67 _Float16 a[32];
68 } union512h;
69
70 typedef union
71 {
72 __m512bh x;
73 unsigned short a[32];
74 } union512bf16_uw;
75
76 typedef union
77 {
78 __m512bh x;
79 __bf16 a[32];
80 } union512bf16_bf;
81
82 typedef union
83 {
84 __m128h x;
85 _Float16 a[8];
86 } union128h;
87
88 typedef union
89 {
90 __m256h x;
91 _Float16 a[16];
92 } union256h;
93
94 typedef union
95 {
96 __m128bh x;
97 unsigned short a[8];
98 } union128bf16_uw;
99
100 typedef union
101 {
102 __m256bh x;
103 unsigned short a[16];
104 } union256bf16_uw;
105
106 typedef union
107 {
108 __m128bh x;
109 __bf16 a[8];
110 } union128bf16_bf;
111
112 typedef union
113 {
114 __m256bh x;
115 __bf16 a[16];
116 } union256bf16_bf;
117
118 #define CHECK_ROUGH_EXP(UNION_TYPE, VALUE_TYPE, FMT) \
119 static int \
120 __attribute__((noinline, unused)) \
121 check_rough_##UNION_TYPE (UNION_TYPE u, const VALUE_TYPE *v, \
122 VALUE_TYPE eps) \
123 { \
124 int i; \
125 int err = 0; \
126 \
127 for (i = 0; i < ARRAY_SIZE (u.a); i++) \
128 { \
129 /* We can have have v[i] == 0 == u.a[i] for some i, \
130 when we test zero-masking. */ \
131 if (v[i] == 0.0 && u.a[i] == 0.0) \
132 continue; \
133 if (v[i] == 0.0 && u.a[i] != 0.0) \
134 { \
135 err++; \
136 PRINTF ("%i: " FMT " != " FMT "\n", \
137 i, v[i], u.a[i]); \
138 } \
139 VALUE_TYPE rel_err = (u.a[i] - v[i]) / v[i]; \
140 if (((rel_err < 0) ? -rel_err : rel_err) > eps) \
141 { \
142 err++; \
143 PRINTF ("%i: " FMT " != " FMT "\n", \
144 i, v[i], u.a[i]); \
145 } \
146 } \
147 return err; \
148 }
149
150 #ifndef ESP_FLOAT16
151 #define ESP_FLOAT16 0.27
152 #endif
153
154 CHECK_ROUGH_EXP (union256, float, "%f")
155 CHECK_ROUGH_EXP (union256d, double, "%f")
156 CHECK_ROUGH_EXP (union128, float, "%f")
157 CHECK_ROUGH_EXP (union128d, double, "%f")
158
159 #ifndef AVX512F_LEN
160 CHECK_EXP (union512i_b, char, "%d")
161 CHECK_EXP (union512i_w, short, "%d")
162 CHECK_EXP (union512i_d, int, "0x%x")
163 CHECK_EXP (union512i_q, long long, "0x%llx")
164 CHECK_EXP (union512, float, "%f")
165 CHECK_EXP (union512d, double, "%f")
166 CHECK_EXP (union512i_ub, unsigned char, "%d")
167 CHECK_EXP (union512i_uw, unsigned short, "%d")
168 CHECK_EXP (union512i_ud, unsigned int, "0x%x")
169 CHECK_EXP (union512i_uq, unsigned long long, "0x%llx")
170
171 CHECK_FP_EXP (union512, float, ESP_FLOAT, "%f")
172 CHECK_FP_EXP (union512d, double, ESP_DOUBLE, "%f")
173
174 CHECK_ROUGH_EXP (union512, float, "%f")
175 CHECK_ROUGH_EXP (union512d, double, "%f")
176
177 #if defined(AVX512FP16)
178 CHECK_EXP (union512h, _Float16, "%f")
179 CHECK_FP_EXP (union512h, _Float16, ESP_FLOAT16, "%f")
180 CHECK_ROUGH_EXP (union512h, _Float16, "%f")
181 #endif
182 #endif
183
184 #if defined(AVX512FP16)
185 CHECK_EXP (union128h, _Float16, "%f")
186 CHECK_EXP (union256h, _Float16, "%f")
187
188 CHECK_FP_EXP (union128h, _Float16, ESP_FLOAT16, "%f")
189 CHECK_FP_EXP (union256h, _Float16, ESP_FLOAT16, "%f")
190
191 CHECK_ROUGH_EXP (union128h, _Float16, "%f")
192 CHECK_ROUGH_EXP (union256h, _Float16, "%f")
193 #endif
194
195 #if defined(AVX512BF16)
196 CHECK_EXP (union512bf16_uw, unsigned short, "%d")
197 CHECK_EXP (union512bf16_bf, __bf16, "%f")
198 #endif
199
200 #if defined(AVX512BF16)
201 CHECK_EXP (union128bf16_uw, unsigned short, "%d")
202 CHECK_EXP (union256bf16_uw, unsigned short, "%d")
203 CHECK_EXP (union128bf16_bf, __bf16, "%f")
204 CHECK_EXP (union256bf16_bf, __bf16, "%f")
205 #endif