Debian Codegraph @

gcc/testsuite/gcc.target/i386/amxavx512-cvtrowps2bf16-2.c

raw
1 /* { dg-do run { target { ! ia32 } } } */
2 /* { dg-require-effective-target amx_avx512 } */
3 /* { dg-options "-O2 -march=x86-64-v3 -mamx-avx512 -mavx512fp16" } */
4 #define AMX_AVX512
5 #define DO_TEST test_amx_avx512_cvtrowps2bf16
6 void test_amx_avx512_cvtrowps2bf16();
7 #include "amx-helper.h"
8
9 volatile __m512bh cal_dst, cmp_dst;
10
11 #define DEFINE_TEST_CVTROWPS2BF16(HL, EI, T) \
12 __m512bh \
13 __attribute__((noinline, noclone, __target__("no-amx-avx512"))) \
14 calc_cvtrowps2bf16##HL##EI (__tile *src, T __A) \
15 { \
16 float *src_buf = (float *) src->buf; \
17 int N = src->colsb / 4; \
18 int vl = 512; \
19 int vl_bytes = vl >> 3; \
20 int row_index, row_chunk, zeropos, pos, j, k; \
21 __m512bh res; \
22 if ((#EI) == "e") \
23 { \
24 row_index = (__A) & 0xffff; \
25 row_chunk = (((__A) >> 16) & 0xffff) * vl_bytes; \
26 } \
27 else \
28 { \
29 row_index = (__A) & 0x3f; \
30 row_chunk = ((__A) >> 6) * vl_bytes; \
31 } \
32 if ((#HL) == "h") \
33 { \
34 zeropos = 0; \
35 pos = 1; \
36 } \
37 else \
38 { \
39 zeropos = 1; \
40 pos = 0; \
41 } \
42 for (j = 0; j < vl_bytes / 4; j++) \
43 if (j + row_chunk / 4 >= N) \
44 for (k = 0; k < 2; k++) \
45 res[2 * j + k] = 0; \
46 else \
47 { \
48 union16bh_uw tmp; \
49 tmp.u = make_f32_bf16 (src_buf[row_index * N + j + row_chunk / 4]); \
50 res[2 * j + pos] = tmp.bf16; \
51 res[2 * j + zeropos] = (__bf16) 0; \
52 } \
53 return res; \
54 }
55
56 DEFINE_TEST_CVTROWPS2BF16(h, e, unsigned)
57 DEFINE_TEST_CVTROWPS2BF16(l, e, unsigned)
58 DEFINE_TEST_CVTROWPS2BF16(h, i, const unsigned)
59 DEFINE_TEST_CVTROWPS2BF16(l, i, const unsigned)
60
61 #define TEST_CVTROWPS2BF16(X, Y, HL, EI, T, INTRIN) \
62 cal_dst = calc_cvtrowps2bf16##HL##EI (X, Y); \
63 cmp_dst = _tile_##INTRIN (1, Y); \
64 COMPARE_ZMM_BF16(cal_dst, cmp_dst);
65
66 void test_amx_avx512_cvtrowps2bf16 ()
67 {
68 __tilecfg_u cfg;
69 __tile src;
70 uint8_t tmp_dst_buf[1024];
71 unsigned a = 2;
72
73 init_fp32_max_tile_buffer (tmp_dst_buf);
74
75 init_tile_config (&cfg);
76 init_tile_reg_and_src_with_buffer (1, src, tmp_dst_buf);
77
78 TEST_CVTROWPS2BF16 (&src, a, h, e, unsigned, cvtrowps2bf16h);
79 TEST_CVTROWPS2BF16 (&src, a, l, e, unsigned, cvtrowps2bf16l);
80 TEST_CVTROWPS2BF16 (&src, 1, h, i, const unsigned, cvtrowps2bf16hi);
81 TEST_CVTROWPS2BF16 (&src, 1, l, i, const unsigned, cvtrowps2bf16li);
82 }