1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/* { dg-do run } */
/* { dg-options "-O2 -mavx512f" } */
/* { dg-require-effective-target avx512f } */
#define AVX512F
#include "avx512f-helper.h"
#define SIZE (AVX512F_LEN / 32)
#include "avx512f-mask-type.h"
#include "math.h"
static void
CALC (float *s, float *r, int imm)
{
int i = 0, rc, m;
rc = imm & 0xf;
m = imm >> 4;
for (i = 0; i < SIZE; i++)
switch (rc)
{
case _MM_FROUND_FLOOR:
r[i] = floor (s[i] * pow (2, m)) / pow (2, m);
break;
case _MM_FROUND_CEIL:
r[i] = ceil (s[i] * pow (2, m)) / pow (2, m);
break;
default:
abort ();
break;
}
}
void
TEST (void)
{
int imm, i, j;
UNION_TYPE (AVX512F_LEN,) res1, res2, res3, s;
float res_ref[SIZE];
MASK_TYPE mask = MASK_VALUE;
imm = _MM_FROUND_FLOOR | (7 << 4);
for (i = 0; i < 3; i++)
{
for (j = 0; j < SIZE; j++)
{
s.a[j] = j * (j + 12.0231);
res1.a[j] = DEFAULT_VALUE;
res2.a[j] = DEFAULT_VALUE;
res3.a[j] = DEFAULT_VALUE;
}
switch (i)
{
case 0:
imm = _MM_FROUND_FLOOR | (7 << 4);
res1.x = INTRINSIC (_roundscale_ps) (s.x, imm);
res2.x = INTRINSIC (_mask_roundscale_ps) (res2.x, mask, s.x, imm);
res3.x = INTRINSIC (_maskz_roundscale_ps) (mask, s.x, imm);
break;
case 1:
imm = _MM_FROUND_FLOOR;
res1.x = INTRINSIC (_floor_ps) (s.x);
#if AVX512F_LEN == 512
res2.x = INTRINSIC (_mask_floor_ps) (res2.x, mask, s.x);
#endif
break;
case 2:
imm = _MM_FROUND_CEIL;
res1.x = INTRINSIC (_ceil_ps) (s.x);
#if AVX512F_LEN == 512
res2.x = INTRINSIC (_mask_ceil_ps) (res2.x, mask, s.x);
#endif
break;
}
CALC (s.a, res_ref, imm);
if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
abort ();
MASK_MERGE ()(res_ref, mask, SIZE);
#if AVX512F_LEN == 512
if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
abort ();
#else
if (!i && UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
abort ();
#endif
MASK_ZERO ()(res_ref, mask, SIZE);
if (!i && UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
abort ();
}
}
|