@@ -37,6 +37,108 @@ volatile uchar2 uc2;
3737volatile uchar3 uc3;
3838volatile uchar4 uc4;
3939
40+ #define DECL_INT(prefix) \
41+ volatile char prefix##_c_1 = 1; \
42+ volatile char2 prefix##_c_2 = 1; \
43+ volatile char3 prefix##_c_3 = 1; \
44+ volatile char4 prefix##_c_4 = 1; \
45+ volatile uchar prefix##_uc_1 = 1; \
46+ volatile uchar2 prefix##_uc_2 = 1; \
47+ volatile uchar3 prefix##_uc_3 = 1; \
48+ volatile uchar4 prefix##_uc_4 = 1; \
49+ volatile short prefix##_s_1 = 1; \
50+ volatile short2 prefix##_s_2 = 1; \
51+ volatile short3 prefix##_s_3 = 1; \
52+ volatile short4 prefix##_s_4 = 1; \
53+ volatile ushort prefix##_us_1 = 1; \
54+ volatile ushort2 prefix##_us_2 = 1; \
55+ volatile ushort3 prefix##_us_3 = 1; \
56+ volatile ushort4 prefix##_us_4 = 1; \
57+ volatile int prefix##_i_1 = 1; \
58+ volatile int2 prefix##_i_2 = 1; \
59+ volatile int3 prefix##_i_3 = 1; \
60+ volatile int4 prefix##_i_4 = 1; \
61+ volatile uint prefix##_ui_1 = 1; \
62+ volatile uint2 prefix##_ui_2 = 1; \
63+ volatile uint3 prefix##_ui_3 = 1; \
64+ volatile uint4 prefix##_ui_4 = 1; \
65+ volatile long prefix##_l_1 = 1; \
66+ volatile ulong prefix##_ul_1 = 1;
67+
68+ DECL_INT(res)
69+ DECL_INT(src1)
70+ DECL_INT(src2)
71+
72+ #define TEST_INT_OP_TYPE(op, type) \
73+ rsDebug("Testing " #op " for " #type "1", i++); \
74+ res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
75+ rsDebug("Testing " #op " for " #type "2", i++); \
76+ res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
77+ rsDebug("Testing " #op " for " #type "3", i++); \
78+ res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
79+ rsDebug("Testing " #op " for " #type "4", i++); \
80+ res_##type##_4 = src1_##type##_4 op src2_##type##_4;
81+
82+ #define TEST_INT_OP(op) \
83+ TEST_INT_OP_TYPE(op, c) \
84+ TEST_INT_OP_TYPE(op, uc) \
85+ TEST_INT_OP_TYPE(op, s) \
86+ TEST_INT_OP_TYPE(op, us) \
87+ TEST_INT_OP_TYPE(op, i) \
88+ TEST_INT_OP_TYPE(op, ui) \
89+ rsDebug("Testing " #op " for l1", i++); \
90+ res_l_1 = src1_l_1 op src2_l_1; \
91+ rsDebug("Testing " #op " for ul1", i++); \
92+ res_ul_1 = src1_ul_1 op src2_ul_1;
93+
94+ #define TEST_XN_FUNC_YN(typeout, fnc, typein) \
95+ res_##typeout##_1 = fnc(src1_##typein##_1); \
96+ res_##typeout##_2 = fnc(src1_##typein##_2); \
97+ res_##typeout##_3 = fnc(src1_##typein##_3); \
98+ res_##typeout##_4 = fnc(src1_##typein##_4);
99+
100+ #define TEST_XN_FUNC_XN_XN(type, fnc) \
101+ res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1); \
102+ res_##type##_2 = fnc(src1_##type##_2, src2_##type##_2); \
103+ res_##type##_3 = fnc(src1_##type##_3, src2_##type##_3); \
104+ res_##type##_4 = fnc(src1_##type##_4, src2_##type##_4);
105+
106+ #define TEST_X_FUNC_X_X_X(type, fnc) \
107+ res_##type##_1 = fnc(src1_##type##_1, src2_##type##_1, src2_##type##_1);
108+
109+ #define TEST_IN_FUNC_IN(fnc) \
110+ rsDebug("Testing " #fnc, 0); \
111+ TEST_XN_FUNC_YN(uc, fnc, uc) \
112+ TEST_XN_FUNC_YN(c, fnc, c) \
113+ TEST_XN_FUNC_YN(us, fnc, us) \
114+ TEST_XN_FUNC_YN(s, fnc, s) \
115+ TEST_XN_FUNC_YN(ui, fnc, ui) \
116+ TEST_XN_FUNC_YN(i, fnc, i)
117+
118+ #define TEST_UIN_FUNC_IN(fnc) \
119+ rsDebug("Testing " #fnc, 0); \
120+ TEST_XN_FUNC_YN(uc, fnc, c) \
121+ TEST_XN_FUNC_YN(us, fnc, s) \
122+ TEST_XN_FUNC_YN(ui, fnc, i) \
123+
124+ #define TEST_IN_FUNC_IN_IN(fnc) \
125+ rsDebug("Testing " #fnc, 0); \
126+ TEST_XN_FUNC_XN_XN(uc, fnc) \
127+ TEST_XN_FUNC_XN_XN(c, fnc) \
128+ TEST_XN_FUNC_XN_XN(us, fnc) \
129+ TEST_XN_FUNC_XN_XN(s, fnc) \
130+ TEST_XN_FUNC_XN_XN(ui, fnc) \
131+ TEST_XN_FUNC_XN_XN(i, fnc)
132+
133+ #define TEST_I_FUNC_I_I_I(fnc) \
134+ rsDebug("Testing " #fnc, 0); \
135+ TEST_X_FUNC_X_X_X(uc, fnc) \
136+ TEST_X_FUNC_X_X_X(c, fnc) \
137+ TEST_X_FUNC_X_X_X(us, fnc) \
138+ TEST_X_FUNC_X_X_X(s, fnc) \
139+ TEST_X_FUNC_X_X_X(ui, fnc) \
140+ TEST_X_FUNC_X_X_X(i, fnc)
141+
40142#define TEST_FN_FUNC_FN(fnc) \
41143 rsDebug("Testing " #fnc, 0); \
42144 f1 = fnc(f1); \
@@ -58,13 +160,32 @@ volatile uchar4 uc4;
58160 f3 = fnc(f3, f3); \
59161 f4 = fnc(f4, f4);
60162
163+ #define TEST_F34_FUNC_F34_F34(fnc) \
164+ rsDebug("Testing " #fnc, 0); \
165+ f3 = fnc(f3, f3); \
166+ f4 = fnc(f4, f4);
167+
61168#define TEST_FN_FUNC_FN_F(fnc) \
62169 rsDebug("Testing " #fnc, 0); \
63170 f1 = fnc(f1, f1); \
64171 f2 = fnc(f2, f1); \
65172 f3 = fnc(f3, f1); \
66173 f4 = fnc(f4, f1);
67174
175+ #define TEST_F_FUNC_FN(fnc) \
176+ rsDebug("Testing " #fnc, 0); \
177+ f1 = fnc(f1); \
178+ f1 = fnc(f2); \
179+ f1 = fnc(f3); \
180+ f1 = fnc(f4);
181+
182+ #define TEST_F_FUNC_FN_FN(fnc) \
183+ rsDebug("Testing " #fnc, 0); \
184+ f1 = fnc(f1, f1); \
185+ f1 = fnc(f2, f2); \
186+ f1 = fnc(f3, f3); \
187+ f1 = fnc(f4, f4);
188+
68189#define TEST_FN_FUNC_FN_IN(fnc) \
69190 rsDebug("Testing " #fnc, 0); \
70191 f1 = fnc(f1, i1); \
@@ -86,6 +207,13 @@ volatile uchar4 uc4;
86207 f3 = fnc(f3, f3, f3); \
87208 f4 = fnc(f4, f4, f4);
88209
210+ #define TEST_FN_FUNC_FN_FN_F(fnc) \
211+ rsDebug("Testing " #fnc, 0); \
212+ f1 = fnc(f1, f1, f1); \
213+ f2 = fnc(f2, f1, f1); \
214+ f3 = fnc(f3, f1, f1); \
215+ f4 = fnc(f4, f1, f1);
216+
89217#define TEST_FN_FUNC_FN_PIN(fnc) \
90218 rsDebug("Testing " #fnc, 0); \
91219 f1 = fnc(f1, (int*) &i1); \
@@ -107,7 +235,6 @@ volatile uchar4 uc4;
107235 i3 = fnc(f3); \
108236 i4 = fnc(f4);
109237
110-
111238static bool test_fp_math(uint32_t index) {
112239 bool failed = false;
113240 start();
@@ -125,10 +252,16 @@ static bool test_fp_math(uint32_t index) {
125252 TEST_FN_FUNC_FN_FN(atan2pi);
126253 TEST_FN_FUNC_FN(cbrt);
127254 TEST_FN_FUNC_FN(ceil);
255+ TEST_FN_FUNC_FN_FN_FN(clamp);
256+ TEST_FN_FUNC_FN_FN_F(clamp);
128257 TEST_FN_FUNC_FN_FN(copysign);
129258 TEST_FN_FUNC_FN(cos);
130259 TEST_FN_FUNC_FN(cosh);
131260 TEST_FN_FUNC_FN(cospi);
261+ TEST_F34_FUNC_F34_F34(cross);
262+ TEST_FN_FUNC_FN(degrees);
263+ TEST_F_FUNC_FN_FN(distance);
264+ TEST_F_FUNC_FN_FN(dot);
132265 TEST_FN_FUNC_FN(erfc);
133266 TEST_FN_FUNC_FN(erf);
134267 TEST_FN_FUNC_FN(exp);
@@ -150,6 +283,7 @@ static bool test_fp_math(uint32_t index) {
150283 TEST_IN_FUNC_FN(ilogb);
151284 TEST_FN_FUNC_FN_IN(ldexp);
152285 TEST_FN_FUNC_FN_I(ldexp);
286+ TEST_F_FUNC_FN(length);
153287 TEST_FN_FUNC_FN(lgamma);
154288 TEST_FN_FUNC_FN_PIN(lgamma);
155289 TEST_FN_FUNC_FN(log);
@@ -158,23 +292,34 @@ static bool test_fp_math(uint32_t index) {
158292 TEST_FN_FUNC_FN(log1p);
159293 TEST_FN_FUNC_FN(logb);
160294 TEST_FN_FUNC_FN_FN_FN(mad);
295+ TEST_FN_FUNC_FN_FN(max);
296+ TEST_FN_FUNC_FN_F(max);
297+ TEST_FN_FUNC_FN_FN(min);
298+ TEST_FN_FUNC_FN_F(min);
299+ TEST_FN_FUNC_FN_FN_FN(mix);
300+ TEST_FN_FUNC_FN_FN_F(mix);
161301 TEST_FN_FUNC_FN_PFN(modf);
162302 // nan
163303 TEST_FN_FUNC_FN_FN(nextafter);
304+ TEST_FN_FUNC_FN(normalize);
164305 TEST_FN_FUNC_FN_FN(pow);
165306 TEST_FN_FUNC_FN_IN(pown);
166307 TEST_FN_FUNC_FN_FN(powr);
308+ TEST_FN_FUNC_FN(radians);
167309 TEST_FN_FUNC_FN_FN(remainder);
168310 TEST_FN_FUNC_FN_FN_PIN(remquo);
169311 TEST_FN_FUNC_FN(rint);
170312 TEST_FN_FUNC_FN_IN(rootn);
171313 TEST_FN_FUNC_FN(round);
172314 TEST_FN_FUNC_FN(rsqrt);
315+ TEST_FN_FUNC_FN(sign);
173316 TEST_FN_FUNC_FN(sin);
174317 TEST_FN_FUNC_FN_PFN(sincos);
175318 TEST_FN_FUNC_FN(sinh);
176319 TEST_FN_FUNC_FN(sinpi);
177320 TEST_FN_FUNC_FN(sqrt);
321+ TEST_FN_FUNC_FN_FN(step);
322+ TEST_FN_FUNC_FN_F(step);
178323 TEST_FN_FUNC_FN(tan);
179324 TEST_FN_FUNC_FN(tanh);
180325 TEST_FN_FUNC_FN(tanpi);
@@ -193,59 +338,27 @@ static bool test_fp_math(uint32_t index) {
193338 return failed;
194339}
195340
196- #define DECL_INT(prefix) \
197- volatile char prefix##_c_1 = 1; \
198- volatile char2 prefix##_c_2 = 1; \
199- volatile char3 prefix##_c_3 = 1; \
200- volatile char4 prefix##_c_4 = 1; \
201- volatile uchar prefix##_uc_1 = 1; \
202- volatile uchar2 prefix##_uc_2 = 1; \
203- volatile uchar3 prefix##_uc_3 = 1; \
204- volatile uchar4 prefix##_uc_4 = 1; \
205- volatile short prefix##_s_1 = 1; \
206- volatile short2 prefix##_s_2 = 1; \
207- volatile short3 prefix##_s_3 = 1; \
208- volatile short4 prefix##_s_4 = 1; \
209- volatile ushort prefix##_us_1 = 1; \
210- volatile ushort2 prefix##_us_2 = 1; \
211- volatile ushort3 prefix##_us_3 = 1; \
212- volatile ushort4 prefix##_us_4 = 1; \
213- volatile int prefix##_i_1 = 1; \
214- volatile int2 prefix##_i_2 = 1; \
215- volatile int3 prefix##_i_3 = 1; \
216- volatile int4 prefix##_i_4 = 1; \
217- volatile uint prefix##_ui_1 = 1; \
218- volatile uint2 prefix##_ui_2 = 1; \
219- volatile uint3 prefix##_ui_3 = 1; \
220- volatile uint4 prefix##_ui_4 = 1; \
221- volatile long prefix##_l_1 = 1; \
222- volatile ulong prefix##_ul_1 = 1;
341+ static bool test_int_math(uint32_t index) {
342+ bool failed = false;
343+ start();
223344
224- #define TEST_INT_OP_TYPE(op, type) \
225- rsDebug("Testing " #op " for " #type "1", i++); \
226- res_##type##_1 = src1_##type##_1 op src2_##type##_1; \
227- rsDebug("Testing " #op " for " #type "2", i++); \
228- res_##type##_2 = src1_##type##_2 op src2_##type##_2; \
229- rsDebug("Testing " #op " for " #type "3", i++); \
230- res_##type##_3 = src1_##type##_3 op src2_##type##_3; \
231- rsDebug("Testing " #op " for " #type "4", i++); \
232- res_##type##_4 = src1_##type##_4 op src2_##type##_4;
345+ TEST_UIN_FUNC_IN(abs);
346+ TEST_IN_FUNC_IN(clz);
347+ TEST_IN_FUNC_IN_IN(min);
348+ TEST_IN_FUNC_IN_IN(max);
349+ TEST_I_FUNC_I_I_I(rsClamp);
233350
234- #define TEST_INT_OP(op) \
235- TEST_INT_OP_TYPE(op, c) \
236- TEST_INT_OP_TYPE(op, uc) \
237- TEST_INT_OP_TYPE(op, s) \
238- TEST_INT_OP_TYPE(op, us) \
239- TEST_INT_OP_TYPE(op, i) \
240- TEST_INT_OP_TYPE(op, ui) \
241- rsDebug("Testing " #op " for l1", i++); \
242- res_l_1 = src1_l_1 op src2_l_1; \
243- rsDebug("Testing " #op " for ul1", i++); \
244- res_ul_1 = src1_ul_1 op src2_ul_1;
351+ float time = end(index);
245352
246- DECL_INT(res)
247- DECL_INT(src1)
248- DECL_INT(src2)
353+ if (failed) {
354+ rsDebug("test_int_math FAILED", time);
355+ }
356+ else {
357+ rsDebug("test_int_math PASSED", time);
358+ }
359+
360+ return failed;
361+ }
249362
250363static bool test_basic_operators() {
251364 bool failed = false;
@@ -310,6 +423,7 @@ void math_test(uint32_t index, int test_num) {
310423 bool failed = false;
311424 failed |= test_convert();
312425 failed |= test_fp_math(index);
426+ failed |= test_int_math(index);
313427 failed |= test_basic_operators();
314428
315429 if (failed) {
0 commit comments