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.

prebuild.cmake 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. ##
  2. ## Author: Hank Anderson <hank@statease.com>
  3. ## Description: Ported from OpenBLAS/Makefile.prebuild
  4. ## This is triggered by system.cmake and runs before any of the code is built.
  5. ## Creates config.h and Makefile.conf by first running the c_check perl script (which creates those files).
  6. ## Next it runs f_check and appends some fortran information to the files.
  7. ## Then it runs getarch and getarch_2nd for even more environment information.
  8. ## Finally it builds gen_config_h for use at build time to generate config.h.
  9. # CMake vars set by this file:
  10. # CORE
  11. # LIBCORE
  12. # NUM_CORES
  13. # HAVE_MMX
  14. # HAVE_SSE
  15. # HAVE_SSE2
  16. # HAVE_SSE3
  17. # MAKE
  18. # SHGEMM_UNROLL_M
  19. # SHGEMM_UNROLL_N
  20. # SGEMM_UNROLL_M
  21. # SGEMM_UNROLL_N
  22. # DGEMM_UNROLL_M
  23. # DGEMM_UNROLL_M
  24. # QGEMM_UNROLL_N
  25. # QGEMM_UNROLL_N
  26. # CGEMM_UNROLL_M
  27. # CGEMM_UNROLL_M
  28. # ZGEMM_UNROLL_N
  29. # ZGEMM_UNROLL_N
  30. # XGEMM_UNROLL_M
  31. # XGEMM_UNROLL_N
  32. # CGEMM3M_UNROLL_M
  33. # CGEMM3M_UNROLL_N
  34. # ZGEMM3M_UNROLL_M
  35. # ZGEMM3M_UNROLL_M
  36. # XGEMM3M_UNROLL_N
  37. # XGEMM3M_UNROLL_N
  38. # CPUIDEMU = ../../cpuid/table.o
  39. if (DEFINED CPUIDEMU)
  40. set(EXFLAGS "-DCPUIDEMU -DVENDOR=99")
  41. endif ()
  42. if (BUILD_KERNEL)
  43. # set the C flags for just this file
  44. set(GETARCH2_FLAGS "-DBUILD_KERNEL")
  45. set(TARGET_CONF "config_kernel.h")
  46. set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR}/kernel_config/${TARGET_CORE})
  47. else()
  48. set(TARGET_CONF "config.h")
  49. set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR})
  50. endif ()
  51. set(TARGET_CONF_TEMP "${PROJECT_BINARY_DIR}/${TARGET_CONF}.tmp")
  52. # c_check
  53. set(FU "")
  54. if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
  55. set(FU "_")
  56. endif()
  57. if(MINGW AND NOT MINGW64)
  58. set(FU "_")
  59. endif()
  60. set(COMPILER_ID ${CMAKE_C_COMPILER_ID})
  61. if (${COMPILER_ID} STREQUAL "GNU")
  62. set(COMPILER_ID "GCC")
  63. endif ()
  64. string(TOUPPER ${ARCH} UC_ARCH)
  65. file(WRITE ${TARGET_CONF_TEMP}
  66. "#define OS_${HOST_OS}\t1\n"
  67. "#define ARCH_${UC_ARCH}\t1\n"
  68. "#define C_${COMPILER_ID}\t1\n"
  69. "#define __${BINARY}BIT__\t1\n"
  70. "#define FUNDERSCORE\t${FU}\n")
  71. if (${HOST_OS} STREQUAL "WINDOWSSTORE")
  72. file(APPEND ${TARGET_CONF_TEMP}
  73. "#define OS_WINNT\t1\n")
  74. endif ()
  75. # f_check
  76. if (NOT NOFORTRAN)
  77. include("${PROJECT_SOURCE_DIR}/cmake/f_check.cmake")
  78. else ()
  79. file(APPEND ${TARGET_CONF_TEMP}
  80. "#define BUNDERSCORE _\n"
  81. "#define NEEDBUNDERSCORE 1\n")
  82. set(BU "_")
  83. endif ()
  84. # Cannot run getarch on target if we are cross-compiling
  85. if (DEFINED CORE AND CMAKE_CROSSCOMPILING AND NOT (${HOST_OS} STREQUAL "WINDOWSSTORE"))
  86. # Write to config as getarch would
  87. if (DEFINED TARGET_CORE)
  88. set(TCORE ${TARGET_CORE})
  89. else()
  90. set(TCORE ${CORE})
  91. endif()
  92. # TODO: Set up defines that getarch sets up based on every other target
  93. # Perhaps this should be inside a different file as it grows larger
  94. file(APPEND ${TARGET_CONF_TEMP}
  95. "#define ${TCORE}\n"
  96. "#define CORE_${TCORE}\n"
  97. "#define CHAR_CORENAME \"${TCORE}\"\n")
  98. if ("${TCORE}" STREQUAL "CORE2")
  99. file(APPEND ${TARGET_CONF_TEMP}
  100. "#define L1_DATA_SIZE\t32768\n"
  101. "#define L1_DATA_LINESIZE\t64\n"
  102. "#define L2_SIZE\t1048576\n"
  103. "#define L2_LINESIZE\t64\n"
  104. "#define DTB_DEFAULT_ENTRIES\t256\n"
  105. "#define DTB_SIZE\t4096\n"
  106. "#define HAVE_CMOV\n"
  107. "#define HAVE_MMX\n"
  108. "#define HAVE_SSE\n"
  109. "#define HAVE_SSE2\n"
  110. "#define HAVE_SSE3\n"
  111. "#define HAVE_SSSE3\n"
  112. "#define SLOCAL_BUFFER_SIZE\t16384\n"
  113. "#define DLOCAL_BUFFER_SIZE\t16384\n"
  114. "#define CLOCAL_BUFFER_SIZE\t16384\n"
  115. "#define ZLOCAL_BUFFER_SIZE\t16384\n")
  116. set(SGEMM_UNROLL_M 8)
  117. set(SGEMM_UNROLL_N 4)
  118. set(DGEMM_UNROLL_M 4)
  119. set(DGEMM_UNROLL_N 4)
  120. set(CGEMM_UNROLL_M 4)
  121. set(CGEMM_UNROLL_N 2)
  122. set(ZGEMM_UNROLL_M 2)
  123. set(ZGEMM_UNROLL_N 2)
  124. set(CGEMM3M_UNROLL_M 8)
  125. set(CGEMM3M_UNROLL_N 4)
  126. set(ZGEMM3M_UNROLL_M 4)
  127. set(ZGEMM3M_UNROLL_N 4)
  128. elseif ("${TCORE}" STREQUAL "ARMV7")
  129. file(APPEND ${TARGET_CONF_TEMP}
  130. "#define L1_DATA_SIZE\t65536\n"
  131. "#define L1_DATA_LINESIZE\t32\n"
  132. "#define L2_SIZE\t512488\n"
  133. "#define L2_LINESIZE\t32\n"
  134. "#define DTB_DEFAULT_ENTRIES\t64\n"
  135. "#define DTB_SIZE\t4096\n"
  136. "#define L2_ASSOCIATIVE\t4\n"
  137. "#define HAVE_VFPV3\n"
  138. "#define HAVE_VFP\n")
  139. set(SGEMM_UNROLL_M 4)
  140. set(SGEMM_UNROLL_N 4)
  141. set(DGEMM_UNROLL_M 4)
  142. set(DGEMM_UNROLL_N 4)
  143. set(CGEMM_UNROLL_M 2)
  144. set(CGEMM_UNROLL_N 2)
  145. set(ZGEMM_UNROLL_M 2)
  146. set(ZGEMM_UNROLL_N 2)
  147. elseif ("${TCORE}" STREQUAL "ARMV8")
  148. file(APPEND ${TARGET_CONF_TEMP}
  149. "#define L1_DATA_SIZE\t32768\n"
  150. "#define L1_DATA_LINESIZE\t64\n"
  151. "#define L2_SIZE\t262144\n"
  152. "#define L2_LINESIZE\t64\n"
  153. "#define DTB_DEFAULT_ENTRIES\t64\n"
  154. "#define DTB_SIZE\t4096\n"
  155. "#define L2_ASSOCIATIVE\t32\n"
  156. "#define ARMV8\n")
  157. set(SGEMM_UNROLL_M 16)
  158. set(SGEMM_UNROLL_N 4)
  159. set(DGEMM_UNROLL_M 8)
  160. set(DGEMM_UNROLL_N 4)
  161. set(CGEMM_UNROLL_M 8)
  162. set(CGEMM_UNROLL_N 4)
  163. set(ZGEMM_UNROLL_M 4)
  164. set(ZGEMM_UNROLL_N 4)
  165. set(SYMV_P 16)
  166. elseif ("${TCORE}" STREQUAL "CORTEXA57" OR "${TCORE}" STREQUAL "CORTEXA53")
  167. file(APPEND ${TARGET_CONF_TEMP}
  168. "#define L1_CODE_SIZE\t32768\n"
  169. "#define L1_CODE_LINESIZE\t64\n"
  170. "#define L1_CODE_ASSOCIATIVE\t3\n"
  171. "#define L1_DATA_SIZE\t32768\n"
  172. "#define L1_DATA_LINESIZE\t64\n"
  173. "#define L1_DATA_ASSOCIATIVE\t2\n"
  174. "#define L2_SIZE\t262144\n"
  175. "#define L2_LINESIZE\t64\n"
  176. "#define L2_ASSOCIATIVE\t16\n"
  177. "#define DTB_DEFAULT_ENTRIES\t64\n"
  178. "#define DTB_SIZE\t4096\n"
  179. "#define HAVE_VFPV4\n"
  180. "#define HAVE_VFPV3\n"
  181. "#define HAVE_VFP\n"
  182. "#define HAVE_NEON\n"
  183. "#define ARMV8\n")
  184. set(SGEMM_UNROLL_M 16)
  185. set(SGEMM_UNROLL_N 4)
  186. set(DGEMM_UNROLL_M 8)
  187. set(DGEMM_UNROLL_N 4)
  188. set(CGEMM_UNROLL_M 8)
  189. set(CGEMM_UNROLL_N 4)
  190. set(ZGEMM_UNROLL_M 4)
  191. set(ZGEMM_UNROLL_N 4)
  192. set(SYMV_P 16)
  193. elseif ("${TCORE}" STREQUAL "CORTEXA72" OR "${TCORE}" STREQUAL "CORTEXA73")
  194. file(APPEND ${TARGET_CONF_TEMP}
  195. "#define L1_CODE_SIZE\t49152\n"
  196. "#define L1_CODE_LINESIZE\t64\n"
  197. "#define L1_CODE_ASSOCIATIVE\t3\n"
  198. "#define L1_DATA_SIZE\t32768\n"
  199. "#define L1_DATA_LINESIZE\t64\n"
  200. "#define L1_DATA_ASSOCIATIVE\t2\n"
  201. "#define L2_SIZE\t524288\n"
  202. "#define L2_LINESIZE\t64\n"
  203. "#define L2_ASSOCIATIVE\t16\n"
  204. "#define DTB_DEFAULT_ENTRIES\t64\n"
  205. "#define DTB_SIZE\t4096\n"
  206. "#define HAVE_VFPV4\n"
  207. "#define HAVE_VFPV3\n"
  208. "#define HAVE_VFP\n"
  209. "#define HAVE_NEON\n"
  210. "#define ARMV8\n")
  211. set(SGEMM_UNROLL_M 16)
  212. set(SGEMM_UNROLL_N 4)
  213. set(DGEMM_UNROLL_M 8)
  214. set(DGEMM_UNROLL_N 4)
  215. set(CGEMM_UNROLL_M 8)
  216. set(CGEMM_UNROLL_N 4)
  217. set(ZGEMM_UNROLL_M 4)
  218. set(ZGEMM_UNROLL_N 4)
  219. set(SYMV_P 16)
  220. elseif ("${TCORE}" STREQUAL "NEOVERSEN1")
  221. file(APPEND ${TARGET_CONF_TEMP}
  222. "#define L1_CODE_SIZE\t65536\n"
  223. "#define L1_CODE_LINESIZE\t64\n"
  224. "#define L1_CODE_ASSOCIATIVE\t4\n"
  225. "#define L1_DATA_SIZE\t65536\n"
  226. "#define L1_DATA_LINESIZE\t64\n"
  227. "#define L1_DATA_ASSOCIATIVE\t2\n"
  228. "#define L2_SIZE\t1048576\n\n"
  229. "#define L2_LINESIZE\t64\n"
  230. "#define L2_ASSOCIATIVE\t16\n"
  231. "#define DTB_DEFAULT_ENTRIES\t64\n"
  232. "#define DTB_SIZE\t4096\n"
  233. "#define HAVE_VFPV4\n"
  234. "#define HAVE_VFPV3\n"
  235. "#define HAVE_VFP\n"
  236. "#define HAVE_NEON\n"
  237. "#define ARMV8\n")
  238. set(SGEMM_UNROLL_M 16)
  239. set(SGEMM_UNROLL_N 4)
  240. set(DGEMM_UNROLL_M 8)
  241. set(DGEMM_UNROLL_N 4)
  242. set(CGEMM_UNROLL_M 8)
  243. set(CGEMM_UNROLL_N 4)
  244. set(ZGEMM_UNROLL_M 4)
  245. set(ZGEMM_UNROLL_N 4)
  246. set(SYMV_P 16)
  247. elseif ("${TCORE}" STREQUAL "FALKOR")
  248. file(APPEND ${TARGET_CONF_TEMP}
  249. "#define L1_CODE_SIZE\t65536\n"
  250. "#define L1_CODE_LINESIZE\t64\n"
  251. "#define L1_CODE_ASSOCIATIVE\t3\n"
  252. "#define L1_DATA_SIZE\t32768\n"
  253. "#define L1_DATA_LINESIZE\t128\n"
  254. "#define L1_DATA_ASSOCIATIVE\t2\n"
  255. "#define L2_SIZE\t524288\n"
  256. "#define L2_LINESIZE\t64\n"
  257. "#define L2_ASSOCIATIVE\t16\n"
  258. "#define DTB_DEFAULT_ENTRIES\t64\n"
  259. "#define DTB_SIZE\t4096\n"
  260. "#define HAVE_VFPV4\n"
  261. "#define HAVE_VFPV3\n"
  262. "#define HAVE_VFP\n"
  263. "#define HAVE_NEON\n"
  264. "#define ARMV8\n")
  265. set(SGEMM_UNROLL_M 16)
  266. set(SGEMM_UNROLL_N 4)
  267. set(DGEMM_UNROLL_M 8)
  268. set(DGEMM_UNROLL_N 4)
  269. set(CGEMM_UNROLL_M 8)
  270. set(CGEMM_UNROLL_N 4)
  271. set(ZGEMM_UNROLL_M 4)
  272. set(ZGEMM_UNROLL_N 4)
  273. set(SYMV_P 16)
  274. elseif ("${TCORE}" STREQUAL "THUNDERX")
  275. file(APPEND ${TARGET_CONF_TEMP}
  276. "#define L1_CODE_SIZE\t32768\n"
  277. "#define L1_CODE_LINESIZE\t64\n"
  278. "#define L1_CODE_ASSOCIATIVE\t3\n"
  279. "#define L1_DATA_SIZE\t32768\n"
  280. "#define L1_DATA_LINESIZE\t128\n"
  281. "#define L1_DATA_ASSOCIATIVE\t2\n"
  282. "#define L2_SIZE\t167772164\n"
  283. "#define L2_LINESIZE\t128\n"
  284. "#define L2_ASSOCIATIVE\t16\n"
  285. "#define DTB_DEFAULT_ENTRIES\t64\n"
  286. "#define DTB_SIZE\t4096\n"
  287. "#define HAVE_VFPV4\n"
  288. "#define HAVE_VFPV3\n"
  289. "#define HAVE_VFP\n"
  290. "#define HAVE_NEON\n"
  291. "#define ARMV8\n")
  292. set(SGEMM_UNROLL_M 4)
  293. set(SGEMM_UNROLL_N 4)
  294. set(DGEMM_UNROLL_M 2)
  295. set(DGEMM_UNROLL_N 2)
  296. set(CGEMM_UNROLL_M 2)
  297. set(CGEMM_UNROLL_N 2)
  298. set(ZGEMM_UNROLL_M 2)
  299. set(ZGEMM_UNROLL_N 2)
  300. set(SYMV_P 16)
  301. elseif ("${TCORE}" STREQUAL "THUNDERX2T99")
  302. file(APPEND ${TARGET_CONF_TEMP}
  303. "#define L1_CODE_SIZE\t32768\n"
  304. "#define L1_CODE_LINESIZE\t64\n"
  305. "#define L1_CODE_ASSOCIATIVE\t8\n"
  306. "#define L1_DATA_SIZE\t32768\n"
  307. "#define L1_DATA_LINESIZE\t64\n"
  308. "#define L1_DATA_ASSOCIATIVE\t8\n"
  309. "#define L2_SIZE\t262144\n"
  310. "#define L2_LINESIZE\t64\n"
  311. "#define L2_ASSOCIATIVE\t8\n"
  312. "#define L3_SIZE\t33554432\n"
  313. "#define L3_LINESIZE\t64\n"
  314. "#define L3_ASSOCIATIVE\t32\n"
  315. "#define DTB_DEFAULT_ENTRIES\t64\n"
  316. "#define DTB_SIZE\t4096\n"
  317. "#define ARMV8\n")
  318. set(SGEMM_UNROLL_M 16)
  319. set(SGEMM_UNROLL_N 4)
  320. set(DGEMM_UNROLL_M 8)
  321. set(DGEMM_UNROLL_N 4)
  322. set(CGEMM_UNROLL_M 8)
  323. set(CGEMM_UNROLL_N 4)
  324. set(ZGEMM_UNROLL_M 4)
  325. set(ZGEMM_UNROLL_N 4)
  326. set(SYMV_P 16)
  327. elseif ("${TCORE}" STREQUAL "TSV110")
  328. file(APPEND ${TARGET_CONF_TEMP}
  329. "#define ARMV8\n"
  330. "#define L1_CODE_SIZE\t65536\n"
  331. "#define L1_CODE_LINESIZE\t64\n"
  332. "#define L1_CODE_ASSOCIATIVE\t4\n"
  333. "#define L1_DATA_SIZE\t65536\n"
  334. "#define L1_DATA_LINESIZE\t64\n"
  335. "#define L1_DATA_ASSOCIATIVE\t4\n"
  336. "#define L2_SIZE\t524288\n"
  337. "#define L2_LINESIZE\t64\n"
  338. "#define L2_ASSOCIATIVE\t8\n"
  339. "#define DTB_DEFAULT_ENTRIES\t64\n"
  340. "#define DTB_SIZE\t4096\n")
  341. set(SGEMM_UNROLL_M 16)
  342. set(SGEMM_UNROLL_N 4)
  343. set(DGEMM_UNROLL_M 8)
  344. set(DGEMM_UNROLL_N 4)
  345. set(CGEMM_UNROLL_M 8)
  346. set(CGEMM_UNROLL_N 4)
  347. set(ZGEMM_UNROLL_M 4)
  348. set(ZGEMM_UNROLL_N 4)
  349. set(SYMV_P 16)
  350. elseif ("${TCORE}" STREQUAL "EMAG8180")
  351. file(APPEND ${TARGET_CONF_TEMP}
  352. "#define ARMV8\n"
  353. "#define L1_CODE_SIZE\t32768\n"
  354. "#define L1_CODE_LINESIZE\t64\n"
  355. "#define L1_CODE_ASSOCIATIVE\t4\n"
  356. "#define L1_DATA_SIZE\t32768\n"
  357. "#define L1_DATA_LINESIZE\t64\n"
  358. "#define L1_DATA_ASSOCIATIVE\t4\n"
  359. "#define L2_SIZE\t5262144\n"
  360. "#define L2_LINESIZE\t64\n"
  361. "#define L2_ASSOCIATIVE\t8\n"
  362. "#define DTB_DEFAULT_ENTRIES\t64\n"
  363. "#define DTB_SIZE\t4096\n")
  364. set(SGEMM_UNROLL_M 16)
  365. set(SGEMM_UNROLL_N 4)
  366. set(DGEMM_UNROLL_M 8)
  367. set(DGEMM_UNROLL_N 4)
  368. set(CGEMM_UNROLL_M 8)
  369. set(CGEMM_UNROLL_N 4)
  370. set(ZGEMM_UNROLL_M 4)
  371. set(ZGEMM_UNROLL_N 4)
  372. set(SYMV_P 16)
  373. elseif ("${TCORE}" STREQUAL "POWER6")
  374. file(APPEND ${TARGET_CONF_TEMP}
  375. "#define L1_DATA_SIZE 32768\n"
  376. "#define L1_DATA_LINESIZE 128\n"
  377. "#define L2_SIZE 524288\n"
  378. "#define L2_LINESIZE 128 \n"
  379. "#define DTB_DEFAULT_ENTRIES 128\n"
  380. "#define DTB_SIZE 4096\n"
  381. "#define L2_ASSOCIATIVE 8\n")
  382. set(SGEMM_UNROLL_M 4)
  383. set(SGEMM_UNROLL_N 4)
  384. set(DGEMM_UNROLL_M 4)
  385. set(DGEMM_UNROLL_N 4)
  386. set(CGEMM_UNROLL_M 2)
  387. set(CGEMM_UNROLL_N 4)
  388. set(ZGEMM_UNROLL_M 2)
  389. set(ZGEMM_UNROLL_N 4)
  390. set(SYMV_P 8)
  391. elseif ("${TCORE}" STREQUAL "POWER8")
  392. file(APPEND ${TARGET_CONF_TEMP}
  393. "#define L1_DATA_SIZE 32768\n"
  394. "#define L1_DATA_LINESIZE 128\n"
  395. "#define L2_SIZE 524288\n"
  396. "#define L2_LINESIZE 128 \n"
  397. "#define DTB_DEFAULT_ENTRIES 128\n"
  398. "#define DTB_SIZE 4096\n"
  399. "#define L2_ASSOCIATIVE 8\n")
  400. set(SGEMM_UNROLL_M 16)
  401. set(SGEMM_UNROLL_N 8)
  402. set(DGEMM_UNROLL_M 16)
  403. set(DGEMM_UNROLL_N 4)
  404. set(CGEMM_UNROLL_M 8)
  405. set(CGEMM_UNROLL_N 4)
  406. set(ZGEMM_UNROLL_M 8)
  407. set(ZGEMM_UNROLL_N 2)
  408. set(SYMV_P 8)
  409. elseif ("${TCORE}" STREQUAL "POWER9")
  410. file(APPEND ${TARGET_CONF_TEMP}
  411. "#define L1_DATA_SIZE 32768\n"
  412. "#define L1_DATA_LINESIZE 128\n"
  413. "#define L2_SIZE 524288\n"
  414. "#define L2_LINESIZE 128 \n"
  415. "#define DTB_DEFAULT_ENTRIES 128\n"
  416. "#define DTB_SIZE 4096\n"
  417. "#define L2_ASSOCIATIVE 8\n")
  418. set(SGEMM_UNROLL_M 16)
  419. set(SGEMM_UNROLL_N 8)
  420. set(DGEMM_UNROLL_M 16)
  421. set(DGEMM_UNROLL_N 4)
  422. set(CGEMM_UNROLL_M 8)
  423. set(CGEMM_UNROLL_N 4)
  424. set(ZGEMM_UNROLL_M 8)
  425. set(ZGEMM_UNROLL_N 2)
  426. set(SYMV_P 8)
  427. endif()
  428. set(SHGEMM_UNROLL_M 8)
  429. set(SHGEMM_UNROLL_N 4)
  430. # Or should this actually be NUM_CORES?
  431. if (${NUM_THREADS} GREATER 0)
  432. file(APPEND ${TARGET_CONF_TEMP} "#define NUM_CORES\t${NUM_THREADS}\n")
  433. endif()
  434. # GetArch_2nd
  435. foreach(float_char S;D;Q;C;Z;X)
  436. if (NOT DEFINED ${float_char}GEMM_UNROLL_M)
  437. set(${float_char}GEMM_UNROLL_M 2)
  438. endif()
  439. if (NOT DEFINED ${float_char}GEMM_UNROLL_N)
  440. set(${float_char}GEMM_UNROLL_N 2)
  441. endif()
  442. endforeach()
  443. file(APPEND ${TARGET_CONF_TEMP}
  444. "#define GEMM_MULTITHREAD_THRESHOLD\t${GEMM_MULTITHREAD_THRESHOLD}\n")
  445. # Move to where gen_config_h would place it
  446. file(MAKE_DIRECTORY ${TARGET_CONF_DIR})
  447. file(RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR}/${TARGET_CONF}")
  448. else(NOT CMAKE_CROSSCOMPILING)
  449. # compile getarch
  450. set(GETARCH_SRC
  451. ${PROJECT_SOURCE_DIR}/getarch.c
  452. ${CPUIDEMU}
  453. )
  454. if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
  455. #Use generic for MSVC now
  456. message("MSVC")
  457. set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC)
  458. else()
  459. list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
  460. if (DEFINED TARGET_CORE)
  461. set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_${TARGET_CORE})
  462. endif ()
  463. endif ()
  464. if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  465. # disable WindowsStore strict CRT checks
  466. set(GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS)
  467. endif ()
  468. set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
  469. set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
  470. file(MAKE_DIRECTORY ${GETARCH_DIR})
  471. configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
  472. if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  473. try_compile(GETARCH_RESULT ${GETARCH_DIR}
  474. SOURCES ${GETARCH_SRC}
  475. COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I"${GETARCH_DIR}" -I"${PROJECT_SOURCE_DIR}" -I"${PROJECT_BINARY_DIR}"
  476. OUTPUT_VARIABLE GETARCH_LOG
  477. COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
  478. )
  479. if (NOT ${GETARCH_RESULT})
  480. MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
  481. endif ()
  482. endif ()
  483. message(STATUS "Running getarch")
  484. # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
  485. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
  486. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
  487. message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
  488. # append config data from getarch to the TARGET file and read in CMake vars
  489. file(APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT})
  490. ParseGetArchVars(${GETARCH_MAKE_OUT})
  491. set(GETARCH2_DIR "${PROJECT_BINARY_DIR}/getarch2_build")
  492. set(GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX}")
  493. file(MAKE_DIRECTORY ${GETARCH2_DIR})
  494. configure_file(${TARGET_CONF_TEMP} ${GETARCH2_DIR}/${TARGET_CONF} COPYONLY)
  495. if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  496. try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
  497. SOURCES ${PROJECT_SOURCE_DIR}/getarch_2nd.c
  498. COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I"${GETARCH2_DIR}" -I"${PROJECT_SOURCE_DIR}" -I"${PROJECT_BINARY_DIR}"
  499. OUTPUT_VARIABLE GETARCH2_LOG
  500. COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
  501. )
  502. if (NOT ${GETARCH2_RESULT})
  503. MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
  504. endif ()
  505. endif ()
  506. # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
  507. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
  508. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
  509. # append config data from getarch_2nd to the TARGET file and read in CMake vars
  510. file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
  511. configure_file(${TARGET_CONF_TEMP} ${TARGET_CONF_DIR}/${TARGET_CONF} COPYONLY)
  512. ParseGetArchVars(${GETARCH2_MAKE_OUT})
  513. endif()