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
|
#include <stdlib.h>
#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
#ifdef GFNI
&& (ecx & bit_GFNI)
#endif
#ifdef AVX512VBMI2
&& (ecx & bit_AVX512VBMI2)
#endif
#ifdef AVX512VNNI
&& (ecx & bit_AVX512VNNI)
#endif
&& avx512f_os_support ())
{
DO_TEST ();
#ifdef DEBUG
printf ("PASSED\n");
#endif
return 0;
}
#ifdef DEBUG
printf ("SKIPPED\n");
#endif
return 0;
}
|