1 |
328 |
jeremybenn |
#include <stdio.h>
|
2 |
|
|
#include "avx-check.h"
|
3 |
|
|
#include "args.h"
|
4 |
|
|
|
5 |
|
|
struct IntegerRegisters iregs;
|
6 |
|
|
struct FloatRegisters fregs;
|
7 |
|
|
unsigned int num_iregs, num_fregs;
|
8 |
|
|
|
9 |
|
|
/* This struct holds values for argument checking. */
|
10 |
|
|
struct
|
11 |
|
|
{
|
12 |
|
|
YMM_T i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
|
13 |
|
|
} values;
|
14 |
|
|
|
15 |
|
|
char *pass;
|
16 |
|
|
int failed = 0;
|
17 |
|
|
|
18 |
|
|
#undef assert
|
19 |
|
|
#define assert(c) do { \
|
20 |
|
|
if (!(c)) {failed++; printf ("failed %s\n", pass); } \
|
21 |
|
|
} while (0)
|
22 |
|
|
|
23 |
|
|
#define compare(X1,X2,T) do { \
|
24 |
|
|
assert (memcmp (&X1, &X2, sizeof (T)) == 0); \
|
25 |
|
|
} while (0)
|
26 |
|
|
|
27 |
|
|
fun_check_passing_m256_8_values (__m256 i0 ATTRIBUTE_UNUSED, __m256 i1 ATTRIBUTE_UNUSED, __m256 i2 ATTRIBUTE_UNUSED, __m256 i3 ATTRIBUTE_UNUSED, __m256 i4 ATTRIBUTE_UNUSED, __m256 i5 ATTRIBUTE_UNUSED, __m256 i6 ATTRIBUTE_UNUSED, __m256 i7 ATTRIBUTE_UNUSED)
|
28 |
|
|
{
|
29 |
|
|
/* Check argument values. */
|
30 |
|
|
compare (values.i0, i0, __m256);
|
31 |
|
|
compare (values.i1, i1, __m256);
|
32 |
|
|
compare (values.i2, i2, __m256);
|
33 |
|
|
compare (values.i3, i3, __m256);
|
34 |
|
|
compare (values.i4, i4, __m256);
|
35 |
|
|
compare (values.i5, i5, __m256);
|
36 |
|
|
compare (values.i6, i6, __m256);
|
37 |
|
|
compare (values.i7, i7, __m256);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
void
|
41 |
|
|
fun_check_passing_m256_8_regs (__m256 i0 ATTRIBUTE_UNUSED, __m256 i1 ATTRIBUTE_UNUSED, __m256 i2 ATTRIBUTE_UNUSED, __m256 i3 ATTRIBUTE_UNUSED, __m256 i4 ATTRIBUTE_UNUSED, __m256 i5 ATTRIBUTE_UNUSED, __m256 i6 ATTRIBUTE_UNUSED, __m256 i7 ATTRIBUTE_UNUSED)
|
42 |
|
|
{
|
43 |
|
|
/* Check register contents. */
|
44 |
|
|
check_m256_arguments;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
void
|
48 |
|
|
fun_check_passing_m256_20_values (__m256 i0 ATTRIBUTE_UNUSED, __m256 i1 ATTRIBUTE_UNUSED, __m256 i2 ATTRIBUTE_UNUSED, __m256 i3 ATTRIBUTE_UNUSED, __m256 i4 ATTRIBUTE_UNUSED, __m256 i5 ATTRIBUTE_UNUSED, __m256 i6 ATTRIBUTE_UNUSED, __m256 i7 ATTRIBUTE_UNUSED, __m256 i8 ATTRIBUTE_UNUSED, __m256 i9 ATTRIBUTE_UNUSED, __m256 i10 ATTRIBUTE_UNUSED, __m256 i11 ATTRIBUTE_UNUSED, __m256 i12 ATTRIBUTE_UNUSED, __m256 i13 ATTRIBUTE_UNUSED, __m256 i14 ATTRIBUTE_UNUSED, __m256 i15 ATTRIBUTE_UNUSED, __m256 i16 ATTRIBUTE_UNUSED, __m256 i17 ATTRIBUTE_UNUSED, __m256 i18 ATTRIBUTE_UNUSED, __m256 i19 ATTRIBUTE_UNUSED)
|
49 |
|
|
{
|
50 |
|
|
/* Check argument values. */
|
51 |
|
|
compare (values.i0, i0, __m256);
|
52 |
|
|
compare (values.i1, i1, __m256);
|
53 |
|
|
compare (values.i2, i2, __m256);
|
54 |
|
|
compare (values.i3, i3, __m256);
|
55 |
|
|
compare (values.i4, i4, __m256);
|
56 |
|
|
compare (values.i5, i5, __m256);
|
57 |
|
|
compare (values.i6, i6, __m256);
|
58 |
|
|
compare (values.i7, i7, __m256);
|
59 |
|
|
compare (values.i8, i8, __m256);
|
60 |
|
|
compare (values.i9, i9, __m256);
|
61 |
|
|
compare (values.i10, i10, __m256);
|
62 |
|
|
compare (values.i11, i11, __m256);
|
63 |
|
|
compare (values.i12, i12, __m256);
|
64 |
|
|
compare (values.i13, i13, __m256);
|
65 |
|
|
compare (values.i14, i14, __m256);
|
66 |
|
|
compare (values.i15, i15, __m256);
|
67 |
|
|
compare (values.i16, i16, __m256);
|
68 |
|
|
compare (values.i17, i17, __m256);
|
69 |
|
|
compare (values.i18, i18, __m256);
|
70 |
|
|
compare (values.i19, i19, __m256);
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
void
|
74 |
|
|
fun_check_passing_m256_20_regs (__m256 i0 ATTRIBUTE_UNUSED, __m256 i1 ATTRIBUTE_UNUSED, __m256 i2 ATTRIBUTE_UNUSED, __m256 i3 ATTRIBUTE_UNUSED, __m256 i4 ATTRIBUTE_UNUSED, __m256 i5 ATTRIBUTE_UNUSED, __m256 i6 ATTRIBUTE_UNUSED, __m256 i7 ATTRIBUTE_UNUSED, __m256 i8 ATTRIBUTE_UNUSED, __m256 i9 ATTRIBUTE_UNUSED, __m256 i10 ATTRIBUTE_UNUSED, __m256 i11 ATTRIBUTE_UNUSED, __m256 i12 ATTRIBUTE_UNUSED, __m256 i13 ATTRIBUTE_UNUSED, __m256 i14 ATTRIBUTE_UNUSED, __m256 i15 ATTRIBUTE_UNUSED, __m256 i16 ATTRIBUTE_UNUSED, __m256 i17 ATTRIBUTE_UNUSED, __m256 i18 ATTRIBUTE_UNUSED, __m256 i19 ATTRIBUTE_UNUSED)
|
75 |
|
|
{
|
76 |
|
|
/* Check register contents. */
|
77 |
|
|
check_m256_arguments;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
#define def_check_passing8(_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _func1, _func2, TYPE) \
|
82 |
|
|
values.i0.TYPE[0] = _i0; \
|
83 |
|
|
values.i1.TYPE[0] = _i1; \
|
84 |
|
|
values.i2.TYPE[0] = _i2; \
|
85 |
|
|
values.i3.TYPE[0] = _i3; \
|
86 |
|
|
values.i4.TYPE[0] = _i4; \
|
87 |
|
|
values.i5.TYPE[0] = _i5; \
|
88 |
|
|
values.i6.TYPE[0] = _i6; \
|
89 |
|
|
values.i7.TYPE[0] = _i7; \
|
90 |
|
|
WRAP_CALL(_func1) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7); \
|
91 |
|
|
\
|
92 |
|
|
clear_struct_registers; \
|
93 |
|
|
fregs.F0.TYPE[0] = _i0; \
|
94 |
|
|
fregs.F1.TYPE[0] = _i1; \
|
95 |
|
|
fregs.F2.TYPE[0] = _i2; \
|
96 |
|
|
fregs.F3.TYPE[0] = _i3; \
|
97 |
|
|
fregs.F4.TYPE[0] = _i4; \
|
98 |
|
|
fregs.F5.TYPE[0] = _i5; \
|
99 |
|
|
fregs.F6.TYPE[0] = _i6; \
|
100 |
|
|
fregs.F7.TYPE[0] = _i7; \
|
101 |
|
|
num_fregs = 8; \
|
102 |
|
|
WRAP_CALL(_func2) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7);
|
103 |
|
|
|
104 |
|
|
#define def_check_passing20(_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11, _i12, _i13, _i14, _i15, _i16, _i17, _i18, _i19, _func1, _func2, TYPE) \
|
105 |
|
|
values.i0.TYPE[0] = _i0; \
|
106 |
|
|
values.i1.TYPE[0] = _i1; \
|
107 |
|
|
values.i2.TYPE[0] = _i2; \
|
108 |
|
|
values.i3.TYPE[0] = _i3; \
|
109 |
|
|
values.i4.TYPE[0] = _i4; \
|
110 |
|
|
values.i5.TYPE[0] = _i5; \
|
111 |
|
|
values.i6.TYPE[0] = _i6; \
|
112 |
|
|
values.i7.TYPE[0] = _i7; \
|
113 |
|
|
values.i8.TYPE[0] = _i8; \
|
114 |
|
|
values.i9.TYPE[0] = _i9; \
|
115 |
|
|
values.i10.TYPE[0] = _i10; \
|
116 |
|
|
values.i11.TYPE[0] = _i11; \
|
117 |
|
|
values.i12.TYPE[0] = _i12; \
|
118 |
|
|
values.i13.TYPE[0] = _i13; \
|
119 |
|
|
values.i14.TYPE[0] = _i14; \
|
120 |
|
|
values.i15.TYPE[0] = _i15; \
|
121 |
|
|
values.i16.TYPE[0] = _i16; \
|
122 |
|
|
values.i17.TYPE[0] = _i17; \
|
123 |
|
|
values.i18.TYPE[0] = _i18; \
|
124 |
|
|
values.i19.TYPE[0] = _i19; \
|
125 |
|
|
WRAP_CALL(_func1) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11, _i12, _i13, _i14, _i15, _i16, _i17, _i18, _i19); \
|
126 |
|
|
\
|
127 |
|
|
clear_struct_registers; \
|
128 |
|
|
fregs.F0.TYPE[0] = _i0; \
|
129 |
|
|
fregs.F1.TYPE[0] = _i1; \
|
130 |
|
|
fregs.F2.TYPE[0] = _i2; \
|
131 |
|
|
fregs.F3.TYPE[0] = _i3; \
|
132 |
|
|
fregs.F4.TYPE[0] = _i4; \
|
133 |
|
|
fregs.F5.TYPE[0] = _i5; \
|
134 |
|
|
fregs.F6.TYPE[0] = _i6; \
|
135 |
|
|
fregs.F7.TYPE[0] = _i7; \
|
136 |
|
|
num_fregs = 8; \
|
137 |
|
|
WRAP_CALL(_func2) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11, _i12, _i13, _i14, _i15, _i16, _i17, _i18, _i19);
|
138 |
|
|
|
139 |
|
|
void
|
140 |
|
|
test_m256_on_stack ()
|
141 |
|
|
{
|
142 |
|
|
__m256 x[8];
|
143 |
|
|
int i;
|
144 |
|
|
for (i = 0; i < 8; i++)
|
145 |
|
|
x[i] = (__m256){32+i, 0, 0, 0, 0, 0, 0, 0};
|
146 |
|
|
pass = "m256-8";
|
147 |
|
|
def_check_passing8(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], fun_check_passing_m256_8_values, fun_check_passing_m256_8_regs, _m256);
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
void
|
151 |
|
|
test_too_many_m256 ()
|
152 |
|
|
{
|
153 |
|
|
__m256 x[20];
|
154 |
|
|
int i;
|
155 |
|
|
for (i = 0; i < 20; i++)
|
156 |
|
|
x[i] = (__m256){32+i, 0, 0, 0, 0, 0, 0, 0};
|
157 |
|
|
pass = "m256-20";
|
158 |
|
|
def_check_passing20(x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], fun_check_passing_m256_20_values, fun_check_passing_m256_20_regs, _m256);
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
static void
|
162 |
|
|
avx_test (void)
|
163 |
|
|
{
|
164 |
|
|
test_m256_on_stack ();
|
165 |
|
|
test_too_many_m256 ();
|
166 |
|
|
if (failed)
|
167 |
|
|
abort ();
|
168 |
|
|
}
|