| 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_cvtrowps2ph |
| 6 |
void test_amx_avx512_cvtrowps2ph(); |
| 7 |
#include "amx-helper.h" |
| 8 |
|
| 9 |
volatile __m512h cal_dst, cmp_dst; |
| 10 |
|
| 11 |
#define DEFINE_TEST_CVTROWPS2PH(HL, EI, T) \ |
| 12 |
__m512h \ |
| 13 |
__attribute__((noinline, noclone, __target__("no-amx-avx512"))) \ |
| 14 |
calc_cvtrowps2ph##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 |
__m512h 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 |
union16f_uw tmp; \ |
| 49 |
tmp.u = make_f32_fp16 (src_buf[row_index * N + j + row_chunk / 4]); \ |
| 50 |
res[2 * j + zeropos] = 0; \ |
| 51 |
res[2 * j + pos] = tmp.f16; \ |
| 52 |
} \ |
| 53 |
return res; \ |
| 54 |
} |
| 55 |
|
| 56 |
DEFINE_TEST_CVTROWPS2PH(h, e, unsigned) |
| 57 |
DEFINE_TEST_CVTROWPS2PH(l, e, unsigned) |
| 58 |
DEFINE_TEST_CVTROWPS2PH(h, i, const unsigned) |
| 59 |
DEFINE_TEST_CVTROWPS2PH(l, i, const unsigned) |
| 60 |
|
| 61 |
#define TEST_CVTROWPS2PH(X, Y, HL, EI, T, INTRIN) \ |
| 62 |
cal_dst = calc_cvtrowps2ph##HL##EI (X, Y); \ |
| 63 |
cmp_dst = _tile_##INTRIN (1, Y); \ |
| 64 |
COMPARE_ZMM_FP16(cal_dst, cmp_dst); |
| 65 |
|
| 66 |
void test_amx_avx512_cvtrowps2ph () |
| 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_CVTROWPS2PH (&src, a, h, e, unsigned, cvtrowps2phh); |
| 79 |
TEST_CVTROWPS2PH (&src, a, l, e, unsigned, cvtrowps2phl); |
| 80 |
TEST_CVTROWPS2PH (&src, 1, h, i, const unsigned, cvtrowps2phhi); |
| 81 |
TEST_CVTROWPS2PH (&src, 1, l, i, const unsigned, cvtrowps2phli); |
| 82 |
} |