15 #include <freerdp/config.h>
17 #include <winpr/sysinfo.h>
18 #include "prim_test.h"
20 #define FUNC_TEST_SIZE 65536
22 static BOOL test_lShift_16s_func(
void)
25 INT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
26 INT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
28 winpr_RAND(&val,
sizeof(val));
29 winpr_RAND(src,
sizeof(src));
32 status =
generic->lShiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
34 if (status == PRIMITIVES_SUCCESS)
37 status = optimized->lShiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
39 if (status == PRIMITIVES_SUCCESS)
43 status =
generic->lShiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
45 if (status != PRIMITIVES_SUCCESS)
48 status = optimized->lShiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
50 if (status != PRIMITIVES_SUCCESS)
54 status =
generic->lShiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
56 if (status != PRIMITIVES_SUCCESS)
59 status = optimized->lShiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
61 if (status != PRIMITIVES_SUCCESS)
67 static BOOL test_lShift_16u_func(
void)
70 UINT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
71 UINT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
73 winpr_RAND(&val,
sizeof(val));
74 winpr_RAND(src,
sizeof(src));
78 status =
generic->lShiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
80 if (status == PRIMITIVES_SUCCESS)
83 status = optimized->lShiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
85 if (status == PRIMITIVES_SUCCESS)
89 status =
generic->lShiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
91 if (status != PRIMITIVES_SUCCESS)
94 status = optimized->lShiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
96 if (status != PRIMITIVES_SUCCESS)
100 status =
generic->lShiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
102 if (status != PRIMITIVES_SUCCESS)
105 status = optimized->lShiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
107 if (status != PRIMITIVES_SUCCESS)
113 static BOOL test_rShift_16s_func(
void)
115 pstatus_t status = 0;
116 INT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
117 INT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
119 winpr_RAND(&val,
sizeof(val));
120 winpr_RAND(src,
sizeof(src));
124 status =
generic->rShiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
126 if (status == PRIMITIVES_SUCCESS)
129 status = optimized->rShiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
131 if (status == PRIMITIVES_SUCCESS)
135 status =
generic->rShiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
137 if (status != PRIMITIVES_SUCCESS)
140 status = optimized->rShiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
142 if (status != PRIMITIVES_SUCCESS)
146 status =
generic->rShiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
148 if (status != PRIMITIVES_SUCCESS)
151 status = optimized->rShiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
153 if (status != PRIMITIVES_SUCCESS)
159 static BOOL test_rShift_16u_func(
void)
161 pstatus_t status = 0;
162 UINT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
163 UINT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
165 winpr_RAND(&val,
sizeof(val));
166 winpr_RAND(src,
sizeof(src));
169 status =
generic->rShiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
171 if (status == PRIMITIVES_SUCCESS)
174 status = optimized->rShiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
176 if (status == PRIMITIVES_SUCCESS)
180 status =
generic->rShiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
182 if (status != PRIMITIVES_SUCCESS)
185 status = optimized->rShiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
187 if (status != PRIMITIVES_SUCCESS)
191 status =
generic->rShiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
193 if (status != PRIMITIVES_SUCCESS)
196 status = optimized->rShiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
198 if (status != PRIMITIVES_SUCCESS)
204 static BOOL test_ShiftWrapper_16s_func(
void)
206 pstatus_t status = 0;
207 INT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
208 INT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
211 winpr_RAND(&tmp,
sizeof(tmp));
212 winpr_RAND(src,
sizeof(src));
216 status =
generic->shiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
218 if (status == PRIMITIVES_SUCCESS)
221 status = optimized->shiftC_16s(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
223 if (status == PRIMITIVES_SUCCESS)
227 status =
generic->shiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
229 if (status != PRIMITIVES_SUCCESS)
232 status = optimized->shiftC_16s(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
234 if (status != PRIMITIVES_SUCCESS)
237 status =
generic->shiftC_16s(src + 1, -val, d1 + 1, FUNC_TEST_SIZE);
239 if (status != PRIMITIVES_SUCCESS)
242 status = optimized->shiftC_16s(src + 1, -val, d1 + 1, FUNC_TEST_SIZE);
244 if (status != PRIMITIVES_SUCCESS)
248 status =
generic->shiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
250 if (status != PRIMITIVES_SUCCESS)
253 status = optimized->shiftC_16s(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
255 if (status != PRIMITIVES_SUCCESS)
258 status =
generic->shiftC_16s(src + 1, -val, d1 + 2, FUNC_TEST_SIZE);
260 if (status != PRIMITIVES_SUCCESS)
263 status = optimized->shiftC_16s(src + 1, -val, d1 + 2, FUNC_TEST_SIZE);
265 if (status != PRIMITIVES_SUCCESS)
271 static BOOL test_ShiftWrapper_16u_func(
void)
273 pstatus_t status = 0;
274 UINT16 ALIGN(src[FUNC_TEST_SIZE + 3]);
275 UINT16 ALIGN(d1[FUNC_TEST_SIZE + 3]);
278 winpr_RAND(&tmp,
sizeof(tmp));
279 winpr_RAND(src,
sizeof(src));
283 status =
generic->shiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
284 if (status == PRIMITIVES_SUCCESS)
287 status = optimized->shiftC_16u(src + 1, 16, d1 + 1, FUNC_TEST_SIZE);
289 if (status == PRIMITIVES_SUCCESS)
293 status =
generic->shiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
295 if (status != PRIMITIVES_SUCCESS)
298 status = optimized->shiftC_16u(src + 1, val, d1 + 1, FUNC_TEST_SIZE);
300 if (status != PRIMITIVES_SUCCESS)
303 status =
generic->shiftC_16u(src + 1, -val, d1 + 1, FUNC_TEST_SIZE);
305 if (status != PRIMITIVES_SUCCESS)
308 status = optimized->shiftC_16u(src + 1, -val, d1 + 1, FUNC_TEST_SIZE);
310 if (status != PRIMITIVES_SUCCESS)
314 status =
generic->shiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
316 if (status != PRIMITIVES_SUCCESS)
319 status = optimized->shiftC_16u(src + 1, val, d1 + 2, FUNC_TEST_SIZE);
321 if (status != PRIMITIVES_SUCCESS)
324 status =
generic->shiftC_16u(src + 1, -val, d1 + 2, FUNC_TEST_SIZE);
326 if (status != PRIMITIVES_SUCCESS)
329 status = optimized->shiftC_16u(src + 1, -val, d1 + 2, FUNC_TEST_SIZE);
331 if (status != PRIMITIVES_SUCCESS)
338 static BOOL test_lShift_16s_speed(
void)
341 INT16 ALIGN(src[MAX_TEST_SIZE + 1]);
342 INT16 ALIGN(dst[MAX_TEST_SIZE + 1]);
343 winpr_RAND(src,
sizeof(src));
344 winpr_RAND(&val,
sizeof(val));
347 if (!speed_test(
"lShift_16s",
"aligned", g_Iterations, (speed_test_fkt)generic->lShiftC_16s,
348 (speed_test_fkt)optimized->lShiftC_16s, src, val, dst, MAX_TEST_SIZE))
351 if (!speed_test(
"lShift_16s",
"unaligned", g_Iterations, (speed_test_fkt)generic->lShiftC_16s,
352 (speed_test_fkt)optimized->lShiftC_16s, src + 1, val, dst, MAX_TEST_SIZE))
359 static BOOL test_lShift_16u_speed(
void)
362 UINT16 ALIGN(src[MAX_TEST_SIZE + 1]);
363 UINT16 ALIGN(dst[MAX_TEST_SIZE + 1]);
364 winpr_RAND(&val,
sizeof(val));
365 winpr_RAND(src,
sizeof(src));
368 if (!speed_test(
"lShift_16u",
"aligned", g_Iterations, (speed_test_fkt)generic->lShiftC_16u,
369 (speed_test_fkt)optimized->lShiftC_16u, src, val, dst, MAX_TEST_SIZE))
372 if (!speed_test(
"lShift_16u",
"unaligned", g_Iterations, (speed_test_fkt)generic->lShiftC_16u,
373 (speed_test_fkt)optimized->lShiftC_16u, src + 1, val, dst, MAX_TEST_SIZE))
380 static BOOL test_rShift_16s_speed(
void)
383 INT16 ALIGN(src[MAX_TEST_SIZE + 1]);
384 INT16 ALIGN(dst[MAX_TEST_SIZE + 1]);
385 winpr_RAND(src,
sizeof(src));
386 winpr_RAND(&val,
sizeof(val));
389 if (!speed_test(
"rShift_16s",
"aligned", g_Iterations, (speed_test_fkt)generic->rShiftC_16s,
390 (speed_test_fkt)optimized->rShiftC_16s, src, val, dst, MAX_TEST_SIZE))
393 if (!speed_test(
"rShift_16s",
"unaligned", g_Iterations, (speed_test_fkt)generic->rShiftC_16s,
394 (speed_test_fkt)optimized->rShiftC_16s, src + 1, val, dst, MAX_TEST_SIZE))
401 static BOOL test_rShift_16u_speed(
void)
404 UINT16 ALIGN(src[MAX_TEST_SIZE + 1]);
405 UINT16 ALIGN(dst[MAX_TEST_SIZE + 1]);
406 winpr_RAND(&val,
sizeof(val));
407 winpr_RAND(src,
sizeof(src));
410 if (!speed_test(
"rShift_16u",
"aligned", g_Iterations, (speed_test_fkt)generic->rShiftC_16u,
411 (speed_test_fkt)optimized->rShiftC_16u, src, val, dst, MAX_TEST_SIZE))
414 if (!speed_test(
"rShift_16u",
"unaligned", g_Iterations, (speed_test_fkt)generic->rShiftC_16u,
415 (speed_test_fkt)optimized->rShiftC_16u, src + 1, val, dst, MAX_TEST_SIZE))
421 int TestPrimitivesShift(
int argc,
char* argv[])
425 prim_test_setup(FALSE);
427 if (!test_lShift_16s_func())
430 if (g_TestPrimitivesPerformance)
432 if (!test_lShift_16s_speed())
436 if (!test_lShift_16u_func())
439 if (g_TestPrimitivesPerformance)
441 if (!test_lShift_16u_speed())
445 if (!test_rShift_16s_func())
448 if (g_TestPrimitivesPerformance)
450 if (!test_rShift_16s_speed())
454 if (!test_rShift_16u_func())
457 if (g_TestPrimitivesPerformance)
459 if (!test_rShift_16u_speed())
463 if (!test_ShiftWrapper_16s_func())
466 if (!test_ShiftWrapper_16u_func())