You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

getarch.c 30 kB

14 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. /*****************************************************************************
  2. Copyright (c) 2011-2014, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written
  16. permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  26. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. **********************************************************************************/
  28. /*********************************************************************/
  29. /* Copyright 2009, 2010 The University of Texas at Austin. */
  30. /* All rights reserved. */
  31. /* */
  32. /* Redistribution and use in source and binary forms, with or */
  33. /* without modification, are permitted provided that the following */
  34. /* conditions are met: */
  35. /* */
  36. /* 1. Redistributions of source code must retain the above */
  37. /* copyright notice, this list of conditions and the following */
  38. /* disclaimer. */
  39. /* */
  40. /* 2. Redistributions in binary form must reproduce the above */
  41. /* copyright notice, this list of conditions and the following */
  42. /* disclaimer in the documentation and/or other materials */
  43. /* provided with the distribution. */
  44. /* */
  45. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  46. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  47. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  48. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  49. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  50. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  51. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  52. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  53. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  54. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  55. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  56. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  57. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  58. /* POSSIBILITY OF SUCH DAMAGE. */
  59. /* */
  60. /* The views and conclusions contained in the software and */
  61. /* documentation are those of the authors and should not be */
  62. /* interpreted as representing official policies, either expressed */
  63. /* or implied, of The University of Texas at Austin. */
  64. /*********************************************************************/
  65. #if defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)
  66. #define OS_WINDOWS
  67. #endif
  68. #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
  69. #define INTEL_AMD
  70. #endif
  71. #include <stdio.h>
  72. #include <string.h>
  73. #ifdef OS_WINDOWS
  74. #include <windows.h>
  75. #endif
  76. #if defined(__FreeBSD__) || defined(__APPLE__)
  77. #include <sys/types.h>
  78. #include <sys/sysctl.h>
  79. #endif
  80. #ifdef linux
  81. #include <sys/sysinfo.h>
  82. #include <unistd.h>
  83. #endif
  84. /* #define FORCE_P2 */
  85. /* #define FORCE_KATMAI */
  86. /* #define FORCE_COPPERMINE */
  87. /* #define FORCE_NORTHWOOD */
  88. /* #define FORCE_PRESCOTT */
  89. /* #define FORCE_BANIAS */
  90. /* #define FORCE_YONAH */
  91. /* #define FORCE_CORE2 */
  92. /* #define FORCE_PENRYN */
  93. /* #define FORCE_DUNNINGTON */
  94. /* #define FORCE_NEHALEM */
  95. /* #define FORCE_SANDYBRIDGE */
  96. /* #define FORCE_ATOM */
  97. /* #define FORCE_ATHLON */
  98. /* #define FORCE_OPTERON */
  99. /* #define FORCE_OPTERON_SSE3 */
  100. /* #define FORCE_BARCELONA */
  101. /* #define FORCE_SHANGHAI */
  102. /* #define FORCE_ISTANBUL */
  103. /* #define FORCE_BOBCAT */
  104. /* #define FORCE_BULLDOZER */
  105. /* #define FORCE_PILEDRIVER */
  106. /* #define FORCE_SSE_GENERIC */
  107. /* #define FORCE_VIAC3 */
  108. /* #define FORCE_NANO */
  109. /* #define FORCE_POWER3 */
  110. /* #define FORCE_POWER4 */
  111. /* #define FORCE_POWER5 */
  112. /* #define FORCE_POWER6 */
  113. /* #define FORCE_PPCG4 */
  114. /* #define FORCE_PPC970 */
  115. /* #define FORCE_PPC970MP */
  116. /* #define FORCE_PPC440 */
  117. /* #define FORCE_PPC440FP2 */
  118. /* #define FORCE_CELL */
  119. /* #define FORCE_SICORTEX */
  120. /* #define FORCE_LOONGSON3A */
  121. /* #define FORCE_LOONGSON3B */
  122. /* #define FORCE_ITANIUM2 */
  123. /* #define FORCE_SPARC */
  124. /* #define FORCE_SPARCV7 */
  125. /* #define FORCE_GENERIC */
  126. #ifdef FORCE_P2
  127. #define FORCE
  128. #define FORCE_INTEL
  129. #define ARCHITECTURE "X86"
  130. #define SUBARCHITECTURE "PENTIUM2"
  131. #define ARCHCONFIG "-DPENTIUM2 " \
  132. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
  133. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  134. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  135. "-DHAVE_CMOV -DHAVE_MMX"
  136. #define LIBNAME "p2"
  137. #define CORENAME "P5"
  138. #endif
  139. #ifdef FORCE_KATMAI
  140. #define FORCE
  141. #define FORCE_INTEL
  142. #define ARCHITECTURE "X86"
  143. #define SUBARCHITECTURE "PENTIUM3"
  144. #define ARCHCONFIG "-DPENTIUM3 " \
  145. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
  146. "-DL2_SIZE=524288 -DL2_LINESIZE=32 " \
  147. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  148. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE "
  149. #define LIBNAME "katmai"
  150. #define CORENAME "KATMAI"
  151. #endif
  152. #ifdef FORCE_COPPERMINE
  153. #define FORCE
  154. #define FORCE_INTEL
  155. #define ARCHITECTURE "X86"
  156. #define SUBARCHITECTURE "PENTIUM3"
  157. #define ARCHCONFIG "-DPENTIUM3 " \
  158. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
  159. "-DL2_SIZE=262144 -DL2_LINESIZE=32 " \
  160. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  161. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE "
  162. #define LIBNAME "coppermine"
  163. #define CORENAME "COPPERMINE"
  164. #endif
  165. #ifdef FORCE_NORTHWOOD
  166. #define FORCE
  167. #define FORCE_INTEL
  168. #define ARCHITECTURE "X86"
  169. #define SUBARCHITECTURE "PENTIUM4"
  170. #define ARCHCONFIG "-DPENTIUM4 " \
  171. "-DL1_DATA_SIZE=8192 -DL1_DATA_LINESIZE=64 " \
  172. "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
  173. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
  174. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
  175. #define LIBNAME "northwood"
  176. #define CORENAME "NORTHWOOD"
  177. #endif
  178. #ifdef FORCE_PRESCOTT
  179. #define FORCE
  180. #define FORCE_INTEL
  181. #define ARCHITECTURE "X86"
  182. #define SUBARCHITECTURE "PENTIUM4"
  183. #define ARCHCONFIG "-DPENTIUM4 " \
  184. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
  185. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  186. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
  187. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3"
  188. #define LIBNAME "prescott"
  189. #define CORENAME "PRESCOTT"
  190. #endif
  191. #ifdef FORCE_BANIAS
  192. #define FORCE
  193. #define FORCE_INTEL
  194. #define ARCHITECTURE "X86"
  195. #define SUBARCHITECTURE "BANIAS"
  196. #define ARCHCONFIG "-DPENTIUMM " \
  197. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  198. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  199. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  200. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
  201. #define LIBNAME "banias"
  202. #define CORENAME "BANIAS"
  203. #endif
  204. #ifdef FORCE_YONAH
  205. #define FORCE
  206. #define FORCE_INTEL
  207. #define ARCHITECTURE "X86"
  208. #define SUBARCHITECTURE "YONAH"
  209. #define ARCHCONFIG "-DPENTIUMM " \
  210. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  211. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  212. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  213. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
  214. #define LIBNAME "yonah"
  215. #define CORENAME "YONAH"
  216. #endif
  217. #ifdef FORCE_CORE2
  218. #define FORCE
  219. #define FORCE_INTEL
  220. #define ARCHITECTURE "X86"
  221. #define SUBARCHITECTURE "CONRORE"
  222. #define ARCHCONFIG "-DCORE2 " \
  223. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  224. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  225. "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
  226. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
  227. #define LIBNAME "core2"
  228. #define CORENAME "CORE2"
  229. #endif
  230. #ifdef FORCE_PENRYN
  231. #define FORCE
  232. #define FORCE_INTEL
  233. #define ARCHITECTURE "X86"
  234. #define SUBARCHITECTURE "PENRYN"
  235. #define ARCHCONFIG "-DPENRYN " \
  236. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  237. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  238. "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
  239. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1"
  240. #define LIBNAME "penryn"
  241. #define CORENAME "PENRYN"
  242. #endif
  243. #ifdef FORCE_DUNNINGTON
  244. #define FORCE
  245. #define FORCE_INTEL
  246. #define ARCHITECTURE "X86"
  247. #define SUBARCHITECTURE "DUNNINGTON"
  248. #define ARCHCONFIG "-DDUNNINGTON " \
  249. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  250. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  251. "-DL3_SIZE=16777216 -DL3_LINESIZE=64 " \
  252. "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
  253. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1"
  254. #define LIBNAME "dunnington"
  255. #define CORENAME "DUNNINGTON"
  256. #endif
  257. #ifdef FORCE_NEHALEM
  258. #define FORCE
  259. #define FORCE_INTEL
  260. #define ARCHITECTURE "X86"
  261. #define SUBARCHITECTURE "NEHALEM"
  262. #define ARCHCONFIG "-DNEHALEM " \
  263. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  264. "-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
  265. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  266. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2"
  267. #define LIBNAME "nehalem"
  268. #define CORENAME "NEHALEM"
  269. #endif
  270. #ifdef FORCE_SANDYBRIDGE
  271. #define FORCE
  272. #define FORCE_INTEL
  273. #define ARCHITECTURE "X86"
  274. #define SUBARCHITECTURE "SANDYBRIDGE"
  275. #define ARCHCONFIG "-DSANDYBRIDGE " \
  276. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  277. "-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
  278. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  279. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 -DHAVE_AVX"
  280. #define LIBNAME "sandybridge"
  281. #define CORENAME "SANDYBRIDGE"
  282. #endif
  283. #ifdef FORCE_HASWELL
  284. #define FORCE
  285. #define FORCE_INTEL
  286. #define ARCHITECTURE "X86"
  287. #define SUBARCHITECTURE "HASWELL"
  288. #define ARCHCONFIG "-DHASWELL " \
  289. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  290. "-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
  291. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  292. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 -DHAVE_AVX " \
  293. "-DFMA3"
  294. #define LIBNAME "haswell"
  295. #define CORENAME "HASWELL"
  296. #endif
  297. #ifdef FORCE_ATOM
  298. #define FORCE
  299. #define FORCE_INTEL
  300. #define ARCHITECTURE "X86"
  301. #define SUBARCHITECTURE "ATOM"
  302. #define ARCHCONFIG "-DATOM " \
  303. "-DL1_DATA_SIZE=24576 -DL1_DATA_LINESIZE=64 " \
  304. "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
  305. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 " \
  306. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
  307. #define LIBNAME "atom"
  308. #define CORENAME "ATOM"
  309. #endif
  310. #ifdef FORCE_ATHLON
  311. #define FORCE
  312. #define FORCE_INTEL
  313. #define ARCHITECTURE "X86"
  314. #define SUBARCHITECTURE "ATHLON"
  315. #define ARCHCONFIG "-DATHLON " \
  316. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  317. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  318. "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
  319. "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE "
  320. #define LIBNAME "athlon"
  321. #define CORENAME "ATHLON"
  322. #endif
  323. #ifdef FORCE_OPTERON
  324. #define FORCE
  325. #define FORCE_INTEL
  326. #define ARCHITECTURE "X86"
  327. #define SUBARCHITECTURE "OPTERON"
  328. #define ARCHCONFIG "-DOPTERON " \
  329. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  330. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  331. "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
  332. "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
  333. #define LIBNAME "opteron"
  334. #define CORENAME "OPTERON"
  335. #endif
  336. #ifdef FORCE_OPTERON_SSE3
  337. #define FORCE
  338. #define FORCE_INTEL
  339. #define ARCHITECTURE "X86"
  340. #define SUBARCHITECTURE "OPTERON"
  341. #define ARCHCONFIG "-DOPTERON " \
  342. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  343. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  344. "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
  345. "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3"
  346. #define LIBNAME "opteron"
  347. #define CORENAME "OPTERON"
  348. #endif
  349. #if defined(FORCE_BARCELONA) || defined(FORCE_SHANGHAI) || defined(FORCE_ISTANBUL)
  350. #define FORCE
  351. #define FORCE_INTEL
  352. #define ARCHITECTURE "X86"
  353. #define SUBARCHITECTURE "BARCELONA"
  354. #define ARCHCONFIG "-DBARCELONA " \
  355. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  356. "-DL2_SIZE=524288 -DL2_LINESIZE=64 -DL3_SIZE=2097152 " \
  357. "-DDTB_DEFAULT_ENTRIES=48 -DDTB_SIZE=4096 " \
  358. "-DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 " \
  359. "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_128BITFPU -DHAVE_FASTMOVU"
  360. #define LIBNAME "barcelona"
  361. #define CORENAME "BARCELONA"
  362. #endif
  363. #if defined(FORCE_BOBCAT)
  364. #define FORCE
  365. #define FORCE_INTEL
  366. #define ARCHITECTURE "X86"
  367. #define SUBARCHITECTURE "BOBCAT"
  368. #define ARCHCONFIG "-DBOBCAT " \
  369. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  370. "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
  371. "-DDTB_DEFAULT_ENTRIES=40 -DDTB_SIZE=4096 " \
  372. "-DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 " \
  373. "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_CFLUSH -DHAVE_CMOV"
  374. #define LIBNAME "bobcat"
  375. #define CORENAME "BOBCAT"
  376. #endif
  377. #if defined (FORCE_BULLDOZER)
  378. #define FORCE
  379. #define FORCE_INTEL
  380. #define ARCHITECTURE "X86"
  381. #define SUBARCHITECTURE "BULLDOZER"
  382. #define ARCHCONFIG "-DBULLDOZER " \
  383. "-DL1_DATA_SIZE=49152 -DL1_DATA_LINESIZE=64 " \
  384. "-DL2_SIZE=1024000 -DL2_LINESIZE=64 -DL3_SIZE=16777216 " \
  385. "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 " \
  386. "-DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 " \
  387. "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_128BITFPU -DHAVE_FASTMOVU " \
  388. "-DHAVE_AVX -DHAVE_FMA4"
  389. #define LIBNAME "bulldozer"
  390. #define CORENAME "BULLDOZER"
  391. #endif
  392. #if defined (FORCE_PILEDRIVER)
  393. #define FORCE
  394. #define FORCE_INTEL
  395. #define ARCHITECTURE "X86"
  396. #define SUBARCHITECTURE "PILEDRIVER"
  397. #define ARCHCONFIG "-DPILEDRIVER " \
  398. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
  399. "-DL2_SIZE=2097152 -DL2_LINESIZE=64 -DL3_SIZE=12582912 " \
  400. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  401. "-DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 " \
  402. "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_128BITFPU -DHAVE_FASTMOVU -DHAVE_CFLUSH " \
  403. "-DHAVE_AVX -DHAVE_FMA4 -DHAVE_FMA3"
  404. #define LIBNAME "piledriver"
  405. #define CORENAME "PILEDRIVER"
  406. #endif
  407. #if defined (FORCE_STEAMROLLER)
  408. #define FORCE
  409. #define FORCE_INTEL
  410. #define ARCHITECTURE "X86"
  411. #define SUBARCHITECTURE "STEAMROLLER"
  412. #define ARCHCONFIG "-DSTEAMROLLER " \
  413. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
  414. "-DL2_SIZE=2097152 -DL2_LINESIZE=64 -DL3_SIZE=12582912 " \
  415. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
  416. "-DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 " \
  417. "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_128BITFPU -DHAVE_FASTMOVU -DHAVE_CFLUSH " \
  418. "-DHAVE_AVX -DHAVE_FMA4 -DHAVE_FMA3"
  419. #define LIBNAME "steamroller"
  420. #define CORENAME "STEAMROLLER"
  421. #endif
  422. #ifdef FORCE_SSE_GENERIC
  423. #define FORCE
  424. #define FORCE_INTEL
  425. #define ARCHITECTURE "X86"
  426. #define SUBARCHITECTURE "GENERIC"
  427. #define ARCHCONFIG "-DGENERIC " \
  428. "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
  429. "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
  430. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
  431. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2"
  432. #define LIBNAME "generic"
  433. #define CORENAME "GENERIC"
  434. #endif
  435. #ifdef FORCE_VIAC3
  436. #define FORCE
  437. #define FORCE_INTEL
  438. #define ARCHITECTURE "X86"
  439. #define SUBARCHITECTURE "VIAC3"
  440. #define ARCHCONFIG "-DVIAC3 " \
  441. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  442. "-DL2_SIZE=65536 -DL2_LINESIZE=32 " \
  443. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 " \
  444. "-DHAVE_MMX -DHAVE_SSE "
  445. #define LIBNAME "viac3"
  446. #define CORENAME "VIAC3"
  447. #endif
  448. #ifdef FORCE_NANO
  449. #define FORCE
  450. #define FORCE_INTEL
  451. #define ARCHITECTURE "X86"
  452. #define SUBARCHITECTURE "NANO"
  453. #define ARCHCONFIG "-DNANO " \
  454. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  455. "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
  456. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
  457. "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
  458. #define LIBNAME "nano"
  459. #define CORENAME "NANO"
  460. #endif
  461. #ifdef FORCE_POWER3
  462. #define FORCE
  463. #define ARCHITECTURE "POWER"
  464. #define SUBARCHITECTURE "POWER3"
  465. #define SUBDIRNAME "power"
  466. #define ARCHCONFIG "-DPOWER3 " \
  467. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=128 " \
  468. "-DL2_SIZE=2097152 -DL2_LINESIZE=128 " \
  469. "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  470. #define LIBNAME "power3"
  471. #define CORENAME "POWER3"
  472. #endif
  473. #ifdef FORCE_POWER4
  474. #define FORCE
  475. #define ARCHITECTURE "POWER"
  476. #define SUBARCHITECTURE "POWER4"
  477. #define SUBDIRNAME "power"
  478. #define ARCHCONFIG "-DPOWER4 " \
  479. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
  480. "-DL2_SIZE=1509949 -DL2_LINESIZE=128 " \
  481. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=6 "
  482. #define LIBNAME "power4"
  483. #define CORENAME "POWER4"
  484. #endif
  485. #ifdef FORCE_POWER5
  486. #define FORCE
  487. #define ARCHITECTURE "POWER"
  488. #define SUBARCHITECTURE "POWER5"
  489. #define SUBDIRNAME "power"
  490. #define ARCHCONFIG "-DPOWER5 " \
  491. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
  492. "-DL2_SIZE=1509949 -DL2_LINESIZE=128 " \
  493. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=6 "
  494. #define LIBNAME "power5"
  495. #define CORENAME "POWER5"
  496. #endif
  497. #ifdef FORCE_POWER6
  498. #define FORCE
  499. #define ARCHITECTURE "POWER"
  500. #define SUBARCHITECTURE "POWER6"
  501. #define SUBDIRNAME "power"
  502. #define ARCHCONFIG "-DPOWER6 " \
  503. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=128 " \
  504. "-DL2_SIZE=4194304 -DL2_LINESIZE=128 " \
  505. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  506. #define LIBNAME "power6"
  507. #define CORENAME "POWER6"
  508. #endif
  509. #ifdef FORCE_PPCG4
  510. #define FORCE
  511. #define ARCHITECTURE "POWER"
  512. #define SUBARCHITECTURE "PPCG4"
  513. #define SUBDIRNAME "power"
  514. #define ARCHCONFIG "-DPPCG4 " \
  515. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
  516. "-DL2_SIZE=262144 -DL2_LINESIZE=32 " \
  517. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  518. #define LIBNAME "ppcg4"
  519. #define CORENAME "PPCG4"
  520. #endif
  521. #ifdef FORCE_PPC970
  522. #define FORCE
  523. #define ARCHITECTURE "POWER"
  524. #define SUBARCHITECTURE "PPC970"
  525. #define SUBDIRNAME "power"
  526. #define ARCHCONFIG "-DPPC970 " \
  527. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
  528. "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
  529. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  530. #define LIBNAME "ppc970"
  531. #define CORENAME "PPC970"
  532. #endif
  533. #ifdef FORCE_PPC970MP
  534. #define FORCE
  535. #define ARCHITECTURE "POWER"
  536. #define SUBARCHITECTURE "PPC970"
  537. #define SUBDIRNAME "power"
  538. #define ARCHCONFIG "-DPPC970 " \
  539. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
  540. "-DL2_SIZE=1024976 -DL2_LINESIZE=128 " \
  541. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  542. #define LIBNAME "ppc970mp"
  543. #define CORENAME "PPC970"
  544. #endif
  545. #ifdef FORCE_PPC440
  546. #define FORCE
  547. #define ARCHITECTURE "POWER"
  548. #define SUBARCHITECTURE "PPC440"
  549. #define SUBDIRNAME "power"
  550. #define ARCHCONFIG "-DPPC440 " \
  551. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
  552. "-DL2_SIZE=16384 -DL2_LINESIZE=128 " \
  553. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=16 "
  554. #define LIBNAME "ppc440"
  555. #define CORENAME "PPC440"
  556. #endif
  557. #ifdef FORCE_PPC440FP2
  558. #define FORCE
  559. #define ARCHITECTURE "POWER"
  560. #define SUBARCHITECTURE "PPC440FP2"
  561. #define SUBDIRNAME "power"
  562. #define ARCHCONFIG "-DPPC440FP2 " \
  563. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
  564. "-DL2_SIZE=16384 -DL2_LINESIZE=128 " \
  565. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=16 "
  566. #define LIBNAME "ppc440FP2"
  567. #define CORENAME "PPC440FP2"
  568. #endif
  569. #ifdef FORCE_CELL
  570. #define FORCE
  571. #define ARCHITECTURE "POWER"
  572. #define SUBARCHITECTURE "CELL"
  573. #define SUBDIRNAME "power"
  574. #define ARCHCONFIG "-DCELL " \
  575. "-DL1_DATA_SIZE=262144 -DL1_DATA_LINESIZE=128 " \
  576. "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
  577. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  578. #define LIBNAME "cell"
  579. #define CORENAME "CELL"
  580. #endif
  581. #ifdef FORCE_SICORTEX
  582. #define FORCE
  583. #define ARCHITECTURE "MIPS"
  584. #define SUBARCHITECTURE "SICORTEX"
  585. #define SUBDIRNAME "mips"
  586. #define ARCHCONFIG "-DSICORTEX " \
  587. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
  588. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  589. "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  590. #define LIBNAME "mips"
  591. #define CORENAME "sicortex"
  592. #endif
  593. #ifdef FORCE_LOONGSON3A
  594. #define FORCE
  595. #define ARCHITECTURE "MIPS"
  596. #define SUBARCHITECTURE "LOONGSON3A"
  597. #define SUBDIRNAME "mips64"
  598. #define ARCHCONFIG "-DLOONGSON3A " \
  599. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  600. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  601. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 "
  602. #define LIBNAME "loongson3a"
  603. #define CORENAME "LOONGSON3A"
  604. #else
  605. #endif
  606. #ifdef FORCE_LOONGSON3B
  607. #define FORCE
  608. #define ARCHITECTURE "MIPS"
  609. #define SUBARCHITECTURE "LOONGSON3B"
  610. #define SUBDIRNAME "mips64"
  611. #define ARCHCONFIG "-DLOONGSON3B " \
  612. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  613. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  614. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 "
  615. #define LIBNAME "loongson3b"
  616. #define CORENAME "LOONGSON3B"
  617. #else
  618. #endif
  619. #ifdef FORCE_ITANIUM2
  620. #define FORCE
  621. #define ARCHITECTURE "IA64"
  622. #define SUBARCHITECTURE "ITANIUM2"
  623. #define SUBDIRNAME "ia64"
  624. #define ARCHCONFIG "-DITANIUM2 " \
  625. "-DL1_DATA_SIZE=262144 -DL1_DATA_LINESIZE=128 " \
  626. "-DL2_SIZE=1572864 -DL2_LINESIZE=128 -DDTB_SIZE=16384 -DDTB_DEFAULT_ENTRIES=128 "
  627. #define LIBNAME "itanium2"
  628. #define CORENAME "itanium2"
  629. #endif
  630. #ifdef FORCE_SPARC
  631. #define FORCE
  632. #define ARCHITECTURE "SPARC"
  633. #define SUBARCHITECTURE "SPARC"
  634. #define SUBDIRNAME "sparc"
  635. #define ARCHCONFIG "-DSPARC -DV9 " \
  636. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  637. "-DL2_SIZE=1572864 -DL2_LINESIZE=64 -DDTB_SIZE=8192 -DDTB_DEFAULT_ENTRIES=64 "
  638. #define LIBNAME "sparc"
  639. #define CORENAME "sparc"
  640. #endif
  641. #ifdef FORCE_SPARCV7
  642. #define FORCE
  643. #define ARCHITECTURE "SPARC"
  644. #define SUBARCHITECTURE "SPARC"
  645. #define SUBDIRNAME "sparc"
  646. #define ARCHCONFIG "-DSPARC -DV7 " \
  647. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
  648. "-DL2_SIZE=1572864 -DL2_LINESIZE=64 -DDTB_SIZE=8192 -DDTB_DEFAULT_ENTRIES=64 "
  649. #define LIBNAME "sparcv7"
  650. #define CORENAME "sparcv7"
  651. #endif
  652. #ifdef FORCE_GENERIC
  653. #define FORCE
  654. #define ARCHITECTURE "GENERIC"
  655. #define SUBARCHITECTURE "GENERIC"
  656. #define SUBDIRNAME "generic"
  657. #define ARCHCONFIG "-DGENERIC " \
  658. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
  659. "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
  660. "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
  661. #define LIBNAME "generic"
  662. #define CORENAME "generic"
  663. #endif
  664. #ifdef FORCE_ARMV7
  665. #define FORCE
  666. #define ARCHITECTURE "ARM"
  667. #define SUBARCHITECTURE "ARMV7"
  668. #define SUBDIRNAME "arm"
  669. #define ARCHCONFIG "-DARMV7 " \
  670. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  671. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  672. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 " \
  673. "-DHAVE_VFPV3 -DHAVE_VFP"
  674. #define LIBNAME "armv7"
  675. #define CORENAME "ARMV7"
  676. #else
  677. #endif
  678. #ifdef FORCE_ARMV6
  679. #define FORCE
  680. #define ARCHITECTURE "ARM"
  681. #define SUBARCHITECTURE "ARMV6"
  682. #define SUBDIRNAME "arm"
  683. #define ARCHCONFIG "-DARMV6 " \
  684. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  685. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  686. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 " \
  687. "-DHAVE_VFP"
  688. #define LIBNAME "armv6"
  689. #define CORENAME "ARMV6"
  690. #else
  691. #endif
  692. #ifdef FORCE_ARMV5
  693. #define FORCE
  694. #define ARCHITECTURE "ARM"
  695. #define SUBARCHITECTURE "ARMV5"
  696. #define SUBDIRNAME "arm"
  697. #define ARCHCONFIG "-DARMV5 " \
  698. "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
  699. "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
  700. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 " \
  701. "-DHAVE_VFP"
  702. #define LIBNAME "armv5"
  703. #define CORENAME "ARMV5"
  704. #else
  705. #endif
  706. #ifdef FORCE_ARMV8
  707. #define FORCE
  708. #define ARCHITECTURE "ARM64"
  709. #define SUBARCHITECTURE "ARMV8"
  710. #define SUBDIRNAME "arm64"
  711. #define ARCHCONFIG "-DARMV8 " \
  712. "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
  713. "-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
  714. "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=32 "
  715. #define LIBNAME "armv8"
  716. #define CORENAME "XGENE1"
  717. #else
  718. #endif
  719. #ifndef FORCE
  720. #if defined(__powerpc__) || defined(__powerpc) || defined(powerpc) || \
  721. defined(__PPC__) || defined(PPC) || defined(_POWER) || defined(__POWERPC__)
  722. #ifndef POWER
  723. #define POWER
  724. #endif
  725. #define OPENBLAS_SUPPORTED
  726. #endif
  727. #ifdef INTEL_AMD
  728. #include "cpuid_x86.c"
  729. #define OPENBLAS_SUPPORTED
  730. #endif
  731. #ifdef __ia64__
  732. #include "cpuid_ia64.c"
  733. #define OPENBLAS_SUPPORTED
  734. #endif
  735. #ifdef __alpha
  736. #include "cpuid_alpha.c"
  737. #define OPENBLAS_SUPPORTED
  738. #endif
  739. #ifdef POWER
  740. #include "cpuid_power.c"
  741. #define OPENBLAS_SUPPORTED
  742. #endif
  743. #ifdef sparc
  744. #include "cpuid_sparc.c"
  745. #define OPENBLAS_SUPPORTED
  746. #endif
  747. #ifdef __mips__
  748. #include "cpuid_mips.c"
  749. #define OPENBLAS_SUPPORTED
  750. #endif
  751. #ifdef __arm__
  752. #include "cpuid_arm.c"
  753. #define OPENBLAS_SUPPORTED
  754. #endif
  755. #ifdef __aarch64__
  756. #include "cpuid_arm64.c"
  757. #define OPENBLAS_SUPPORTED
  758. #endif
  759. #ifndef OPENBLAS_SUPPORTED
  760. #error "This arch/CPU is not supported by OpenBLAS."
  761. #endif
  762. #else
  763. #endif
  764. static int get_num_cores(void) {
  765. #ifdef OS_WINDOWS
  766. SYSTEM_INFO sysinfo;
  767. #elif defined(__FreeBSD__) || defined(__APPLE__)
  768. int m[2], count;
  769. size_t len;
  770. #endif
  771. #ifdef linux
  772. //returns the number of processors which are currently online
  773. return sysconf(_SC_NPROCESSORS_ONLN);
  774. #elif defined(OS_WINDOWS)
  775. GetSystemInfo(&sysinfo);
  776. return sysinfo.dwNumberOfProcessors;
  777. #elif defined(__FreeBSD__) || defined(__APPLE__)
  778. m[0] = CTL_HW;
  779. m[1] = HW_NCPU;
  780. len = sizeof(int);
  781. sysctl(m, 2, &count, &len, NULL, 0);
  782. return count;
  783. #else
  784. return 2;
  785. #endif
  786. }
  787. int main(int argc, char *argv[]){
  788. #ifdef FORCE
  789. char buffer[8192], *p, *q;
  790. int length;
  791. #endif
  792. if (argc == 1) return 0;
  793. switch (argv[1][0]) {
  794. case '0' : /* for Makefile */
  795. #ifdef FORCE
  796. printf("CORE=%s\n", CORENAME);
  797. #else
  798. #if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__)
  799. printf("CORE=%s\n", get_corename());
  800. #endif
  801. #endif
  802. #ifdef FORCE
  803. printf("LIBCORE=%s\n", LIBNAME);
  804. #else
  805. printf("LIBCORE=");
  806. get_libname();
  807. printf("\n");
  808. #endif
  809. printf("NUM_CORES=%d\n", get_num_cores());
  810. #if defined(__arm__) && !defined(FORCE)
  811. get_features();
  812. #endif
  813. #ifdef INTEL_AMD
  814. #ifndef FORCE
  815. get_sse();
  816. #else
  817. sprintf(buffer, "%s", ARCHCONFIG);
  818. p = &buffer[0];
  819. while (*p) {
  820. if ((*p == '-') && (*(p + 1) == 'D')) {
  821. p += 2;
  822. while ((*p != ' ') && (*p != '\0')) {
  823. if (*p == '=') {
  824. printf("=");
  825. p ++;
  826. while ((*p != ' ') && (*p != '\0')) {
  827. printf("%c", *p);
  828. p ++;
  829. }
  830. } else {
  831. printf("%c", *p);
  832. p ++;
  833. if ((*p == ' ') || (*p =='\0')) printf("=1");
  834. }
  835. }
  836. printf("\n");
  837. } else p ++;
  838. }
  839. #endif
  840. #endif
  841. #if NO_PARALLEL_MAKE==1
  842. printf("MAKE += -j 1\n");
  843. #else
  844. #ifndef OS_WINDOWS
  845. printf("MAKE += -j %d\n", get_num_cores());
  846. #endif
  847. #endif
  848. break;
  849. case '1' : /* For config.h */
  850. #ifdef FORCE
  851. sprintf(buffer, "%s -DCORE_%s\n", ARCHCONFIG, CORENAME);
  852. p = &buffer[0];
  853. while (*p) {
  854. if ((*p == '-') && (*(p + 1) == 'D')) {
  855. p += 2;
  856. printf("#define ");
  857. while ((*p != ' ') && (*p != '\0')) {
  858. if (*p == '=') {
  859. printf(" ");
  860. p ++;
  861. while ((*p != ' ') && (*p != '\0')) {
  862. printf("%c", *p);
  863. p ++;
  864. }
  865. } else {
  866. printf("%c", *p);
  867. p ++;
  868. }
  869. }
  870. printf("\n");
  871. } else p ++;
  872. }
  873. #else
  874. get_cpuconfig();
  875. #endif
  876. #ifdef FORCE
  877. printf("#define CHAR_CORENAME \"%s\"\n", CORENAME);
  878. #else
  879. #if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__)
  880. printf("#define CHAR_CORENAME \"%s\"\n", get_corename());
  881. #endif
  882. #endif
  883. break;
  884. case '2' : /* SMP */
  885. if (get_num_cores() > 1) printf("SMP=1\n");
  886. break;
  887. }
  888. fflush(stdout);
  889. return 0;
  890. }