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