#include #include "cpuid.h" #include "m512-check.h" #include "avx512f-os-support.h" #ifndef DO_TEST #define DO_TEST do_test #ifdef AVX512VL static void test_256 (void); static void test_128 (void); #else static void test_512 (void); #endif __attribute__ ((noinline)) static void do_test (void) { #ifdef AVX512VL test_256 (); test_128 (); #else test_512 (); #endif } #endif static int check_osxsave (void) { unsigned int eax, ebx, ecx, edx; __cpuid (1, eax, ebx, ecx, edx); return (ecx & bit_OSXSAVE) != 0; } int main () { unsigned int eax, ebx, ecx, edx; if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) return 0; /* Run AVX512 test only if host has ISA support. */ if (check_osxsave () && (ebx & bit_AVX512F) #ifdef AVX512VL && (ebx & bit_AVX512VL) #endif #ifdef AVX512ER && (ebx & bit_AVX512ER) #endif #ifdef AVX512CD && (ebx & bit_AVX512CD) #endif #ifdef AVX512DQ && (ebx & bit_AVX512DQ) #endif #ifdef AVX512BW && (ebx & bit_AVX512BW) #endif #ifdef AVX512IFMA && (ebx & bit_AVX512IFMA) #endif #ifdef AVX512VBMI && (ecx & bit_AVX512VBMI) #endif #ifdef AVX5124FMAPS && (edx & bit_AVX5124FMAPS) #endif #ifdef AVX5124VNNIW && (edx & bit_AVX5124VNNIW) #endif #ifdef AVX512VPOPCNTDQ && (ecx & bit_AVX512VPOPCNTDQ) #endif && avx512f_os_support ()) { DO_TEST (); #ifdef DEBUG printf ("PASSED\n"); #endif return 0; } #ifdef DEBUG printf ("SKIPPED\n"); #endif return 0; }