|
#pragma once |
|
#ifndef CPUINFO_H |
|
#define CPUINFO_H |
|
|
|
#ifndef __cplusplus |
|
#include <stdbool.h> |
|
#endif |
|
|
|
#ifdef __APPLE__ |
|
#include <TargetConditionals.h> |
|
#endif |
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) |
|
#define CPUINFO_ARCH_X86 1 |
|
#endif |
|
|
|
#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) |
|
#define CPUINFO_ARCH_X86_64 1 |
|
#endif |
|
|
|
#if defined(__arm__) || defined(_M_ARM) |
|
#define CPUINFO_ARCH_ARM 1 |
|
#endif |
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64) |
|
#define CPUINFO_ARCH_ARM64 1 |
|
#endif |
|
|
|
#if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) |
|
#define CPUINFO_ARCH_PPC64 1 |
|
#endif |
|
|
|
#if defined(__asmjs__) |
|
#define CPUINFO_ARCH_ASMJS 1 |
|
#endif |
|
|
|
#if defined(__wasm__) |
|
#if defined(__wasm_simd128__) |
|
#define CPUINFO_ARCH_WASMSIMD 1 |
|
#else |
|
#define CPUINFO_ARCH_WASM 1 |
|
#endif |
|
#endif |
|
|
|
|
|
|
|
#ifndef CPUINFO_ARCH_X86 |
|
#define CPUINFO_ARCH_X86 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_X86_64 |
|
#define CPUINFO_ARCH_X86_64 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_ARM |
|
#define CPUINFO_ARCH_ARM 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_ARM64 |
|
#define CPUINFO_ARCH_ARM64 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_PPC64 |
|
#define CPUINFO_ARCH_PPC64 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_ASMJS |
|
#define CPUINFO_ARCH_ASMJS 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_WASM |
|
#define CPUINFO_ARCH_WASM 0 |
|
#endif |
|
|
|
#ifndef CPUINFO_ARCH_WASMSIMD |
|
#define CPUINFO_ARCH_WASMSIMD 0 |
|
#endif |
|
|
|
#if CPUINFO_ARCH_X86 && defined(_MSC_VER) |
|
#define CPUINFO_ABI __cdecl |
|
#elif CPUINFO_ARCH_X86 && defined(__GNUC__) |
|
#define CPUINFO_ABI __attribute__((__cdecl__)) |
|
#else |
|
#define CPUINFO_ABI |
|
#endif |
|
|
|
#define CPUINFO_CACHE_UNIFIED 0x00000001 |
|
#define CPUINFO_CACHE_INCLUSIVE 0x00000002 |
|
#define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004 |
|
|
|
struct cpuinfo_cache { |
|
|
|
uint32_t size; |
|
|
|
uint32_t associativity; |
|
|
|
uint32_t sets; |
|
|
|
uint32_t partitions; |
|
|
|
uint32_t line_size; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t flags; |
|
|
|
uint32_t processor_start; |
|
|
|
uint32_t processor_count; |
|
}; |
|
|
|
struct cpuinfo_trace_cache { |
|
uint32_t uops; |
|
uint32_t associativity; |
|
}; |
|
|
|
#define CPUINFO_PAGE_SIZE_4KB 0x1000 |
|
#define CPUINFO_PAGE_SIZE_1MB 0x100000 |
|
#define CPUINFO_PAGE_SIZE_2MB 0x200000 |
|
#define CPUINFO_PAGE_SIZE_4MB 0x400000 |
|
#define CPUINFO_PAGE_SIZE_16MB 0x1000000 |
|
#define CPUINFO_PAGE_SIZE_1GB 0x40000000 |
|
|
|
struct cpuinfo_tlb { |
|
uint32_t entries; |
|
uint32_t associativity; |
|
uint64_t pages; |
|
}; |
|
|
|
|
|
enum cpuinfo_vendor { |
|
|
|
cpuinfo_vendor_unknown = 0, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_intel = 1, |
|
|
|
cpuinfo_vendor_amd = 2, |
|
|
|
cpuinfo_vendor_arm = 3, |
|
|
|
cpuinfo_vendor_qualcomm = 4, |
|
|
|
cpuinfo_vendor_apple = 5, |
|
|
|
cpuinfo_vendor_samsung = 6, |
|
|
|
cpuinfo_vendor_nvidia = 7, |
|
|
|
cpuinfo_vendor_mips = 8, |
|
|
|
cpuinfo_vendor_ibm = 9, |
|
|
|
cpuinfo_vendor_ingenic = 10, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_via = 11, |
|
|
|
cpuinfo_vendor_cavium = 12, |
|
|
|
cpuinfo_vendor_broadcom = 13, |
|
|
|
cpuinfo_vendor_apm = 14, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_huawei = 15, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_hygon = 16, |
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_texas_instruments = 30, |
|
|
|
cpuinfo_vendor_marvell = 31, |
|
|
|
cpuinfo_vendor_rdc = 32, |
|
|
|
cpuinfo_vendor_dmp = 33, |
|
|
|
cpuinfo_vendor_motorola = 34, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_transmeta = 50, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_cyrix = 51, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_rise = 52, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_nsc = 53, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_sis = 54, |
|
|
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_nexgen = 55, |
|
|
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_umc = 56, |
|
|
|
|
|
|
|
|
|
|
|
cpuinfo_vendor_dec = 57, |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum cpuinfo_uarch { |
|
|
|
cpuinfo_uarch_unknown = 0, |
|
|
|
|
|
cpuinfo_uarch_p5 = 0x00100100, |
|
|
|
cpuinfo_uarch_quark = 0x00100101, |
|
|
|
|
|
cpuinfo_uarch_p6 = 0x00100200, |
|
|
|
cpuinfo_uarch_dothan = 0x00100201, |
|
|
|
cpuinfo_uarch_yonah = 0x00100202, |
|
|
|
cpuinfo_uarch_conroe = 0x00100203, |
|
|
|
cpuinfo_uarch_penryn = 0x00100204, |
|
|
|
cpuinfo_uarch_nehalem = 0x00100205, |
|
|
|
cpuinfo_uarch_sandy_bridge = 0x00100206, |
|
|
|
cpuinfo_uarch_ivy_bridge = 0x00100207, |
|
|
|
cpuinfo_uarch_haswell = 0x00100208, |
|
|
|
cpuinfo_uarch_broadwell = 0x00100209, |
|
|
|
cpuinfo_uarch_sky_lake = 0x0010020A, |
|
|
|
cpuinfo_uarch_kaby_lake = 0x0010020A, |
|
|
|
cpuinfo_uarch_palm_cove = 0x0010020B, |
|
|
|
cpuinfo_uarch_sunny_cove = 0x0010020C, |
|
|
|
|
|
cpuinfo_uarch_willamette = 0x00100300, |
|
|
|
cpuinfo_uarch_prescott = 0x00100301, |
|
|
|
|
|
cpuinfo_uarch_bonnell = 0x00100400, |
|
|
|
cpuinfo_uarch_saltwell = 0x00100401, |
|
|
|
cpuinfo_uarch_silvermont = 0x00100402, |
|
|
|
cpuinfo_uarch_airmont = 0x00100403, |
|
|
|
cpuinfo_uarch_goldmont = 0x00100404, |
|
|
|
cpuinfo_uarch_goldmont_plus = 0x00100405, |
|
|
|
|
|
cpuinfo_uarch_knights_ferry = 0x00100500, |
|
|
|
cpuinfo_uarch_knights_corner = 0x00100501, |
|
|
|
cpuinfo_uarch_knights_landing = 0x00100502, |
|
|
|
cpuinfo_uarch_knights_hill = 0x00100503, |
|
|
|
cpuinfo_uarch_knights_mill = 0x00100504, |
|
|
|
|
|
cpuinfo_uarch_xscale = 0x00100600, |
|
|
|
|
|
cpuinfo_uarch_k5 = 0x00200100, |
|
|
|
cpuinfo_uarch_k6 = 0x00200101, |
|
|
|
cpuinfo_uarch_k7 = 0x00200102, |
|
|
|
cpuinfo_uarch_k8 = 0x00200103, |
|
|
|
cpuinfo_uarch_k10 = 0x00200104, |
|
|
|
|
|
|
|
|
|
cpuinfo_uarch_bulldozer = 0x00200105, |
|
|
|
|
|
|
|
|
|
cpuinfo_uarch_piledriver = 0x00200106, |
|
|
|
cpuinfo_uarch_steamroller = 0x00200107, |
|
|
|
cpuinfo_uarch_excavator = 0x00200108, |
|
|
|
cpuinfo_uarch_zen = 0x00200109, |
|
|
|
cpuinfo_uarch_zen2 = 0x0020010A, |
|
|
|
cpuinfo_uarch_zen3 = 0x0020010B, |
|
|
|
cpuinfo_uarch_zen4 = 0x0020010C, |
|
|
|
|
|
cpuinfo_uarch_geode = 0x00200200, |
|
|
|
cpuinfo_uarch_bobcat = 0x00200201, |
|
|
|
cpuinfo_uarch_jaguar = 0x00200202, |
|
|
|
cpuinfo_uarch_puma = 0x00200203, |
|
|
|
|
|
cpuinfo_uarch_arm7 = 0x00300100, |
|
|
|
cpuinfo_uarch_arm9 = 0x00300101, |
|
|
|
cpuinfo_uarch_arm11 = 0x00300102, |
|
|
|
|
|
cpuinfo_uarch_cortex_a5 = 0x00300205, |
|
|
|
cpuinfo_uarch_cortex_a7 = 0x00300207, |
|
|
|
cpuinfo_uarch_cortex_a8 = 0x00300208, |
|
|
|
cpuinfo_uarch_cortex_a9 = 0x00300209, |
|
|
|
cpuinfo_uarch_cortex_a12 = 0x00300212, |
|
|
|
cpuinfo_uarch_cortex_a15 = 0x00300215, |
|
|
|
cpuinfo_uarch_cortex_a17 = 0x00300217, |
|
|
|
|
|
cpuinfo_uarch_cortex_a32 = 0x00300332, |
|
|
|
cpuinfo_uarch_cortex_a35 = 0x00300335, |
|
|
|
cpuinfo_uarch_cortex_a53 = 0x00300353, |
|
|
|
cpuinfo_uarch_cortex_a55r0 = 0x00300354, |
|
|
|
cpuinfo_uarch_cortex_a55 = 0x00300355, |
|
|
|
cpuinfo_uarch_cortex_a57 = 0x00300357, |
|
|
|
cpuinfo_uarch_cortex_a65 = 0x00300365, |
|
|
|
cpuinfo_uarch_cortex_a72 = 0x00300372, |
|
|
|
cpuinfo_uarch_cortex_a73 = 0x00300373, |
|
|
|
cpuinfo_uarch_cortex_a75 = 0x00300375, |
|
|
|
cpuinfo_uarch_cortex_a76 = 0x00300376, |
|
|
|
cpuinfo_uarch_cortex_a77 = 0x00300377, |
|
|
|
cpuinfo_uarch_cortex_a78 = 0x00300378, |
|
|
|
|
|
cpuinfo_uarch_neoverse_n1 = 0x00300400, |
|
|
|
cpuinfo_uarch_neoverse_e1 = 0x00300401, |
|
|
|
cpuinfo_uarch_neoverse_v1 = 0x00300402, |
|
|
|
cpuinfo_uarch_neoverse_n2 = 0x00300403, |
|
|
|
|
|
cpuinfo_uarch_cortex_x1 = 0x00300501, |
|
|
|
cpuinfo_uarch_cortex_x2 = 0x00300502, |
|
|
|
cpuinfo_uarch_cortex_x3 = 0x00300503, |
|
|
|
|
|
cpuinfo_uarch_cortex_a510 = 0x00300551, |
|
|
|
cpuinfo_uarch_cortex_a710 = 0x00300571, |
|
|
|
cpuinfo_uarch_cortex_a715 = 0x00300572, |
|
|
|
|
|
cpuinfo_uarch_scorpion = 0x00400100, |
|
|
|
cpuinfo_uarch_krait = 0x00400101, |
|
|
|
cpuinfo_uarch_kryo = 0x00400102, |
|
|
|
cpuinfo_uarch_falkor = 0x00400103, |
|
|
|
cpuinfo_uarch_saphira = 0x00400104, |
|
|
|
|
|
cpuinfo_uarch_denver = 0x00500100, |
|
|
|
cpuinfo_uarch_denver2 = 0x00500101, |
|
|
|
cpuinfo_uarch_carmel = 0x00500102, |
|
|
|
|
|
cpuinfo_uarch_exynos_m1 = 0x00600100, |
|
|
|
cpuinfo_uarch_exynos_m2 = 0x00600101, |
|
|
|
cpuinfo_uarch_exynos_m3 = 0x00600102, |
|
|
|
cpuinfo_uarch_exynos_m4 = 0x00600103, |
|
|
|
cpuinfo_uarch_exynos_m5 = 0x00600104, |
|
|
|
|
|
cpuinfo_uarch_cortex_a76ae = 0x00300376, |
|
|
|
cpuinfo_uarch_mongoose_m1 = 0x00600100, |
|
cpuinfo_uarch_mongoose_m2 = 0x00600101, |
|
cpuinfo_uarch_meerkat_m3 = 0x00600102, |
|
cpuinfo_uarch_meerkat_m4 = 0x00600103, |
|
|
|
|
|
cpuinfo_uarch_swift = 0x00700100, |
|
|
|
cpuinfo_uarch_cyclone = 0x00700101, |
|
|
|
cpuinfo_uarch_typhoon = 0x00700102, |
|
|
|
cpuinfo_uarch_twister = 0x00700103, |
|
|
|
cpuinfo_uarch_hurricane = 0x00700104, |
|
|
|
cpuinfo_uarch_monsoon = 0x00700105, |
|
|
|
cpuinfo_uarch_mistral = 0x00700106, |
|
|
|
cpuinfo_uarch_vortex = 0x00700107, |
|
|
|
cpuinfo_uarch_tempest = 0x00700108, |
|
|
|
cpuinfo_uarch_lightning = 0x00700109, |
|
|
|
cpuinfo_uarch_thunder = 0x0070010A, |
|
|
|
cpuinfo_uarch_firestorm = 0x0070010B, |
|
|
|
cpuinfo_uarch_icestorm = 0x0070010C, |
|
|
|
cpuinfo_uarch_avalanche = 0x0070010D, |
|
|
|
cpuinfo_uarch_blizzard = 0x0070010E, |
|
|
|
|
|
cpuinfo_uarch_thunderx = 0x00800100, |
|
|
|
cpuinfo_uarch_thunderx2 = 0x00800200, |
|
|
|
|
|
cpuinfo_uarch_pj4 = 0x00900100, |
|
|
|
|
|
cpuinfo_uarch_brahma_b15 = 0x00A00100, |
|
|
|
cpuinfo_uarch_brahma_b53 = 0x00A00101, |
|
|
|
|
|
cpuinfo_uarch_xgene = 0x00B00100, |
|
|
|
|
|
cpuinfo_uarch_dhyana = 0x01000100, |
|
|
|
|
|
cpuinfo_uarch_taishan_v110 = 0x00C00100, |
|
}; |
|
|
|
struct cpuinfo_processor { |
|
|
|
uint32_t smt_id; |
|
|
|
const struct cpuinfo_core* core; |
|
|
|
const struct cpuinfo_cluster* cluster; |
|
|
|
const struct cpuinfo_package* package; |
|
#if defined(__linux__) |
|
|
|
|
|
|
|
|
|
|
|
int linux_id; |
|
#endif |
|
#if defined(_WIN32) || defined(__CYGWIN__) |
|
|
|
uint16_t windows_group_id; |
|
|
|
|
|
|
|
|
|
uint16_t windows_processor_id; |
|
#endif |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
|
|
uint32_t apic_id; |
|
#endif |
|
struct { |
|
|
|
const struct cpuinfo_cache* l1i; |
|
|
|
const struct cpuinfo_cache* l1d; |
|
|
|
const struct cpuinfo_cache* l2; |
|
|
|
const struct cpuinfo_cache* l3; |
|
|
|
const struct cpuinfo_cache* l4; |
|
} cache; |
|
}; |
|
|
|
struct cpuinfo_core { |
|
|
|
uint32_t processor_start; |
|
|
|
uint32_t processor_count; |
|
|
|
uint32_t core_id; |
|
|
|
const struct cpuinfo_cluster* cluster; |
|
|
|
const struct cpuinfo_package* package; |
|
|
|
enum cpuinfo_vendor vendor; |
|
|
|
enum cpuinfo_uarch uarch; |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
|
|
uint32_t cpuid; |
|
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
|
|
uint32_t midr; |
|
#endif |
|
|
|
uint64_t frequency; |
|
}; |
|
|
|
struct cpuinfo_cluster { |
|
|
|
uint32_t processor_start; |
|
|
|
uint32_t processor_count; |
|
|
|
uint32_t core_start; |
|
|
|
uint32_t core_count; |
|
|
|
uint32_t cluster_id; |
|
|
|
const struct cpuinfo_package* package; |
|
|
|
enum cpuinfo_vendor vendor; |
|
|
|
enum cpuinfo_uarch uarch; |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
|
|
uint32_t cpuid; |
|
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
|
|
uint32_t midr; |
|
#endif |
|
|
|
uint64_t frequency; |
|
}; |
|
|
|
#define CPUINFO_PACKAGE_NAME_MAX 48 |
|
|
|
struct cpuinfo_package { |
|
|
|
char name[CPUINFO_PACKAGE_NAME_MAX]; |
|
|
|
uint32_t processor_start; |
|
|
|
uint32_t processor_count; |
|
|
|
uint32_t core_start; |
|
|
|
uint32_t core_count; |
|
|
|
uint32_t cluster_start; |
|
|
|
uint32_t cluster_count; |
|
}; |
|
|
|
struct cpuinfo_uarch_info { |
|
|
|
enum cpuinfo_uarch uarch; |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
|
|
uint32_t cpuid; |
|
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
|
|
uint32_t midr; |
|
#endif |
|
|
|
uint32_t processor_count; |
|
|
|
uint32_t core_count; |
|
}; |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
bool CPUINFO_ABI cpuinfo_initialize(void); |
|
|
|
void CPUINFO_ABI cpuinfo_deinitialize(void); |
|
|
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
|
|
struct cpuinfo_x86_isa { |
|
#if CPUINFO_ARCH_X86 |
|
bool rdtsc; |
|
#endif |
|
bool rdtscp; |
|
bool rdpid; |
|
bool sysenter; |
|
#if CPUINFO_ARCH_X86 |
|
bool syscall; |
|
#endif |
|
bool msr; |
|
bool clzero; |
|
bool clflush; |
|
bool clflushopt; |
|
bool mwait; |
|
bool mwaitx; |
|
#if CPUINFO_ARCH_X86 |
|
bool emmx; |
|
#endif |
|
bool fxsave; |
|
bool xsave; |
|
#if CPUINFO_ARCH_X86 |
|
bool fpu; |
|
bool mmx; |
|
bool mmx_plus; |
|
#endif |
|
bool three_d_now; |
|
bool three_d_now_plus; |
|
#if CPUINFO_ARCH_X86 |
|
bool three_d_now_geode; |
|
#endif |
|
bool prefetch; |
|
bool prefetchw; |
|
bool prefetchwt1; |
|
#if CPUINFO_ARCH_X86 |
|
bool daz; |
|
bool sse; |
|
bool sse2; |
|
#endif |
|
bool sse3; |
|
bool ssse3; |
|
bool sse4_1; |
|
bool sse4_2; |
|
bool sse4a; |
|
bool misaligned_sse; |
|
bool avx; |
|
bool fma3; |
|
bool fma4; |
|
bool xop; |
|
bool f16c; |
|
bool avx2; |
|
bool avx512f; |
|
bool avx512pf; |
|
bool avx512er; |
|
bool avx512cd; |
|
bool avx512dq; |
|
bool avx512bw; |
|
bool avx512vl; |
|
bool avx512ifma; |
|
bool avx512vbmi; |
|
bool avx512vbmi2; |
|
bool avx512bitalg; |
|
bool avx512vpopcntdq; |
|
bool avx512vnni; |
|
bool avx512bf16; |
|
bool avx512fp16; |
|
bool avx512vp2intersect; |
|
bool avx512_4vnniw; |
|
bool avx512_4fmaps; |
|
bool hle; |
|
bool rtm; |
|
bool xtest; |
|
bool mpx; |
|
#if CPUINFO_ARCH_X86 |
|
bool cmov; |
|
bool cmpxchg8b; |
|
#endif |
|
bool cmpxchg16b; |
|
bool clwb; |
|
bool movbe; |
|
#if CPUINFO_ARCH_X86_64 |
|
bool lahf_sahf; |
|
#endif |
|
bool fs_gs_base; |
|
bool lzcnt; |
|
bool popcnt; |
|
bool tbm; |
|
bool bmi; |
|
bool bmi2; |
|
bool adx; |
|
bool aes; |
|
bool vaes; |
|
bool pclmulqdq; |
|
bool vpclmulqdq; |
|
bool gfni; |
|
bool rdrand; |
|
bool rdseed; |
|
bool sha; |
|
bool rng; |
|
bool ace; |
|
bool ace2; |
|
bool phe; |
|
bool pmm; |
|
bool lwp; |
|
}; |
|
|
|
extern struct cpuinfo_x86_isa cpuinfo_isa; |
|
#endif |
|
|
|
static inline bool cpuinfo_has_x86_rdtsc(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.rdtsc; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_rdtscp(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.rdtscp; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_rdpid(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.rdpid; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_clzero(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.clzero; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_mwait(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.mwait; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_mwaitx(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.mwaitx; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_fxsave(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.fxsave; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_xsave(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.xsave; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_fpu(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.fpu; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_mmx(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.mmx; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_mmx_plus(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.mmx_plus; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_3dnow(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.three_d_now; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_3dnow_plus(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.three_d_now_plus; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_3dnow_geode(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return false; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return false; |
|
#else |
|
return cpuinfo_isa.three_d_now_geode; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_prefetch(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.prefetch; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_prefetchw(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.prefetchw; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_prefetchwt1(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.prefetchwt1; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_daz(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.daz; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.sse; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse2(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.sse2; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse3(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.sse3; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_ssse3(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.ssse3; |
|
#endif |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse4_1(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.sse4_1; |
|
#endif |
|
#elif CPUINFO_ARCH_X86 |
|
return cpuinfo_isa.sse4_1; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse4_2(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.sse4_2; |
|
#endif |
|
#elif CPUINFO_ARCH_X86 |
|
return cpuinfo_isa.sse4_2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sse4a(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.sse4a; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_misaligned_sse(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.misaligned_sse; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_fma3(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.fma3; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_fma4(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.fma4; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_xop(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.xop; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_f16c(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.f16c; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx2(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512f(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512f; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512pf(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512pf; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512er(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512er; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512cd(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512cd; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512dq(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512dq; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512bw(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512bw; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vl(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vl; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512ifma(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512ifma; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vbmi(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vbmi; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vbmi2(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vbmi2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512bitalg(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512bitalg; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vpopcntdq; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vnni(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vnni; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512bf16(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512bf16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512fp16(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512fp16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512vp2intersect(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512vp2intersect; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512_4vnniw; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_avx512_4fmaps(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.avx512_4fmaps; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_hle(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.hle; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_rtm(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.rtm; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_xtest(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.xtest; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_mpx(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.mpx; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_cmov(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
return cpuinfo_isa.cmov; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_cmpxchg8b(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return true; |
|
#elif CPUINFO_ARCH_X86 |
|
return cpuinfo_isa.cmpxchg8b; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_cmpxchg16b(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.cmpxchg16b; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_clwb(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.clwb; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_movbe(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.movbe; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_lahf_sahf(void) { |
|
#if CPUINFO_ARCH_X86 |
|
return true; |
|
#elif CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.lahf_sahf; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_lzcnt(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.lzcnt; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_popcnt(void) { |
|
#if CPUINFO_ARCH_X86_64 |
|
#if defined(__ANDROID__) |
|
return true; |
|
#else |
|
return cpuinfo_isa.popcnt; |
|
#endif |
|
#elif CPUINFO_ARCH_X86 |
|
return cpuinfo_isa.popcnt; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_tbm(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.tbm; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_bmi(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.bmi; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_bmi2(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.bmi2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_adx(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.adx; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_aes(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.aes; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_vaes(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.vaes; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_pclmulqdq(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.pclmulqdq; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_vpclmulqdq(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.vpclmulqdq; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_gfni(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.gfni; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_rdrand(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.rdrand; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_rdseed(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.rdseed; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_x86_sha(void) { |
|
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
|
return cpuinfo_isa.sha; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
|
|
struct cpuinfo_arm_isa { |
|
#if CPUINFO_ARCH_ARM |
|
bool thumb; |
|
bool thumb2; |
|
bool thumbee; |
|
bool jazelle; |
|
bool armv5e; |
|
bool armv6; |
|
bool armv6k; |
|
bool armv7; |
|
bool armv7mp; |
|
bool armv8; |
|
bool idiv; |
|
|
|
bool vfpv2; |
|
bool vfpv3; |
|
bool d32; |
|
bool fp16; |
|
bool fma; |
|
|
|
bool wmmx; |
|
bool wmmx2; |
|
bool neon; |
|
#endif |
|
#if CPUINFO_ARCH_ARM64 |
|
bool atomics; |
|
bool bf16; |
|
bool sve; |
|
bool sve2; |
|
bool i8mm; |
|
#endif |
|
bool rdm; |
|
bool fp16arith; |
|
bool dot; |
|
bool jscvt; |
|
bool fcma; |
|
bool fhm; |
|
|
|
bool aes; |
|
bool sha1; |
|
bool sha2; |
|
bool pmull; |
|
bool crc32; |
|
}; |
|
|
|
extern struct cpuinfo_arm_isa cpuinfo_isa; |
|
#endif |
|
|
|
static inline bool cpuinfo_has_arm_thumb(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.thumb; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_thumb2(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.thumb2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v5e(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv5e; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v6(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv6; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v6k(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv6k; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v7(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv7; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v7mp(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv7mp; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_v8(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.armv8; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_idiv(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.idiv; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv2(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv3(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv3_d32(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv3_fp16(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv4(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_vfpv4_d32(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_fp16_arith(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.fp16arith; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_bf16(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.bf16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_wmmx(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.wmmx; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_wmmx2(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.wmmx2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.neon; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_fp16(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.neon && cpuinfo_isa.fp16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_fma(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.neon && cpuinfo_isa.fma; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_v8(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return true; |
|
#elif CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.neon && cpuinfo_isa.armv8; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_atomics(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.atomics; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_rdm(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.rdm; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { |
|
#if CPUINFO_ARCH_ARM |
|
return cpuinfo_isa.neon && cpuinfo_isa.fp16arith; |
|
#elif CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.fp16arith; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_fhm(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.fhm; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_dot(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.dot; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_neon_bf16(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.bf16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_jscvt(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.jscvt; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_fcma(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.fcma; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_i8mm(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.i8mm; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_aes(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.aes; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_sha1(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.sha1; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_sha2(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.sha2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_pmull(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.pmull; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_crc32(void) { |
|
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.crc32; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_sve(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.sve; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_sve_bf16(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.sve && cpuinfo_isa.bf16; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
static inline bool cpuinfo_has_arm_sve2(void) { |
|
#if CPUINFO_ARCH_ARM64 |
|
return cpuinfo_isa.sve2; |
|
#else |
|
return false; |
|
#endif |
|
} |
|
|
|
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); |
|
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); |
|
const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); |
|
const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); |
|
const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); |
|
|
|
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); |
|
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); |
|
const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); |
|
const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); |
|
const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index); |
|
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index); |
|
|
|
uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); |
|
uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); |
|
|
|
|
|
|
|
|
|
uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
#endif |
|
|