Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | #ifndef CPUINFO_H |
| 3 | #define CPUINFO_H |
| 4 | |
| 5 | #ifndef __cplusplus |
| 6 | #include <stdbool.h> |
| 7 | #endif |
| 8 | |
Hao Lu | 3617d5b | 2017-10-23 15:16:50 -0700 | [diff] [blame] | 9 | #ifdef __APPLE__ |
| 10 | #include <TargetConditionals.h> |
| 11 | #endif |
| 12 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | |
| 15 | /* Identify architecture and define corresponding macro */ |
| 16 | |
| 17 | #if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) |
| 18 | #define CPUINFO_ARCH_X86 1 |
| 19 | #endif |
| 20 | |
| 21 | #if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) |
| 22 | #define CPUINFO_ARCH_X86_64 1 |
| 23 | #endif |
| 24 | |
| 25 | #if defined(__arm__) || defined(_M_ARM) |
| 26 | #define CPUINFO_ARCH_ARM 1 |
| 27 | #endif |
| 28 | |
| 29 | #if defined(__aarch64__) || defined(_M_ARM64) |
| 30 | #define CPUINFO_ARCH_ARM64 1 |
| 31 | #endif |
| 32 | |
| 33 | #if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) |
| 34 | #define CPUINFO_ARCH_PPC64 1 |
| 35 | #endif |
| 36 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 37 | #if defined(__asmjs__) |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 38 | #define CPUINFO_ARCH_ASMJS 1 |
| 39 | #endif |
| 40 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 41 | #if defined(__wasm__) |
| 42 | #if defined(__wasm_simd128__) |
| 43 | #define CPUINFO_ARCH_WASMSIMD 1 |
| 44 | #else |
| 45 | #define CPUINFO_ARCH_WASM 1 |
| 46 | #endif |
| 47 | #endif |
| 48 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 49 | /* Define other architecture-specific macros as 0 */ |
| 50 | |
| 51 | #ifndef CPUINFO_ARCH_X86 |
| 52 | #define CPUINFO_ARCH_X86 0 |
| 53 | #endif |
| 54 | |
| 55 | #ifndef CPUINFO_ARCH_X86_64 |
| 56 | #define CPUINFO_ARCH_X86_64 0 |
| 57 | #endif |
| 58 | |
| 59 | #ifndef CPUINFO_ARCH_ARM |
| 60 | #define CPUINFO_ARCH_ARM 0 |
| 61 | #endif |
| 62 | |
| 63 | #ifndef CPUINFO_ARCH_ARM64 |
| 64 | #define CPUINFO_ARCH_ARM64 0 |
| 65 | #endif |
| 66 | |
| 67 | #ifndef CPUINFO_ARCH_PPC64 |
| 68 | #define CPUINFO_ARCH_PPC64 0 |
| 69 | #endif |
| 70 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 71 | #ifndef CPUINFO_ARCH_ASMJS |
| 72 | #define CPUINFO_ARCH_ASMJS 0 |
| 73 | #endif |
| 74 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 75 | #ifndef CPUINFO_ARCH_WASM |
| 76 | #define CPUINFO_ARCH_WASM 0 |
| 77 | #endif |
| 78 | |
| 79 | #ifndef CPUINFO_ARCH_WASMSIMD |
| 80 | #define CPUINFO_ARCH_WASMSIMD 0 |
| 81 | #endif |
| 82 | |
Ashkan Aliabadi | 7e4c009 | 2020-06-01 18:23:11 -0700 | [diff] [blame] | 83 | #if CPUINFO_ARCH_X86 && defined(_MSC_VER) |
| 84 | #define CPUINFO_ABI __cdecl |
| 85 | #elif CPUINFO_ARCH_X86 && defined(__GNUC__) |
| 86 | #define CPUINFO_ABI __attribute__((__cdecl__)) |
| 87 | #else |
| 88 | #define CPUINFO_ABI |
| 89 | #endif |
| 90 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 91 | #define CPUINFO_CACHE_UNIFIED 0x00000001 |
| 92 | #define CPUINFO_CACHE_INCLUSIVE 0x00000002 |
| 93 | #define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004 |
| 94 | |
| 95 | struct cpuinfo_cache { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 96 | /** Cache size in bytes */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 97 | uint32_t size; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 98 | /** Number of ways of associativity */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 99 | uint32_t associativity; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 100 | /** Number of sets */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 101 | uint32_t sets; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 102 | /** Number of partitions */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 103 | uint32_t partitions; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 104 | /** Line size in bytes */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 105 | uint32_t line_size; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 106 | /** |
| 107 | * Binary characteristics of the cache (unified cache, inclusive cache, cache with complex indexing). |
| 108 | * |
| 109 | * @see CPUINFO_CACHE_UNIFIED, CPUINFO_CACHE_INCLUSIVE, CPUINFO_CACHE_COMPLEX_INDEXING |
| 110 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 111 | uint32_t flags; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 112 | /** Index of the first logical processor that shares this cache */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 113 | uint32_t processor_start; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 114 | /** Number of logical processors that share this cache */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 115 | uint32_t processor_count; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct cpuinfo_trace_cache { |
| 119 | uint32_t uops; |
| 120 | uint32_t associativity; |
| 121 | }; |
| 122 | |
| 123 | #define CPUINFO_PAGE_SIZE_4KB 0x1000 |
| 124 | #define CPUINFO_PAGE_SIZE_1MB 0x100000 |
| 125 | #define CPUINFO_PAGE_SIZE_2MB 0x200000 |
| 126 | #define CPUINFO_PAGE_SIZE_4MB 0x400000 |
| 127 | #define CPUINFO_PAGE_SIZE_16MB 0x1000000 |
| 128 | #define CPUINFO_PAGE_SIZE_1GB 0x40000000 |
| 129 | |
| 130 | struct cpuinfo_tlb { |
| 131 | uint32_t entries; |
| 132 | uint32_t associativity; |
| 133 | uint64_t pages; |
| 134 | }; |
| 135 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 136 | /** Vendor of processor core design */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 137 | enum cpuinfo_vendor { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 138 | /** Processor vendor is not known to the library, or the library failed to get vendor information from the OS. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 139 | cpuinfo_vendor_unknown = 0, |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 140 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 141 | /* Active vendors of modern CPUs */ |
| 142 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 143 | /** |
| 144 | * Intel Corporation. Vendor of x86, x86-64, IA64, and ARM processor microarchitectures. |
| 145 | * |
| 146 | * Sold its ARM design subsidiary in 2006. The last ARM processor design was released in 2004. |
| 147 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 148 | cpuinfo_vendor_intel = 1, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 149 | /** Advanced Micro Devices, Inc. Vendor of x86 and x86-64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 150 | cpuinfo_vendor_amd = 2, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 151 | /** ARM Holdings plc. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 152 | cpuinfo_vendor_arm = 3, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 153 | /** Qualcomm Incorporated. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 154 | cpuinfo_vendor_qualcomm = 4, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 155 | /** Apple Inc. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 156 | cpuinfo_vendor_apple = 5, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 157 | /** Samsung Electronics Co., Ltd. Vendir if ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 158 | cpuinfo_vendor_samsung = 6, |
Marat Dukhan | 93982f2 | 2017-10-20 13:10:23 -0700 | [diff] [blame] | 159 | /** Nvidia Corporation. Vendor of ARM64-compatible processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 160 | cpuinfo_vendor_nvidia = 7, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 161 | /** MIPS Technologies, Inc. Vendor of MIPS processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 162 | cpuinfo_vendor_mips = 8, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 163 | /** International Business Machines Corporation. Vendor of PowerPC processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 164 | cpuinfo_vendor_ibm = 9, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 165 | /** Ingenic Semiconductor. Vendor of MIPS processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 166 | cpuinfo_vendor_ingenic = 10, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 167 | /** |
| 168 | * VIA Technologies, Inc. Vendor of x86 and x86-64 processor microarchitectures. |
| 169 | * |
| 170 | * Processors are designed by Centaur Technology, a subsidiary of VIA Technologies. |
| 171 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 172 | cpuinfo_vendor_via = 11, |
Marat Dukhan | 92dae31 | 2017-05-09 14:10:17 +0000 | [diff] [blame] | 173 | /** Cavium, Inc. Vendor of ARM64 processor microarchitectures. */ |
| 174 | cpuinfo_vendor_cavium = 12, |
Marat Dukhan | 1ae7ff8 | 2018-05-13 19:30:58 -0700 | [diff] [blame] | 175 | /** Broadcom, Inc. Vendor of ARM processor microarchitectures. */ |
| 176 | cpuinfo_vendor_broadcom = 13, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 177 | /** Applied Micro Circuits Corporation (APM). Vendor of ARM64 processor microarchitectures. */ |
| 178 | cpuinfo_vendor_apm = 14, |
Marat Dukhan | b73f61a | 2018-09-02 23:57:56 +0300 | [diff] [blame] | 179 | /** |
| 180 | * Huawei Technologies Co., Ltd. Vendor of ARM64 processor microarchitectures. |
| 181 | * |
| 182 | * Processors are designed by HiSilicon, a subsidiary of Huawei. |
| 183 | */ |
| 184 | cpuinfo_vendor_huawei = 15, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 185 | /** |
| 186 | * Hygon (Chengdu Haiguang Integrated Circuit Design Co., Ltd), Vendor of x86-64 processor microarchitectures. |
| 187 | * |
| 188 | * Processors are variants of AMD cores. |
| 189 | */ |
| 190 | cpuinfo_vendor_hygon = 16, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 191 | |
| 192 | /* Active vendors of embedded CPUs */ |
| 193 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 194 | /** Texas Instruments Inc. Vendor of ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 195 | cpuinfo_vendor_texas_instruments = 30, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 196 | /** Marvell Technology Group Ltd. Vendor of ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 197 | cpuinfo_vendor_marvell = 31, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 198 | /** RDC Semiconductor Co., Ltd. Vendor of x86 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 199 | cpuinfo_vendor_rdc = 32, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 200 | /** DM&P Electronics Inc. Vendor of x86 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 201 | cpuinfo_vendor_dmp = 33, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 202 | /** Motorola, Inc. Vendor of PowerPC and ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 203 | cpuinfo_vendor_motorola = 34, |
| 204 | |
| 205 | /* Defunct CPU vendors */ |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 206 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 207 | /** |
| 208 | * Transmeta Corporation. Vendor of x86 processor microarchitectures. |
| 209 | * |
| 210 | * Now defunct. The last processor design was released in 2004. |
| 211 | * Transmeta processors implemented VLIW ISA and used binary translation to execute x86 code. |
| 212 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 213 | cpuinfo_vendor_transmeta = 50, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 214 | /** |
| 215 | * Cyrix Corporation. Vendor of x86 processor microarchitectures. |
| 216 | * |
| 217 | * Now defunct. The last processor design was released in 1996. |
| 218 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 219 | cpuinfo_vendor_cyrix = 51, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 220 | /** |
| 221 | * Rise Technology. Vendor of x86 processor microarchitectures. |
| 222 | * |
| 223 | * Now defunct. The last processor design was released in 1999. |
| 224 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 225 | cpuinfo_vendor_rise = 52, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 226 | /** |
| 227 | * National Semiconductor. Vendor of x86 processor microarchitectures. |
| 228 | * |
| 229 | * Sold its x86 design subsidiary in 1999. The last processor design was released in 1998. |
| 230 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 231 | cpuinfo_vendor_nsc = 53, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 232 | /** |
| 233 | * Silicon Integrated Systems. Vendor of x86 processor microarchitectures. |
| 234 | * |
| 235 | * Sold its x86 design subsidiary in 2001. The last processor design was released in 2001. |
| 236 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 237 | cpuinfo_vendor_sis = 54, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 238 | /** |
| 239 | * NexGen. Vendor of x86 processor microarchitectures. |
| 240 | * |
| 241 | * Now defunct. The last processor design was released in 1994. |
| 242 | * NexGen designed the first x86 microarchitecture which decomposed x86 instructions into simple microoperations. |
| 243 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 244 | cpuinfo_vendor_nexgen = 55, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 245 | /** |
| 246 | * United Microelectronics Corporation. Vendor of x86 processor microarchitectures. |
| 247 | * |
| 248 | * Ceased x86 in the early 1990s. The last processor design was released in 1991. |
| 249 | * Designed U5C and U5D processors. Both are 486 level. |
| 250 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 251 | cpuinfo_vendor_umc = 56, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 252 | /** |
| 253 | * Digital Equipment Corporation. Vendor of ARM processor microarchitecture. |
| 254 | * |
| 255 | * Sold its ARM designs in 1997. The last processor design was released in 1997. |
| 256 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 257 | cpuinfo_vendor_dec = 57, |
| 258 | }; |
| 259 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 260 | /** |
| 261 | * Processor microarchitecture |
| 262 | * |
| 263 | * Processors with different microarchitectures often have different instruction performance characteristics, |
| 264 | * and may have dramatically different pipeline organization. |
| 265 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 266 | enum cpuinfo_uarch { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 267 | /** Microarchitecture is unknown, or the library failed to get information about the microarchitecture from OS */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 268 | cpuinfo_uarch_unknown = 0, |
| 269 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 270 | /** Pentium and Pentium MMX microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 271 | cpuinfo_uarch_p5 = 0x00100100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 272 | /** Intel Quark microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 273 | cpuinfo_uarch_quark = 0x00100101, |
| 274 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 275 | /** Pentium Pro, Pentium II, and Pentium III. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 276 | cpuinfo_uarch_p6 = 0x00100200, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 277 | /** Pentium M. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 278 | cpuinfo_uarch_dothan = 0x00100201, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 279 | /** Intel Core microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 280 | cpuinfo_uarch_yonah = 0x00100202, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 281 | /** Intel Core 2 microarchitecture on 65 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 282 | cpuinfo_uarch_conroe = 0x00100203, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 283 | /** Intel Core 2 microarchitecture on 45 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 284 | cpuinfo_uarch_penryn = 0x00100204, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 285 | /** Intel Nehalem and Westmere microarchitectures (Core i3/i5/i7 1st gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 286 | cpuinfo_uarch_nehalem = 0x00100205, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 287 | /** Intel Sandy Bridge microarchitecture (Core i3/i5/i7 2nd gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 288 | cpuinfo_uarch_sandy_bridge = 0x00100206, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 289 | /** Intel Ivy Bridge microarchitecture (Core i3/i5/i7 3rd gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 290 | cpuinfo_uarch_ivy_bridge = 0x00100207, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 291 | /** Intel Haswell microarchitecture (Core i3/i5/i7 4th gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 292 | cpuinfo_uarch_haswell = 0x00100208, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 293 | /** Intel Broadwell microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 294 | cpuinfo_uarch_broadwell = 0x00100209, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 295 | /** Intel Sky Lake microarchitecture (14 nm, including Kaby/Coffee/Whiskey/Amber/Comet/Cascade/Cooper Lake). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 296 | cpuinfo_uarch_sky_lake = 0x0010020A, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 297 | /** DEPRECATED (Intel Kaby Lake microarchitecture). */ |
| 298 | cpuinfo_uarch_kaby_lake = 0x0010020A, |
| 299 | /** Intel Palm Cove microarchitecture (10 nm, Cannon Lake). */ |
| 300 | cpuinfo_uarch_palm_cove = 0x0010020B, |
| 301 | /** Intel Sunny Cove microarchitecture (10 nm, Ice Lake). */ |
| 302 | cpuinfo_uarch_sunny_cove = 0x0010020C, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 303 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 304 | /** Pentium 4 with Willamette, Northwood, or Foster cores. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 305 | cpuinfo_uarch_willamette = 0x00100300, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 306 | /** Pentium 4 with Prescott and later cores. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 307 | cpuinfo_uarch_prescott = 0x00100301, |
| 308 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 309 | /** Intel Atom on 45 nm process. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 310 | cpuinfo_uarch_bonnell = 0x00100400, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 311 | /** Intel Atom on 32 nm process. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 312 | cpuinfo_uarch_saltwell = 0x00100401, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 313 | /** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 314 | cpuinfo_uarch_silvermont = 0x00100402, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 315 | /** Intel Airmont microarchitecture (14 nm out-of-order Atom). */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 316 | cpuinfo_uarch_airmont = 0x00100403, |
| 317 | /** Intel Goldmont microarchitecture (Denverton, Apollo Lake). */ |
| 318 | cpuinfo_uarch_goldmont = 0x00100404, |
| 319 | /** Intel Goldmont Plus microarchitecture (Gemini Lake). */ |
| 320 | cpuinfo_uarch_goldmont_plus = 0x00100405, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 321 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 322 | /** Intel Knights Ferry HPC boards. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 323 | cpuinfo_uarch_knights_ferry = 0x00100500, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 324 | /** Intel Knights Corner HPC boards (aka Xeon Phi). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 325 | cpuinfo_uarch_knights_corner = 0x00100501, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 326 | /** Intel Knights Landing microarchitecture (second-gen MIC). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 327 | cpuinfo_uarch_knights_landing = 0x00100502, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 328 | /** Intel Knights Hill microarchitecture (third-gen MIC). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 329 | cpuinfo_uarch_knights_hill = 0x00100503, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 330 | /** Intel Knights Mill Xeon Phi. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 331 | cpuinfo_uarch_knights_mill = 0x00100504, |
| 332 | |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 333 | /** Intel/Marvell XScale series. */ |
| 334 | cpuinfo_uarch_xscale = 0x00100600, |
| 335 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 336 | /** AMD K5. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 337 | cpuinfo_uarch_k5 = 0x00200100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 338 | /** AMD K6 and alike. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 339 | cpuinfo_uarch_k6 = 0x00200101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 340 | /** AMD Athlon and Duron. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 341 | cpuinfo_uarch_k7 = 0x00200102, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 342 | /** AMD Athlon 64, Opteron 64. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 343 | cpuinfo_uarch_k8 = 0x00200103, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 344 | /** AMD Family 10h (Barcelona, Istambul, Magny-Cours). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 345 | cpuinfo_uarch_k10 = 0x00200104, |
| 346 | /** |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 347 | * AMD Bulldozer microarchitecture |
| 348 | * Zambezi FX-series CPUs, Zurich, Valencia and Interlagos Opteron CPUs. |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 349 | */ |
| 350 | cpuinfo_uarch_bulldozer = 0x00200105, |
| 351 | /** |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 352 | * AMD Piledriver microarchitecture |
| 353 | * Vishera FX-series CPUs, Trinity and Richland APUs, Delhi, Seoul, Abu Dhabi Opteron CPUs. |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 354 | */ |
| 355 | cpuinfo_uarch_piledriver = 0x00200106, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 356 | /** AMD Steamroller microarchitecture (Kaveri APUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 357 | cpuinfo_uarch_steamroller = 0x00200107, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 358 | /** AMD Excavator microarchitecture (Carizzo APUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 359 | cpuinfo_uarch_excavator = 0x00200108, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 360 | /** AMD Zen microarchitecture (12/14 nm Ryzen and EPYC CPUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 361 | cpuinfo_uarch_zen = 0x00200109, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 362 | /** AMD Zen 2 microarchitecture (7 nm Ryzen and EPYC CPUs). */ |
| 363 | cpuinfo_uarch_zen2 = 0x0020010A, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 364 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 365 | /** NSC Geode and AMD Geode GX and LX. */ |
Marat Dukhan | e25187d | 2017-04-16 05:03:07 -0400 | [diff] [blame] | 366 | cpuinfo_uarch_geode = 0x00200200, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 367 | /** AMD Bobcat mobile microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 368 | cpuinfo_uarch_bobcat = 0x00200201, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 369 | /** AMD Jaguar mobile microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 370 | cpuinfo_uarch_jaguar = 0x00200202, |
Marat Dukhan | 818e199 | 2018-02-24 15:39:18 +0100 | [diff] [blame] | 371 | /** AMD Puma mobile microarchitecture. */ |
| 372 | cpuinfo_uarch_puma = 0x00200203, |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 373 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 374 | /** ARM7 series. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 375 | cpuinfo_uarch_arm7 = 0x00300100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 376 | /** ARM9 series. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 377 | cpuinfo_uarch_arm9 = 0x00300101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 378 | /** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 379 | cpuinfo_uarch_arm11 = 0x00300102, |
| 380 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 381 | /** ARM Cortex-A5. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 382 | cpuinfo_uarch_cortex_a5 = 0x00300205, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 383 | /** ARM Cortex-A7. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 384 | cpuinfo_uarch_cortex_a7 = 0x00300207, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 385 | /** ARM Cortex-A8. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 386 | cpuinfo_uarch_cortex_a8 = 0x00300208, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 387 | /** ARM Cortex-A9. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 388 | cpuinfo_uarch_cortex_a9 = 0x00300209, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 389 | /** ARM Cortex-A12. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 390 | cpuinfo_uarch_cortex_a12 = 0x00300212, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 391 | /** ARM Cortex-A15. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 392 | cpuinfo_uarch_cortex_a15 = 0x00300215, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 393 | /** ARM Cortex-A17. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 394 | cpuinfo_uarch_cortex_a17 = 0x00300217, |
| 395 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 396 | /** ARM Cortex-A32. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 397 | cpuinfo_uarch_cortex_a32 = 0x00300332, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 398 | /** ARM Cortex-A35. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 399 | cpuinfo_uarch_cortex_a35 = 0x00300335, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 400 | /** ARM Cortex-A53. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 401 | cpuinfo_uarch_cortex_a53 = 0x00300353, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 402 | /** ARM Cortex-A55 revision 0 (restricted dual-issue capabilities compared to revision 1+). */ |
| 403 | cpuinfo_uarch_cortex_a55r0 = 0x00300354, |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 404 | /** ARM Cortex-A55. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 405 | cpuinfo_uarch_cortex_a55 = 0x00300355, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 406 | /** ARM Cortex-A57. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 407 | cpuinfo_uarch_cortex_a57 = 0x00300357, |
| 408 | /** ARM Cortex-A65. */ |
| 409 | cpuinfo_uarch_cortex_a65 = 0x00300365, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 410 | /** ARM Cortex-A72. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 411 | cpuinfo_uarch_cortex_a72 = 0x00300372, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 412 | /** ARM Cortex-A73. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 413 | cpuinfo_uarch_cortex_a73 = 0x00300373, |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 414 | /** ARM Cortex-A75. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 415 | cpuinfo_uarch_cortex_a75 = 0x00300375, |
Marat Dukhan | b73f61a | 2018-09-02 23:57:56 +0300 | [diff] [blame] | 416 | /** ARM Cortex-A76. */ |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 417 | cpuinfo_uarch_cortex_a76 = 0x00300376, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 418 | /** ARM Cortex-A77. */ |
| 419 | cpuinfo_uarch_cortex_a77 = 0x00300377, |
Ashkan Aliabadi | f558241 | 2020-06-11 21:17:20 -0700 | [diff] [blame] | 420 | /** ARM Cortex-A78. */ |
| 421 | cpuinfo_uarch_cortex_a78 = 0x00300378, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 422 | |
| 423 | /** ARM Neoverse N1. */ |
| 424 | cpuinfo_uarch_neoverse_n1 = 0x00300400, |
| 425 | /** ARM Neoverse E1. */ |
| 426 | cpuinfo_uarch_neoverse_e1 = 0x00300401, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 427 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 428 | /** Qualcomm Scorpion. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 429 | cpuinfo_uarch_scorpion = 0x00400100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 430 | /** Qualcomm Krait. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 431 | cpuinfo_uarch_krait = 0x00400101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 432 | /** Qualcomm Kryo. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 433 | cpuinfo_uarch_kryo = 0x00400102, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 434 | /** Qualcomm Falkor. */ |
| 435 | cpuinfo_uarch_falkor = 0x00400103, |
| 436 | /** Qualcomm Saphira. */ |
| 437 | cpuinfo_uarch_saphira = 0x00400104, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 438 | |
Marat Dukhan | 93982f2 | 2017-10-20 13:10:23 -0700 | [diff] [blame] | 439 | /** Nvidia Denver. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 440 | cpuinfo_uarch_denver = 0x00500100, |
Marat Dukhan | 1e6c8c9 | 2018-05-13 20:24:07 -0700 | [diff] [blame] | 441 | /** Nvidia Denver 2. */ |
| 442 | cpuinfo_uarch_denver2 = 0x00500101, |
Marat Dukhan | 8101c50 | 2018-09-18 21:05:58 -0500 | [diff] [blame] | 443 | /** Nvidia Carmel. */ |
| 444 | cpuinfo_uarch_carmel = 0x00500102, |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 445 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 446 | /** Samsung Exynos M1 (Exynos 8890 big cores). */ |
| 447 | cpuinfo_uarch_exynos_m1 = 0x00600100, |
| 448 | /** Samsung Exynos M2 (Exynos 8895 big cores). */ |
| 449 | cpuinfo_uarch_exynos_m2 = 0x00600101, |
| 450 | /** Samsung Exynos M3 (Exynos 9810 big cores). */ |
| 451 | cpuinfo_uarch_exynos_m3 = 0x00600102, |
| 452 | /** Samsung Exynos M4 (Exynos 9820 big cores). */ |
| 453 | cpuinfo_uarch_exynos_m4 = 0x00600103, |
| 454 | /** Samsung Exynos M5 (Exynos 9830 big cores). */ |
| 455 | cpuinfo_uarch_exynos_m5 = 0x00600104, |
| 456 | |
Ashkan Aliabadi | 7e4c009 | 2020-06-01 18:23:11 -0700 | [diff] [blame] | 457 | /* Deprecated synonym for Cortex-A76 */ |
| 458 | cpuinfo_uarch_cortex_a76ae = 0x00300376, |
| 459 | /* Deprecated names for Exynos. */ |
Marat Dukhan | a750f2a | 2018-03-07 11:07:48 -0800 | [diff] [blame] | 460 | cpuinfo_uarch_mongoose_m1 = 0x00600100, |
| 461 | cpuinfo_uarch_mongoose_m2 = 0x00600101, |
Marat Dukhan | 10eae00 | 2018-03-29 18:36:31 -0700 | [diff] [blame] | 462 | cpuinfo_uarch_meerkat_m3 = 0x00600102, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 463 | cpuinfo_uarch_meerkat_m4 = 0x00600103, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 464 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 465 | /** Apple A6 and A6X processors. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 466 | cpuinfo_uarch_swift = 0x00700100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 467 | /** Apple A7 processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 468 | cpuinfo_uarch_cyclone = 0x00700101, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 469 | /** Apple A8 and A8X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 470 | cpuinfo_uarch_typhoon = 0x00700102, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 471 | /** Apple A9 and A9X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 472 | cpuinfo_uarch_twister = 0x00700103, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 473 | /** Apple A10 and A10X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 474 | cpuinfo_uarch_hurricane = 0x00700104, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 475 | /** Apple A11 processor (big cores). */ |
| 476 | cpuinfo_uarch_monsoon = 0x00700105, |
| 477 | /** Apple A11 processor (little cores). */ |
| 478 | cpuinfo_uarch_mistral = 0x00700106, |
Marat Dukhan | 44dafc5 | 2018-12-26 20:19:15 -0800 | [diff] [blame] | 479 | /** Apple A12 processor (big cores). */ |
| 480 | cpuinfo_uarch_vortex = 0x00700107, |
| 481 | /** Apple A12 processor (little cores). */ |
| 482 | cpuinfo_uarch_tempest = 0x00700108, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 483 | /** Apple A13 processor (big cores). */ |
| 484 | cpuinfo_uarch_lightning = 0x00700109, |
| 485 | /** Apple A13 processor (little cores). */ |
| 486 | cpuinfo_uarch_thunder = 0x0070010A, |
Nikita Shulga | ed8b86a | 2020-11-18 17:25:18 -0800 | [diff] [blame^] | 487 | /** Apple M1 processor (big cores). */ |
| 488 | cpuinfo_uarch_firestorm = 0x0070010B, |
| 489 | /** Apple M1 processor (little cores). */ |
| 490 | cpuinfo_uarch_icestorm = 0x0070010C, |
Marat Dukhan | 92dae31 | 2017-05-09 14:10:17 +0000 | [diff] [blame] | 491 | |
| 492 | /** Cavium ThunderX. */ |
| 493 | cpuinfo_uarch_thunderx = 0x00800100, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 494 | /** Cavium ThunderX2 (originally Broadcom Vulkan). */ |
| 495 | cpuinfo_uarch_thunderx2 = 0x00800200, |
Marat Dukhan | 8871832 | 2017-08-24 10:12:20 -0700 | [diff] [blame] | 496 | |
| 497 | /** Marvell PJ4. */ |
| 498 | cpuinfo_uarch_pj4 = 0x00900100, |
Marat Dukhan | 1ae7ff8 | 2018-05-13 19:30:58 -0700 | [diff] [blame] | 499 | |
| 500 | /** Broadcom Brahma B15. */ |
| 501 | cpuinfo_uarch_brahma_b15 = 0x00A00100, |
| 502 | /** Broadcom Brahma B53. */ |
| 503 | cpuinfo_uarch_brahma_b53 = 0x00A00101, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 504 | |
| 505 | /** Applied Micro X-Gene. */ |
| 506 | cpuinfo_uarch_xgene = 0x00B00100, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 507 | |
| 508 | /* Hygon Dhyana (a modification of AMD Zen for Chinese market). */ |
| 509 | cpuinfo_uarch_dhyana = 0x01000100, |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 510 | |
| 511 | /** HiSilicon TaiShan v110 (Huawei Kunpeng 920 series processors). */ |
| 512 | cpuinfo_uarch_taishan_v110 = 0x00C00100, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | struct cpuinfo_processor { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 516 | /** SMT (hyperthread) ID within a core */ |
| 517 | uint32_t smt_id; |
| 518 | /** Core containing this logical processor */ |
| 519 | const struct cpuinfo_core* core; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 520 | /** Cluster of cores containing this logical processor */ |
| 521 | const struct cpuinfo_cluster* cluster; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 522 | /** Physical package containing this logical processor */ |
| 523 | const struct cpuinfo_package* package; |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 524 | #if defined(__linux__) |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 525 | /** |
| 526 | * Linux-specific ID for the logical processor: |
| 527 | * - Linux kernel exposes information about this logical processor in /sys/devices/system/cpu/cpu<linux_id>/ |
| 528 | * - Bit <linux_id> in the cpu_set_t identifies this logical processor |
| 529 | */ |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 530 | int linux_id; |
| 531 | #endif |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 532 | #if defined(_WIN32) || defined(__CYGWIN__) |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 533 | /** Windows-specific ID for the group containing the logical processor. */ |
| 534 | uint16_t windows_group_id; |
| 535 | /** |
| 536 | * Windows-specific ID of the logical processor within its group: |
| 537 | * - Bit <windows_processor_id> in the KAFFINITY mask identifies this logical processor within its group. |
| 538 | */ |
| 539 | uint16_t windows_processor_id; |
| 540 | #endif |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 541 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 542 | /** APIC ID (unique x86-specific ID of the logical processor) */ |
| 543 | uint32_t apic_id; |
| 544 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 545 | struct { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 546 | /** Level 1 instruction cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 547 | const struct cpuinfo_cache* l1i; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 548 | /** Level 1 data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 549 | const struct cpuinfo_cache* l1d; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 550 | /** Level 2 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 551 | const struct cpuinfo_cache* l2; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 552 | /** Level 3 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 553 | const struct cpuinfo_cache* l3; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 554 | /** Level 4 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 555 | const struct cpuinfo_cache* l4; |
| 556 | } cache; |
| 557 | }; |
| 558 | |
| 559 | struct cpuinfo_core { |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 560 | /** Index of the first logical processor on this core. */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 561 | uint32_t processor_start; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 562 | /** Number of logical processors on this core */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 563 | uint32_t processor_count; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 564 | /** Core ID within a package */ |
| 565 | uint32_t core_id; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 566 | /** Cluster containing this core */ |
| 567 | const struct cpuinfo_cluster* cluster; |
| 568 | /** Physical package containing this core. */ |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 569 | const struct cpuinfo_package* package; |
| 570 | /** Vendor of the CPU microarchitecture for this core */ |
| 571 | enum cpuinfo_vendor vendor; |
| 572 | /** CPU microarchitecture for this core */ |
| 573 | enum cpuinfo_uarch uarch; |
| 574 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 575 | /** Value of CPUID leaf 1 EAX register for this core */ |
| 576 | uint32_t cpuid; |
| 577 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 578 | /** Value of Main ID Register (MIDR) for this core */ |
| 579 | uint32_t midr; |
| 580 | #endif |
Marat Dukhan | 28538f4 | 2018-03-10 14:28:14 -0800 | [diff] [blame] | 581 | /** Clock rate (non-Turbo) of the core, in Hz */ |
| 582 | uint64_t frequency; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 583 | }; |
| 584 | |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 585 | struct cpuinfo_cluster { |
| 586 | /** Index of the first logical processor in the cluster */ |
| 587 | uint32_t processor_start; |
| 588 | /** Number of logical processors in the cluster */ |
| 589 | uint32_t processor_count; |
| 590 | /** Index of the first core in the cluster */ |
| 591 | uint32_t core_start; |
| 592 | /** Number of cores on the cluster */ |
| 593 | uint32_t core_count; |
| 594 | /** Cluster ID within a package */ |
| 595 | uint32_t cluster_id; |
| 596 | /** Physical package containing the cluster */ |
| 597 | const struct cpuinfo_package* package; |
| 598 | /** CPU microarchitecture vendor of the cores in the cluster */ |
| 599 | enum cpuinfo_vendor vendor; |
| 600 | /** CPU microarchitecture of the cores in the cluster */ |
| 601 | enum cpuinfo_uarch uarch; |
| 602 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 603 | /** Value of CPUID leaf 1 EAX register of the cores in the cluster */ |
| 604 | uint32_t cpuid; |
| 605 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 606 | /** Value of Main ID Register (MIDR) of the cores in the cluster */ |
| 607 | uint32_t midr; |
| 608 | #endif |
| 609 | /** Clock rate (non-Turbo) of the cores in the cluster, in Hz */ |
| 610 | uint64_t frequency; |
| 611 | }; |
| 612 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 613 | #define CPUINFO_PACKAGE_NAME_MAX 48 |
| 614 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 615 | struct cpuinfo_package { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 616 | /** SoC or processor chip model name */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 617 | char name[CPUINFO_PACKAGE_NAME_MAX]; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 618 | /** Index of the first logical processor on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 619 | uint32_t processor_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 620 | /** Number of logical processors on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 621 | uint32_t processor_count; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 622 | /** Index of the first core on this physical package */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 623 | uint32_t core_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 624 | /** Number of cores on this physical package */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 625 | uint32_t core_count; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 626 | /** Index of the first cluster of cores on this physical package */ |
| 627 | uint32_t cluster_start; |
| 628 | /** Number of clusters of cores on this physical package */ |
| 629 | uint32_t cluster_count; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 630 | }; |
| 631 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 632 | struct cpuinfo_uarch_info { |
| 633 | /** Type of CPU microarchitecture */ |
| 634 | enum cpuinfo_uarch uarch; |
| 635 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 636 | /** Value of CPUID leaf 1 EAX register for the microarchitecture */ |
| 637 | uint32_t cpuid; |
| 638 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 639 | /** Value of Main ID Register (MIDR) for the microarchitecture */ |
| 640 | uint32_t midr; |
| 641 | #endif |
| 642 | /** Number of logical processors with the microarchitecture */ |
| 643 | uint32_t processor_count; |
| 644 | /** Number of cores with the microarchitecture */ |
| 645 | uint32_t core_count; |
| 646 | }; |
| 647 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 648 | #ifdef __cplusplus |
| 649 | extern "C" { |
| 650 | #endif |
| 651 | |
Marat Dukhan | 5355651 | 2018-02-25 09:01:27 +0100 | [diff] [blame] | 652 | bool CPUINFO_ABI cpuinfo_initialize(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 653 | |
| 654 | void CPUINFO_ABI cpuinfo_deinitialize(void); |
| 655 | |
| 656 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 657 | /* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions instead. */ |
| 658 | struct cpuinfo_x86_isa { |
| 659 | #if CPUINFO_ARCH_X86 |
| 660 | bool rdtsc; |
| 661 | #endif |
| 662 | bool rdtscp; |
| 663 | bool rdpid; |
| 664 | bool sysenter; |
| 665 | #if CPUINFO_ARCH_X86 |
| 666 | bool syscall; |
| 667 | #endif |
| 668 | bool msr; |
| 669 | bool clzero; |
| 670 | bool clflush; |
| 671 | bool clflushopt; |
| 672 | bool mwait; |
| 673 | bool mwaitx; |
| 674 | #if CPUINFO_ARCH_X86 |
| 675 | bool emmx; |
| 676 | #endif |
| 677 | bool fxsave; |
| 678 | bool xsave; |
| 679 | #if CPUINFO_ARCH_X86 |
| 680 | bool fpu; |
| 681 | bool mmx; |
| 682 | bool mmx_plus; |
| 683 | #endif |
| 684 | bool three_d_now; |
| 685 | bool three_d_now_plus; |
| 686 | #if CPUINFO_ARCH_X86 |
| 687 | bool three_d_now_geode; |
| 688 | #endif |
| 689 | bool prefetch; |
| 690 | bool prefetchw; |
| 691 | bool prefetchwt1; |
| 692 | #if CPUINFO_ARCH_X86 |
| 693 | bool daz; |
| 694 | bool sse; |
| 695 | bool sse2; |
| 696 | #endif |
| 697 | bool sse3; |
| 698 | bool ssse3; |
| 699 | bool sse4_1; |
| 700 | bool sse4_2; |
| 701 | bool sse4a; |
| 702 | bool misaligned_sse; |
| 703 | bool avx; |
| 704 | bool fma3; |
| 705 | bool fma4; |
| 706 | bool xop; |
| 707 | bool f16c; |
| 708 | bool avx2; |
| 709 | bool avx512f; |
| 710 | bool avx512pf; |
| 711 | bool avx512er; |
| 712 | bool avx512cd; |
| 713 | bool avx512dq; |
| 714 | bool avx512bw; |
| 715 | bool avx512vl; |
| 716 | bool avx512ifma; |
| 717 | bool avx512vbmi; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 718 | bool avx512vbmi2; |
| 719 | bool avx512bitalg; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 720 | bool avx512vpopcntdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 721 | bool avx512vnni; |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 722 | bool avx512bf16; |
| 723 | bool avx512vp2intersect; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 724 | bool avx512_4vnniw; |
| 725 | bool avx512_4fmaps; |
| 726 | bool hle; |
| 727 | bool rtm; |
| 728 | bool xtest; |
| 729 | bool mpx; |
| 730 | #if CPUINFO_ARCH_X86 |
| 731 | bool cmov; |
| 732 | bool cmpxchg8b; |
| 733 | #endif |
| 734 | bool cmpxchg16b; |
| 735 | bool clwb; |
| 736 | bool movbe; |
| 737 | #if CPUINFO_ARCH_X86_64 |
| 738 | bool lahf_sahf; |
| 739 | #endif |
| 740 | bool fs_gs_base; |
| 741 | bool lzcnt; |
| 742 | bool popcnt; |
| 743 | bool tbm; |
| 744 | bool bmi; |
| 745 | bool bmi2; |
| 746 | bool adx; |
| 747 | bool aes; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 748 | bool vaes; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 749 | bool pclmulqdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 750 | bool vpclmulqdq; |
| 751 | bool gfni; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 752 | bool rdrand; |
| 753 | bool rdseed; |
| 754 | bool sha; |
| 755 | bool rng; |
| 756 | bool ace; |
| 757 | bool ace2; |
| 758 | bool phe; |
| 759 | bool pmm; |
| 760 | bool lwp; |
| 761 | }; |
| 762 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 763 | extern struct cpuinfo_x86_isa cpuinfo_isa; |
| 764 | #endif |
| 765 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 766 | static inline bool cpuinfo_has_x86_rdtsc(void) { |
| 767 | #if CPUINFO_ARCH_X86_64 |
| 768 | return true; |
| 769 | #elif CPUINFO_ARCH_X86 |
| 770 | #if defined(__ANDROID__) |
| 771 | return true; |
| 772 | #else |
| 773 | return cpuinfo_isa.rdtsc; |
| 774 | #endif |
| 775 | #else |
| 776 | return false; |
| 777 | #endif |
| 778 | } |
| 779 | |
| 780 | static inline bool cpuinfo_has_x86_rdtscp(void) { |
| 781 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 782 | return cpuinfo_isa.rdtscp; |
| 783 | #else |
| 784 | return false; |
| 785 | #endif |
| 786 | } |
| 787 | |
| 788 | static inline bool cpuinfo_has_x86_rdpid(void) { |
| 789 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 790 | return cpuinfo_isa.rdpid; |
| 791 | #else |
| 792 | return false; |
| 793 | #endif |
| 794 | } |
| 795 | |
| 796 | static inline bool cpuinfo_has_x86_clzero(void) { |
| 797 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 798 | return cpuinfo_isa.clzero; |
| 799 | #else |
| 800 | return false; |
| 801 | #endif |
| 802 | } |
| 803 | |
| 804 | static inline bool cpuinfo_has_x86_mwait(void) { |
| 805 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 806 | return cpuinfo_isa.mwait; |
| 807 | #else |
| 808 | return false; |
| 809 | #endif |
| 810 | } |
| 811 | |
| 812 | static inline bool cpuinfo_has_x86_mwaitx(void) { |
| 813 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 814 | return cpuinfo_isa.mwaitx; |
| 815 | #else |
| 816 | return false; |
| 817 | #endif |
| 818 | } |
| 819 | |
| 820 | static inline bool cpuinfo_has_x86_fxsave(void) { |
| 821 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 822 | return cpuinfo_isa.fxsave; |
| 823 | #else |
| 824 | return false; |
| 825 | #endif |
| 826 | } |
| 827 | |
| 828 | static inline bool cpuinfo_has_x86_xsave(void) { |
| 829 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 830 | return cpuinfo_isa.xsave; |
| 831 | #else |
| 832 | return false; |
| 833 | #endif |
| 834 | } |
| 835 | |
| 836 | static inline bool cpuinfo_has_x86_fpu(void) { |
| 837 | #if CPUINFO_ARCH_X86_64 |
| 838 | return true; |
| 839 | #elif CPUINFO_ARCH_X86 |
| 840 | #if defined(__ANDROID__) |
| 841 | return true; |
| 842 | #else |
| 843 | return cpuinfo_isa.fpu; |
| 844 | #endif |
| 845 | #else |
| 846 | return false; |
| 847 | #endif |
| 848 | } |
| 849 | |
| 850 | static inline bool cpuinfo_has_x86_mmx(void) { |
| 851 | #if CPUINFO_ARCH_X86_64 |
| 852 | return true; |
| 853 | #elif CPUINFO_ARCH_X86 |
| 854 | #if defined(__ANDROID__) |
| 855 | return true; |
| 856 | #else |
| 857 | return cpuinfo_isa.mmx; |
| 858 | #endif |
| 859 | #else |
| 860 | return false; |
| 861 | #endif |
| 862 | } |
| 863 | |
| 864 | static inline bool cpuinfo_has_x86_mmx_plus(void) { |
| 865 | #if CPUINFO_ARCH_X86_64 |
| 866 | return true; |
| 867 | #elif CPUINFO_ARCH_X86 |
| 868 | #if defined(__ANDROID__) |
| 869 | return true; |
| 870 | #else |
| 871 | return cpuinfo_isa.mmx_plus; |
| 872 | #endif |
| 873 | #else |
| 874 | return false; |
| 875 | #endif |
| 876 | } |
| 877 | |
| 878 | static inline bool cpuinfo_has_x86_3dnow(void) { |
| 879 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 880 | return cpuinfo_isa.three_d_now; |
| 881 | #else |
| 882 | return false; |
| 883 | #endif |
| 884 | } |
| 885 | |
| 886 | static inline bool cpuinfo_has_x86_3dnow_plus(void) { |
| 887 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 888 | return cpuinfo_isa.three_d_now_plus; |
| 889 | #else |
| 890 | return false; |
| 891 | #endif |
| 892 | } |
| 893 | |
| 894 | static inline bool cpuinfo_has_x86_3dnow_geode(void) { |
| 895 | #if CPUINFO_ARCH_X86_64 |
| 896 | return false; |
| 897 | #elif CPUINFO_ARCH_X86 |
| 898 | #if defined(__ANDROID__) |
| 899 | return false; |
| 900 | #else |
| 901 | return cpuinfo_isa.three_d_now_geode; |
| 902 | #endif |
| 903 | #else |
| 904 | return false; |
| 905 | #endif |
| 906 | } |
| 907 | |
| 908 | static inline bool cpuinfo_has_x86_prefetch(void) { |
| 909 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 910 | return cpuinfo_isa.prefetch; |
| 911 | #else |
| 912 | return false; |
| 913 | #endif |
| 914 | } |
| 915 | |
| 916 | static inline bool cpuinfo_has_x86_prefetchw(void) { |
| 917 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 918 | return cpuinfo_isa.prefetchw; |
| 919 | #else |
| 920 | return false; |
| 921 | #endif |
| 922 | } |
| 923 | |
| 924 | static inline bool cpuinfo_has_x86_prefetchwt1(void) { |
| 925 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 926 | return cpuinfo_isa.prefetchwt1; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 927 | #else |
| 928 | return false; |
| 929 | #endif |
| 930 | } |
| 931 | |
| 932 | static inline bool cpuinfo_has_x86_daz(void) { |
| 933 | #if CPUINFO_ARCH_X86_64 |
| 934 | return true; |
| 935 | #elif CPUINFO_ARCH_X86 |
| 936 | #if defined(__ANDROID__) |
| 937 | return true; |
| 938 | #else |
| 939 | return cpuinfo_isa.daz; |
| 940 | #endif |
| 941 | #else |
| 942 | return false; |
| 943 | #endif |
| 944 | } |
| 945 | |
Marat Dukhan | 9da4c91 | 2017-09-26 10:53:28 -0700 | [diff] [blame] | 946 | static inline bool cpuinfo_has_x86_sse(void) { |
| 947 | #if CPUINFO_ARCH_X86_64 |
| 948 | return true; |
| 949 | #elif CPUINFO_ARCH_X86 |
| 950 | #if defined(__ANDROID__) |
| 951 | return true; |
| 952 | #else |
| 953 | return cpuinfo_isa.sse; |
| 954 | #endif |
| 955 | #else |
| 956 | return false; |
| 957 | #endif |
| 958 | } |
| 959 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 960 | static inline bool cpuinfo_has_x86_sse2(void) { |
| 961 | #if CPUINFO_ARCH_X86_64 |
| 962 | return true; |
| 963 | #elif CPUINFO_ARCH_X86 |
| 964 | #if defined(__ANDROID__) |
| 965 | return true; |
| 966 | #else |
| 967 | return cpuinfo_isa.sse2; |
| 968 | #endif |
| 969 | #else |
| 970 | return false; |
| 971 | #endif |
| 972 | } |
| 973 | |
| 974 | static inline bool cpuinfo_has_x86_sse3(void) { |
| 975 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 976 | #if defined(__ANDROID__) |
| 977 | return true; |
| 978 | #else |
| 979 | return cpuinfo_isa.sse3; |
| 980 | #endif |
| 981 | #else |
| 982 | return false; |
| 983 | #endif |
| 984 | } |
| 985 | |
| 986 | static inline bool cpuinfo_has_x86_ssse3(void) { |
| 987 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 988 | #if defined(__ANDROID__) |
| 989 | return true; |
| 990 | #else |
| 991 | return cpuinfo_isa.ssse3; |
| 992 | #endif |
| 993 | #else |
| 994 | return false; |
| 995 | #endif |
| 996 | } |
| 997 | |
| 998 | static inline bool cpuinfo_has_x86_sse4_1(void) { |
| 999 | #if CPUINFO_ARCH_X86_64 |
| 1000 | #if defined(__ANDROID__) |
| 1001 | return true; |
| 1002 | #else |
| 1003 | return cpuinfo_isa.sse4_1; |
| 1004 | #endif |
| 1005 | #elif CPUINFO_ARCH_X86 |
| 1006 | return cpuinfo_isa.sse4_1; |
| 1007 | #else |
| 1008 | return false; |
| 1009 | #endif |
| 1010 | } |
| 1011 | |
| 1012 | static inline bool cpuinfo_has_x86_sse4_2(void) { |
| 1013 | #if CPUINFO_ARCH_X86_64 |
| 1014 | #if defined(__ANDROID__) |
| 1015 | return true; |
| 1016 | #else |
| 1017 | return cpuinfo_isa.sse4_2; |
| 1018 | #endif |
| 1019 | #elif CPUINFO_ARCH_X86 |
| 1020 | return cpuinfo_isa.sse4_2; |
| 1021 | #else |
| 1022 | return false; |
| 1023 | #endif |
| 1024 | } |
| 1025 | |
| 1026 | static inline bool cpuinfo_has_x86_sse4a(void) { |
| 1027 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1028 | return cpuinfo_isa.sse4a; |
| 1029 | #else |
| 1030 | return false; |
| 1031 | #endif |
| 1032 | } |
| 1033 | |
| 1034 | static inline bool cpuinfo_has_x86_misaligned_sse(void) { |
| 1035 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1036 | return cpuinfo_isa.misaligned_sse; |
| 1037 | #else |
| 1038 | return false; |
| 1039 | #endif |
| 1040 | } |
| 1041 | |
| 1042 | static inline bool cpuinfo_has_x86_avx(void) { |
| 1043 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1044 | return cpuinfo_isa.avx; |
| 1045 | #else |
| 1046 | return false; |
| 1047 | #endif |
| 1048 | } |
| 1049 | |
| 1050 | static inline bool cpuinfo_has_x86_fma3(void) { |
| 1051 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1052 | return cpuinfo_isa.fma3; |
| 1053 | #else |
| 1054 | return false; |
| 1055 | #endif |
| 1056 | } |
| 1057 | |
| 1058 | static inline bool cpuinfo_has_x86_fma4(void) { |
| 1059 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1060 | return cpuinfo_isa.fma4; |
| 1061 | #else |
| 1062 | return false; |
| 1063 | #endif |
| 1064 | } |
| 1065 | |
| 1066 | static inline bool cpuinfo_has_x86_xop(void) { |
| 1067 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1068 | return cpuinfo_isa.xop; |
| 1069 | #else |
| 1070 | return false; |
| 1071 | #endif |
| 1072 | } |
| 1073 | |
| 1074 | static inline bool cpuinfo_has_x86_f16c(void) { |
| 1075 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1076 | return cpuinfo_isa.f16c; |
| 1077 | #else |
| 1078 | return false; |
| 1079 | #endif |
| 1080 | } |
| 1081 | |
| 1082 | static inline bool cpuinfo_has_x86_avx2(void) { |
| 1083 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1084 | return cpuinfo_isa.avx2; |
| 1085 | #else |
| 1086 | return false; |
| 1087 | #endif |
| 1088 | } |
| 1089 | |
| 1090 | static inline bool cpuinfo_has_x86_avx512f(void) { |
| 1091 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1092 | return cpuinfo_isa.avx512f; |
| 1093 | #else |
| 1094 | return false; |
| 1095 | #endif |
| 1096 | } |
| 1097 | |
| 1098 | static inline bool cpuinfo_has_x86_avx512pf(void) { |
| 1099 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1100 | return cpuinfo_isa.avx512pf; |
| 1101 | #else |
| 1102 | return false; |
| 1103 | #endif |
| 1104 | } |
| 1105 | |
| 1106 | static inline bool cpuinfo_has_x86_avx512er(void) { |
| 1107 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1108 | return cpuinfo_isa.avx512er; |
| 1109 | #else |
| 1110 | return false; |
| 1111 | #endif |
| 1112 | } |
| 1113 | |
| 1114 | static inline bool cpuinfo_has_x86_avx512cd(void) { |
| 1115 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1116 | return cpuinfo_isa.avx512cd; |
| 1117 | #else |
| 1118 | return false; |
| 1119 | #endif |
| 1120 | } |
| 1121 | |
| 1122 | static inline bool cpuinfo_has_x86_avx512dq(void) { |
| 1123 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1124 | return cpuinfo_isa.avx512dq; |
| 1125 | #else |
| 1126 | return false; |
| 1127 | #endif |
| 1128 | } |
| 1129 | |
| 1130 | static inline bool cpuinfo_has_x86_avx512bw(void) { |
| 1131 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1132 | return cpuinfo_isa.avx512bw; |
| 1133 | #else |
| 1134 | return false; |
| 1135 | #endif |
| 1136 | } |
| 1137 | |
| 1138 | static inline bool cpuinfo_has_x86_avx512vl(void) { |
| 1139 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1140 | return cpuinfo_isa.avx512vl; |
| 1141 | #else |
| 1142 | return false; |
| 1143 | #endif |
| 1144 | } |
| 1145 | |
| 1146 | static inline bool cpuinfo_has_x86_avx512ifma(void) { |
| 1147 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1148 | return cpuinfo_isa.avx512ifma; |
| 1149 | #else |
| 1150 | return false; |
| 1151 | #endif |
| 1152 | } |
| 1153 | |
| 1154 | static inline bool cpuinfo_has_x86_avx512vbmi(void) { |
| 1155 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1156 | return cpuinfo_isa.avx512vbmi; |
| 1157 | #else |
| 1158 | return false; |
| 1159 | #endif |
| 1160 | } |
| 1161 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1162 | static inline bool cpuinfo_has_x86_avx512vbmi2(void) { |
| 1163 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1164 | return cpuinfo_isa.avx512vbmi2; |
| 1165 | #else |
| 1166 | return false; |
| 1167 | #endif |
| 1168 | } |
| 1169 | |
| 1170 | static inline bool cpuinfo_has_x86_avx512bitalg(void) { |
| 1171 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1172 | return cpuinfo_isa.avx512bitalg; |
| 1173 | #else |
| 1174 | return false; |
| 1175 | #endif |
| 1176 | } |
| 1177 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1178 | static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) { |
| 1179 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1180 | return cpuinfo_isa.avx512vpopcntdq; |
| 1181 | #else |
| 1182 | return false; |
| 1183 | #endif |
| 1184 | } |
| 1185 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1186 | static inline bool cpuinfo_has_x86_avx512vnni(void) { |
Marat Dukhan | 6b33b23 | 2017-10-13 09:36:52 -0700 | [diff] [blame] | 1187 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1188 | return cpuinfo_isa.avx512vnni; |
| 1189 | #else |
| 1190 | return false; |
| 1191 | #endif |
| 1192 | } |
| 1193 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 1194 | static inline bool cpuinfo_has_x86_avx512bf16(void) { |
| 1195 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1196 | return cpuinfo_isa.avx512bf16; |
| 1197 | #else |
| 1198 | return false; |
| 1199 | #endif |
| 1200 | } |
| 1201 | |
| 1202 | static inline bool cpuinfo_has_x86_avx512vp2intersect(void) { |
| 1203 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1204 | return cpuinfo_isa.avx512vp2intersect; |
| 1205 | #else |
| 1206 | return false; |
| 1207 | #endif |
| 1208 | } |
| 1209 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1210 | static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { |
| 1211 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1212 | return cpuinfo_isa.avx512_4vnniw; |
| 1213 | #else |
| 1214 | return false; |
| 1215 | #endif |
| 1216 | } |
| 1217 | |
| 1218 | static inline bool cpuinfo_has_x86_avx512_4fmaps(void) { |
| 1219 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1220 | return cpuinfo_isa.avx512_4fmaps; |
| 1221 | #else |
| 1222 | return false; |
| 1223 | #endif |
| 1224 | } |
| 1225 | |
Marat Dukhan | 9e32e8d | 2017-09-26 11:02:37 -0700 | [diff] [blame] | 1226 | static inline bool cpuinfo_has_x86_hle(void) { |
| 1227 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1228 | return cpuinfo_isa.hle; |
| 1229 | #else |
| 1230 | return false; |
| 1231 | #endif |
| 1232 | } |
| 1233 | |
| 1234 | static inline bool cpuinfo_has_x86_rtm(void) { |
| 1235 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1236 | return cpuinfo_isa.rtm; |
| 1237 | #else |
| 1238 | return false; |
| 1239 | #endif |
| 1240 | } |
| 1241 | |
| 1242 | static inline bool cpuinfo_has_x86_xtest(void) { |
| 1243 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1244 | return cpuinfo_isa.xtest; |
| 1245 | #else |
| 1246 | return false; |
| 1247 | #endif |
| 1248 | } |
| 1249 | |
| 1250 | static inline bool cpuinfo_has_x86_mpx(void) { |
| 1251 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1252 | return cpuinfo_isa.mpx; |
| 1253 | #else |
| 1254 | return false; |
| 1255 | #endif |
| 1256 | } |
| 1257 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1258 | static inline bool cpuinfo_has_x86_cmov(void) { |
| 1259 | #if CPUINFO_ARCH_X86_64 |
| 1260 | return true; |
| 1261 | #elif CPUINFO_ARCH_X86 |
| 1262 | return cpuinfo_isa.cmov; |
| 1263 | #else |
| 1264 | return false; |
| 1265 | #endif |
| 1266 | } |
| 1267 | |
| 1268 | static inline bool cpuinfo_has_x86_cmpxchg8b(void) { |
| 1269 | #if CPUINFO_ARCH_X86_64 |
| 1270 | return true; |
| 1271 | #elif CPUINFO_ARCH_X86 |
| 1272 | return cpuinfo_isa.cmpxchg8b; |
| 1273 | #else |
| 1274 | return false; |
| 1275 | #endif |
| 1276 | } |
| 1277 | |
| 1278 | static inline bool cpuinfo_has_x86_cmpxchg16b(void) { |
| 1279 | #if CPUINFO_ARCH_X86_64 |
| 1280 | return cpuinfo_isa.cmpxchg16b; |
| 1281 | #else |
| 1282 | return false; |
| 1283 | #endif |
| 1284 | } |
| 1285 | |
| 1286 | static inline bool cpuinfo_has_x86_clwb(void) { |
| 1287 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1288 | return cpuinfo_isa.clwb; |
| 1289 | #else |
| 1290 | return false; |
| 1291 | #endif |
| 1292 | } |
| 1293 | |
| 1294 | static inline bool cpuinfo_has_x86_movbe(void) { |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1295 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1296 | return cpuinfo_isa.movbe; |
| 1297 | #else |
| 1298 | return false; |
| 1299 | #endif |
| 1300 | } |
| 1301 | |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1302 | static inline bool cpuinfo_has_x86_lahf_sahf(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1303 | #if CPUINFO_ARCH_X86 |
| 1304 | return true; |
| 1305 | #elif CPUINFO_ARCH_X86_64 |
| 1306 | return cpuinfo_isa.lahf_sahf; |
| 1307 | #else |
| 1308 | return false; |
| 1309 | #endif |
| 1310 | } |
| 1311 | |
| 1312 | static inline bool cpuinfo_has_x86_lzcnt(void) { |
| 1313 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1314 | return cpuinfo_isa.lzcnt; |
| 1315 | #else |
| 1316 | return false; |
| 1317 | #endif |
| 1318 | } |
| 1319 | |
| 1320 | static inline bool cpuinfo_has_x86_popcnt(void) { |
| 1321 | #if CPUINFO_ARCH_X86_64 |
| 1322 | #if defined(__ANDROID__) |
| 1323 | return true; |
| 1324 | #else |
| 1325 | return cpuinfo_isa.popcnt; |
| 1326 | #endif |
| 1327 | #elif CPUINFO_ARCH_X86 |
| 1328 | return cpuinfo_isa.popcnt; |
| 1329 | #else |
| 1330 | return false; |
| 1331 | #endif |
| 1332 | } |
| 1333 | |
| 1334 | static inline bool cpuinfo_has_x86_tbm(void) { |
| 1335 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1336 | return cpuinfo_isa.tbm; |
| 1337 | #else |
| 1338 | return false; |
| 1339 | #endif |
| 1340 | } |
| 1341 | |
| 1342 | static inline bool cpuinfo_has_x86_bmi(void) { |
| 1343 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1344 | return cpuinfo_isa.bmi; |
| 1345 | #else |
| 1346 | return false; |
| 1347 | #endif |
| 1348 | } |
| 1349 | |
| 1350 | static inline bool cpuinfo_has_x86_bmi2(void) { |
| 1351 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1352 | return cpuinfo_isa.bmi2; |
| 1353 | #else |
| 1354 | return false; |
| 1355 | #endif |
| 1356 | } |
| 1357 | |
| 1358 | static inline bool cpuinfo_has_x86_adx(void) { |
| 1359 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1360 | return cpuinfo_isa.adx; |
| 1361 | #else |
| 1362 | return false; |
| 1363 | #endif |
| 1364 | } |
| 1365 | |
| 1366 | static inline bool cpuinfo_has_x86_aes(void) { |
| 1367 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1368 | return cpuinfo_isa.aes; |
| 1369 | #else |
| 1370 | return false; |
| 1371 | #endif |
| 1372 | } |
| 1373 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1374 | static inline bool cpuinfo_has_x86_vaes(void) { |
| 1375 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1376 | return cpuinfo_isa.vaes; |
| 1377 | #else |
| 1378 | return false; |
| 1379 | #endif |
| 1380 | } |
| 1381 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1382 | static inline bool cpuinfo_has_x86_pclmulqdq(void) { |
| 1383 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1384 | return cpuinfo_isa.pclmulqdq; |
| 1385 | #else |
| 1386 | return false; |
| 1387 | #endif |
| 1388 | } |
| 1389 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1390 | static inline bool cpuinfo_has_x86_vpclmulqdq(void) { |
| 1391 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1392 | return cpuinfo_isa.vpclmulqdq; |
| 1393 | #else |
| 1394 | return false; |
| 1395 | #endif |
| 1396 | } |
| 1397 | |
| 1398 | static inline bool cpuinfo_has_x86_gfni(void) { |
| 1399 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1400 | return cpuinfo_isa.gfni; |
| 1401 | #else |
| 1402 | return false; |
| 1403 | #endif |
| 1404 | } |
| 1405 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1406 | static inline bool cpuinfo_has_x86_rdrand(void) { |
| 1407 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1408 | return cpuinfo_isa.rdrand; |
| 1409 | #else |
| 1410 | return false; |
| 1411 | #endif |
| 1412 | } |
| 1413 | |
| 1414 | static inline bool cpuinfo_has_x86_rdseed(void) { |
| 1415 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1416 | return cpuinfo_isa.rdseed; |
| 1417 | #else |
| 1418 | return false; |
| 1419 | #endif |
| 1420 | } |
| 1421 | |
| 1422 | static inline bool cpuinfo_has_x86_sha(void) { |
| 1423 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1424 | return cpuinfo_isa.sha; |
| 1425 | #else |
| 1426 | return false; |
| 1427 | #endif |
| 1428 | } |
| 1429 | |
Marat Dukhan | ab42e7e | 2017-05-09 13:19:39 +0000 | [diff] [blame] | 1430 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1431 | /* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions instead. */ |
| 1432 | struct cpuinfo_arm_isa { |
| 1433 | #if CPUINFO_ARCH_ARM |
| 1434 | bool thumb; |
| 1435 | bool thumb2; |
| 1436 | bool thumbee; |
| 1437 | bool jazelle; |
| 1438 | bool armv5e; |
| 1439 | bool armv6; |
| 1440 | bool armv6k; |
| 1441 | bool armv7; |
| 1442 | bool armv7mp; |
Ashkan Aliabadi | f558241 | 2020-06-11 21:17:20 -0700 | [diff] [blame] | 1443 | bool armv8; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1444 | bool idiv; |
| 1445 | |
| 1446 | bool vfpv2; |
| 1447 | bool vfpv3; |
| 1448 | bool d32; |
| 1449 | bool fp16; |
| 1450 | bool fma; |
| 1451 | |
| 1452 | bool wmmx; |
| 1453 | bool wmmx2; |
| 1454 | bool neon; |
| 1455 | #endif |
| 1456 | #if CPUINFO_ARCH_ARM64 |
| 1457 | bool atomics; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1458 | #endif |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1459 | bool rdm; |
| 1460 | bool fp16arith; |
Marat Dukhan | db14c22 | 2018-12-19 02:34:17 -0800 | [diff] [blame] | 1461 | bool dot; |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1462 | bool jscvt; |
| 1463 | bool fcma; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1464 | |
| 1465 | bool aes; |
| 1466 | bool sha1; |
| 1467 | bool sha2; |
| 1468 | bool pmull; |
| 1469 | bool crc32; |
| 1470 | }; |
| 1471 | |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 1472 | extern struct cpuinfo_arm_isa cpuinfo_isa; |
| 1473 | #endif |
| 1474 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1475 | static inline bool cpuinfo_has_arm_thumb(void) { |
| 1476 | #if CPUINFO_ARCH_ARM |
| 1477 | return cpuinfo_isa.thumb; |
| 1478 | #else |
| 1479 | return false; |
| 1480 | #endif |
| 1481 | } |
| 1482 | |
| 1483 | static inline bool cpuinfo_has_arm_thumb2(void) { |
| 1484 | #if CPUINFO_ARCH_ARM |
| 1485 | return cpuinfo_isa.thumb2; |
| 1486 | #else |
| 1487 | return false; |
| 1488 | #endif |
| 1489 | } |
| 1490 | |
| 1491 | static inline bool cpuinfo_has_arm_v5e(void) { |
| 1492 | #if CPUINFO_ARCH_ARM |
| 1493 | return cpuinfo_isa.armv5e; |
| 1494 | #else |
| 1495 | return false; |
| 1496 | #endif |
| 1497 | } |
| 1498 | |
| 1499 | static inline bool cpuinfo_has_arm_v6(void) { |
| 1500 | #if CPUINFO_ARCH_ARM |
| 1501 | return cpuinfo_isa.armv6; |
| 1502 | #else |
| 1503 | return false; |
| 1504 | #endif |
| 1505 | } |
| 1506 | |
| 1507 | static inline bool cpuinfo_has_arm_v6k(void) { |
| 1508 | #if CPUINFO_ARCH_ARM |
| 1509 | return cpuinfo_isa.armv6k; |
| 1510 | #else |
| 1511 | return false; |
| 1512 | #endif |
| 1513 | } |
| 1514 | |
| 1515 | static inline bool cpuinfo_has_arm_v7(void) { |
| 1516 | #if CPUINFO_ARCH_ARM |
| 1517 | return cpuinfo_isa.armv7; |
| 1518 | #else |
| 1519 | return false; |
| 1520 | #endif |
| 1521 | } |
| 1522 | |
| 1523 | static inline bool cpuinfo_has_arm_v7mp(void) { |
| 1524 | #if CPUINFO_ARCH_ARM |
| 1525 | return cpuinfo_isa.armv7mp; |
| 1526 | #else |
| 1527 | return false; |
| 1528 | #endif |
| 1529 | } |
| 1530 | |
Ashkan Aliabadi | f558241 | 2020-06-11 21:17:20 -0700 | [diff] [blame] | 1531 | static inline bool cpuinfo_has_arm_v8(void) { |
| 1532 | #if CPUINFO_ARCH_ARM64 |
| 1533 | return true; |
| 1534 | #elif CPUINFO_ARCH_ARM |
| 1535 | return cpuinfo_isa.armv8; |
| 1536 | #else |
| 1537 | return false; |
| 1538 | #endif |
| 1539 | } |
| 1540 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1541 | static inline bool cpuinfo_has_arm_idiv(void) { |
| 1542 | #if CPUINFO_ARCH_ARM64 |
| 1543 | return true; |
| 1544 | #elif CPUINFO_ARCH_ARM |
| 1545 | return cpuinfo_isa.idiv; |
| 1546 | #else |
| 1547 | return false; |
| 1548 | #endif |
| 1549 | } |
| 1550 | |
| 1551 | static inline bool cpuinfo_has_arm_vfpv2(void) { |
| 1552 | #if CPUINFO_ARCH_ARM |
| 1553 | return cpuinfo_isa.vfpv2; |
| 1554 | #else |
| 1555 | return false; |
| 1556 | #endif |
| 1557 | } |
| 1558 | |
| 1559 | static inline bool cpuinfo_has_arm_vfpv3(void) { |
| 1560 | #if CPUINFO_ARCH_ARM64 |
| 1561 | return true; |
| 1562 | #elif CPUINFO_ARCH_ARM |
| 1563 | return cpuinfo_isa.vfpv3; |
| 1564 | #else |
| 1565 | return false; |
| 1566 | #endif |
| 1567 | } |
| 1568 | |
| 1569 | static inline bool cpuinfo_has_arm_vfpv3_d32(void) { |
| 1570 | #if CPUINFO_ARCH_ARM64 |
| 1571 | return true; |
| 1572 | #elif CPUINFO_ARCH_ARM |
| 1573 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32; |
| 1574 | #else |
| 1575 | return false; |
| 1576 | #endif |
| 1577 | } |
| 1578 | |
| 1579 | static inline bool cpuinfo_has_arm_vfpv3_fp16(void) { |
| 1580 | #if CPUINFO_ARCH_ARM64 |
| 1581 | return true; |
| 1582 | #elif CPUINFO_ARCH_ARM |
| 1583 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16; |
| 1584 | #else |
| 1585 | return false; |
| 1586 | #endif |
| 1587 | } |
| 1588 | |
| 1589 | static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) { |
| 1590 | #if CPUINFO_ARCH_ARM64 |
| 1591 | return true; |
| 1592 | #elif CPUINFO_ARCH_ARM |
| 1593 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32; |
| 1594 | #else |
| 1595 | return false; |
| 1596 | #endif |
| 1597 | } |
| 1598 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1599 | static inline bool cpuinfo_has_arm_vfpv4(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1600 | #if CPUINFO_ARCH_ARM64 |
| 1601 | return true; |
| 1602 | #elif CPUINFO_ARCH_ARM |
| 1603 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma; |
| 1604 | #else |
| 1605 | return false; |
| 1606 | #endif |
| 1607 | } |
| 1608 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1609 | static inline bool cpuinfo_has_arm_vfpv4_d32(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1610 | #if CPUINFO_ARCH_ARM64 |
| 1611 | return true; |
| 1612 | #elif CPUINFO_ARCH_ARM |
| 1613 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32; |
| 1614 | #else |
| 1615 | return false; |
| 1616 | #endif |
| 1617 | } |
| 1618 | |
| 1619 | static inline bool cpuinfo_has_arm_wmmx(void) { |
| 1620 | #if CPUINFO_ARCH_ARM |
| 1621 | return cpuinfo_isa.wmmx; |
| 1622 | #else |
| 1623 | return false; |
| 1624 | #endif |
| 1625 | } |
| 1626 | |
| 1627 | static inline bool cpuinfo_has_arm_wmmx2(void) { |
| 1628 | #if CPUINFO_ARCH_ARM |
| 1629 | return cpuinfo_isa.wmmx2; |
| 1630 | #else |
| 1631 | return false; |
| 1632 | #endif |
| 1633 | } |
| 1634 | |
| 1635 | static inline bool cpuinfo_has_arm_neon(void) { |
| 1636 | #if CPUINFO_ARCH_ARM64 |
| 1637 | return true; |
| 1638 | #elif CPUINFO_ARCH_ARM |
| 1639 | return cpuinfo_isa.neon; |
| 1640 | #else |
| 1641 | return false; |
| 1642 | #endif |
| 1643 | } |
| 1644 | |
| 1645 | static inline bool cpuinfo_has_arm_neon_fp16(void) { |
| 1646 | #if CPUINFO_ARCH_ARM64 |
| 1647 | return true; |
| 1648 | #elif CPUINFO_ARCH_ARM |
| 1649 | return cpuinfo_isa.neon && cpuinfo_isa.fp16; |
| 1650 | #else |
| 1651 | return false; |
| 1652 | #endif |
| 1653 | } |
| 1654 | |
| 1655 | static inline bool cpuinfo_has_arm_neon_fma(void) { |
| 1656 | #if CPUINFO_ARCH_ARM64 |
| 1657 | return true; |
| 1658 | #elif CPUINFO_ARCH_ARM |
| 1659 | return cpuinfo_isa.neon && cpuinfo_isa.fma; |
| 1660 | #else |
| 1661 | return false; |
| 1662 | #endif |
| 1663 | } |
| 1664 | |
Ashkan Aliabadi | f558241 | 2020-06-11 21:17:20 -0700 | [diff] [blame] | 1665 | static inline bool cpuinfo_has_arm_neon_v8(void) { |
| 1666 | #if CPUINFO_ARCH_ARM64 |
| 1667 | return true; |
| 1668 | #elif CPUINFO_ARCH_ARM |
| 1669 | return cpuinfo_isa.neon && cpuinfo_isa.armv8; |
| 1670 | #else |
| 1671 | return false; |
| 1672 | #endif |
| 1673 | } |
| 1674 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1675 | static inline bool cpuinfo_has_arm_atomics(void) { |
| 1676 | #if CPUINFO_ARCH_ARM64 |
| 1677 | return cpuinfo_isa.atomics; |
| 1678 | #else |
| 1679 | return false; |
| 1680 | #endif |
| 1681 | } |
| 1682 | |
| 1683 | static inline bool cpuinfo_has_arm_neon_rdm(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1684 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1685 | return cpuinfo_isa.rdm; |
| 1686 | #else |
| 1687 | return false; |
| 1688 | #endif |
| 1689 | } |
| 1690 | |
Marat Dukhan | de2f71e | 2018-06-11 13:30:21 -0700 | [diff] [blame] | 1691 | static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { |
| 1692 | #if CPUINFO_ARCH_ARM |
| 1693 | return cpuinfo_isa.neon && cpuinfo_isa.fp16arith; |
| 1694 | #elif CPUINFO_ARCH_ARM64 |
| 1695 | return cpuinfo_isa.fp16arith; |
| 1696 | #else |
| 1697 | return false; |
| 1698 | #endif |
| 1699 | } |
| 1700 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1701 | static inline bool cpuinfo_has_arm_fp16_arith(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1702 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1703 | return cpuinfo_isa.fp16arith; |
| 1704 | #else |
| 1705 | return false; |
| 1706 | #endif |
| 1707 | } |
| 1708 | |
Marat Dukhan | db14c22 | 2018-12-19 02:34:17 -0800 | [diff] [blame] | 1709 | static inline bool cpuinfo_has_arm_neon_dot(void) { |
| 1710 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1711 | return cpuinfo_isa.dot; |
| 1712 | #else |
| 1713 | return false; |
| 1714 | #endif |
| 1715 | } |
| 1716 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1717 | static inline bool cpuinfo_has_arm_jscvt(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1718 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1719 | return cpuinfo_isa.jscvt; |
| 1720 | #else |
| 1721 | return false; |
| 1722 | #endif |
| 1723 | } |
| 1724 | |
| 1725 | static inline bool cpuinfo_has_arm_fcma(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1726 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1727 | return cpuinfo_isa.fcma; |
| 1728 | #else |
| 1729 | return false; |
| 1730 | #endif |
| 1731 | } |
| 1732 | |
| 1733 | static inline bool cpuinfo_has_arm_aes(void) { |
| 1734 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1735 | return cpuinfo_isa.aes; |
| 1736 | #else |
| 1737 | return false; |
| 1738 | #endif |
| 1739 | } |
| 1740 | |
| 1741 | static inline bool cpuinfo_has_arm_sha1(void) { |
| 1742 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1743 | return cpuinfo_isa.sha1; |
| 1744 | #else |
| 1745 | return false; |
| 1746 | #endif |
| 1747 | } |
| 1748 | |
| 1749 | static inline bool cpuinfo_has_arm_sha2(void) { |
| 1750 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1751 | return cpuinfo_isa.sha2; |
| 1752 | #else |
| 1753 | return false; |
| 1754 | #endif |
| 1755 | } |
| 1756 | |
| 1757 | static inline bool cpuinfo_has_arm_pmull(void) { |
| 1758 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1759 | return cpuinfo_isa.pmull; |
| 1760 | #else |
| 1761 | return false; |
| 1762 | #endif |
| 1763 | } |
| 1764 | |
| 1765 | static inline bool cpuinfo_has_arm_crc32(void) { |
| 1766 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1767 | return cpuinfo_isa.crc32; |
| 1768 | #else |
| 1769 | return false; |
| 1770 | #endif |
| 1771 | } |
| 1772 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1773 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); |
| 1774 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1775 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1776 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1777 | const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1778 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); |
| 1779 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); |
| 1780 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void); |
| 1781 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void); |
| 1782 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 1783 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1784 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); |
| 1785 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1786 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1787 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1788 | const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1789 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); |
| 1790 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); |
| 1791 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index); |
| 1792 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index); |
| 1793 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index); |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 1794 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1795 | uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); |
| 1796 | uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1797 | uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1798 | uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1799 | uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1800 | uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); |
| 1801 | uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); |
| 1802 | uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); |
| 1803 | uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); |
| 1804 | uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); |
Marat Dukhan | 8ecad1a | 2017-05-08 07:21:57 +0000 | [diff] [blame] | 1805 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 1806 | /** |
| 1807 | * Returns upper bound on cache size. |
| 1808 | */ |
| 1809 | uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void); |
| 1810 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1811 | /** |
| 1812 | * Identify the logical processor that executes the current thread. |
| 1813 | * |
| 1814 | * There is no guarantee that the thread will stay on the same logical processor for any time. |
| 1815 | * Callers should treat the result as only a hint, and be prepared to handle NULL return value. |
| 1816 | */ |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1817 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1818 | |
| 1819 | /** |
| 1820 | * Identify the core that executes the current thread. |
| 1821 | * |
| 1822 | * There is no guarantee that the thread will stay on the same core for any time. |
| 1823 | * Callers should treat the result as only a hint, and be prepared to handle NULL return value. |
| 1824 | */ |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1825 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1826 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1827 | /** |
| 1828 | * Identify the microarchitecture index of the core that executes the current thread. |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 1829 | * If the system does not support such identification, the function returns 0. |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1830 | * |
| 1831 | * There is no guarantee that the thread will stay on the same type of core for any time. |
| 1832 | * Callers should treat the result as only a hint. |
| 1833 | */ |
| 1834 | uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void); |
| 1835 | |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 1836 | /** |
| 1837 | * Identify the microarchitecture index of the core that executes the current thread. |
| 1838 | * If the system does not support such identification, the function returns the user-specified default value. |
| 1839 | * |
| 1840 | * There is no guarantee that the thread will stay on the same type of core for any time. |
| 1841 | * Callers should treat the result as only a hint. |
| 1842 | */ |
| 1843 | uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index); |
| 1844 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1845 | #ifdef __cplusplus |
| 1846 | } /* extern "C" */ |
| 1847 | #endif |
| 1848 | |
| 1849 | #endif /* CPUINFO_H */ |