Atlas - testautomation_intrinsics.c

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