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

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

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.