|
Packit Service |
53171b |
/* Test CPU feature data against __builtin_cpu_supports.
|
|
Packit Service |
53171b |
This file is part of the GNU C Library.
|
|
Packit Service |
53171b |
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
53171b |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
53171b |
License as published by the Free Software Foundation; either
|
|
Packit Service |
53171b |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
53171b |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
53171b |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
53171b |
Lesser General Public License for more details.
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
53171b |
License along with the GNU C Library; if not, see
|
|
Packit Service |
53171b |
<https://www.gnu.org/licenses/>. */
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
#include <sys/platform/x86.h>
|
|
Packit Service |
53171b |
#include <stdio.h>
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
int
|
|
Packit Service |
53171b |
check_supports (int supports, int usable, const char *supports_name,
|
|
Packit Service |
53171b |
const char *name)
|
|
Packit Service |
53171b |
{
|
|
Packit Service |
53171b |
printf ("Checking %s:\n", name);
|
|
Packit Service |
53171b |
printf (" %s: %d\n", name, usable);
|
|
Packit Service |
53171b |
printf (" __builtin_cpu_supports (%s): %d\n",
|
|
Packit Service |
53171b |
supports_name, supports);
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
if ((supports != 0) != (usable != 0))
|
|
Packit Service |
53171b |
{
|
|
Packit Service |
53171b |
printf (" *** failure ***\n");
|
|
Packit Service |
53171b |
return 1;
|
|
Packit Service |
53171b |
}
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
return 0;
|
|
Packit Service |
53171b |
}
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
#define CHECK_SUPPORTS(str, name) \
|
|
Packit Service |
53171b |
check_supports (__builtin_cpu_supports (#str), \
|
|
Packit Service |
53171b |
CPU_FEATURE_USABLE (name), \
|
|
Packit Service |
53171b |
#str, "HAS_CPU_FEATURE (" #name ")");
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
static int
|
|
Packit Service |
53171b |
do_test (int argc, char **argv)
|
|
Packit Service |
53171b |
{
|
|
Packit Service |
53171b |
int fails = 0;
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (adx, ADX);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (6, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (aes, AES);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 1)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (amx_bf16, AMX_BF16);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (amx_int8, AMX_INT8);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (amx_tile, AMX_TILE);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx, AVX);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx2, AVX2);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (7, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx5124fmaps, AVX512_4FMAPS);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx5124vnniw, AVX512_4VNNIW);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (10, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512bf16, AVX512_BF16);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (8, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512bitalg, AVX512_BITALG);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (6, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512ifma, AVX512_IFMA);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vbmi, AVX512_VBMI);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (8, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vbmi2, AVX512_VBMI2);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vnni, AVX512_VNNI);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (10, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vp2intersect, AVX512_VP2INTERSECT);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (7, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vpopcntdq, AVX512_VPOPCNTDQ);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (6, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512bw, AVX512BW);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512cd, AVX512CD);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512er, AVX512ER);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512dq, AVX512DQ);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (5, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512f, AVX512F);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (6, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512pf, AVX512PF);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (avx512vl, AVX512VL);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (5, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (bmi, BMI1);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (bmi2, BMI2);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (cldemote, CLDEMOTE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (clflushopt, CLFLUSHOPT);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (clwb, CLWB);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (cmov, CMOV);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (cmpxchg16b, CMPXCHG16B);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (cmpxchg8b, CX8);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (enqcmd, ENQCMD);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (f16c, F16C);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (4, 9)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (fma, FMA);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (fma4, FMA4);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (fsgsbase, FSGSBASE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (fxsave, FXSR);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (8, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (gfni, GFNI);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (hle, HLE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (ibt, IBT);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (lahf_lm, LAHF64_SAHF64);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (lm, LM);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (lwp, LWP);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (lzcnt, LZCNT);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (mmx, MMX);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (movbe, MOVBE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (movdiri, MOVDIRI);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (movdir64b, MOVDIR64B);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (osxsave, OSXSAVE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (pconfig, PCONFIG);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (pku, PKU);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (popcnt, POPCNT);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (prefetchwt1, PREFETCHWT1);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (rdpid, RDPID);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (rdrnd, RDRAND);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (rdseed, RDSEED);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (rtm, RTM);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (serialize, SERIALIZE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sha, SHA);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (shstk, SHSTK);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse, SSE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse2, SSE2);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse3, SSE3);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse4.1, SSE4_1);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse4.2, SSE4_2);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (4, 9)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (sse4a, SSE4A);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (ssse3, SSSE3);
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (tbm, TBM);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (tsxldtrk, TSXLDTRK);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (vaes, VAES);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (8, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (vpclmulqdq, VPCLMULQDQ);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (waitpkg, WAITPKG);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (wbnoinvd, WBNOINVD);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (4, 9)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (xop, XOP);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
#if __GNUC_PREREQ (11, 0)
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (xsave, XSAVE);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (xsavec, XSAVEC);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (xsaveopt, XSAVEOPT);
|
|
Packit Service |
53171b |
fails += CHECK_SUPPORTS (xsaves, XSAVES);
|
|
Packit Service |
53171b |
#endif
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
printf ("%d differences between __builtin_cpu_supports and glibc code.\n",
|
|
Packit Service |
53171b |
fails);
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
return (fails != 0);
|
|
Packit Service |
53171b |
}
|
|
Packit Service |
53171b |
|
|
Packit Service |
53171b |
#include "../../../test-skeleton.c"
|