25#if defined(INFIX_ARCH_X64)
28#elif defined(__GNUC__) || defined(__clang__)
32#if defined(INFIX_ARCH_AARCH64) && defined(__has_include)
33#if __has_include(<sys/auxv.h>) && defined(__linux__)
36#define HWCAP_SVE (1 << 22)
38#elif __has_include(<sys/sysctl.h>) && defined(__APPLE__)
39#include <sys/sysctl.h>
42#if defined(INFIX_ARCH_X64)
43bool infix_cpu_has_avx2(
void) {
46 __cpuidex(cpuInfo, 7, 0);
47 return (cpuInfo[1] & (1 << 5)) != 0;
48#elif defined(__GNUC__) || defined(__clang__)
49 unsigned int eax, ebx, ecx, edx;
50 if (__get_cpuid_max(0, NULL) >= 7) {
51 __cpuid_count(7, 0, eax, ebx, ecx, edx);
52 return (ebx & (1 << 5)) != 0;
59bool infix_cpu_has_avx512f(
void) {
62 __cpuidex(cpuInfo, 7, 0);
63 return (cpuInfo[1] & (1 << 16)) != 0;
64#elif defined(__GNUC__) || defined(__clang__)
65 unsigned int eax, ebx, ecx, edx;
66 if (__get_cpuid_max(0, NULL) >= 7) {
67 __cpuid_count(7, 0, eax, ebx, ecx, edx);
68 return (ebx & (1 << 16)) != 0;
76#if defined(INFIX_ARCH_AARCH64)
77bool infix_cpu_has_sve(
void) {
78#if defined(__linux__) && defined(HWCAP_SVE)
79 return (getauxval(AT_HWCAP) & HWCAP_SVE) != 0;
80#elif defined(__APPLE__)
82 size_t size =
sizeof(sve_present);
83 if (sysctlbyname(
"hw.optional.arm.FEAT_SVE", &sve_present, &size, NULL, 0) == 0)
84 return sve_present == 1;