cpuinfo.h 56 KB

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