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, |
| 420 | |
| 421 | /** ARM Neoverse N1. */ |
| 422 | cpuinfo_uarch_neoverse_n1 = 0x00300400, |
| 423 | /** ARM Neoverse E1. */ |
| 424 | cpuinfo_uarch_neoverse_e1 = 0x00300401, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 425 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 426 | /** Qualcomm Scorpion. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 427 | cpuinfo_uarch_scorpion = 0x00400100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 428 | /** Qualcomm Krait. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 429 | cpuinfo_uarch_krait = 0x00400101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 430 | /** Qualcomm Kryo. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 431 | cpuinfo_uarch_kryo = 0x00400102, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 432 | /** Qualcomm Falkor. */ |
| 433 | cpuinfo_uarch_falkor = 0x00400103, |
| 434 | /** Qualcomm Saphira. */ |
| 435 | cpuinfo_uarch_saphira = 0x00400104, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 436 | |
Marat Dukhan | 93982f2 | 2017-10-20 13:10:23 -0700 | [diff] [blame] | 437 | /** Nvidia Denver. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 438 | cpuinfo_uarch_denver = 0x00500100, |
Marat Dukhan | 1e6c8c9 | 2018-05-13 20:24:07 -0700 | [diff] [blame] | 439 | /** Nvidia Denver 2. */ |
| 440 | cpuinfo_uarch_denver2 = 0x00500101, |
Marat Dukhan | 8101c50 | 2018-09-18 21:05:58 -0500 | [diff] [blame] | 441 | /** Nvidia Carmel. */ |
| 442 | cpuinfo_uarch_carmel = 0x00500102, |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 443 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 444 | /** Samsung Exynos M1 (Exynos 8890 big cores). */ |
| 445 | cpuinfo_uarch_exynos_m1 = 0x00600100, |
| 446 | /** Samsung Exynos M2 (Exynos 8895 big cores). */ |
| 447 | cpuinfo_uarch_exynos_m2 = 0x00600101, |
| 448 | /** Samsung Exynos M3 (Exynos 9810 big cores). */ |
| 449 | cpuinfo_uarch_exynos_m3 = 0x00600102, |
| 450 | /** Samsung Exynos M4 (Exynos 9820 big cores). */ |
| 451 | cpuinfo_uarch_exynos_m4 = 0x00600103, |
| 452 | /** Samsung Exynos M5 (Exynos 9830 big cores). */ |
| 453 | cpuinfo_uarch_exynos_m5 = 0x00600104, |
| 454 | |
Ashkan Aliabadi | 7e4c009 | 2020-06-01 18:23:11 -0700 | [diff] [blame^] | 455 | /* Deprecated synonym for Cortex-A76 */ |
| 456 | cpuinfo_uarch_cortex_a76ae = 0x00300376, |
| 457 | /* Deprecated names for Exynos. */ |
Marat Dukhan | a750f2a | 2018-03-07 11:07:48 -0800 | [diff] [blame] | 458 | cpuinfo_uarch_mongoose_m1 = 0x00600100, |
| 459 | cpuinfo_uarch_mongoose_m2 = 0x00600101, |
Marat Dukhan | 10eae00 | 2018-03-29 18:36:31 -0700 | [diff] [blame] | 460 | cpuinfo_uarch_meerkat_m3 = 0x00600102, |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 461 | cpuinfo_uarch_meerkat_m4 = 0x00600103, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 462 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 463 | /** Apple A6 and A6X processors. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 464 | cpuinfo_uarch_swift = 0x00700100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 465 | /** Apple A7 processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 466 | cpuinfo_uarch_cyclone = 0x00700101, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 467 | /** Apple A8 and A8X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 468 | cpuinfo_uarch_typhoon = 0x00700102, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 469 | /** Apple A9 and A9X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 470 | cpuinfo_uarch_twister = 0x00700103, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 471 | /** Apple A10 and A10X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 472 | cpuinfo_uarch_hurricane = 0x00700104, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 473 | /** Apple A11 processor (big cores). */ |
| 474 | cpuinfo_uarch_monsoon = 0x00700105, |
| 475 | /** Apple A11 processor (little cores). */ |
| 476 | cpuinfo_uarch_mistral = 0x00700106, |
Marat Dukhan | 44dafc5 | 2018-12-26 20:19:15 -0800 | [diff] [blame] | 477 | /** Apple A12 processor (big cores). */ |
| 478 | cpuinfo_uarch_vortex = 0x00700107, |
| 479 | /** Apple A12 processor (little cores). */ |
| 480 | cpuinfo_uarch_tempest = 0x00700108, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 481 | /** Apple A13 processor (big cores). */ |
| 482 | cpuinfo_uarch_lightning = 0x00700109, |
| 483 | /** Apple A13 processor (little cores). */ |
| 484 | cpuinfo_uarch_thunder = 0x0070010A, |
Marat Dukhan | 92dae31 | 2017-05-09 14:10:17 +0000 | [diff] [blame] | 485 | |
| 486 | /** Cavium ThunderX. */ |
| 487 | cpuinfo_uarch_thunderx = 0x00800100, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 488 | /** Cavium ThunderX2 (originally Broadcom Vulkan). */ |
| 489 | cpuinfo_uarch_thunderx2 = 0x00800200, |
Marat Dukhan | 8871832 | 2017-08-24 10:12:20 -0700 | [diff] [blame] | 490 | |
| 491 | /** Marvell PJ4. */ |
| 492 | cpuinfo_uarch_pj4 = 0x00900100, |
Marat Dukhan | 1ae7ff8 | 2018-05-13 19:30:58 -0700 | [diff] [blame] | 493 | |
| 494 | /** Broadcom Brahma B15. */ |
| 495 | cpuinfo_uarch_brahma_b15 = 0x00A00100, |
| 496 | /** Broadcom Brahma B53. */ |
| 497 | cpuinfo_uarch_brahma_b53 = 0x00A00101, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 498 | |
| 499 | /** Applied Micro X-Gene. */ |
| 500 | cpuinfo_uarch_xgene = 0x00B00100, |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 501 | |
| 502 | /* Hygon Dhyana (a modification of AMD Zen for Chinese market). */ |
| 503 | cpuinfo_uarch_dhyana = 0x01000100, |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 504 | |
| 505 | /** HiSilicon TaiShan v110 (Huawei Kunpeng 920 series processors). */ |
| 506 | cpuinfo_uarch_taishan_v110 = 0x00C00100, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 507 | }; |
| 508 | |
| 509 | struct cpuinfo_processor { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 510 | /** SMT (hyperthread) ID within a core */ |
| 511 | uint32_t smt_id; |
| 512 | /** Core containing this logical processor */ |
| 513 | const struct cpuinfo_core* core; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 514 | /** Cluster of cores containing this logical processor */ |
| 515 | const struct cpuinfo_cluster* cluster; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 516 | /** Physical package containing this logical processor */ |
| 517 | const struct cpuinfo_package* package; |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 518 | #if defined(__linux__) |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 519 | /** |
| 520 | * Linux-specific ID for the logical processor: |
| 521 | * - Linux kernel exposes information about this logical processor in /sys/devices/system/cpu/cpu<linux_id>/ |
| 522 | * - Bit <linux_id> in the cpu_set_t identifies this logical processor |
| 523 | */ |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 524 | int linux_id; |
| 525 | #endif |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 526 | #if defined(_WIN32) || defined(__CYGWIN__) |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 527 | /** Windows-specific ID for the group containing the logical processor. */ |
| 528 | uint16_t windows_group_id; |
| 529 | /** |
| 530 | * Windows-specific ID of the logical processor within its group: |
| 531 | * - Bit <windows_processor_id> in the KAFFINITY mask identifies this logical processor within its group. |
| 532 | */ |
| 533 | uint16_t windows_processor_id; |
| 534 | #endif |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 535 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 536 | /** APIC ID (unique x86-specific ID of the logical processor) */ |
| 537 | uint32_t apic_id; |
| 538 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 539 | struct { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 540 | /** Level 1 instruction cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 541 | const struct cpuinfo_cache* l1i; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 542 | /** Level 1 data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 543 | const struct cpuinfo_cache* l1d; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 544 | /** Level 2 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 545 | const struct cpuinfo_cache* l2; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 546 | /** Level 3 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 547 | const struct cpuinfo_cache* l3; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 548 | /** Level 4 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 549 | const struct cpuinfo_cache* l4; |
| 550 | } cache; |
| 551 | }; |
| 552 | |
| 553 | struct cpuinfo_core { |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 554 | /** Index of the first logical processor on this core. */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 555 | uint32_t processor_start; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 556 | /** Number of logical processors on this core */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 557 | uint32_t processor_count; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 558 | /** Core ID within a package */ |
| 559 | uint32_t core_id; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 560 | /** Cluster containing this core */ |
| 561 | const struct cpuinfo_cluster* cluster; |
| 562 | /** Physical package containing this core. */ |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 563 | const struct cpuinfo_package* package; |
| 564 | /** Vendor of the CPU microarchitecture for this core */ |
| 565 | enum cpuinfo_vendor vendor; |
| 566 | /** CPU microarchitecture for this core */ |
| 567 | enum cpuinfo_uarch uarch; |
| 568 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 569 | /** Value of CPUID leaf 1 EAX register for this core */ |
| 570 | uint32_t cpuid; |
| 571 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 572 | /** Value of Main ID Register (MIDR) for this core */ |
| 573 | uint32_t midr; |
| 574 | #endif |
Marat Dukhan | 28538f4 | 2018-03-10 14:28:14 -0800 | [diff] [blame] | 575 | /** Clock rate (non-Turbo) of the core, in Hz */ |
| 576 | uint64_t frequency; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 577 | }; |
| 578 | |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 579 | struct cpuinfo_cluster { |
| 580 | /** Index of the first logical processor in the cluster */ |
| 581 | uint32_t processor_start; |
| 582 | /** Number of logical processors in the cluster */ |
| 583 | uint32_t processor_count; |
| 584 | /** Index of the first core in the cluster */ |
| 585 | uint32_t core_start; |
| 586 | /** Number of cores on the cluster */ |
| 587 | uint32_t core_count; |
| 588 | /** Cluster ID within a package */ |
| 589 | uint32_t cluster_id; |
| 590 | /** Physical package containing the cluster */ |
| 591 | const struct cpuinfo_package* package; |
| 592 | /** CPU microarchitecture vendor of the cores in the cluster */ |
| 593 | enum cpuinfo_vendor vendor; |
| 594 | /** CPU microarchitecture of the cores in the cluster */ |
| 595 | enum cpuinfo_uarch uarch; |
| 596 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 597 | /** Value of CPUID leaf 1 EAX register of the cores in the cluster */ |
| 598 | uint32_t cpuid; |
| 599 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 600 | /** Value of Main ID Register (MIDR) of the cores in the cluster */ |
| 601 | uint32_t midr; |
| 602 | #endif |
| 603 | /** Clock rate (non-Turbo) of the cores in the cluster, in Hz */ |
| 604 | uint64_t frequency; |
| 605 | }; |
| 606 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 607 | #define CPUINFO_PACKAGE_NAME_MAX 48 |
| 608 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 609 | struct cpuinfo_package { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 610 | /** SoC or processor chip model name */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 611 | char name[CPUINFO_PACKAGE_NAME_MAX]; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 612 | /** Index of the first logical processor on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 613 | uint32_t processor_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 614 | /** Number of logical processors on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 615 | uint32_t processor_count; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 616 | /** Index of the first core on this physical package */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 617 | uint32_t core_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 618 | /** Number of cores on this physical package */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 619 | uint32_t core_count; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 620 | /** Index of the first cluster of cores on this physical package */ |
| 621 | uint32_t cluster_start; |
| 622 | /** Number of clusters of cores on this physical package */ |
| 623 | uint32_t cluster_count; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 624 | }; |
| 625 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 626 | struct cpuinfo_uarch_info { |
| 627 | /** Type of CPU microarchitecture */ |
| 628 | enum cpuinfo_uarch uarch; |
| 629 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 630 | /** Value of CPUID leaf 1 EAX register for the microarchitecture */ |
| 631 | uint32_t cpuid; |
| 632 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 633 | /** Value of Main ID Register (MIDR) for the microarchitecture */ |
| 634 | uint32_t midr; |
| 635 | #endif |
| 636 | /** Number of logical processors with the microarchitecture */ |
| 637 | uint32_t processor_count; |
| 638 | /** Number of cores with the microarchitecture */ |
| 639 | uint32_t core_count; |
| 640 | }; |
| 641 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 642 | #ifdef __cplusplus |
| 643 | extern "C" { |
| 644 | #endif |
| 645 | |
Marat Dukhan | 5355651 | 2018-02-25 09:01:27 +0100 | [diff] [blame] | 646 | bool CPUINFO_ABI cpuinfo_initialize(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 647 | |
| 648 | void CPUINFO_ABI cpuinfo_deinitialize(void); |
| 649 | |
| 650 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 651 | /* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions instead. */ |
| 652 | struct cpuinfo_x86_isa { |
| 653 | #if CPUINFO_ARCH_X86 |
| 654 | bool rdtsc; |
| 655 | #endif |
| 656 | bool rdtscp; |
| 657 | bool rdpid; |
| 658 | bool sysenter; |
| 659 | #if CPUINFO_ARCH_X86 |
| 660 | bool syscall; |
| 661 | #endif |
| 662 | bool msr; |
| 663 | bool clzero; |
| 664 | bool clflush; |
| 665 | bool clflushopt; |
| 666 | bool mwait; |
| 667 | bool mwaitx; |
| 668 | #if CPUINFO_ARCH_X86 |
| 669 | bool emmx; |
| 670 | #endif |
| 671 | bool fxsave; |
| 672 | bool xsave; |
| 673 | #if CPUINFO_ARCH_X86 |
| 674 | bool fpu; |
| 675 | bool mmx; |
| 676 | bool mmx_plus; |
| 677 | #endif |
| 678 | bool three_d_now; |
| 679 | bool three_d_now_plus; |
| 680 | #if CPUINFO_ARCH_X86 |
| 681 | bool three_d_now_geode; |
| 682 | #endif |
| 683 | bool prefetch; |
| 684 | bool prefetchw; |
| 685 | bool prefetchwt1; |
| 686 | #if CPUINFO_ARCH_X86 |
| 687 | bool daz; |
| 688 | bool sse; |
| 689 | bool sse2; |
| 690 | #endif |
| 691 | bool sse3; |
| 692 | bool ssse3; |
| 693 | bool sse4_1; |
| 694 | bool sse4_2; |
| 695 | bool sse4a; |
| 696 | bool misaligned_sse; |
| 697 | bool avx; |
| 698 | bool fma3; |
| 699 | bool fma4; |
| 700 | bool xop; |
| 701 | bool f16c; |
| 702 | bool avx2; |
| 703 | bool avx512f; |
| 704 | bool avx512pf; |
| 705 | bool avx512er; |
| 706 | bool avx512cd; |
| 707 | bool avx512dq; |
| 708 | bool avx512bw; |
| 709 | bool avx512vl; |
| 710 | bool avx512ifma; |
| 711 | bool avx512vbmi; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 712 | bool avx512vbmi2; |
| 713 | bool avx512bitalg; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 714 | bool avx512vpopcntdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 715 | bool avx512vnni; |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 716 | bool avx512bf16; |
| 717 | bool avx512vp2intersect; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 718 | bool avx512_4vnniw; |
| 719 | bool avx512_4fmaps; |
| 720 | bool hle; |
| 721 | bool rtm; |
| 722 | bool xtest; |
| 723 | bool mpx; |
| 724 | #if CPUINFO_ARCH_X86 |
| 725 | bool cmov; |
| 726 | bool cmpxchg8b; |
| 727 | #endif |
| 728 | bool cmpxchg16b; |
| 729 | bool clwb; |
| 730 | bool movbe; |
| 731 | #if CPUINFO_ARCH_X86_64 |
| 732 | bool lahf_sahf; |
| 733 | #endif |
| 734 | bool fs_gs_base; |
| 735 | bool lzcnt; |
| 736 | bool popcnt; |
| 737 | bool tbm; |
| 738 | bool bmi; |
| 739 | bool bmi2; |
| 740 | bool adx; |
| 741 | bool aes; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 742 | bool vaes; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 743 | bool pclmulqdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 744 | bool vpclmulqdq; |
| 745 | bool gfni; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 746 | bool rdrand; |
| 747 | bool rdseed; |
| 748 | bool sha; |
| 749 | bool rng; |
| 750 | bool ace; |
| 751 | bool ace2; |
| 752 | bool phe; |
| 753 | bool pmm; |
| 754 | bool lwp; |
| 755 | }; |
| 756 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 757 | extern struct cpuinfo_x86_isa cpuinfo_isa; |
| 758 | #endif |
| 759 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 760 | static inline bool cpuinfo_has_x86_rdtsc(void) { |
| 761 | #if CPUINFO_ARCH_X86_64 |
| 762 | return true; |
| 763 | #elif CPUINFO_ARCH_X86 |
| 764 | #if defined(__ANDROID__) |
| 765 | return true; |
| 766 | #else |
| 767 | return cpuinfo_isa.rdtsc; |
| 768 | #endif |
| 769 | #else |
| 770 | return false; |
| 771 | #endif |
| 772 | } |
| 773 | |
| 774 | static inline bool cpuinfo_has_x86_rdtscp(void) { |
| 775 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 776 | return cpuinfo_isa.rdtscp; |
| 777 | #else |
| 778 | return false; |
| 779 | #endif |
| 780 | } |
| 781 | |
| 782 | static inline bool cpuinfo_has_x86_rdpid(void) { |
| 783 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 784 | return cpuinfo_isa.rdpid; |
| 785 | #else |
| 786 | return false; |
| 787 | #endif |
| 788 | } |
| 789 | |
| 790 | static inline bool cpuinfo_has_x86_clzero(void) { |
| 791 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 792 | return cpuinfo_isa.clzero; |
| 793 | #else |
| 794 | return false; |
| 795 | #endif |
| 796 | } |
| 797 | |
| 798 | static inline bool cpuinfo_has_x86_mwait(void) { |
| 799 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 800 | return cpuinfo_isa.mwait; |
| 801 | #else |
| 802 | return false; |
| 803 | #endif |
| 804 | } |
| 805 | |
| 806 | static inline bool cpuinfo_has_x86_mwaitx(void) { |
| 807 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 808 | return cpuinfo_isa.mwaitx; |
| 809 | #else |
| 810 | return false; |
| 811 | #endif |
| 812 | } |
| 813 | |
| 814 | static inline bool cpuinfo_has_x86_fxsave(void) { |
| 815 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 816 | return cpuinfo_isa.fxsave; |
| 817 | #else |
| 818 | return false; |
| 819 | #endif |
| 820 | } |
| 821 | |
| 822 | static inline bool cpuinfo_has_x86_xsave(void) { |
| 823 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 824 | return cpuinfo_isa.xsave; |
| 825 | #else |
| 826 | return false; |
| 827 | #endif |
| 828 | } |
| 829 | |
| 830 | static inline bool cpuinfo_has_x86_fpu(void) { |
| 831 | #if CPUINFO_ARCH_X86_64 |
| 832 | return true; |
| 833 | #elif CPUINFO_ARCH_X86 |
| 834 | #if defined(__ANDROID__) |
| 835 | return true; |
| 836 | #else |
| 837 | return cpuinfo_isa.fpu; |
| 838 | #endif |
| 839 | #else |
| 840 | return false; |
| 841 | #endif |
| 842 | } |
| 843 | |
| 844 | static inline bool cpuinfo_has_x86_mmx(void) { |
| 845 | #if CPUINFO_ARCH_X86_64 |
| 846 | return true; |
| 847 | #elif CPUINFO_ARCH_X86 |
| 848 | #if defined(__ANDROID__) |
| 849 | return true; |
| 850 | #else |
| 851 | return cpuinfo_isa.mmx; |
| 852 | #endif |
| 853 | #else |
| 854 | return false; |
| 855 | #endif |
| 856 | } |
| 857 | |
| 858 | static inline bool cpuinfo_has_x86_mmx_plus(void) { |
| 859 | #if CPUINFO_ARCH_X86_64 |
| 860 | return true; |
| 861 | #elif CPUINFO_ARCH_X86 |
| 862 | #if defined(__ANDROID__) |
| 863 | return true; |
| 864 | #else |
| 865 | return cpuinfo_isa.mmx_plus; |
| 866 | #endif |
| 867 | #else |
| 868 | return false; |
| 869 | #endif |
| 870 | } |
| 871 | |
| 872 | static inline bool cpuinfo_has_x86_3dnow(void) { |
| 873 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 874 | return cpuinfo_isa.three_d_now; |
| 875 | #else |
| 876 | return false; |
| 877 | #endif |
| 878 | } |
| 879 | |
| 880 | static inline bool cpuinfo_has_x86_3dnow_plus(void) { |
| 881 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 882 | return cpuinfo_isa.three_d_now_plus; |
| 883 | #else |
| 884 | return false; |
| 885 | #endif |
| 886 | } |
| 887 | |
| 888 | static inline bool cpuinfo_has_x86_3dnow_geode(void) { |
| 889 | #if CPUINFO_ARCH_X86_64 |
| 890 | return false; |
| 891 | #elif CPUINFO_ARCH_X86 |
| 892 | #if defined(__ANDROID__) |
| 893 | return false; |
| 894 | #else |
| 895 | return cpuinfo_isa.three_d_now_geode; |
| 896 | #endif |
| 897 | #else |
| 898 | return false; |
| 899 | #endif |
| 900 | } |
| 901 | |
| 902 | static inline bool cpuinfo_has_x86_prefetch(void) { |
| 903 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 904 | return cpuinfo_isa.prefetch; |
| 905 | #else |
| 906 | return false; |
| 907 | #endif |
| 908 | } |
| 909 | |
| 910 | static inline bool cpuinfo_has_x86_prefetchw(void) { |
| 911 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 912 | return cpuinfo_isa.prefetchw; |
| 913 | #else |
| 914 | return false; |
| 915 | #endif |
| 916 | } |
| 917 | |
| 918 | static inline bool cpuinfo_has_x86_prefetchwt1(void) { |
| 919 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 920 | return cpuinfo_isa.prefetchwt1; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 921 | #else |
| 922 | return false; |
| 923 | #endif |
| 924 | } |
| 925 | |
| 926 | static inline bool cpuinfo_has_x86_daz(void) { |
| 927 | #if CPUINFO_ARCH_X86_64 |
| 928 | return true; |
| 929 | #elif CPUINFO_ARCH_X86 |
| 930 | #if defined(__ANDROID__) |
| 931 | return true; |
| 932 | #else |
| 933 | return cpuinfo_isa.daz; |
| 934 | #endif |
| 935 | #else |
| 936 | return false; |
| 937 | #endif |
| 938 | } |
| 939 | |
Marat Dukhan | 9da4c91 | 2017-09-26 10:53:28 -0700 | [diff] [blame] | 940 | static inline bool cpuinfo_has_x86_sse(void) { |
| 941 | #if CPUINFO_ARCH_X86_64 |
| 942 | return true; |
| 943 | #elif CPUINFO_ARCH_X86 |
| 944 | #if defined(__ANDROID__) |
| 945 | return true; |
| 946 | #else |
| 947 | return cpuinfo_isa.sse; |
| 948 | #endif |
| 949 | #else |
| 950 | return false; |
| 951 | #endif |
| 952 | } |
| 953 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 954 | static inline bool cpuinfo_has_x86_sse2(void) { |
| 955 | #if CPUINFO_ARCH_X86_64 |
| 956 | return true; |
| 957 | #elif CPUINFO_ARCH_X86 |
| 958 | #if defined(__ANDROID__) |
| 959 | return true; |
| 960 | #else |
| 961 | return cpuinfo_isa.sse2; |
| 962 | #endif |
| 963 | #else |
| 964 | return false; |
| 965 | #endif |
| 966 | } |
| 967 | |
| 968 | static inline bool cpuinfo_has_x86_sse3(void) { |
| 969 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 970 | #if defined(__ANDROID__) |
| 971 | return true; |
| 972 | #else |
| 973 | return cpuinfo_isa.sse3; |
| 974 | #endif |
| 975 | #else |
| 976 | return false; |
| 977 | #endif |
| 978 | } |
| 979 | |
| 980 | static inline bool cpuinfo_has_x86_ssse3(void) { |
| 981 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 982 | #if defined(__ANDROID__) |
| 983 | return true; |
| 984 | #else |
| 985 | return cpuinfo_isa.ssse3; |
| 986 | #endif |
| 987 | #else |
| 988 | return false; |
| 989 | #endif |
| 990 | } |
| 991 | |
| 992 | static inline bool cpuinfo_has_x86_sse4_1(void) { |
| 993 | #if CPUINFO_ARCH_X86_64 |
| 994 | #if defined(__ANDROID__) |
| 995 | return true; |
| 996 | #else |
| 997 | return cpuinfo_isa.sse4_1; |
| 998 | #endif |
| 999 | #elif CPUINFO_ARCH_X86 |
| 1000 | return cpuinfo_isa.sse4_1; |
| 1001 | #else |
| 1002 | return false; |
| 1003 | #endif |
| 1004 | } |
| 1005 | |
| 1006 | static inline bool cpuinfo_has_x86_sse4_2(void) { |
| 1007 | #if CPUINFO_ARCH_X86_64 |
| 1008 | #if defined(__ANDROID__) |
| 1009 | return true; |
| 1010 | #else |
| 1011 | return cpuinfo_isa.sse4_2; |
| 1012 | #endif |
| 1013 | #elif CPUINFO_ARCH_X86 |
| 1014 | return cpuinfo_isa.sse4_2; |
| 1015 | #else |
| 1016 | return false; |
| 1017 | #endif |
| 1018 | } |
| 1019 | |
| 1020 | static inline bool cpuinfo_has_x86_sse4a(void) { |
| 1021 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1022 | return cpuinfo_isa.sse4a; |
| 1023 | #else |
| 1024 | return false; |
| 1025 | #endif |
| 1026 | } |
| 1027 | |
| 1028 | static inline bool cpuinfo_has_x86_misaligned_sse(void) { |
| 1029 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1030 | return cpuinfo_isa.misaligned_sse; |
| 1031 | #else |
| 1032 | return false; |
| 1033 | #endif |
| 1034 | } |
| 1035 | |
| 1036 | static inline bool cpuinfo_has_x86_avx(void) { |
| 1037 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1038 | return cpuinfo_isa.avx; |
| 1039 | #else |
| 1040 | return false; |
| 1041 | #endif |
| 1042 | } |
| 1043 | |
| 1044 | static inline bool cpuinfo_has_x86_fma3(void) { |
| 1045 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1046 | return cpuinfo_isa.fma3; |
| 1047 | #else |
| 1048 | return false; |
| 1049 | #endif |
| 1050 | } |
| 1051 | |
| 1052 | static inline bool cpuinfo_has_x86_fma4(void) { |
| 1053 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1054 | return cpuinfo_isa.fma4; |
| 1055 | #else |
| 1056 | return false; |
| 1057 | #endif |
| 1058 | } |
| 1059 | |
| 1060 | static inline bool cpuinfo_has_x86_xop(void) { |
| 1061 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1062 | return cpuinfo_isa.xop; |
| 1063 | #else |
| 1064 | return false; |
| 1065 | #endif |
| 1066 | } |
| 1067 | |
| 1068 | static inline bool cpuinfo_has_x86_f16c(void) { |
| 1069 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1070 | return cpuinfo_isa.f16c; |
| 1071 | #else |
| 1072 | return false; |
| 1073 | #endif |
| 1074 | } |
| 1075 | |
| 1076 | static inline bool cpuinfo_has_x86_avx2(void) { |
| 1077 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1078 | return cpuinfo_isa.avx2; |
| 1079 | #else |
| 1080 | return false; |
| 1081 | #endif |
| 1082 | } |
| 1083 | |
| 1084 | static inline bool cpuinfo_has_x86_avx512f(void) { |
| 1085 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1086 | return cpuinfo_isa.avx512f; |
| 1087 | #else |
| 1088 | return false; |
| 1089 | #endif |
| 1090 | } |
| 1091 | |
| 1092 | static inline bool cpuinfo_has_x86_avx512pf(void) { |
| 1093 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1094 | return cpuinfo_isa.avx512pf; |
| 1095 | #else |
| 1096 | return false; |
| 1097 | #endif |
| 1098 | } |
| 1099 | |
| 1100 | static inline bool cpuinfo_has_x86_avx512er(void) { |
| 1101 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1102 | return cpuinfo_isa.avx512er; |
| 1103 | #else |
| 1104 | return false; |
| 1105 | #endif |
| 1106 | } |
| 1107 | |
| 1108 | static inline bool cpuinfo_has_x86_avx512cd(void) { |
| 1109 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1110 | return cpuinfo_isa.avx512cd; |
| 1111 | #else |
| 1112 | return false; |
| 1113 | #endif |
| 1114 | } |
| 1115 | |
| 1116 | static inline bool cpuinfo_has_x86_avx512dq(void) { |
| 1117 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1118 | return cpuinfo_isa.avx512dq; |
| 1119 | #else |
| 1120 | return false; |
| 1121 | #endif |
| 1122 | } |
| 1123 | |
| 1124 | static inline bool cpuinfo_has_x86_avx512bw(void) { |
| 1125 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1126 | return cpuinfo_isa.avx512bw; |
| 1127 | #else |
| 1128 | return false; |
| 1129 | #endif |
| 1130 | } |
| 1131 | |
| 1132 | static inline bool cpuinfo_has_x86_avx512vl(void) { |
| 1133 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1134 | return cpuinfo_isa.avx512vl; |
| 1135 | #else |
| 1136 | return false; |
| 1137 | #endif |
| 1138 | } |
| 1139 | |
| 1140 | static inline bool cpuinfo_has_x86_avx512ifma(void) { |
| 1141 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1142 | return cpuinfo_isa.avx512ifma; |
| 1143 | #else |
| 1144 | return false; |
| 1145 | #endif |
| 1146 | } |
| 1147 | |
| 1148 | static inline bool cpuinfo_has_x86_avx512vbmi(void) { |
| 1149 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1150 | return cpuinfo_isa.avx512vbmi; |
| 1151 | #else |
| 1152 | return false; |
| 1153 | #endif |
| 1154 | } |
| 1155 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1156 | static inline bool cpuinfo_has_x86_avx512vbmi2(void) { |
| 1157 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1158 | return cpuinfo_isa.avx512vbmi2; |
| 1159 | #else |
| 1160 | return false; |
| 1161 | #endif |
| 1162 | } |
| 1163 | |
| 1164 | static inline bool cpuinfo_has_x86_avx512bitalg(void) { |
| 1165 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1166 | return cpuinfo_isa.avx512bitalg; |
| 1167 | #else |
| 1168 | return false; |
| 1169 | #endif |
| 1170 | } |
| 1171 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1172 | static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) { |
| 1173 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1174 | return cpuinfo_isa.avx512vpopcntdq; |
| 1175 | #else |
| 1176 | return false; |
| 1177 | #endif |
| 1178 | } |
| 1179 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1180 | static inline bool cpuinfo_has_x86_avx512vnni(void) { |
Marat Dukhan | 6b33b23 | 2017-10-13 09:36:52 -0700 | [diff] [blame] | 1181 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1182 | return cpuinfo_isa.avx512vnni; |
| 1183 | #else |
| 1184 | return false; |
| 1185 | #endif |
| 1186 | } |
| 1187 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 1188 | static inline bool cpuinfo_has_x86_avx512bf16(void) { |
| 1189 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1190 | return cpuinfo_isa.avx512bf16; |
| 1191 | #else |
| 1192 | return false; |
| 1193 | #endif |
| 1194 | } |
| 1195 | |
| 1196 | static inline bool cpuinfo_has_x86_avx512vp2intersect(void) { |
| 1197 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1198 | return cpuinfo_isa.avx512vp2intersect; |
| 1199 | #else |
| 1200 | return false; |
| 1201 | #endif |
| 1202 | } |
| 1203 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1204 | static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { |
| 1205 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1206 | return cpuinfo_isa.avx512_4vnniw; |
| 1207 | #else |
| 1208 | return false; |
| 1209 | #endif |
| 1210 | } |
| 1211 | |
| 1212 | static inline bool cpuinfo_has_x86_avx512_4fmaps(void) { |
| 1213 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1214 | return cpuinfo_isa.avx512_4fmaps; |
| 1215 | #else |
| 1216 | return false; |
| 1217 | #endif |
| 1218 | } |
| 1219 | |
Marat Dukhan | 9e32e8d | 2017-09-26 11:02:37 -0700 | [diff] [blame] | 1220 | static inline bool cpuinfo_has_x86_hle(void) { |
| 1221 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1222 | return cpuinfo_isa.hle; |
| 1223 | #else |
| 1224 | return false; |
| 1225 | #endif |
| 1226 | } |
| 1227 | |
| 1228 | static inline bool cpuinfo_has_x86_rtm(void) { |
| 1229 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1230 | return cpuinfo_isa.rtm; |
| 1231 | #else |
| 1232 | return false; |
| 1233 | #endif |
| 1234 | } |
| 1235 | |
| 1236 | static inline bool cpuinfo_has_x86_xtest(void) { |
| 1237 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1238 | return cpuinfo_isa.xtest; |
| 1239 | #else |
| 1240 | return false; |
| 1241 | #endif |
| 1242 | } |
| 1243 | |
| 1244 | static inline bool cpuinfo_has_x86_mpx(void) { |
| 1245 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1246 | return cpuinfo_isa.mpx; |
| 1247 | #else |
| 1248 | return false; |
| 1249 | #endif |
| 1250 | } |
| 1251 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1252 | static inline bool cpuinfo_has_x86_cmov(void) { |
| 1253 | #if CPUINFO_ARCH_X86_64 |
| 1254 | return true; |
| 1255 | #elif CPUINFO_ARCH_X86 |
| 1256 | return cpuinfo_isa.cmov; |
| 1257 | #else |
| 1258 | return false; |
| 1259 | #endif |
| 1260 | } |
| 1261 | |
| 1262 | static inline bool cpuinfo_has_x86_cmpxchg8b(void) { |
| 1263 | #if CPUINFO_ARCH_X86_64 |
| 1264 | return true; |
| 1265 | #elif CPUINFO_ARCH_X86 |
| 1266 | return cpuinfo_isa.cmpxchg8b; |
| 1267 | #else |
| 1268 | return false; |
| 1269 | #endif |
| 1270 | } |
| 1271 | |
| 1272 | static inline bool cpuinfo_has_x86_cmpxchg16b(void) { |
| 1273 | #if CPUINFO_ARCH_X86_64 |
| 1274 | return cpuinfo_isa.cmpxchg16b; |
| 1275 | #else |
| 1276 | return false; |
| 1277 | #endif |
| 1278 | } |
| 1279 | |
| 1280 | static inline bool cpuinfo_has_x86_clwb(void) { |
| 1281 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1282 | return cpuinfo_isa.clwb; |
| 1283 | #else |
| 1284 | return false; |
| 1285 | #endif |
| 1286 | } |
| 1287 | |
| 1288 | static inline bool cpuinfo_has_x86_movbe(void) { |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1289 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1290 | return cpuinfo_isa.movbe; |
| 1291 | #else |
| 1292 | return false; |
| 1293 | #endif |
| 1294 | } |
| 1295 | |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1296 | static inline bool cpuinfo_has_x86_lahf_sahf(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1297 | #if CPUINFO_ARCH_X86 |
| 1298 | return true; |
| 1299 | #elif CPUINFO_ARCH_X86_64 |
| 1300 | return cpuinfo_isa.lahf_sahf; |
| 1301 | #else |
| 1302 | return false; |
| 1303 | #endif |
| 1304 | } |
| 1305 | |
| 1306 | static inline bool cpuinfo_has_x86_lzcnt(void) { |
| 1307 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1308 | return cpuinfo_isa.lzcnt; |
| 1309 | #else |
| 1310 | return false; |
| 1311 | #endif |
| 1312 | } |
| 1313 | |
| 1314 | static inline bool cpuinfo_has_x86_popcnt(void) { |
| 1315 | #if CPUINFO_ARCH_X86_64 |
| 1316 | #if defined(__ANDROID__) |
| 1317 | return true; |
| 1318 | #else |
| 1319 | return cpuinfo_isa.popcnt; |
| 1320 | #endif |
| 1321 | #elif CPUINFO_ARCH_X86 |
| 1322 | return cpuinfo_isa.popcnt; |
| 1323 | #else |
| 1324 | return false; |
| 1325 | #endif |
| 1326 | } |
| 1327 | |
| 1328 | static inline bool cpuinfo_has_x86_tbm(void) { |
| 1329 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1330 | return cpuinfo_isa.tbm; |
| 1331 | #else |
| 1332 | return false; |
| 1333 | #endif |
| 1334 | } |
| 1335 | |
| 1336 | static inline bool cpuinfo_has_x86_bmi(void) { |
| 1337 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1338 | return cpuinfo_isa.bmi; |
| 1339 | #else |
| 1340 | return false; |
| 1341 | #endif |
| 1342 | } |
| 1343 | |
| 1344 | static inline bool cpuinfo_has_x86_bmi2(void) { |
| 1345 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1346 | return cpuinfo_isa.bmi2; |
| 1347 | #else |
| 1348 | return false; |
| 1349 | #endif |
| 1350 | } |
| 1351 | |
| 1352 | static inline bool cpuinfo_has_x86_adx(void) { |
| 1353 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1354 | return cpuinfo_isa.adx; |
| 1355 | #else |
| 1356 | return false; |
| 1357 | #endif |
| 1358 | } |
| 1359 | |
| 1360 | static inline bool cpuinfo_has_x86_aes(void) { |
| 1361 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1362 | return cpuinfo_isa.aes; |
| 1363 | #else |
| 1364 | return false; |
| 1365 | #endif |
| 1366 | } |
| 1367 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1368 | static inline bool cpuinfo_has_x86_vaes(void) { |
| 1369 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1370 | return cpuinfo_isa.vaes; |
| 1371 | #else |
| 1372 | return false; |
| 1373 | #endif |
| 1374 | } |
| 1375 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1376 | static inline bool cpuinfo_has_x86_pclmulqdq(void) { |
| 1377 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1378 | return cpuinfo_isa.pclmulqdq; |
| 1379 | #else |
| 1380 | return false; |
| 1381 | #endif |
| 1382 | } |
| 1383 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1384 | static inline bool cpuinfo_has_x86_vpclmulqdq(void) { |
| 1385 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1386 | return cpuinfo_isa.vpclmulqdq; |
| 1387 | #else |
| 1388 | return false; |
| 1389 | #endif |
| 1390 | } |
| 1391 | |
| 1392 | static inline bool cpuinfo_has_x86_gfni(void) { |
| 1393 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1394 | return cpuinfo_isa.gfni; |
| 1395 | #else |
| 1396 | return false; |
| 1397 | #endif |
| 1398 | } |
| 1399 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1400 | static inline bool cpuinfo_has_x86_rdrand(void) { |
| 1401 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1402 | return cpuinfo_isa.rdrand; |
| 1403 | #else |
| 1404 | return false; |
| 1405 | #endif |
| 1406 | } |
| 1407 | |
| 1408 | static inline bool cpuinfo_has_x86_rdseed(void) { |
| 1409 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1410 | return cpuinfo_isa.rdseed; |
| 1411 | #else |
| 1412 | return false; |
| 1413 | #endif |
| 1414 | } |
| 1415 | |
| 1416 | static inline bool cpuinfo_has_x86_sha(void) { |
| 1417 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1418 | return cpuinfo_isa.sha; |
| 1419 | #else |
| 1420 | return false; |
| 1421 | #endif |
| 1422 | } |
| 1423 | |
Marat Dukhan | ab42e7e | 2017-05-09 13:19:39 +0000 | [diff] [blame] | 1424 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1425 | /* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions instead. */ |
| 1426 | struct cpuinfo_arm_isa { |
| 1427 | #if CPUINFO_ARCH_ARM |
| 1428 | bool thumb; |
| 1429 | bool thumb2; |
| 1430 | bool thumbee; |
| 1431 | bool jazelle; |
| 1432 | bool armv5e; |
| 1433 | bool armv6; |
| 1434 | bool armv6k; |
| 1435 | bool armv7; |
| 1436 | bool armv7mp; |
| 1437 | bool idiv; |
| 1438 | |
| 1439 | bool vfpv2; |
| 1440 | bool vfpv3; |
| 1441 | bool d32; |
| 1442 | bool fp16; |
| 1443 | bool fma; |
| 1444 | |
| 1445 | bool wmmx; |
| 1446 | bool wmmx2; |
| 1447 | bool neon; |
| 1448 | #endif |
| 1449 | #if CPUINFO_ARCH_ARM64 |
| 1450 | bool atomics; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1451 | #endif |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1452 | bool rdm; |
| 1453 | bool fp16arith; |
Marat Dukhan | db14c22 | 2018-12-19 02:34:17 -0800 | [diff] [blame] | 1454 | bool dot; |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1455 | bool jscvt; |
| 1456 | bool fcma; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1457 | |
| 1458 | bool aes; |
| 1459 | bool sha1; |
| 1460 | bool sha2; |
| 1461 | bool pmull; |
| 1462 | bool crc32; |
| 1463 | }; |
| 1464 | |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 1465 | extern struct cpuinfo_arm_isa cpuinfo_isa; |
| 1466 | #endif |
| 1467 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1468 | static inline bool cpuinfo_has_arm_thumb(void) { |
| 1469 | #if CPUINFO_ARCH_ARM |
| 1470 | return cpuinfo_isa.thumb; |
| 1471 | #else |
| 1472 | return false; |
| 1473 | #endif |
| 1474 | } |
| 1475 | |
| 1476 | static inline bool cpuinfo_has_arm_thumb2(void) { |
| 1477 | #if CPUINFO_ARCH_ARM |
| 1478 | return cpuinfo_isa.thumb2; |
| 1479 | #else |
| 1480 | return false; |
| 1481 | #endif |
| 1482 | } |
| 1483 | |
| 1484 | static inline bool cpuinfo_has_arm_v5e(void) { |
| 1485 | #if CPUINFO_ARCH_ARM |
| 1486 | return cpuinfo_isa.armv5e; |
| 1487 | #else |
| 1488 | return false; |
| 1489 | #endif |
| 1490 | } |
| 1491 | |
| 1492 | static inline bool cpuinfo_has_arm_v6(void) { |
| 1493 | #if CPUINFO_ARCH_ARM |
| 1494 | return cpuinfo_isa.armv6; |
| 1495 | #else |
| 1496 | return false; |
| 1497 | #endif |
| 1498 | } |
| 1499 | |
| 1500 | static inline bool cpuinfo_has_arm_v6k(void) { |
| 1501 | #if CPUINFO_ARCH_ARM |
| 1502 | return cpuinfo_isa.armv6k; |
| 1503 | #else |
| 1504 | return false; |
| 1505 | #endif |
| 1506 | } |
| 1507 | |
| 1508 | static inline bool cpuinfo_has_arm_v7(void) { |
| 1509 | #if CPUINFO_ARCH_ARM |
| 1510 | return cpuinfo_isa.armv7; |
| 1511 | #else |
| 1512 | return false; |
| 1513 | #endif |
| 1514 | } |
| 1515 | |
| 1516 | static inline bool cpuinfo_has_arm_v7mp(void) { |
| 1517 | #if CPUINFO_ARCH_ARM |
| 1518 | return cpuinfo_isa.armv7mp; |
| 1519 | #else |
| 1520 | return false; |
| 1521 | #endif |
| 1522 | } |
| 1523 | |
| 1524 | static inline bool cpuinfo_has_arm_idiv(void) { |
| 1525 | #if CPUINFO_ARCH_ARM64 |
| 1526 | return true; |
| 1527 | #elif CPUINFO_ARCH_ARM |
| 1528 | return cpuinfo_isa.idiv; |
| 1529 | #else |
| 1530 | return false; |
| 1531 | #endif |
| 1532 | } |
| 1533 | |
| 1534 | static inline bool cpuinfo_has_arm_vfpv2(void) { |
| 1535 | #if CPUINFO_ARCH_ARM |
| 1536 | return cpuinfo_isa.vfpv2; |
| 1537 | #else |
| 1538 | return false; |
| 1539 | #endif |
| 1540 | } |
| 1541 | |
| 1542 | static inline bool cpuinfo_has_arm_vfpv3(void) { |
| 1543 | #if CPUINFO_ARCH_ARM64 |
| 1544 | return true; |
| 1545 | #elif CPUINFO_ARCH_ARM |
| 1546 | return cpuinfo_isa.vfpv3; |
| 1547 | #else |
| 1548 | return false; |
| 1549 | #endif |
| 1550 | } |
| 1551 | |
| 1552 | static inline bool cpuinfo_has_arm_vfpv3_d32(void) { |
| 1553 | #if CPUINFO_ARCH_ARM64 |
| 1554 | return true; |
| 1555 | #elif CPUINFO_ARCH_ARM |
| 1556 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32; |
| 1557 | #else |
| 1558 | return false; |
| 1559 | #endif |
| 1560 | } |
| 1561 | |
| 1562 | static inline bool cpuinfo_has_arm_vfpv3_fp16(void) { |
| 1563 | #if CPUINFO_ARCH_ARM64 |
| 1564 | return true; |
| 1565 | #elif CPUINFO_ARCH_ARM |
| 1566 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16; |
| 1567 | #else |
| 1568 | return false; |
| 1569 | #endif |
| 1570 | } |
| 1571 | |
| 1572 | static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) { |
| 1573 | #if CPUINFO_ARCH_ARM64 |
| 1574 | return true; |
| 1575 | #elif CPUINFO_ARCH_ARM |
| 1576 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32; |
| 1577 | #else |
| 1578 | return false; |
| 1579 | #endif |
| 1580 | } |
| 1581 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1582 | static inline bool cpuinfo_has_arm_vfpv4(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1583 | #if CPUINFO_ARCH_ARM64 |
| 1584 | return true; |
| 1585 | #elif CPUINFO_ARCH_ARM |
| 1586 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma; |
| 1587 | #else |
| 1588 | return false; |
| 1589 | #endif |
| 1590 | } |
| 1591 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1592 | static inline bool cpuinfo_has_arm_vfpv4_d32(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1593 | #if CPUINFO_ARCH_ARM64 |
| 1594 | return true; |
| 1595 | #elif CPUINFO_ARCH_ARM |
| 1596 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32; |
| 1597 | #else |
| 1598 | return false; |
| 1599 | #endif |
| 1600 | } |
| 1601 | |
| 1602 | static inline bool cpuinfo_has_arm_wmmx(void) { |
| 1603 | #if CPUINFO_ARCH_ARM |
| 1604 | return cpuinfo_isa.wmmx; |
| 1605 | #else |
| 1606 | return false; |
| 1607 | #endif |
| 1608 | } |
| 1609 | |
| 1610 | static inline bool cpuinfo_has_arm_wmmx2(void) { |
| 1611 | #if CPUINFO_ARCH_ARM |
| 1612 | return cpuinfo_isa.wmmx2; |
| 1613 | #else |
| 1614 | return false; |
| 1615 | #endif |
| 1616 | } |
| 1617 | |
| 1618 | static inline bool cpuinfo_has_arm_neon(void) { |
| 1619 | #if CPUINFO_ARCH_ARM64 |
| 1620 | return true; |
| 1621 | #elif CPUINFO_ARCH_ARM |
| 1622 | return cpuinfo_isa.neon; |
| 1623 | #else |
| 1624 | return false; |
| 1625 | #endif |
| 1626 | } |
| 1627 | |
| 1628 | static inline bool cpuinfo_has_arm_neon_fp16(void) { |
| 1629 | #if CPUINFO_ARCH_ARM64 |
| 1630 | return true; |
| 1631 | #elif CPUINFO_ARCH_ARM |
| 1632 | return cpuinfo_isa.neon && cpuinfo_isa.fp16; |
| 1633 | #else |
| 1634 | return false; |
| 1635 | #endif |
| 1636 | } |
| 1637 | |
| 1638 | static inline bool cpuinfo_has_arm_neon_fma(void) { |
| 1639 | #if CPUINFO_ARCH_ARM64 |
| 1640 | return true; |
| 1641 | #elif CPUINFO_ARCH_ARM |
| 1642 | return cpuinfo_isa.neon && cpuinfo_isa.fma; |
| 1643 | #else |
| 1644 | return false; |
| 1645 | #endif |
| 1646 | } |
| 1647 | |
| 1648 | static inline bool cpuinfo_has_arm_atomics(void) { |
| 1649 | #if CPUINFO_ARCH_ARM64 |
| 1650 | return cpuinfo_isa.atomics; |
| 1651 | #else |
| 1652 | return false; |
| 1653 | #endif |
| 1654 | } |
| 1655 | |
| 1656 | static inline bool cpuinfo_has_arm_neon_rdm(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1657 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1658 | return cpuinfo_isa.rdm; |
| 1659 | #else |
| 1660 | return false; |
| 1661 | #endif |
| 1662 | } |
| 1663 | |
Marat Dukhan | de2f71e | 2018-06-11 13:30:21 -0700 | [diff] [blame] | 1664 | static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { |
| 1665 | #if CPUINFO_ARCH_ARM |
| 1666 | return cpuinfo_isa.neon && cpuinfo_isa.fp16arith; |
| 1667 | #elif CPUINFO_ARCH_ARM64 |
| 1668 | return cpuinfo_isa.fp16arith; |
| 1669 | #else |
| 1670 | return false; |
| 1671 | #endif |
| 1672 | } |
| 1673 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1674 | static inline bool cpuinfo_has_arm_fp16_arith(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1675 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1676 | return cpuinfo_isa.fp16arith; |
| 1677 | #else |
| 1678 | return false; |
| 1679 | #endif |
| 1680 | } |
| 1681 | |
Marat Dukhan | db14c22 | 2018-12-19 02:34:17 -0800 | [diff] [blame] | 1682 | static inline bool cpuinfo_has_arm_neon_dot(void) { |
| 1683 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1684 | return cpuinfo_isa.dot; |
| 1685 | #else |
| 1686 | return false; |
| 1687 | #endif |
| 1688 | } |
| 1689 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1690 | static inline bool cpuinfo_has_arm_jscvt(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1691 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1692 | return cpuinfo_isa.jscvt; |
| 1693 | #else |
| 1694 | return false; |
| 1695 | #endif |
| 1696 | } |
| 1697 | |
| 1698 | static inline bool cpuinfo_has_arm_fcma(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1699 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1700 | return cpuinfo_isa.fcma; |
| 1701 | #else |
| 1702 | return false; |
| 1703 | #endif |
| 1704 | } |
| 1705 | |
| 1706 | static inline bool cpuinfo_has_arm_aes(void) { |
| 1707 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1708 | return cpuinfo_isa.aes; |
| 1709 | #else |
| 1710 | return false; |
| 1711 | #endif |
| 1712 | } |
| 1713 | |
| 1714 | static inline bool cpuinfo_has_arm_sha1(void) { |
| 1715 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1716 | return cpuinfo_isa.sha1; |
| 1717 | #else |
| 1718 | return false; |
| 1719 | #endif |
| 1720 | } |
| 1721 | |
| 1722 | static inline bool cpuinfo_has_arm_sha2(void) { |
| 1723 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1724 | return cpuinfo_isa.sha2; |
| 1725 | #else |
| 1726 | return false; |
| 1727 | #endif |
| 1728 | } |
| 1729 | |
| 1730 | static inline bool cpuinfo_has_arm_pmull(void) { |
| 1731 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1732 | return cpuinfo_isa.pmull; |
| 1733 | #else |
| 1734 | return false; |
| 1735 | #endif |
| 1736 | } |
| 1737 | |
| 1738 | static inline bool cpuinfo_has_arm_crc32(void) { |
| 1739 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1740 | return cpuinfo_isa.crc32; |
| 1741 | #else |
| 1742 | return false; |
| 1743 | #endif |
| 1744 | } |
| 1745 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1746 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); |
| 1747 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1748 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1749 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1750 | const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1751 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); |
| 1752 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); |
| 1753 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void); |
| 1754 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void); |
| 1755 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 1756 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1757 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); |
| 1758 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1759 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1760 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1761 | 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] | 1762 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); |
| 1763 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); |
| 1764 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index); |
| 1765 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index); |
| 1766 | 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] | 1767 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1768 | uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); |
| 1769 | uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1770 | uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1771 | uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1772 | uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1773 | uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); |
| 1774 | uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); |
| 1775 | uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); |
| 1776 | uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); |
| 1777 | uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); |
Marat Dukhan | 8ecad1a | 2017-05-08 07:21:57 +0000 | [diff] [blame] | 1778 | |
Ashkan Aliabadi | 0e6bde9 | 2020-01-21 14:15:03 -0800 | [diff] [blame] | 1779 | /** |
| 1780 | * Returns upper bound on cache size. |
| 1781 | */ |
| 1782 | uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void); |
| 1783 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1784 | /** |
| 1785 | * Identify the logical processor that executes the current thread. |
| 1786 | * |
| 1787 | * There is no guarantee that the thread will stay on the same logical processor for any time. |
| 1788 | * Callers should treat the result as only a hint, and be prepared to handle NULL return value. |
| 1789 | */ |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1790 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1791 | |
| 1792 | /** |
| 1793 | * Identify the core that executes the current thread. |
| 1794 | * |
| 1795 | * There is no guarantee that the thread will stay on the same core for any time. |
| 1796 | * Callers should treat the result as only a hint, and be prepared to handle NULL return value. |
| 1797 | */ |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1798 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1799 | |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1800 | /** |
| 1801 | * Identify the microarchitecture index of the core that executes the current thread. |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 1802 | * If the system does not support such identification, the function returns 0. |
Ashkan Aliabadi | dcf8e18 | 2020-03-19 19:34:26 -0700 | [diff] [blame] | 1803 | * |
| 1804 | * There is no guarantee that the thread will stay on the same type of core for any time. |
| 1805 | * Callers should treat the result as only a hint. |
| 1806 | */ |
| 1807 | uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void); |
| 1808 | |
Ashkan Aliabadi | c209221 | 2020-05-08 20:40:33 -0700 | [diff] [blame] | 1809 | /** |
| 1810 | * Identify the microarchitecture index of the core that executes the current thread. |
| 1811 | * If the system does not support such identification, the function returns the user-specified default value. |
| 1812 | * |
| 1813 | * There is no guarantee that the thread will stay on the same type of core for any time. |
| 1814 | * Callers should treat the result as only a hint. |
| 1815 | */ |
| 1816 | uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index); |
| 1817 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1818 | #ifdef __cplusplus |
| 1819 | } /* extern "C" */ |
| 1820 | #endif |
| 1821 | |
| 1822 | #endif /* CPUINFO_H */ |