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 31 kB

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