| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -march=x86-64-v3 -mavx10.2" } */ |
| 3 |
/* { dg-require-effective-target avx10_2 } */ |
| 4 |
|
| 5 |
#ifndef AVX10_2 |
| 6 |
#define AVX10_2 |
| 7 |
#define AVX10_2_512 |
| 8 |
#define AVX10_512BIT |
| 9 |
#endif |
| 10 |
|
| 11 |
#include "avx10-helper.h" |
| 12 |
#include "fp8-helper.h" |
| 13 |
|
| 14 |
#define SIZE_SRC (AVX512F_LEN_HALF / 8) |
| 15 |
#define SIZE (AVX512F_LEN / 16) |
| 16 |
#include "avx512f-mask-type.h" |
| 17 |
|
| 18 |
void |
| 19 |
CALC (_Float16 *r, unsigned char *s) |
| 20 |
{ |
| 21 |
int i; |
| 22 |
for (i = 0; i < SIZE; i++) |
| 23 |
r[i] = convert_hf8_to_fp16(s[i]); |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
TEST (void) |
| 28 |
{ |
| 29 |
int i,sign; |
| 30 |
UNION_TYPE (AVX512F_LEN, h) res1, res2, res3; |
| 31 |
UNION_TYPE (AVX512F_LEN_HALF, i_b) src; |
| 32 |
MASK_TYPE mask = MASK_VALUE; |
| 33 |
_Float16 res_ref[SIZE]; |
| 34 |
|
| 35 |
sign = 1; |
| 36 |
for (i = 0; i < SIZE_SRC; i++) |
| 37 |
{ |
| 38 |
src.a[i] = sign * (2.5 * (1 << (i % 3))); |
| 39 |
sign = -sign; |
| 40 |
} |
| 41 |
|
| 42 |
for (i = 0; i < SIZE; i++) |
| 43 |
res2.a[i] = DEFAULT_VALUE; |
| 44 |
|
| 45 |
CALC(res_ref, src.a); |
| 46 |
|
| 47 |
res1.x = INTRINSIC (_cvthf8_ph) (src.x); |
| 48 |
if (UNION_ROUGH_CHECK (AVX512F_LEN, h) (res1, res_ref, 0.0009765625)) |
| 49 |
abort (); |
| 50 |
|
| 51 |
res2.x = INTRINSIC (_mask_cvthf8_ph) (res2.x, mask, src.x); |
| 52 |
MASK_MERGE (h) (res_ref, mask, SIZE); |
| 53 |
if (UNION_ROUGH_CHECK (AVX512F_LEN, h) (res2, res_ref, 0.0009765625)) |
| 54 |
abort (); |
| 55 |
|
| 56 |
res3.x = INTRINSIC (_maskz_cvthf8_ph) (mask, src.x); |
| 57 |
MASK_ZERO (h) (res_ref, mask, SIZE); |
| 58 |
if (UNION_ROUGH_CHECK (AVX512F_LEN, h) (res3, res_ref, 0.0009765625)) |
| 59 |
abort (); |
| 60 |
} |