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.

dynamic.c 32 kB

7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #include "common.h"
  39. #ifdef _MSC_VER
  40. #define strncasecmp _strnicmp
  41. #define strcasecmp _stricmp
  42. #endif
  43. #ifdef ARCH_X86
  44. #define EXTERN extern
  45. #else
  46. #define EXTERN
  47. #endif
  48. #ifdef DYNAMIC_LIST
  49. extern gotoblas_t gotoblas_PRESCOTT;
  50. #ifdef DYN_ATHLON
  51. extern gotoblas_t gotoblas_ATHLON;
  52. #else
  53. #define gotoblas_ATHLON gotoblas_PRESCOTT
  54. #endif
  55. #ifdef DYN_KATMAI
  56. extern gotoblas_t gotoblas_KATMAI;
  57. #else
  58. #define gotoblas_KATMAI gotoblas_PRESCOTT
  59. #endif
  60. #ifdef DYN_BANIAS
  61. extern gotoblas_t gotoblas_BANIAS;
  62. #else
  63. #define gotoblas_BANIAS gotoblas_PRESCOTT
  64. #endif
  65. #ifdef DYN_COPPERMINE
  66. extern gotoblas_t gotoblas_COPPERMINE;
  67. #else
  68. #define gotoblas_COPPERMINE gotoblas_PRESCOTT
  69. #endif
  70. #ifdef DYN_NORTHWOOD
  71. extern gotoblas_t gotoblas_NORTHWOOD;
  72. #else
  73. #define gotoblas_NORTHWOOD gotoblas_PRESCOTT
  74. #endif
  75. #ifdef DYN_CORE2
  76. extern gotoblas_t gotoblas_CORE2;
  77. #else
  78. #define gotoblas_CORE2 gotoblas_PRESCOTT
  79. #endif
  80. #ifdef DYN_NEHALEM
  81. extern gotoblas_t gotoblas_NEHALEM;
  82. #else
  83. #define gotoblas_NEHALEM gotoblas_PRESCOTT
  84. #endif
  85. #ifdef DYN_BARCELONA
  86. extern gotoblas_t gotoblas_BARCELONA;
  87. #elif defined(DYN_NEHALEM)
  88. #define gotoblas_BARCELONA gotoblas_NEHALEM
  89. #else
  90. #define gotoblas_BARCELONA gotoblas_PRESCOTT
  91. #endif
  92. #ifdef DYN_ATOM
  93. extern gotoblas_t gotoblas_ATOM;
  94. elif defined(DYN_NEHALEM)
  95. #define gotoblas_ATOM gotoblas_NEHALEM
  96. #else
  97. #define gotoblas_ATOM gotoblas_PRESCOTT
  98. #endif
  99. #ifdef DYN_NANO
  100. extern gotoblas_t gotoblas_NANO;
  101. #else
  102. #define gotoblas_NANO gotoblas_PRESCOTT
  103. #endif
  104. #ifdef DYN_PENRYN
  105. extern gotoblas_t gotoblas_PENRYN;
  106. #else
  107. #define gotoblas_PENRYN gotoblas_PRESCOTT
  108. #endif
  109. #ifdef DYN_DUNNINGTON
  110. extern gotoblas_t gotoblas_DUNNINGTON;
  111. #else
  112. #define gotoblas_DUNNINGTON gotoblas_PRESCOTT
  113. #endif
  114. #ifdef DYN_OPTERON
  115. extern gotoblas_t gotoblas_OPTERON;
  116. #else
  117. #define gotoblas_OPTERON gotoblas_PRESCOTT
  118. #endif
  119. #ifdef DYN_OPTERON_SSE3
  120. extern gotoblas_t gotoblas_OPTERON_SSE3;
  121. #else
  122. #define gotoblas_OPTERON_SSE3 gotoblas_PRESCOTT
  123. #endif
  124. #ifdef DYN_BOBCAT
  125. extern gotoblas_t gotoblas_BOBCAT;
  126. #elif defined(DYN_NEHALEM)
  127. #define gotoblas_BOBCAT gotoblas_NEHALEM
  128. #else
  129. #define gotoblas_BOBCAT gotoblas_PRESCOTT
  130. #endif
  131. #ifdef DYN_SANDYBRIDGE
  132. extern gotoblas_t gotoblas_SANDYBRIDGE;
  133. #elif defined(DYN_NEHALEM)
  134. #define gotoblas_SANDYBRIDGE gotoblas_NEHALEM
  135. #else
  136. #define gotoblas_SANDYBRIDGE gotoblas_PRESCOTT
  137. #endif
  138. #ifdef DYN_BULLDOZER
  139. extern gotoblas_t gotoblas_BULLDOZER;
  140. #elif defined(DYN_SANDYBRIDGE)
  141. #define gotoblas_BULLDOZER gotoblas_SANDYBRIDGE
  142. #elif defined(DYN_NEHALEM)
  143. #define gotoblas_BULLDOZER gotoblas_NEHALEM
  144. #else
  145. #define gotoblas_BULLDOZER gotoblas_PRESCOTT
  146. #endif
  147. #ifdef DYN_PILEDRIVER
  148. extern gotoblas_t gotoblas_PILEDRIVER;
  149. #elif defined(DYN_SANDYBRIDGE)
  150. #define gotoblas_PILEDRIVER gotoblas_SANDYBRIDGE
  151. #elif defined(DYN_NEHALEM)
  152. #define gotoblas_PILEDRIVER gotoblas_NEHALEM
  153. #else
  154. #define gotoblas_PILEDRIVER gotoblas_PRESCOTT
  155. #endif
  156. #ifdef DYN_STEAMROLLER
  157. extern gotoblas_t gotoblas_STEAMROLLER;
  158. #elif defined(DYN_SANDYBRIDGE)
  159. #define gotoblas_STEAMROLLER gotoblas_SANDYBRIDGE
  160. #elif defined(DYN_NEHALEM)
  161. #define gotoblas_STEAMROLLER gotoblas_NEHALEM
  162. #else
  163. #define gotoblas_STEAMROLLER gotoblas_PRESCOTT
  164. #endif
  165. #ifdef DYN_EXCAVATOR
  166. extern gotoblas_t gotoblas_EXCAVATOR;
  167. #elif defined(DYN_SANDYBRIDGE)
  168. #define gotoblas_EXCAVATOR gotoblas_SANDYBRIDGE
  169. #elif defined(DYN_NEHALEM)
  170. #define gotoblas_EXCAVATOR gotoblas_NEHALEM
  171. #else
  172. #define gotoblas_EXCAVATOR gotoblas_PRESCOTT
  173. #endif
  174. #ifdef DYN_HASWELL
  175. extern gotoblas_t gotoblas_HASWELL;
  176. #elif defined(DYN_SANDYBRIDGE)
  177. #define gotoblas_HASWELL gotoblas_SANDYBRIDGE
  178. #elif defined(DYN_NEHALEM)
  179. #define gotoblas_HASWELL gotoblas_NEHALEM
  180. #else
  181. #define gotoblas_HASWELL gotoblas_PRESCOTT
  182. #endif
  183. #ifdef DYN_ZEN
  184. extern gotoblas_t gotoblas_ZEN;
  185. #elif defined(DYN_HASWELL)
  186. #define gotoblas_ZEN gotoblas_HASWELL
  187. #elif defined(DYN_SANDYBRIDGE)
  188. #define gotoblas_ZEN gotoblas_SANDYBRIDGE
  189. #elif defined(DYN_NEHALEM)
  190. #define gotoblas_ZEN gotoblas_NEHALEM
  191. #else
  192. #define gotoblas_ZEN gotoblas_PRESCOTT
  193. #endif
  194. #ifdef DYN_SKYLAKEX
  195. extern gotoblas_t gotoblas_SKYLAKEX;
  196. #elif defined(DYN_HASWELL)
  197. #define gotoblas_SKYLAKEX gotoblas_HASWELL
  198. #elif defined(DYN_SANDYBRIDGE)
  199. #define gotoblas_SKYLAKEX gotoblas_SANDYBRIDGE
  200. #elif defined(DYN_NEHALEM)
  201. #define gotoblas_SKYLAKEX gotoblas_NEHALEM
  202. #else
  203. #define gotoblas_SKYLAKEX gotoblas_PRESCOTT
  204. #endif
  205. #ifdef DYN_COOPERLAKE
  206. extern gotoblas_t gotoblas_COOPERLAKE;
  207. #elif defined(DYN_SKYLAKEX)
  208. #define gotoblas_COOPERLAKE gotoblas_SKYLAKEX
  209. #elif defined(DYN_HASWELL)
  210. #define gotoblas_COOPERLAKE gotoblas_HASWELL
  211. #elif defined(DYN_SANDYBRIDGE)
  212. #define gotoblas_COOPERLAKE gotoblas_SANDYBRIDGE
  213. #elif defined(DYN_NEHALEM)
  214. #define gotoblas_COOPERLAKE gotoblas_NEHALEM
  215. #else
  216. #define gotoblas_COOPERLAKE gotoblas_PRESCOTT
  217. #endif
  218. #else // not DYNAMIC_LIST
  219. EXTERN gotoblas_t gotoblas_KATMAI;
  220. EXTERN gotoblas_t gotoblas_COPPERMINE;
  221. EXTERN gotoblas_t gotoblas_NORTHWOOD;
  222. EXTERN gotoblas_t gotoblas_BANIAS;
  223. EXTERN gotoblas_t gotoblas_ATHLON;
  224. extern gotoblas_t gotoblas_PRESCOTT;
  225. extern gotoblas_t gotoblas_CORE2;
  226. extern gotoblas_t gotoblas_NEHALEM;
  227. extern gotoblas_t gotoblas_BARCELONA;
  228. #ifdef DYNAMIC_OLDER
  229. extern gotoblas_t gotoblas_ATOM;
  230. extern gotoblas_t gotoblas_NANO;
  231. extern gotoblas_t gotoblas_PENRYN;
  232. extern gotoblas_t gotoblas_DUNNINGTON;
  233. extern gotoblas_t gotoblas_OPTERON;
  234. extern gotoblas_t gotoblas_OPTERON_SSE3;
  235. extern gotoblas_t gotoblas_BOBCAT;
  236. #else
  237. #define gotoblas_ATOM gotoblas_NEHALEM
  238. #define gotoblas_NANO gotoblas_NEHALEM
  239. #define gotoblas_PENRYN gotoblas_CORE2
  240. #define gotoblas_DUNNINGTON gotoblas_CORE2
  241. #define gotoblas_OPTERON gotoblas_CORE2
  242. #define gotoblas_OPTERON_SSE3 gotoblas_CORE2
  243. #define gotoblas_BOBCAT gotoblas_CORE2
  244. #endif
  245. #ifndef NO_AVX
  246. extern gotoblas_t gotoblas_SANDYBRIDGE;
  247. extern gotoblas_t gotoblas_BULLDOZER;
  248. extern gotoblas_t gotoblas_PILEDRIVER;
  249. extern gotoblas_t gotoblas_STEAMROLLER;
  250. extern gotoblas_t gotoblas_EXCAVATOR;
  251. #ifdef NO_AVX2
  252. #define gotoblas_HASWELL gotoblas_SANDYBRIDGE
  253. #define gotoblas_SKYLAKEX gotoblas_SANDYBRIDGE
  254. #define gotoblas_COOPERLAKE gotoblas_SANDYBRIDGE
  255. #define gotoblas_ZEN gotoblas_SANDYBRIDGE
  256. #else
  257. extern gotoblas_t gotoblas_HASWELL;
  258. extern gotoblas_t gotoblas_ZEN;
  259. #ifndef NO_AVX512
  260. extern gotoblas_t gotoblas_SKYLAKEX;
  261. extern gotoblas_t gotoblas_COOPERLAKE;
  262. #else
  263. #define gotoblas_SKYLAKEX gotoblas_HASWELL
  264. #define gotoblas_COOPERLAKE gotoblas_HASWELL
  265. #endif
  266. #endif
  267. #else
  268. //Use NEHALEM kernels for sandy bridge
  269. #define gotoblas_SANDYBRIDGE gotoblas_NEHALEM
  270. #define gotoblas_HASWELL gotoblas_NEHALEM
  271. #define gotoblas_SKYLAKEX gotoblas_NEHALEM
  272. #define gotoblas_COOPERLAKE gotoblas_NEHALEM
  273. #define gotoblas_BULLDOZER gotoblas_BARCELONA
  274. #define gotoblas_PILEDRIVER gotoblas_BARCELONA
  275. #define gotoblas_STEAMROLLER gotoblas_BARCELONA
  276. #define gotoblas_EXCAVATOR gotoblas_BARCELONA
  277. #define gotoblas_ZEN gotoblas_BARCELONA
  278. #endif
  279. #endif // DYNAMIC_LIST
  280. #define VENDOR_INTEL 1
  281. #define VENDOR_AMD 2
  282. #define VENDOR_CENTAUR 3
  283. #define VENDOR_HYGON 4
  284. #define VENDOR_ZHAOXIN 5
  285. #define VENDOR_UNKNOWN 99
  286. #define BITMASK(a, b, c) ((((a) >> (b)) & (c)))
  287. #ifndef NO_AVX
  288. static inline void xgetbv(int op, int * eax, int * edx){
  289. //Use binary code for xgetbv
  290. __asm__ __volatile__
  291. (".byte 0x0f, 0x01, 0xd0": "=a" (*eax), "=d" (*edx) : "c" (op) : "cc");
  292. }
  293. #endif
  294. int support_avx(){
  295. #ifndef NO_AVX
  296. int eax, ebx, ecx, edx;
  297. int ret=0;
  298. cpuid(1, &eax, &ebx, &ecx, &edx);
  299. if ((ecx & (1 << 28)) != 0 && (ecx & (1 << 27)) != 0 && (ecx & (1 << 26)) != 0){
  300. xgetbv(0, &eax, &edx);
  301. if((eax & 6) == 6){
  302. ret=1; //OS support AVX
  303. }
  304. }
  305. return ret;
  306. #else
  307. return 0;
  308. #endif
  309. }
  310. int support_avx2(){
  311. #ifndef NO_AVX2
  312. int eax, ebx, ecx=0, edx;
  313. int ret=0;
  314. if (!support_avx())
  315. return 0;
  316. cpuid(7, &eax, &ebx, &ecx, &edx);
  317. if((ebx & (1<<5)) != 0)
  318. ret=1; //AVX2 flag is set
  319. return ret;
  320. #else
  321. return 0;
  322. #endif
  323. }
  324. int support_avx512(){
  325. #if !defined(NO_AVX) && !defined(NO_AVX512)
  326. int eax, ebx, ecx, edx;
  327. int ret=0;
  328. if (!support_avx())
  329. return 0;
  330. cpuid(7, &eax, &ebx, &ecx, &edx);
  331. if((ebx & (1<<5)) == 0){
  332. ret=0; //cpu does not have avx2 flag
  333. }
  334. if((ebx & (1<<31)) != 0){ //AVX512VL flag is set
  335. xgetbv(0, &eax, &edx);
  336. if((eax & 0xe0) == 0xe0)
  337. ret=1; //OS supports saving zmm register
  338. }
  339. return ret;
  340. #else
  341. return 0;
  342. #endif
  343. }
  344. int support_avx512_bf16(){
  345. #if !defined(NO_AVX) && !defined(NO_AVX512)
  346. int eax, ebx, ecx, edx;
  347. int ret=0;
  348. if (!support_avx512())
  349. return 0;
  350. cpuid_count(7, 1, &eax, &ebx, &ecx, &edx);
  351. if((eax & 32) == 32){
  352. ret=1; // CPUID.7.1:EAX[bit 5] indicates whether avx512_bf16 supported or not
  353. }
  354. return ret;
  355. #else
  356. return 0;
  357. #endif
  358. }
  359. extern void openblas_warning(int verbose, const char * msg);
  360. #define FALLBACK_VERBOSE 1
  361. #define NEHALEM_FALLBACK "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n"
  362. #define SANDYBRIDGE_FALLBACK "OpenBLAS : Your OS does not support AVX2 instructions. OpenBLAS is using Sandybridge kernels as a fallback, which may give poorer performance.\n"
  363. #define HASWELL_FALLBACK "OpenBLAS : Your OS does not support AVX512VL instructions. OpenBLAS is using Haswell kernels as a fallback, which may give poorer performance.\n"
  364. #define BARCELONA_FALLBACK "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Barcelona kernels as a fallback, which may give poorer performance.\n"
  365. static int get_vendor(void){
  366. int eax, ebx, ecx, edx;
  367. union
  368. {
  369. char vchar[16];
  370. int vint[4];
  371. } vendor;
  372. cpuid(0, &eax, &ebx, &ecx, &edx);
  373. *(&vendor.vint[0]) = ebx;
  374. *(&vendor.vint[1]) = edx;
  375. *(&vendor.vint[2]) = ecx;
  376. vendor.vchar[12] = '\0';
  377. if (!strcmp(vendor.vchar, "GenuineIntel")) return VENDOR_INTEL;
  378. if (!strcmp(vendor.vchar, "AuthenticAMD")) return VENDOR_AMD;
  379. if (!strcmp(vendor.vchar, "CentaurHauls")) return VENDOR_CENTAUR;
  380. if (!strcmp(vendor.vchar, " Shanghai ")) return VENDOR_ZHAOXIN;
  381. if (!strcmp(vendor.vchar, "HygonGenuine")) return VENDOR_HYGON;
  382. if ((eax == 0) || ((eax & 0x500) != 0)) return VENDOR_INTEL;
  383. return VENDOR_UNKNOWN;
  384. }
  385. static gotoblas_t *get_coretype(void){
  386. int eax, ebx, ecx, edx;
  387. int family, exfamily, model, vendor, exmodel, stepping;
  388. cpuid(1, &eax, &ebx, &ecx, &edx);
  389. family = BITMASK(eax, 8, 0x0f);
  390. exfamily = BITMASK(eax, 20, 0xff);
  391. model = BITMASK(eax, 4, 0x0f);
  392. exmodel = BITMASK(eax, 16, 0x0f);
  393. stepping = BITMASK(eax, 0, 0x0f);
  394. vendor = get_vendor();
  395. if (vendor == VENDOR_INTEL){
  396. switch (family) {
  397. case 0x6:
  398. switch (exmodel) {
  399. case 0:
  400. if (model <= 0x7) return &gotoblas_KATMAI;
  401. if ((model == 0x8) || (model == 0xa) || (model == 0xb)) return &gotoblas_COPPERMINE;
  402. if ((model == 0x9) || (model == 0xd)) return &gotoblas_BANIAS;
  403. if (model == 14) return &gotoblas_BANIAS;
  404. if (model == 15) return &gotoblas_CORE2;
  405. return NULL;
  406. case 1:
  407. if (model == 6) return &gotoblas_CORE2;
  408. if (model == 7) return &gotoblas_PENRYN;
  409. if (model == 13) return &gotoblas_DUNNINGTON;
  410. if ((model == 10) || (model == 11) || (model == 14) || (model == 15)) return &gotoblas_NEHALEM;
  411. if (model == 12) return &gotoblas_ATOM;
  412. return NULL;
  413. case 2:
  414. //Intel Core (Clarkdale) / Core (Arrandale)
  415. // Pentium (Clarkdale) / Pentium Mobile (Arrandale)
  416. // Xeon (Clarkdale), 32nm
  417. if (model == 5) return &gotoblas_NEHALEM;
  418. //Intel Xeon Processor 5600 (Westmere-EP)
  419. //Xeon Processor E7 (Westmere-EX)
  420. //Xeon E7540
  421. if (model == 12 || model == 14 || model == 15) return &gotoblas_NEHALEM;
  422. //Intel Core i5-2000 /i7-2000 (Sandy Bridge)
  423. //Intel Core i7-3000 / Xeon E5
  424. if (model == 10 || model == 13) {
  425. if(support_avx())
  426. return &gotoblas_SANDYBRIDGE;
  427. else{
  428. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  429. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  430. }
  431. }
  432. return NULL;
  433. case 3:
  434. //Intel Sandy Bridge 22nm (Ivy Bridge?)
  435. if (model == 10 || model == 14) {
  436. if(support_avx())
  437. return &gotoblas_SANDYBRIDGE;
  438. else{
  439. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  440. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  441. }
  442. }
  443. //Intel Haswell
  444. if (model == 12 || model == 15) {
  445. if(support_avx2())
  446. return &gotoblas_HASWELL;
  447. if(support_avx()) {
  448. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  449. return &gotoblas_SANDYBRIDGE;
  450. } else {
  451. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  452. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  453. }
  454. }
  455. //Intel Broadwell
  456. if (model == 13) {
  457. if(support_avx2())
  458. return &gotoblas_HASWELL;
  459. if(support_avx()) {
  460. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  461. return &gotoblas_SANDYBRIDGE;
  462. } else {
  463. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  464. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  465. }
  466. }
  467. if (model == 7) return &gotoblas_ATOM; //Bay Trail
  468. return NULL;
  469. case 4:
  470. //Intel Haswell
  471. if (model == 5 || model == 6) {
  472. if(support_avx2())
  473. return &gotoblas_HASWELL;
  474. if(support_avx()) {
  475. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  476. return &gotoblas_SANDYBRIDGE;
  477. } else {
  478. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  479. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  480. }
  481. }
  482. //Intel Broadwell
  483. if (model == 7 || model == 15) {
  484. if(support_avx2())
  485. return &gotoblas_HASWELL;
  486. if(support_avx()) {
  487. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  488. return &gotoblas_SANDYBRIDGE;
  489. } else {
  490. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  491. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  492. }
  493. }
  494. //Intel Skylake
  495. if (model == 14) {
  496. if(support_avx2())
  497. return &gotoblas_HASWELL;
  498. if(support_avx()) {
  499. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  500. return &gotoblas_SANDYBRIDGE;
  501. } else {
  502. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  503. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  504. }
  505. }
  506. //Intel Braswell / Avoton
  507. if (model == 12 || model == 13) {
  508. return &gotoblas_NEHALEM;
  509. }
  510. return NULL;
  511. case 5:
  512. //Intel Broadwell
  513. if (model == 6) {
  514. if(support_avx2())
  515. return &gotoblas_HASWELL;
  516. if(support_avx()) {
  517. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  518. return &gotoblas_SANDYBRIDGE;
  519. } else {
  520. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  521. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  522. }
  523. }
  524. if (model == 5) {
  525. // Intel Cooperlake
  526. if(support_avx512_bf16())
  527. return &gotoblas_COOPERLAKE;
  528. // Intel Skylake X
  529. if (support_avx512())
  530. return &gotoblas_SKYLAKEX;
  531. if(support_avx2()){
  532. openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK);
  533. return &gotoblas_HASWELL;
  534. }
  535. if(support_avx()) {
  536. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  537. return &gotoblas_SANDYBRIDGE;
  538. } else {
  539. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  540. return &gotoblas_NEHALEM;
  541. }
  542. }
  543. //Intel Skylake
  544. if (model == 14) {
  545. if(support_avx2())
  546. return &gotoblas_HASWELL;
  547. if(support_avx()) {
  548. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  549. return &gotoblas_SANDYBRIDGE;
  550. } else {
  551. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  552. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  553. }
  554. }
  555. //Intel Phi Knights Landing
  556. if (model == 7) {
  557. if(support_avx2()){
  558. openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK);
  559. return &gotoblas_HASWELL;
  560. }
  561. if(support_avx()) {
  562. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  563. return &gotoblas_SANDYBRIDGE;
  564. } else {
  565. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  566. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  567. }
  568. }
  569. //Apollo Lake or Denverton
  570. if (model == 12 || model == 15) {
  571. return &gotoblas_NEHALEM;
  572. }
  573. return NULL;
  574. case 6:
  575. if (model == 6) {
  576. // Cannon Lake
  577. if(support_avx2())
  578. return &gotoblas_HASWELL;
  579. if(support_avx()) {
  580. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  581. return &gotoblas_SANDYBRIDGE;
  582. } else {
  583. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  584. return &gotoblas_NEHALEM;
  585. }
  586. }
  587. if (model == 10 || model == 12){
  588. // Ice Lake SP
  589. if(support_avx512_bf16())
  590. return &gotoblas_COOPERLAKE;
  591. if (support_avx512())
  592. return &gotoblas_SKYLAKEX;
  593. if(support_avx2())
  594. return &gotoblas_HASWELL;
  595. if(support_avx()) {
  596. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  597. return &gotoblas_SANDYBRIDGE;
  598. } else {
  599. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  600. return &gotoblas_NEHALEM;
  601. }
  602. }
  603. return NULL;
  604. case 7:
  605. if (model == 10) // Goldmont Plus
  606. return &gotoblas_NEHALEM;
  607. if (model == 13 || model == 14) {
  608. // Ice Lake
  609. if (support_avx512())
  610. return &gotoblas_SKYLAKEX;
  611. if(support_avx2()){
  612. openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK);
  613. return &gotoblas_HASWELL;
  614. }
  615. if(support_avx()) {
  616. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  617. return &gotoblas_SANDYBRIDGE;
  618. } else {
  619. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  620. return &gotoblas_NEHALEM;
  621. }
  622. }
  623. return NULL;
  624. case 8:
  625. if (model == 12 || model == 13) { // Tiger Lake
  626. if (support_avx512())
  627. return &gotoblas_SKYLAKEX;
  628. if(support_avx2()){
  629. openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK);
  630. return &gotoblas_HASWELL;
  631. }
  632. if(support_avx()) {
  633. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  634. return &gotoblas_SANDYBRIDGE;
  635. } else {
  636. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  637. return &gotoblas_NEHALEM;
  638. }
  639. }
  640. if (model == 14 ) { // Kaby Lake, Coffee Lake
  641. if(support_avx2())
  642. return &gotoblas_HASWELL;
  643. if(support_avx()) {
  644. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  645. return &gotoblas_SANDYBRIDGE;
  646. } else {
  647. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  648. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  649. }
  650. }
  651. if (model == 15){ // Sapphire Rapids
  652. if(support_avx512_bf16())
  653. return &gotoblas_COOPERLAKE;
  654. if (support_avx512())
  655. return &gotoblas_SKYLAKEX;
  656. if(support_avx2())
  657. return &gotoblas_HASWELL;
  658. if(support_avx()) {
  659. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  660. return &gotoblas_SANDYBRIDGE;
  661. } else {
  662. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  663. return &gotoblas_NEHALEM;
  664. }
  665. }
  666. return NULL;
  667. case 9:
  668. if (model == 7 || model == 10) { // Alder Lake
  669. if(support_avx2()){
  670. openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK);
  671. return &gotoblas_HASWELL;
  672. }
  673. if(support_avx()) {
  674. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  675. return &gotoblas_SANDYBRIDGE;
  676. } else {
  677. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  678. return &gotoblas_NEHALEM;
  679. }
  680. }
  681. if (model == 14 ) { // Kaby Lake, Coffee Lake
  682. if(support_avx2())
  683. return &gotoblas_HASWELL;
  684. if(support_avx()) {
  685. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  686. return &gotoblas_SANDYBRIDGE;
  687. } else {
  688. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  689. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  690. }
  691. }
  692. return NULL;
  693. case 10:
  694. if (model == 5 || model == 6) {
  695. if(support_avx2())
  696. return &gotoblas_HASWELL;
  697. if(support_avx()) {
  698. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  699. return &gotoblas_SANDYBRIDGE;
  700. } else {
  701. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  702. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  703. }
  704. }
  705. if (model == 7) {
  706. if (support_avx512())
  707. return &gotoblas_SKYLAKEX;
  708. if(support_avx2())
  709. return &gotoblas_HASWELL;
  710. if(support_avx()) {
  711. openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK);
  712. return &gotoblas_SANDYBRIDGE;
  713. } else {
  714. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  715. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  716. }
  717. }
  718. return NULL;
  719. }
  720. case 0xf:
  721. if (model <= 0x2) return &gotoblas_NORTHWOOD;
  722. return &gotoblas_PRESCOTT;
  723. }
  724. }
  725. if (vendor == VENDOR_AMD || vendor == VENDOR_HYGON){
  726. if (family <= 0xe) {
  727. // Verify that CPU has 3dnow and 3dnowext before claiming it is Athlon
  728. cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
  729. if ( (eax & 0xffff) >= 0x01) {
  730. cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
  731. if ((edx & (1 << 30)) == 0 || (edx & (1u << 31)) == 0)
  732. return NULL;
  733. }
  734. else
  735. return NULL;
  736. return &gotoblas_ATHLON;
  737. }
  738. if (family == 0xf){
  739. if ((exfamily == 0) || (exfamily == 2)) {
  740. if (ecx & (1 << 0)) return &gotoblas_OPTERON_SSE3;
  741. else return &gotoblas_OPTERON;
  742. } else if (exfamily == 5 || exfamily == 7) {
  743. return &gotoblas_BOBCAT;
  744. } else if (exfamily == 6) {
  745. if(model == 1){
  746. //AMD Bulldozer Opteron 6200 / Opteron 4200 / AMD FX-Series
  747. if(support_avx())
  748. return &gotoblas_BULLDOZER;
  749. else{
  750. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  751. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  752. }
  753. }else if(model == 2 || model == 3){
  754. //AMD Bulldozer Opteron 6300 / Opteron 4300 / Opteron 3300
  755. if(support_avx())
  756. return &gotoblas_PILEDRIVER;
  757. else{
  758. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  759. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  760. }
  761. }else if(model == 5){
  762. if(support_avx())
  763. return &gotoblas_EXCAVATOR;
  764. else{
  765. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  766. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  767. }
  768. }else if(model == 0 || model == 8){
  769. if (exmodel == 1) {
  770. //AMD Trinity
  771. if(support_avx())
  772. return &gotoblas_PILEDRIVER;
  773. else{
  774. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  775. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  776. }
  777. }else if (exmodel == 3) {
  778. //AMD STEAMROLLER
  779. if(support_avx())
  780. return &gotoblas_STEAMROLLER;
  781. else{
  782. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  783. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  784. }
  785. }else if (exmodel == 6) {
  786. if(support_avx())
  787. return &gotoblas_EXCAVATOR;
  788. else{
  789. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  790. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  791. }
  792. }
  793. }
  794. } else if (exfamily == 8) {
  795. /* if (model == 1 || model == 8) */ {
  796. if(support_avx())
  797. return &gotoblas_ZEN;
  798. else{
  799. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  800. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  801. }
  802. }
  803. } else if (exfamily == 9) {
  804. if(support_avx())
  805. return &gotoblas_ZEN;
  806. else{
  807. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  808. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  809. }
  810. } else if (exfamily == 10) {
  811. if(support_avx())
  812. return &gotoblas_ZEN;
  813. else{
  814. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  815. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  816. }
  817. }else {
  818. return &gotoblas_BARCELONA;
  819. }
  820. }
  821. }
  822. if (vendor == VENDOR_CENTAUR) {
  823. switch (family) {
  824. case 0x6:
  825. if (model == 0xf && stepping < 0xe)
  826. return &gotoblas_NANO;
  827. return &gotoblas_NEHALEM;
  828. default:
  829. if (family >= 0x7)
  830. return &gotoblas_NEHALEM;
  831. }
  832. }
  833. if (vendor == VENDOR_ZHAOXIN) {
  834. return &gotoblas_NEHALEM;
  835. }
  836. return NULL;
  837. }
  838. static char *corename[] = {
  839. "Unknown",
  840. "Katmai",
  841. "Coppermine",
  842. "Northwood",
  843. "Prescott",
  844. "Banias",
  845. "Atom",
  846. "Core2",
  847. "Penryn",
  848. "Dunnington",
  849. "Nehalem",
  850. "Athlon",
  851. "Opteron",
  852. "Opteron_SSE3",
  853. "Barcelona",
  854. "Nano",
  855. "Sandybridge",
  856. "Bobcat",
  857. "Bulldozer",
  858. "Piledriver",
  859. "Haswell",
  860. "Steamroller",
  861. "Excavator",
  862. "Zen",
  863. "SkylakeX",
  864. "Cooperlake"
  865. };
  866. char *gotoblas_corename(void) {
  867. if (gotoblas == &gotoblas_KATMAI) return corename[ 1];
  868. if (gotoblas == &gotoblas_COPPERMINE) return corename[ 2];
  869. if (gotoblas == &gotoblas_NORTHWOOD) return corename[ 3];
  870. if (gotoblas == &gotoblas_PRESCOTT) return corename[ 4];
  871. if (gotoblas == &gotoblas_BANIAS) return corename[ 5];
  872. if (gotoblas == &gotoblas_ATOM)
  873. #ifdef DYNAMIC_OLDER
  874. return corename[ 6];
  875. #else
  876. return corename[10];
  877. #endif
  878. if (gotoblas == &gotoblas_CORE2) return corename[ 7];
  879. if (gotoblas == &gotoblas_PENRYN)
  880. #ifdef DYNAMIC_OLDER
  881. return corename[ 8];
  882. #else
  883. return corename[7];
  884. #endif
  885. if (gotoblas == &gotoblas_DUNNINGTON)
  886. #ifdef DYNAMIC_OLDER
  887. return corename[ 9];
  888. #else
  889. return corename[7];
  890. #endif
  891. if (gotoblas == &gotoblas_NEHALEM) return corename[10];
  892. if (gotoblas == &gotoblas_ATHLON) return corename[11];
  893. if (gotoblas == &gotoblas_OPTERON_SSE3)
  894. #ifdef DYNAMIC_OLDER
  895. return corename[12];
  896. #else
  897. return corename[7];
  898. #endif
  899. if (gotoblas == &gotoblas_OPTERON)
  900. #ifdef DYNAMIC_OLDER
  901. return corename[13];
  902. #else
  903. return corename[7];
  904. #endif
  905. if (gotoblas == &gotoblas_BARCELONA) return corename[14];
  906. if (gotoblas == &gotoblas_NANO)
  907. #ifdef DYNAMIC_OLDER
  908. return corename[15];
  909. #else
  910. return corename[10];
  911. #endif
  912. if (gotoblas == &gotoblas_SANDYBRIDGE) return corename[16];
  913. if (gotoblas == &gotoblas_BOBCAT)
  914. #ifdef DYNAMIC_OLDER
  915. return corename[17];
  916. #else
  917. return corename[7];
  918. #endif
  919. if (gotoblas == &gotoblas_BULLDOZER) return corename[18];
  920. if (gotoblas == &gotoblas_PILEDRIVER) return corename[19];
  921. if (gotoblas == &gotoblas_HASWELL) return corename[20];
  922. if (gotoblas == &gotoblas_STEAMROLLER) return corename[21];
  923. if (gotoblas == &gotoblas_EXCAVATOR) return corename[22];
  924. if (gotoblas == &gotoblas_ZEN) return corename[23];
  925. if (gotoblas == &gotoblas_SKYLAKEX) return corename[24];
  926. if (gotoblas == &gotoblas_COOPERLAKE) return corename[25];
  927. return corename[0];
  928. }
  929. static gotoblas_t *force_coretype(char *coretype){
  930. int i ;
  931. int found = -1;
  932. char message[128];
  933. //char mname[20];
  934. for ( i=1 ; i <= 24; i++)
  935. {
  936. if (!strncasecmp(coretype,corename[i],20))
  937. {
  938. found = i;
  939. break;
  940. }
  941. }
  942. if (found < 0)
  943. {
  944. //strncpy(mname,coretype,20);
  945. snprintf(message, 128, "Core not found: %s\n",coretype);
  946. openblas_warning(1, message);
  947. return(NULL);
  948. }
  949. switch (found)
  950. {
  951. case 25: return (&gotoblas_COOPERLAKE);
  952. case 24: return (&gotoblas_SKYLAKEX);
  953. case 23: return (&gotoblas_ZEN);
  954. case 22: return (&gotoblas_EXCAVATOR);
  955. case 21: return (&gotoblas_STEAMROLLER);
  956. case 20: return (&gotoblas_HASWELL);
  957. case 19: return (&gotoblas_PILEDRIVER);
  958. case 18: return (&gotoblas_BULLDOZER);
  959. case 17: return (&gotoblas_BOBCAT);
  960. case 16: return (&gotoblas_SANDYBRIDGE);
  961. case 15: return (&gotoblas_NANO);
  962. case 14: return (&gotoblas_BARCELONA);
  963. case 13: return (&gotoblas_OPTERON);
  964. case 12: return (&gotoblas_OPTERON_SSE3);
  965. case 11: return (&gotoblas_ATHLON);
  966. case 10: return (&gotoblas_NEHALEM);
  967. case 9: return (&gotoblas_DUNNINGTON);
  968. case 8: return (&gotoblas_PENRYN);
  969. case 7: return (&gotoblas_CORE2);
  970. case 6: return (&gotoblas_ATOM);
  971. case 5: return (&gotoblas_BANIAS);
  972. case 4: return (&gotoblas_PRESCOTT);
  973. case 3: return (&gotoblas_NORTHWOOD);
  974. case 2: return (&gotoblas_COPPERMINE);
  975. case 1: return (&gotoblas_KATMAI);
  976. }
  977. return(NULL);
  978. }
  979. void gotoblas_dynamic_init(void) {
  980. char coremsg[128];
  981. char coren[22];
  982. char *p;
  983. if (gotoblas) return;
  984. p = getenv("OPENBLAS_CORETYPE");
  985. if ( p )
  986. {
  987. gotoblas = force_coretype(p);
  988. }
  989. else
  990. {
  991. gotoblas = get_coretype();
  992. }
  993. #ifdef ARCH_X86
  994. if (gotoblas == NULL) gotoblas = &gotoblas_KATMAI;
  995. #else
  996. if (gotoblas == NULL) {
  997. if (support_avx512_bf16()) gotoblas = &gotoblas_COOPERLAKE;
  998. else if (support_avx512()) gotoblas = &gotoblas_SKYLAKEX;
  999. else if (support_avx2()) gotoblas = &gotoblas_HASWELL;
  1000. else if (support_avx()) gotoblas = &gotoblas_SANDYBRIDGE;
  1001. else gotoblas = &gotoblas_PRESCOTT;
  1002. }
  1003. /* sanity check, if 64bit pointer we can't have a 32 bit cpu */
  1004. if (sizeof(void*) == 8) {
  1005. if (gotoblas == &gotoblas_KATMAI ||
  1006. gotoblas == &gotoblas_COPPERMINE ||
  1007. gotoblas == &gotoblas_NORTHWOOD ||
  1008. gotoblas == &gotoblas_BANIAS ||
  1009. gotoblas == &gotoblas_ATHLON)
  1010. gotoblas = &gotoblas_PRESCOTT;
  1011. }
  1012. #endif
  1013. if (gotoblas && gotoblas -> init) {
  1014. strncpy(coren,gotoblas_corename(),20);
  1015. sprintf(coremsg, "Core: %s\n",coren);
  1016. openblas_warning(2, coremsg);
  1017. gotoblas -> init();
  1018. } else {
  1019. openblas_warning(0, "OpenBLAS : Architecture Initialization failed. No initialization function found.\n");
  1020. exit(1);
  1021. }
  1022. }
  1023. void gotoblas_dynamic_quit(void) {
  1024. gotoblas = NULL;
  1025. }