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

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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. # SBGEMM_UNROLL_M
  19. # SBGEMM_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(HAVE_SSE 1)
  117. set(HAVE_SSE2 1)
  118. set(HAVE_SSE3 1)
  119. set(HAVE_SSSE3 1)
  120. set(SGEMM_UNROLL_M 8)
  121. set(SGEMM_UNROLL_N 4)
  122. set(DGEMM_UNROLL_M 4)
  123. set(DGEMM_UNROLL_N 4)
  124. set(CGEMM_UNROLL_M 4)
  125. set(CGEMM_UNROLL_N 2)
  126. set(ZGEMM_UNROLL_M 2)
  127. set(ZGEMM_UNROLL_N 2)
  128. set(CGEMM3M_UNROLL_M 8)
  129. set(CGEMM3M_UNROLL_N 4)
  130. set(ZGEMM3M_UNROLL_M 4)
  131. set(ZGEMM3M_UNROLL_N 4)
  132. elseif ("${TCORE}" STREQUAL "ARMV7")
  133. file(APPEND ${TARGET_CONF_TEMP}
  134. "#define L1_DATA_SIZE\t65536\n"
  135. "#define L1_DATA_LINESIZE\t32\n"
  136. "#define L2_SIZE\t512488\n"
  137. "#define L2_LINESIZE\t32\n"
  138. "#define DTB_DEFAULT_ENTRIES\t64\n"
  139. "#define DTB_SIZE\t4096\n"
  140. "#define L2_ASSOCIATIVE\t4\n"
  141. "#define HAVE_VFPV3\n"
  142. "#define HAVE_VFP\n")
  143. set(SGEMM_UNROLL_M 4)
  144. set(SGEMM_UNROLL_N 4)
  145. set(DGEMM_UNROLL_M 4)
  146. set(DGEMM_UNROLL_N 4)
  147. set(CGEMM_UNROLL_M 2)
  148. set(CGEMM_UNROLL_N 2)
  149. set(ZGEMM_UNROLL_M 2)
  150. set(ZGEMM_UNROLL_N 2)
  151. elseif ("${TCORE}" STREQUAL "ARMV8")
  152. file(APPEND ${TARGET_CONF_TEMP}
  153. "#define L1_DATA_SIZE\t32768\n"
  154. "#define L1_DATA_LINESIZE\t64\n"
  155. "#define L2_SIZE\t262144\n"
  156. "#define L2_LINESIZE\t64\n"
  157. "#define DTB_DEFAULT_ENTRIES\t64\n"
  158. "#define DTB_SIZE\t4096\n"
  159. "#define L2_ASSOCIATIVE\t32\n"
  160. "#define ARMV8\n")
  161. set(SGEMM_UNROLL_M 16)
  162. set(SGEMM_UNROLL_N 4)
  163. set(DGEMM_UNROLL_M 8)
  164. set(DGEMM_UNROLL_N 4)
  165. set(CGEMM_UNROLL_M 8)
  166. set(CGEMM_UNROLL_N 4)
  167. set(ZGEMM_UNROLL_M 4)
  168. set(ZGEMM_UNROLL_N 4)
  169. set(SYMV_P 16)
  170. elseif ("${TCORE}" STREQUAL "CORTEXA57" OR "${TCORE}" STREQUAL "CORTEXA53" OR "${TCORE}" STREQUAL "CORTEXA55")
  171. file(APPEND ${TARGET_CONF_TEMP}
  172. "#define L1_CODE_SIZE\t32768\n"
  173. "#define L1_CODE_LINESIZE\t64\n"
  174. "#define L1_CODE_ASSOCIATIVE\t3\n"
  175. "#define L1_DATA_SIZE\t32768\n"
  176. "#define L1_DATA_LINESIZE\t64\n"
  177. "#define L1_DATA_ASSOCIATIVE\t2\n"
  178. "#define L2_SIZE\t262144\n"
  179. "#define L2_LINESIZE\t64\n"
  180. "#define L2_ASSOCIATIVE\t16\n"
  181. "#define DTB_DEFAULT_ENTRIES\t64\n"
  182. "#define DTB_SIZE\t4096\n"
  183. "#define HAVE_VFPV4\n"
  184. "#define HAVE_VFPV3\n"
  185. "#define HAVE_VFP\n"
  186. "#define HAVE_NEON\n"
  187. "#define ARMV8\n")
  188. if ("${TCORE}" STREQUAL "CORTEXA57")
  189. set(SGEMM_UNROLL_M 16)
  190. set(SGEMM_UNROLL_N 4)
  191. else ()
  192. set(SGEMM_UNROLL_M 8)
  193. set(SGEMM_UNROLL_N 8)
  194. endif ()
  195. set(DGEMM_UNROLL_M 8)
  196. set(DGEMM_UNROLL_N 4)
  197. set(CGEMM_UNROLL_M 8)
  198. set(CGEMM_UNROLL_N 4)
  199. set(ZGEMM_UNROLL_M 4)
  200. set(ZGEMM_UNROLL_N 4)
  201. set(SYMV_P 16)
  202. elseif ("${TCORE}" STREQUAL "CORTEXA72" OR "${TCORE}" STREQUAL "CORTEXA73")
  203. file(APPEND ${TARGET_CONF_TEMP}
  204. "#define L1_CODE_SIZE\t49152\n"
  205. "#define L1_CODE_LINESIZE\t64\n"
  206. "#define L1_CODE_ASSOCIATIVE\t3\n"
  207. "#define L1_DATA_SIZE\t32768\n"
  208. "#define L1_DATA_LINESIZE\t64\n"
  209. "#define L1_DATA_ASSOCIATIVE\t2\n"
  210. "#define L2_SIZE\t524288\n"
  211. "#define L2_LINESIZE\t64\n"
  212. "#define L2_ASSOCIATIVE\t16\n"
  213. "#define DTB_DEFAULT_ENTRIES\t64\n"
  214. "#define DTB_SIZE\t4096\n"
  215. "#define HAVE_VFPV4\n"
  216. "#define HAVE_VFPV3\n"
  217. "#define HAVE_VFP\n"
  218. "#define HAVE_NEON\n"
  219. "#define ARMV8\n")
  220. set(SGEMM_UNROLL_M 16)
  221. set(SGEMM_UNROLL_N 4)
  222. set(DGEMM_UNROLL_M 8)
  223. set(DGEMM_UNROLL_N 4)
  224. set(CGEMM_UNROLL_M 8)
  225. set(CGEMM_UNROLL_N 4)
  226. set(ZGEMM_UNROLL_M 4)
  227. set(ZGEMM_UNROLL_N 4)
  228. set(SYMV_P 16)
  229. elseif ("${TCORE}" STREQUAL "NEOVERSEN1")
  230. file(APPEND ${TARGET_CONF_TEMP}
  231. "#define L1_CODE_SIZE\t65536\n"
  232. "#define L1_CODE_LINESIZE\t64\n"
  233. "#define L1_CODE_ASSOCIATIVE\t4\n"
  234. "#define L1_DATA_SIZE\t65536\n"
  235. "#define L1_DATA_LINESIZE\t64\n"
  236. "#define L1_DATA_ASSOCIATIVE\t4\n"
  237. "#define L2_SIZE\t1048576\n\n"
  238. "#define L2_LINESIZE\t64\n"
  239. "#define L2_ASSOCIATIVE\t8\n"
  240. "#define DTB_DEFAULT_ENTRIES\t48\n"
  241. "#define DTB_SIZE\t4096\n"
  242. "#define HAVE_VFPV4\n"
  243. "#define HAVE_VFPV3\n"
  244. "#define HAVE_VFP\n"
  245. "#define HAVE_NEON\n"
  246. "#define ARMV8\n")
  247. set(SGEMM_UNROLL_M 16)
  248. set(SGEMM_UNROLL_N 4)
  249. set(DGEMM_UNROLL_M 8)
  250. set(DGEMM_UNROLL_N 4)
  251. set(CGEMM_UNROLL_M 8)
  252. set(CGEMM_UNROLL_N 4)
  253. set(ZGEMM_UNROLL_M 4)
  254. set(ZGEMM_UNROLL_N 4)
  255. set(SYMV_P 16)
  256. elseif ("${TCORE}" STREQUAL "NEOVERSEV1")
  257. file(APPEND ${TARGET_CONF_TEMP}
  258. "#define L1_CODE_SIZE\t65536\n"
  259. "#define L1_CODE_LINESIZE\t64\n"
  260. "#define L1_CODE_ASSOCIATIVE\t4\n"
  261. "#define L1_DATA_SIZE\t65536\n"
  262. "#define L1_DATA_LINESIZE\t64\n"
  263. "#define L1_DATA_ASSOCIATIVE\t4\n"
  264. "#define L2_SIZE\t1048576\n\n"
  265. "#define L2_LINESIZE\t64\n"
  266. "#define L2_ASSOCIATIVE\t8\n"
  267. "#define DTB_DEFAULT_ENTRIES\t48\n"
  268. "#define DTB_SIZE\t4096\n"
  269. "#define HAVE_VFPV4\n"
  270. "#define HAVE_VFPV3\n"
  271. "#define HAVE_VFP\n"
  272. "#define HAVE_NEON\n"
  273. "#define HAVE_SVE\n"
  274. "#define ARMV8\n")
  275. set(SGEMM_UNROLL_M 16)
  276. set(SGEMM_UNROLL_N 4)
  277. set(DGEMM_UNROLL_M 8)
  278. set(DGEMM_UNROLL_N 4)
  279. set(CGEMM_UNROLL_M 8)
  280. set(CGEMM_UNROLL_N 4)
  281. set(ZGEMM_UNROLL_M 4)
  282. set(ZGEMM_UNROLL_N 4)
  283. set(SYMV_P 16)
  284. elseif ("${TCORE}" STREQUAL "NEOVERSEN2")
  285. file(APPEND ${TARGET_CONF_TEMP}
  286. "#define L1_CODE_SIZE\t65536\n"
  287. "#define L1_CODE_LINESIZE\t64\n"
  288. "#define L1_CODE_ASSOCIATIVE\t4\n"
  289. "#define L1_DATA_SIZE\t65536\n"
  290. "#define L1_DATA_LINESIZE\t64\n"
  291. "#define L1_DATA_ASSOCIATIVE\t2\n"
  292. "#define L2_SIZE\t1048576\n\n"
  293. "#define L2_LINESIZE\t64\n"
  294. "#define L2_ASSOCIATIVE\t8\n"
  295. "#define DTB_DEFAULT_ENTRIES\t48\n"
  296. "#define DTB_SIZE\t4096\n"
  297. "#define HAVE_VFPV4\n"
  298. "#define HAVE_VFPV3\n"
  299. "#define HAVE_VFP\n"
  300. "#define HAVE_NEON\n"
  301. "#define HAVE_SVE\n"
  302. "#define ARMV8\n")
  303. set(SGEMM_UNROLL_M 16)
  304. set(SGEMM_UNROLL_N 4)
  305. set(DGEMM_UNROLL_M 8)
  306. set(DGEMM_UNROLL_N 4)
  307. set(CGEMM_UNROLL_M 8)
  308. set(CGEMM_UNROLL_N 4)
  309. set(ZGEMM_UNROLL_M 4)
  310. set(ZGEMM_UNROLL_N 4)
  311. set(SYMV_P 16)
  312. elseif ("${TCORE}" STREQUAL "FALKOR")
  313. file(APPEND ${TARGET_CONF_TEMP}
  314. "#define L1_CODE_SIZE\t65536\n"
  315. "#define L1_CODE_LINESIZE\t64\n"
  316. "#define L1_CODE_ASSOCIATIVE\t3\n"
  317. "#define L1_DATA_SIZE\t32768\n"
  318. "#define L1_DATA_LINESIZE\t128\n"
  319. "#define L1_DATA_ASSOCIATIVE\t2\n"
  320. "#define L2_SIZE\t524288\n"
  321. "#define L2_LINESIZE\t64\n"
  322. "#define L2_ASSOCIATIVE\t16\n"
  323. "#define DTB_DEFAULT_ENTRIES\t64\n"
  324. "#define DTB_SIZE\t4096\n"
  325. "#define HAVE_VFPV4\n"
  326. "#define HAVE_VFPV3\n"
  327. "#define HAVE_VFP\n"
  328. "#define HAVE_NEON\n"
  329. "#define ARMV8\n")
  330. set(SGEMM_UNROLL_M 16)
  331. set(SGEMM_UNROLL_N 4)
  332. set(DGEMM_UNROLL_M 8)
  333. set(DGEMM_UNROLL_N 4)
  334. set(CGEMM_UNROLL_M 8)
  335. set(CGEMM_UNROLL_N 4)
  336. set(ZGEMM_UNROLL_M 4)
  337. set(ZGEMM_UNROLL_N 4)
  338. set(SYMV_P 16)
  339. elseif ("${TCORE}" STREQUAL "THUNDERX")
  340. file(APPEND ${TARGET_CONF_TEMP}
  341. "#define L1_CODE_SIZE\t32768\n"
  342. "#define L1_CODE_LINESIZE\t64\n"
  343. "#define L1_CODE_ASSOCIATIVE\t3\n"
  344. "#define L1_DATA_SIZE\t32768\n"
  345. "#define L1_DATA_LINESIZE\t128\n"
  346. "#define L1_DATA_ASSOCIATIVE\t2\n"
  347. "#define L2_SIZE\t167772164\n"
  348. "#define L2_LINESIZE\t128\n"
  349. "#define L2_ASSOCIATIVE\t16\n"
  350. "#define DTB_DEFAULT_ENTRIES\t64\n"
  351. "#define DTB_SIZE\t4096\n"
  352. "#define HAVE_VFPV4\n"
  353. "#define HAVE_VFPV3\n"
  354. "#define HAVE_VFP\n"
  355. "#define HAVE_NEON\n"
  356. "#define ARMV8\n")
  357. set(SGEMM_UNROLL_M 4)
  358. set(SGEMM_UNROLL_N 4)
  359. set(DGEMM_UNROLL_M 2)
  360. set(DGEMM_UNROLL_N 2)
  361. set(CGEMM_UNROLL_M 2)
  362. set(CGEMM_UNROLL_N 2)
  363. set(ZGEMM_UNROLL_M 2)
  364. set(ZGEMM_UNROLL_N 2)
  365. set(SYMV_P 16)
  366. elseif ("${TCORE}" STREQUAL "THUNDERX2T99")
  367. file(APPEND ${TARGET_CONF_TEMP}
  368. "#define L1_CODE_SIZE\t32768\n"
  369. "#define L1_CODE_LINESIZE\t64\n"
  370. "#define L1_CODE_ASSOCIATIVE\t8\n"
  371. "#define L1_DATA_SIZE\t32768\n"
  372. "#define L1_DATA_LINESIZE\t64\n"
  373. "#define L1_DATA_ASSOCIATIVE\t8\n"
  374. "#define L2_SIZE\t262144\n"
  375. "#define L2_LINESIZE\t64\n"
  376. "#define L2_ASSOCIATIVE\t8\n"
  377. "#define L3_SIZE\t33554432\n"
  378. "#define L3_LINESIZE\t64\n"
  379. "#define L3_ASSOCIATIVE\t32\n"
  380. "#define DTB_DEFAULT_ENTRIES\t64\n"
  381. "#define DTB_SIZE\t4096\n"
  382. "#define ARMV8\n")
  383. set(SGEMM_UNROLL_M 16)
  384. set(SGEMM_UNROLL_N 4)
  385. set(DGEMM_UNROLL_M 8)
  386. set(DGEMM_UNROLL_N 4)
  387. set(CGEMM_UNROLL_M 8)
  388. set(CGEMM_UNROLL_N 4)
  389. set(ZGEMM_UNROLL_M 4)
  390. set(ZGEMM_UNROLL_N 4)
  391. set(SYMV_P 16)
  392. elseif ("${TCORE}" STREQUAL "THUNDERX3T110")
  393. file(APPEND ${TARGET_CONF_TEMP}
  394. "#define THUNDERX3T110\n"
  395. "#define L1_CODE_SIZE\t65536\n"
  396. "#define L1_CODE_LINESIZE\t64\n"
  397. "#define L1_CODE_ASSOCIATIVE\t8\n"
  398. "#define L1_DATA_SIZE\t65536\n"
  399. "#define L1_DATA_LINESIZE\t64\n"
  400. "#define L1_DATA_ASSOCIATIVE\t8\n"
  401. "#define L2_SIZE\t524288\n"
  402. "#define L2_LINESIZE\t64\n"
  403. "#define L2_ASSOCIATIVE\t8\n"
  404. "#define L3_SIZE\t94371840\n"
  405. "#define L3_LINESIZE\t64\n"
  406. "#define L3_ASSOCIATIVE\t32\n"
  407. "#define DTB_DEFAULT_ENTRIES\t64\n"
  408. "#define DTB_SIZE\t4096\n"
  409. "#define ARMV8\n")
  410. set(SGEMM_UNROLL_M 16)
  411. set(SGEMM_UNROLL_N 4)
  412. set(DGEMM_UNROLL_M 8)
  413. set(DGEMM_UNROLL_N 4)
  414. set(CGEMM_UNROLL_M 8)
  415. set(CGEMM_UNROLL_N 4)
  416. set(ZGEMM_UNROLL_M 4)
  417. set(ZGEMM_UNROLL_N 4)
  418. set(SYMV_P 16)
  419. elseif ("${TCORE}" STREQUAL "TSV110")
  420. file(APPEND ${TARGET_CONF_TEMP}
  421. "#define ARMV8\n"
  422. "#define L1_CODE_SIZE\t65536\n"
  423. "#define L1_CODE_LINESIZE\t64\n"
  424. "#define L1_CODE_ASSOCIATIVE\t4\n"
  425. "#define L1_DATA_SIZE\t65536\n"
  426. "#define L1_DATA_LINESIZE\t64\n"
  427. "#define L1_DATA_ASSOCIATIVE\t4\n"
  428. "#define L2_SIZE\t524288\n"
  429. "#define L2_LINESIZE\t64\n"
  430. "#define L2_ASSOCIATIVE\t8\n"
  431. "#define DTB_DEFAULT_ENTRIES\t64\n"
  432. "#define DTB_SIZE\t4096\n")
  433. set(SGEMM_UNROLL_M 16)
  434. set(SGEMM_UNROLL_N 4)
  435. set(DGEMM_UNROLL_M 8)
  436. set(DGEMM_UNROLL_N 4)
  437. set(CGEMM_UNROLL_M 8)
  438. set(CGEMM_UNROLL_N 4)
  439. set(ZGEMM_UNROLL_M 4)
  440. set(ZGEMM_UNROLL_N 4)
  441. set(SYMV_P 16)
  442. elseif ("${TCORE}" STREQUAL "EMAG8180")
  443. file(APPEND ${TARGET_CONF_TEMP}
  444. "#define ARMV8\n"
  445. "#define L1_CODE_SIZE\t32768\n"
  446. "#define L1_CODE_LINESIZE\t64\n"
  447. "#define L1_CODE_ASSOCIATIVE\t4\n"
  448. "#define L1_DATA_SIZE\t32768\n"
  449. "#define L1_DATA_LINESIZE\t64\n"
  450. "#define L1_DATA_ASSOCIATIVE\t4\n"
  451. "#define L2_SIZE\t5262144\n"
  452. "#define L2_LINESIZE\t64\n"
  453. "#define L2_ASSOCIATIVE\t8\n"
  454. "#define DTB_DEFAULT_ENTRIES\t64\n"
  455. "#define DTB_SIZE\t4096\n")
  456. set(SGEMM_UNROLL_M 16)
  457. set(SGEMM_UNROLL_N 4)
  458. set(DGEMM_UNROLL_M 8)
  459. set(DGEMM_UNROLL_N 4)
  460. set(CGEMM_UNROLL_M 8)
  461. set(CGEMM_UNROLL_N 4)
  462. set(ZGEMM_UNROLL_M 4)
  463. set(ZGEMM_UNROLL_N 4)
  464. set(SYMV_P 16)
  465. elseif ("${TCORE}" STREQUAL "VORTEX")
  466. file(APPEND ${TARGET_CONF_TEMP}
  467. "#define ARMV8\n"
  468. "#define L1_CODE_SIZE\t32768\n"
  469. "#define L1_CODE_LINESIZE\t64\n"
  470. "#define L1_CODE_ASSOCIATIVE\t4\n"
  471. "#define L1_DATA_SIZE\t32768\n"
  472. "#define L1_DATA_LINESIZE\t64\n"
  473. "#define L1_DATA_ASSOCIATIVE\t4\n"
  474. "#define L2_SIZE\t5262144\n"
  475. "#define L2_LINESIZE\t64\n"
  476. "#define L2_ASSOCIATIVE\t8\n"
  477. "#define DTB_DEFAULT_ENTRIES\t64\n"
  478. "#define DTB_SIZE\t4096\n")
  479. set(SGEMM_UNROLL_M 16)
  480. set(SGEMM_UNROLL_N 4)
  481. set(DGEMM_UNROLL_M 8)
  482. set(DGEMM_UNROLL_N 4)
  483. set(CGEMM_UNROLL_M 8)
  484. set(CGEMM_UNROLL_N 4)
  485. set(ZGEMM_UNROLL_M 4)
  486. set(ZGEMM_UNROLL_N 4)
  487. set(SYMV_P 16)
  488. elseif ("${TCORE}" STREQUAL "P5600")
  489. file(APPEND ${TARGET_CONF_TEMP}
  490. "#define L2_SIZE 1048576\n"
  491. "#define DTB_SIZE 4096\n"
  492. "#define DTB_DEFAULT_ENTRIES 64\n")
  493. set(SGEMM_UNROLL_M 2)
  494. set(SGEMM_UNROLL_N 2)
  495. set(DGEMM_UNROLL_M 2)
  496. set(DGEMM_UNROLL_N 2)
  497. set(CGEMM_UNROLL_M 2)
  498. set(CGEMM_UNROLL_N 2)
  499. set(ZGEMM_UNROLL_M 2)
  500. set(ZGEMM_UNROLL_N 2)
  501. set(SYMV_P 16)
  502. elseif ("${TCORE}" MATCHES "MIPS")
  503. file(APPEND ${TARGET_CONF_TEMP}
  504. "#define L2_SIZE 262144\n"
  505. "#define DTB_SIZE 4096\n"
  506. "#define DTB_DEFAULT_ENTRIES 64\n")
  507. set(SGEMM_UNROLL_M 2)
  508. set(SGEMM_UNROLL_N 2)
  509. set(DGEMM_UNROLL_M 2)
  510. set(DGEMM_UNROLL_N 2)
  511. set(CGEMM_UNROLL_M 2)
  512. set(CGEMM_UNROLL_N 2)
  513. set(ZGEMM_UNROLL_M 2)
  514. set(ZGEMM_UNROLL_N 2)
  515. set(SYMV_P 16)
  516. elseif ("${TCORE}" STREQUAL "POWER6")
  517. file(APPEND ${TARGET_CONF_TEMP}
  518. "#define L1_DATA_SIZE 32768\n"
  519. "#define L1_DATA_LINESIZE 128\n"
  520. "#define L2_SIZE 524288\n"
  521. "#define L2_LINESIZE 128 \n"
  522. "#define DTB_DEFAULT_ENTRIES 128\n"
  523. "#define DTB_SIZE 4096\n"
  524. "#define L2_ASSOCIATIVE 8\n")
  525. set(SGEMM_UNROLL_M 4)
  526. set(SGEMM_UNROLL_N 4)
  527. set(DGEMM_UNROLL_M 4)
  528. set(DGEMM_UNROLL_N 4)
  529. set(CGEMM_UNROLL_M 2)
  530. set(CGEMM_UNROLL_N 4)
  531. set(ZGEMM_UNROLL_M 2)
  532. set(ZGEMM_UNROLL_N 4)
  533. set(SYMV_P 8)
  534. elseif ("${TCORE}" STREQUAL "POWER8")
  535. file(APPEND ${TARGET_CONF_TEMP}
  536. "#define L1_DATA_SIZE 32768\n"
  537. "#define L1_DATA_LINESIZE 128\n"
  538. "#define L2_SIZE 524288\n"
  539. "#define L2_LINESIZE 128 \n"
  540. "#define DTB_DEFAULT_ENTRIES 128\n"
  541. "#define DTB_SIZE 4096\n"
  542. "#define L2_ASSOCIATIVE 8\n")
  543. set(SGEMM_UNROLL_M 16)
  544. set(SGEMM_UNROLL_N 8)
  545. set(DGEMM_UNROLL_M 16)
  546. set(DGEMM_UNROLL_N 4)
  547. set(CGEMM_UNROLL_M 8)
  548. set(CGEMM_UNROLL_N 4)
  549. set(ZGEMM_UNROLL_M 8)
  550. set(ZGEMM_UNROLL_N 2)
  551. set(SYMV_P 8)
  552. elseif ("${TCORE}" STREQUAL "POWER9" OR "${TCORE}" STREQUAL "POWER10")
  553. file(APPEND ${TARGET_CONF_TEMP}
  554. "#define L1_DATA_SIZE 32768\n"
  555. "#define L1_DATA_LINESIZE 128\n"
  556. "#define L2_SIZE 524288\n"
  557. "#define L2_LINESIZE 128 \n"
  558. "#define DTB_DEFAULT_ENTRIES 128\n"
  559. "#define DTB_SIZE 4096\n"
  560. "#define L2_ASSOCIATIVE 8\n")
  561. set(SGEMM_UNROLL_M 16)
  562. set(SGEMM_UNROLL_N 8)
  563. set(DGEMM_UNROLL_M 16)
  564. set(DGEMM_UNROLL_N 4)
  565. set(CGEMM_UNROLL_M 8)
  566. set(CGEMM_UNROLL_N 4)
  567. set(ZGEMM_UNROLL_M 8)
  568. set(ZGEMM_UNROLL_N 2)
  569. set(SYMV_P 8)
  570. endif()
  571. set(SBGEMM_UNROLL_M 8)
  572. set(SBGEMM_UNROLL_N 4)
  573. # Or should this actually be NUM_CORES?
  574. if (${NUM_THREADS} GREATER 0)
  575. file(APPEND ${TARGET_CONF_TEMP} "#define NUM_CORES\t${NUM_THREADS}\n")
  576. endif()
  577. # GetArch_2nd
  578. foreach(float_char S;D;Q;C;Z;X)
  579. if (NOT DEFINED ${float_char}GEMM_UNROLL_M)
  580. set(${float_char}GEMM_UNROLL_M 2)
  581. endif()
  582. if (NOT DEFINED ${float_char}GEMM_UNROLL_N)
  583. set(${float_char}GEMM_UNROLL_N 2)
  584. endif()
  585. endforeach()
  586. file(APPEND ${TARGET_CONF_TEMP}
  587. "#define GEMM_MULTITHREAD_THRESHOLD\t${GEMM_MULTITHREAD_THRESHOLD}\n")
  588. # Move to where gen_config_h would place it
  589. file(MAKE_DIRECTORY ${TARGET_CONF_DIR})
  590. file(RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR}/${TARGET_CONF}")
  591. else(NOT CMAKE_CROSSCOMPILING)
  592. # compile getarch
  593. set(GETARCH_SRC
  594. ${PROJECT_SOURCE_DIR}/getarch.c
  595. ${CPUIDEMU}
  596. )
  597. if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
  598. #Use generic for MSVC now
  599. message("MSVC")
  600. set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC)
  601. else()
  602. list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
  603. if (DEFINED TARGET_CORE)
  604. set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_${TARGET_CORE})
  605. endif ()
  606. endif ()
  607. if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  608. # disable WindowsStore strict CRT checks
  609. set(GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS)
  610. endif ()
  611. set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
  612. set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
  613. file(MAKE_DIRECTORY ${GETARCH_DIR})
  614. configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
  615. if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  616. try_compile(GETARCH_RESULT ${GETARCH_DIR}
  617. SOURCES ${GETARCH_SRC}
  618. COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I"${GETARCH_DIR}" -I"${PROJECT_SOURCE_DIR}" -I"${PROJECT_BINARY_DIR}"
  619. OUTPUT_VARIABLE GETARCH_LOG
  620. COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
  621. )
  622. if (NOT ${GETARCH_RESULT})
  623. MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
  624. endif ()
  625. endif ()
  626. unset (HAVE_AVX2)
  627. unset (HAVE_AVX)
  628. unset (HAVE_FMA3)
  629. unset (HAVE_MMX)
  630. unset (HAVE_SSE)
  631. unset (HAVE_SSE2)
  632. unset (HAVE_SSE3)
  633. unset (HAVE_SSSE3)
  634. unset (HAVE_SSE4A)
  635. unset (HAVE_SSE4_1)
  636. unset (HAVE_SSE4_2)
  637. unset (HAVE_NEON)
  638. unset (HAVE_VFP)
  639. unset (HAVE_VFPV3)
  640. unset (HAVE_VFPV4)
  641. message(STATUS "Running getarch")
  642. # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
  643. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
  644. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH_BIN}" 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
  645. message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
  646. # append config data from getarch to the TARGET file and read in CMake vars
  647. file(APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT})
  648. ParseGetArchVars(${GETARCH_MAKE_OUT})
  649. set(GETARCH2_DIR "${PROJECT_BINARY_DIR}/getarch2_build")
  650. set(GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX}")
  651. file(MAKE_DIRECTORY ${GETARCH2_DIR})
  652. configure_file(${TARGET_CONF_TEMP} ${GETARCH2_DIR}/${TARGET_CONF} COPYONLY)
  653. if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  654. try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
  655. SOURCES ${PROJECT_SOURCE_DIR}/getarch_2nd.c
  656. COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I"${GETARCH2_DIR}" -I"${PROJECT_SOURCE_DIR}" -I"${PROJECT_BINARY_DIR}"
  657. OUTPUT_VARIABLE GETARCH2_LOG
  658. COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
  659. )
  660. if (NOT ${GETARCH2_RESULT})
  661. MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
  662. endif ()
  663. endif ()
  664. # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
  665. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
  666. execute_process(COMMAND "${PROJECT_BINARY_DIR}/${GETARCH2_BIN}" 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
  667. # append config data from getarch_2nd to the TARGET file and read in CMake vars
  668. file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
  669. configure_file(${TARGET_CONF_TEMP} ${TARGET_CONF_DIR}/${TARGET_CONF} COPYONLY)
  670. ParseGetArchVars(${GETARCH2_MAKE_OUT})
  671. endif()