| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx512fp16 -mavx512vl" } */ |
| 3 |
/* { dg-require-effective-target avx512fp16 } */ |
| 4 |
|
| 5 |
#define AVX512FP16 |
| 6 |
#include "avx512f-helper.h" |
| 7 |
|
| 8 |
__attribute__((optimize("O2"),noipa)) |
| 9 |
void func1(_Float16 *a, _Float16 *b, int n, _Float16 *c) { |
| 10 |
__m512h rA = _mm512_loadu_ph(a); |
| 11 |
for (int i = 0; i < n; i += 32) { |
| 12 |
__m512h rB = _mm512_loadu_ph(b + i); |
| 13 |
_mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA)); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
test_512 (void) |
| 19 |
{ |
| 20 |
int n = 32; |
| 21 |
_Float16 a[n], b[n], c[n]; |
| 22 |
_Float16 exp[n]; |
| 23 |
for (int i = 1; i <= n; i++) { |
| 24 |
a[i - 1] = i & 1 ? -i : i; |
| 25 |
b[i - 1] = i; |
| 26 |
} |
| 27 |
|
| 28 |
func1(a, b, n, c); |
| 29 |
for (int i = 0; i < n / 32; i += 2) { |
| 30 |
if (c[i] != a[i] * b[i] + a[i+1] * b[i+1] |
| 31 |
|| c[i+1] != a[i] * b[i+1] - a[i+1]*b[i]) |
| 32 |
__builtin_abort (); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
|