forked from libsdl-org/SDL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testautomation_intrinsics.c
690 lines (602 loc) · 21.1 KB
/
testautomation_intrinsics.c
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
/**
* Intrinsics test suite
*/
#ifndef NO_BUILD_CONFIG
/* Disable intrinsics that are unsupported by the current compiler */
#include "SDL_build_config.h"
#endif
#include <SDL3/SDL.h>
#include <SDL3/SDL_intrin.h>
#include <SDL3/SDL_test.h>
#include "testautomation_suites.h"
// FIXME: missing tests for loongarch lsx/lasx
// FIXME: missing tests for powerpc altivec
/* ================= Test Case Implementation ================== */
/* Helper functions */
static int allocate_random_int_arrays(Sint32 **dest, Sint32 **a, Sint32 **b, size_t *size) {
size_t i;
*size = (size_t)SDLTest_RandomIntegerInRange(127, 999);
*dest = SDL_malloc(sizeof(Sint32) * *size);
*a = SDL_malloc(sizeof(Sint32) * *size);
*b = SDL_malloc(sizeof(Sint32) * *size);
if (!*dest || !*a || !*b) {
SDLTest_AssertCheck(false, "SDL_malloc failed");
return -1;
}
for (i = 0; i < *size; ++i) {
(*a)[i] = SDLTest_RandomSint32();
(*b)[i] = SDLTest_RandomSint32();
}
return 0;
}
static int allocate_random_float_arrays(float **dest, float **a, float **b, size_t *size) {
size_t i;
*size = (size_t)SDLTest_RandomIntegerInRange(127, 999);
*dest = SDL_malloc(sizeof(float) * *size);
*a = SDL_malloc(sizeof(float) * *size);
*b = SDL_malloc(sizeof(float) * *size);
if (!*dest || !*a || !*b) {
SDLTest_AssertCheck(false, "SDL_malloc failed");
return -1;
}
for (i = 0; i < *size; ++i) {
(*a)[i] = SDLTest_RandomUnitFloat();
(*b)[i] = SDLTest_RandomUnitFloat();
}
return 0;
}
static int allocate_random_double_arrays(double **dest, double **a, double **b, size_t *size) {
size_t i;
*size = (size_t)SDLTest_RandomIntegerInRange(127, 999);
*dest = SDL_malloc(sizeof(double) * *size);
*a = SDL_malloc(sizeof(double) * *size);
*b = SDL_malloc(sizeof(double) * *size);
if (!*dest || !*a || !*b) {
SDLTest_AssertCheck(false, "SDL_malloc failed");
return -1;
}
for (i = 0; i < *size; ++i) {
(*a)[i] = SDLTest_RandomUnitDouble();
(*b)[i] = SDLTest_RandomUnitDouble();
}
return 0;
}
static void free_arrays(void *dest, void *a, void *b) {
SDL_free(dest);
SDL_free(a);
SDL_free(b);
}
/**
* Verify element-wise addition of 2 int arrays.
*/
static void verify_ints_addition(const Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size, const char *desc) {
size_t i;
int all_good = 1;
for (i = 0; i < size; ++i) {
Sint32 expected = a[i] + b[i];
if (dest[i] != expected) {
SDLTest_AssertCheck(false, "%" SDL_PRIs32 " + %" SDL_PRIs32 " = %" SDL_PRIs32 ", expected %" SDL_PRIs32 " ([%" SDL_PRIu32 "/%" SDL_PRIu32 "] %s)",
a[i], b[i], dest[i], expected, (Uint32)i, (Uint32)size, desc);
all_good = 0;
}
}
if (all_good) {
SDLTest_AssertCheck(true, "All int additions were correct (%s)", desc);
}
}
/**
* Verify element-wise multiplication of 2 int arrays.
*/
static void verify_ints_multiplication(const Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size, const char *desc) {
size_t i;
int all_good = 1;
for (i = 0; i < size; ++i) {
Sint32 expected = a[i] * b[i];
if (dest[i] != expected) {
SDLTest_AssertCheck(false, "%" SDL_PRIs32 " * %" SDL_PRIs32 " = %" SDL_PRIs32 ", expected %" SDL_PRIs32 " ([%" SDL_PRIu32 "/%" SDL_PRIu32 "] %s)",
a[i], b[i], dest[i], expected, (Uint32)i, (Uint32)size, desc);
all_good = 0;
}
}
if (all_good) {
SDLTest_AssertCheck(true, "All int multiplication were correct (%s)", desc);
}
}
/**
* Verify element-wise addition of 2 float arrays.
*/
static void verify_floats_addition(const float *dest, const float *a, const float *b, size_t size, const char *desc) {
size_t i;
int all_good = 1;
for (i = 0; i < size; ++i) {
float expected = a[i] + b[i];
float abs_error = SDL_fabsf(dest[i] - expected);
if (abs_error > 1.0e-5f) {
SDLTest_AssertCheck(false, "%g + %g = %g, expected %g (error = %g) ([%" SDL_PRIu32 "/%" SDL_PRIu32 "] %s)",
a[i], b[i], dest[i], expected, abs_error, (Uint32) i, (Uint32) size, desc);
all_good = 0;
}
}
if (all_good) {
SDLTest_AssertCheck(true, "All float additions were correct (%s)", desc);
}
}
/**
* Verify element-wise addition of 2 double arrays.
*/
static void verify_doubles_addition(const double *dest, const double *a, const double *b, size_t size, const char *desc) {
size_t i;
int all_good = 1;
for (i = 0; i < size; ++i) {
double expected = a[i] + b[i];
double abs_error = SDL_fabs(dest[i] - expected);
if (abs_error > 1.0e-5) {
SDLTest_AssertCheck(abs_error < 1.0e-5f, "%g + %g = %g, expected %g (error = %g) ([%" SDL_PRIu32 "/%" SDL_PRIu32 "] %s)",
a[i], b[i], dest[i], expected, abs_error, (Uint32) i, (Uint32) size, desc);
all_good = false;
}
}
if (all_good) {
SDLTest_AssertCheck(true, "All double additions were correct (%s)", desc);
}
}
/* Intrinsic kernels */
static void kernel_ints_add_cpu(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size; --size, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
static void kernel_ints_mul_cpu(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size; --size, ++dest, ++a, ++b) {
*dest = *a * *b;
}
}
static void kernel_floats_add_cpu(float *dest, const float *a, const float *b, size_t size) {
for (; size; --size, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
static void kernel_doubles_add_cpu(double *dest, const double *a, const double *b, size_t size) {
for (; size; --size, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
#ifdef SDL_MMX_INTRINSICS
SDL_TARGETING("mmx") static void kernel_ints_add_mmx(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
*(__m64*)dest = _mm_add_pi32(*(__m64*)a, *(__m64*)b);
}
if (size) {
*dest = *a + *b;
}
_mm_empty();
}
#endif
#ifdef SDL_SSE_INTRINSICS
SDL_TARGETING("sse") static void kernel_floats_add_sse(float *dest, const float *a, const float *b, size_t size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
_mm_storeu_ps(dest, _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps (b)));
}
for (; size; size--, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
#endif
#ifdef SDL_SSE2_INTRINSICS
SDL_TARGETING("sse2") static void kernel_doubles_add_sse2(double *dest, const double *a, const double *b, size_t size) {
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
_mm_storeu_pd(dest, _mm_add_pd(_mm_loadu_pd(a), _mm_loadu_pd(b)));
}
if (size) {
*dest = *a + *b;
}
}
#endif
#ifdef SDL_SSE3_INTRINSICS
SDL_TARGETING("sse3") static void kernel_ints_add_sse3(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
_mm_storeu_si128((__m128i*)dest, _mm_add_epi32(_mm_lddqu_si128((__m128i*)a), _mm_lddqu_si128((__m128i*)b)));
}
for (;size; --size, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
#endif
#ifdef SDL_SSE4_1_INTRINSICS
SDL_TARGETING("sse4.1") static void kernel_ints_mul_sse4_1(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
_mm_storeu_si128((__m128i*)dest, _mm_mullo_epi32(_mm_lddqu_si128((__m128i*)a), _mm_lddqu_si128((__m128i*)b)));
}
for (;size; --size, ++dest, ++a, ++b) {
*dest = *a * *b;
}
}
#endif
#ifdef SDL_SSE4_2_INTRINSICS
SDL_TARGETING("sse4.2") static Uint32 calculate_crc32c_sse4_2(const char *text) {
Uint32 crc32c = ~0u;
size_t len = SDL_strlen(text);
#if defined(__x86_64__) || defined(_M_X64)
for (; len >= 8; len -= 8, text += 8) {
crc32c = (Uint32)_mm_crc32_u64(crc32c, *(Sint64*)text);
}
if (len >= 4) {
crc32c = (Uint32)_mm_crc32_u32(crc32c, *(Sint32*)text);
len -= 4;
text += 4;
}
#else
for (; len >= 4; len -= 4, text += 4) {
crc32c = (Uint32)_mm_crc32_u32(crc32c, *(Sint32*)text);
}
#endif
if (len >= 2) {
crc32c = (Uint32)_mm_crc32_u16(crc32c, *(Sint16*)text);
len -= 2;
text += 2;
}
if (len) {
crc32c = (Uint32)_mm_crc32_u8(crc32c, *text);
}
return ~crc32c;
}
#endif
#ifdef SDL_AVX_INTRINSICS
SDL_TARGETING("avx") static void kernel_floats_add_avx(float *dest, const float *a, const float *b, size_t size) {
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
_mm256_storeu_ps(dest, _mm256_add_ps(_mm256_loadu_ps(a), _mm256_loadu_ps(b)));
}
for (; size; size--, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
#endif
#ifdef SDL_AVX2_INTRINSICS
SDL_TARGETING("avx2") static void kernel_ints_add_avx2(Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size) {
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
_mm256_storeu_si256((__m256i*)dest, _mm256_add_epi32(_mm256_loadu_si256((__m256i*)a), _mm256_loadu_si256((__m256i*)b)));
}
for (; size; size--, ++dest, ++a, ++b) {
*dest = *a + *b;
}
}
#endif
#ifdef SDL_AVX512F_INTRINSICS
SDL_TARGETING("avx512f") static void kernel_floats_add_avx512f(float *dest, const float *a, const float *b, size_t size) {
for (; size >= 16; size -= 16, dest += 16, a += 16, b += 16) {
_mm512_storeu_ps(dest, _mm512_add_ps(_mm512_loadu_ps(a), _mm512_loadu_ps(b)));
}
for (; size; --size) {
*dest++ = *a++ + *b++;
}
}
#endif
/* Test case functions */
static int SDLCALL intrinsics_selftest(void *arg)
{
{
size_t size;
Sint32 *dest, *a, *b;
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_mul_cpu(dest, a, b, size);
verify_ints_multiplication(dest, a, b, size, "CPU");
free_arrays(dest, a, b);
}
{
size_t size;
Sint32 *dest, *a, *b;
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_add_cpu(dest, a, b, size);
verify_ints_addition(dest, a, b, size, "CPU");
free_arrays(dest, a, b);
}
{
size_t size;
float *dest, *a, *b;
if (allocate_random_float_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_floats_add_cpu(dest, a, b, size);
verify_floats_addition(dest, a, b, size, "CPU");
free_arrays(dest, a, b);
}
{
size_t size;
double *dest, *a, *b;
if (allocate_random_double_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_doubles_add_cpu(dest, a, b, size);
verify_doubles_addition(dest, a, b, size, "CPU");
free_arrays(dest, a, b);
}
return TEST_COMPLETED;
}
static int SDLCALL intrinsics_testMMX(void *arg)
{
if (SDL_HasMMX()) {
SDLTest_AssertCheck(true, "CPU of test machine has MMX support.");
#ifdef SDL_MMX_INTRINSICS
{
size_t size;
Sint32 *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses MMX intrinsics.");
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_add_mmx(dest, a, b, size);
verify_ints_addition(dest, a, b, size, "MMX");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use MMX intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO MMX support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testSSE(void *arg)
{
if (SDL_HasSSE()) {
SDLTest_AssertCheck(true, "CPU of test machine has SSE support.");
#ifdef SDL_SSE_INTRINSICS
{
size_t size;
float *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses SSE intrinsics.");
if (allocate_random_float_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_floats_add_sse(dest, a, b, size);
verify_floats_addition(dest, a, b, size, "SSE");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use SSE intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO SSE support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testSSE2(void *arg)
{
if (SDL_HasSSE2()) {
SDLTest_AssertCheck(true, "CPU of test machine has SSE2 support.");
#ifdef SDL_SSE2_INTRINSICS
{
size_t size;
double *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses SSE2 intrinsics.");
if (allocate_random_double_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_doubles_add_sse2(dest, a, b, size);
verify_doubles_addition(dest, a, b, size, "SSE2");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use SSE2 intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO SSE2 support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testSSE3(void *arg)
{
if (SDL_HasSSE3()) {
SDLTest_AssertCheck(true, "CPU of test machine has SSE3 support.");
#ifdef SDL_SSE3_INTRINSICS
{
size_t size;
Sint32 *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses SSE3 intrinsics.");
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_add_sse3(dest, a, b, size);
verify_ints_addition(dest, a, b, size, "SSE3");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use SSE3 intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO SSE3 support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testSSE4_1(void *arg)
{
if (SDL_HasSSE41()) {
SDLTest_AssertCheck(true, "CPU of test machine has SSE4.1 support.");
#ifdef SDL_SSE4_1_INTRINSICS
{
size_t size;
Sint32 *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses SSE4.1 intrinsics.");
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_mul_sse4_1(dest, a, b, size);
verify_ints_multiplication(dest, a, b, size, "SSE4.1");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use SSE4.1 intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO SSE4.1 support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testSSE4_2(void *arg)
{
if (SDL_HasSSE42()) {
SDLTest_AssertCheck(true, "CPU of test machine has SSE4.2 support.");
#ifdef SDL_SSE4_2_INTRINSICS
{
struct {
const char *input;
Uint32 crc32c;
} references[] = {
{"", 0x00000000},
{"Hello world", 0x72b51f78},
{"Simple DirectMedia Layer", 0x56f85341, },
};
size_t i;
SDLTest_AssertCheck(true, "Test executable uses SSE4.2 intrinsics.");
for (i = 0; i < SDL_arraysize(references); ++i) {
Uint32 actual = calculate_crc32c_sse4_2(references[i].input);
SDLTest_AssertCheck(actual == references[i].crc32c, "CRC32-C(\"%s\")=0x%08x, got 0x%08x",
references[i].input, references[i].crc32c, actual);
}
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use SSE4.2 intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO SSE4.2 support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testAVX(void *arg)
{
if (SDL_HasAVX()) {
SDLTest_AssertCheck(true, "CPU of test machine has AVX support.");
#ifdef SDL_AVX_INTRINSICS
{
size_t size;
float *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses AVX intrinsics.");
if (allocate_random_float_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_floats_add_avx(dest, a, b, size);
verify_floats_addition(dest, a, b, size, "AVX");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use AVX intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO AVX support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testAVX2(void *arg)
{
if (SDL_HasAVX2()) {
SDLTest_AssertCheck(true, "CPU of test machine has AVX2 support.");
#ifdef SDL_AVX2_INTRINSICS
{
size_t size;
Sint32 *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses AVX2 intrinsics.");
if (allocate_random_int_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_ints_add_avx2(dest, a, b, size);
verify_ints_addition(dest, a, b, size, "AVX2");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use AVX2 intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO AVX2 support.");
}
return TEST_SKIPPED;
}
static int SDLCALL intrinsics_testAVX512F(void *arg)
{
if (SDL_HasAVX512F()) {
SDLTest_AssertCheck(true, "CPU of test machine has AVX512F support.");
#ifdef SDL_AVX512F_INTRINSICS
{
size_t size;
float *dest, *a, *b;
SDLTest_AssertCheck(true, "Test executable uses AVX512F intrinsics.");
if (allocate_random_float_arrays(&dest, &a, &b, &size) < 0) {
return TEST_ABORTED;
}
kernel_floats_add_avx512f(dest, a, b, size);
verify_floats_addition(dest, a, b, size, "AVX512F");
free_arrays(dest, a, b);
return TEST_COMPLETED;
}
#else
SDLTest_AssertCheck(true, "Test executable does NOT use AVX512F intrinsics.");
#endif
} else {
SDLTest_AssertCheck(true, "CPU of test machine has NO AVX512F support.");
}
return TEST_SKIPPED;
}
/* ================= Test References ================== */
/* Intrinsics test cases */
static const SDLTest_TestCaseReference intrinsicsTest1 = {
intrinsics_selftest, "intrinsics_selftest", "Intrinsics testautomation selftest", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest2 = {
intrinsics_testMMX, "intrinsics_testMMX", "Tests MMX intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest3 = {
intrinsics_testSSE, "intrinsics_testSSE", "Tests SSE intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest4 = {
intrinsics_testSSE2, "intrinsics_testSSE2", "Tests SSE2 intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest5 = {
intrinsics_testSSE3, "intrinsics_testSSE3", "Tests SSE3 intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest6 = {
intrinsics_testSSE4_1, "intrinsics_testSSE4.1", "Tests SSE4.1 intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest7 = {
intrinsics_testSSE4_2, "intrinsics_testSSE4.2", "Tests SSE4.2 intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest8 = {
intrinsics_testAVX, "intrinsics_testAVX", "Tests AVX intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest9 = {
intrinsics_testAVX2, "intrinsics_testAVX2", "Tests AVX2 intrinsics", TEST_ENABLED
};
static const SDLTest_TestCaseReference intrinsicsTest10 = {
intrinsics_testAVX512F, "intrinsics_testAVX512F", "Tests AVX512F intrinsics", TEST_ENABLED
};
/* Sequence of Platform test cases */
static const SDLTest_TestCaseReference *platformTests[] = {
&intrinsicsTest1,
&intrinsicsTest2,
&intrinsicsTest3,
&intrinsicsTest4,
&intrinsicsTest5,
&intrinsicsTest6,
&intrinsicsTest7,
&intrinsicsTest8,
&intrinsicsTest9,
&intrinsicsTest10,
NULL
};
/* Platform test suite (global) */
SDLTest_TestSuiteReference intrinsicsTestSuite = {
"Intrinsics",
NULL,
platformTests,
NULL
};