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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. EXTERN gotoblas_t gotoblas_KATMAI;
  49. EXTERN gotoblas_t gotoblas_COPPERMINE;
  50. EXTERN gotoblas_t gotoblas_NORTHWOOD;
  51. EXTERN gotoblas_t gotoblas_BANIAS;
  52. EXTERN gotoblas_t gotoblas_ATHLON;
  53. extern gotoblas_t gotoblas_PRESCOTT;
  54. extern gotoblas_t gotoblas_ATOM;
  55. extern gotoblas_t gotoblas_NANO;
  56. extern gotoblas_t gotoblas_CORE2;
  57. extern gotoblas_t gotoblas_PENRYN;
  58. extern gotoblas_t gotoblas_DUNNINGTON;
  59. extern gotoblas_t gotoblas_NEHALEM;
  60. extern gotoblas_t gotoblas_OPTERON;
  61. extern gotoblas_t gotoblas_OPTERON_SSE3;
  62. extern gotoblas_t gotoblas_BARCELONA;
  63. extern gotoblas_t gotoblas_BOBCAT;
  64. #ifndef NO_AVX
  65. extern gotoblas_t gotoblas_SANDYBRIDGE;
  66. extern gotoblas_t gotoblas_BULLDOZER;
  67. extern gotoblas_t gotoblas_PILEDRIVER;
  68. extern gotoblas_t gotoblas_STEAMROLLER;
  69. extern gotoblas_t gotoblas_EXCAVATOR;
  70. #ifdef NO_AVX2
  71. #define gotoblas_HASWELL gotoblas_SANDYBRIDGE
  72. #define gotoblas_ZEN gotoblas_SANDYBRIDGE
  73. #else
  74. extern gotoblas_t gotoblas_HASWELL;
  75. extern gotoblas_t gotoblas_ZEN;
  76. #endif
  77. #else
  78. //Use NEHALEM kernels for sandy bridge
  79. #define gotoblas_SANDYBRIDGE gotoblas_NEHALEM
  80. #define gotoblas_HASWELL gotoblas_NEHALEM
  81. #define gotoblas_BULLDOZER gotoblas_BARCELONA
  82. #define gotoblas_PILEDRIVER gotoblas_BARCELONA
  83. #define gotoblas_STEAMROLLER gotoblas_BARCELONA
  84. #define gotoblas_EXCAVATOR gotoblas_BARCELONA
  85. #define gotoblas_ZEN gotoblas_BARCELONA
  86. #endif
  87. #define VENDOR_INTEL 1
  88. #define VENDOR_AMD 2
  89. #define VENDOR_CENTAUR 3
  90. #define VENDOR_UNKNOWN 99
  91. #define BITMASK(a, b, c) ((((a) >> (b)) & (c)))
  92. #ifndef NO_AVX
  93. static inline void xgetbv(int op, int * eax, int * edx){
  94. //Use binary code for xgetbv
  95. __asm__ __volatile__
  96. (".byte 0x0f, 0x01, 0xd0": "=a" (*eax), "=d" (*edx) : "c" (op) : "cc");
  97. }
  98. #endif
  99. int support_avx(){
  100. #ifndef NO_AVX
  101. int eax, ebx, ecx, edx;
  102. int ret=0;
  103. cpuid(1, &eax, &ebx, &ecx, &edx);
  104. if ((ecx & (1 << 28)) != 0 && (ecx & (1 << 27)) != 0 && (ecx & (1 << 26)) != 0){
  105. xgetbv(0, &eax, &edx);
  106. if((eax & 6) == 6){
  107. ret=1; //OS support AVX
  108. }
  109. }
  110. return ret;
  111. #else
  112. return 0;
  113. #endif
  114. }
  115. extern void openblas_warning(int verbose, const char * msg);
  116. #define FALLBACK_VERBOSE 1
  117. #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"
  118. #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"
  119. static int get_vendor(void){
  120. int eax, ebx, ecx, edx;
  121. union
  122. {
  123. char vchar[16];
  124. int vint[4];
  125. } vendor;
  126. cpuid(0, &eax, &ebx, &ecx, &edx);
  127. *(&vendor.vint[0]) = ebx;
  128. *(&vendor.vint[1]) = edx;
  129. *(&vendor.vint[2]) = ecx;
  130. vendor.vchar[12] = '\0';
  131. if (!strcmp(vendor.vchar, "GenuineIntel")) return VENDOR_INTEL;
  132. if (!strcmp(vendor.vchar, "AuthenticAMD")) return VENDOR_AMD;
  133. if (!strcmp(vendor.vchar, "CentaurHauls")) return VENDOR_CENTAUR;
  134. if ((eax == 0) || ((eax & 0x500) != 0)) return VENDOR_INTEL;
  135. return VENDOR_UNKNOWN;
  136. }
  137. static gotoblas_t *get_coretype(void){
  138. int eax, ebx, ecx, edx;
  139. int family, exfamily, model, vendor, exmodel;
  140. cpuid(1, &eax, &ebx, &ecx, &edx);
  141. family = BITMASK(eax, 8, 0x0f);
  142. exfamily = BITMASK(eax, 20, 0xff);
  143. model = BITMASK(eax, 4, 0x0f);
  144. exmodel = BITMASK(eax, 16, 0x0f);
  145. vendor = get_vendor();
  146. if (vendor == VENDOR_INTEL){
  147. switch (family) {
  148. case 0x6:
  149. switch (exmodel) {
  150. case 0:
  151. if (model <= 0x7) return &gotoblas_KATMAI;
  152. if ((model == 0x8) || (model == 0xa) || (model == 0xb)) return &gotoblas_COPPERMINE;
  153. if ((model == 0x9) || (model == 0xd)) return &gotoblas_BANIAS;
  154. if (model == 14) return &gotoblas_BANIAS;
  155. if (model == 15) return &gotoblas_CORE2;
  156. return NULL;
  157. case 1:
  158. if (model == 6) return &gotoblas_CORE2;
  159. if (model == 7) return &gotoblas_PENRYN;
  160. if (model == 13) return &gotoblas_DUNNINGTON;
  161. if ((model == 10) || (model == 11) || (model == 14) || (model == 15)) return &gotoblas_NEHALEM;
  162. if (model == 12) return &gotoblas_ATOM;
  163. return NULL;
  164. case 2:
  165. //Intel Core (Clarkdale) / Core (Arrandale)
  166. // Pentium (Clarkdale) / Pentium Mobile (Arrandale)
  167. // Xeon (Clarkdale), 32nm
  168. if (model == 5) return &gotoblas_NEHALEM;
  169. //Intel Xeon Processor 5600 (Westmere-EP)
  170. //Xeon Processor E7 (Westmere-EX)
  171. //Xeon E7540
  172. if (model == 12 || model == 14 || model == 15) return &gotoblas_NEHALEM;
  173. //Intel Core i5-2000 /i7-2000 (Sandy Bridge)
  174. //Intel Core i7-3000 / Xeon E5
  175. if (model == 10 || model == 13) {
  176. if(support_avx())
  177. return &gotoblas_SANDYBRIDGE;
  178. else{
  179. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  180. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  181. }
  182. }
  183. return NULL;
  184. case 3:
  185. //Intel Sandy Bridge 22nm (Ivy Bridge?)
  186. if (model == 10 || model == 14) {
  187. if(support_avx())
  188. return &gotoblas_SANDYBRIDGE;
  189. else{
  190. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  191. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  192. }
  193. }
  194. //Intel Haswell
  195. if (model == 12 || model == 15) {
  196. if(support_avx())
  197. return &gotoblas_HASWELL;
  198. else{
  199. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  200. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  201. }
  202. }
  203. //Intel Broadwell
  204. if (model == 13) {
  205. if(support_avx())
  206. return &gotoblas_HASWELL;
  207. else{
  208. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  209. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  210. }
  211. }
  212. if (model == 7) return &gotoblas_ATOM; //Bay Trail
  213. return NULL;
  214. case 4:
  215. //Intel Haswell
  216. if (model == 5 || model == 6) {
  217. if(support_avx())
  218. return &gotoblas_HASWELL;
  219. else{
  220. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  221. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  222. }
  223. }
  224. //Intel Broadwell
  225. if (model == 7 || model == 15) {
  226. if(support_avx())
  227. return &gotoblas_HASWELL;
  228. else{
  229. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  230. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  231. }
  232. }
  233. //Intel Skylake
  234. if (model == 14) {
  235. if(support_avx())
  236. return &gotoblas_HASWELL;
  237. else{
  238. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  239. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  240. }
  241. }
  242. //Intel Braswell / Avoton
  243. if (model == 12 || model == 13) {
  244. return &gotoblas_NEHALEM;
  245. }
  246. return NULL;
  247. case 5:
  248. //Intel Broadwell
  249. if (model == 6) {
  250. if(support_avx())
  251. return &gotoblas_HASWELL;
  252. else{
  253. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  254. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  255. }
  256. }
  257. //Intel Skylake
  258. if (model == 14 || model == 5) {
  259. if(support_avx())
  260. return &gotoblas_HASWELL;
  261. else{
  262. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  263. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  264. }
  265. }
  266. //Intel Phi Knights Landing
  267. if (model == 7) {
  268. if(support_avx())
  269. return &gotoblas_HASWELL;
  270. else{
  271. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  272. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  273. }
  274. }
  275. //Apollo Lake
  276. if (model == 12) {
  277. return &gotoblas_NEHALEM;
  278. }
  279. return NULL;
  280. case 9:
  281. case 8:
  282. if (model == 14 ) { // Kaby Lake
  283. if(support_avx())
  284. return &gotoblas_HASWELL;
  285. else{
  286. openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK);
  287. return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels.
  288. }
  289. }
  290. return NULL;
  291. }
  292. case 0xf:
  293. if (model <= 0x2) return &gotoblas_NORTHWOOD;
  294. return &gotoblas_PRESCOTT;
  295. }
  296. }
  297. if (vendor == VENDOR_AMD){
  298. if (family <= 0xe) {
  299. // Verify that CPU has 3dnow and 3dnowext before claiming it is Athlon
  300. cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
  301. if ( (eax & 0xffff) >= 0x01) {
  302. cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
  303. if ((edx & (1 << 30)) == 0 || (edx & (1 << 31)) == 0)
  304. return NULL;
  305. }
  306. else
  307. return NULL;
  308. return &gotoblas_ATHLON;
  309. }
  310. if (family == 0xf){
  311. if ((exfamily == 0) || (exfamily == 2)) {
  312. if (ecx & (1 << 0)) return &gotoblas_OPTERON_SSE3;
  313. else return &gotoblas_OPTERON;
  314. } else if (exfamily == 5) {
  315. return &gotoblas_BOBCAT;
  316. } else if (exfamily == 6) {
  317. if(model == 1){
  318. //AMD Bulldozer Opteron 6200 / Opteron 4200 / AMD FX-Series
  319. if(support_avx())
  320. return &gotoblas_BULLDOZER;
  321. else{
  322. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  323. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  324. }
  325. }else if(model == 2 || model == 3){
  326. //AMD Bulldozer Opteron 6300 / Opteron 4300 / Opteron 3300
  327. if(support_avx())
  328. return &gotoblas_PILEDRIVER;
  329. else{
  330. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  331. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  332. }
  333. }else if(model == 5){
  334. if(support_avx())
  335. return &gotoblas_EXCAVATOR;
  336. else{
  337. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  338. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  339. }
  340. }else if(model == 0 || model == 8){
  341. if (exmodel == 1) {
  342. //AMD Trinity
  343. if(support_avx())
  344. return &gotoblas_PILEDRIVER;
  345. else{
  346. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  347. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  348. }
  349. }else if (exmodel == 3) {
  350. //AMD STEAMROLLER
  351. if(support_avx())
  352. return &gotoblas_STEAMROLLER;
  353. else{
  354. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  355. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  356. }
  357. }else if (exmodel == 6) {
  358. if(support_avx())
  359. return &gotoblas_EXCAVATOR;
  360. else{
  361. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  362. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  363. }
  364. }
  365. }
  366. } else if (exfamily == 8) {
  367. if (model == 1) {
  368. if(support_avx())
  369. return &gotoblas_ZEN;
  370. else{
  371. openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK);
  372. return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels.
  373. }
  374. }
  375. }else {
  376. return &gotoblas_BARCELONA;
  377. }
  378. }
  379. }
  380. if (vendor == VENDOR_CENTAUR) {
  381. switch (family) {
  382. case 0x6:
  383. return &gotoblas_NANO;
  384. }
  385. }
  386. return NULL;
  387. }
  388. static char *corename[] = {
  389. "Unknown",
  390. "Katmai",
  391. "Coppermine",
  392. "Northwood",
  393. "Prescott",
  394. "Banias",
  395. "Atom",
  396. "Core2",
  397. "Penryn",
  398. "Dunnington",
  399. "Nehalem",
  400. "Athlon",
  401. "Opteron",
  402. "Opteron_SSE3",
  403. "Barcelona",
  404. "Nano",
  405. "Sandybridge",
  406. "Bobcat",
  407. "Bulldozer",
  408. "Piledriver",
  409. "Haswell",
  410. "Steamroller",
  411. "Excavator",
  412. "Zen"
  413. };
  414. char *gotoblas_corename(void) {
  415. if (gotoblas == &gotoblas_KATMAI) return corename[ 1];
  416. if (gotoblas == &gotoblas_COPPERMINE) return corename[ 2];
  417. if (gotoblas == &gotoblas_NORTHWOOD) return corename[ 3];
  418. if (gotoblas == &gotoblas_PRESCOTT) return corename[ 4];
  419. if (gotoblas == &gotoblas_BANIAS) return corename[ 5];
  420. if (gotoblas == &gotoblas_ATOM) return corename[ 6];
  421. if (gotoblas == &gotoblas_CORE2) return corename[ 7];
  422. if (gotoblas == &gotoblas_PENRYN) return corename[ 8];
  423. if (gotoblas == &gotoblas_DUNNINGTON) return corename[ 9];
  424. if (gotoblas == &gotoblas_NEHALEM) return corename[10];
  425. if (gotoblas == &gotoblas_ATHLON) return corename[11];
  426. if (gotoblas == &gotoblas_OPTERON_SSE3) return corename[12];
  427. if (gotoblas == &gotoblas_OPTERON) return corename[13];
  428. if (gotoblas == &gotoblas_BARCELONA) return corename[14];
  429. if (gotoblas == &gotoblas_NANO) return corename[15];
  430. if (gotoblas == &gotoblas_SANDYBRIDGE) return corename[16];
  431. if (gotoblas == &gotoblas_BOBCAT) return corename[17];
  432. if (gotoblas == &gotoblas_BULLDOZER) return corename[18];
  433. if (gotoblas == &gotoblas_PILEDRIVER) return corename[19];
  434. if (gotoblas == &gotoblas_HASWELL) return corename[20];
  435. if (gotoblas == &gotoblas_STEAMROLLER) return corename[21];
  436. if (gotoblas == &gotoblas_EXCAVATOR) return corename[22];
  437. if (gotoblas == &gotoblas_ZEN) return corename[23];
  438. return corename[0];
  439. }
  440. static gotoblas_t *force_coretype(char *coretype){
  441. int i ;
  442. int found = -1;
  443. char message[128];
  444. //char mname[20];
  445. for ( i=1 ; i <= 23; i++)
  446. {
  447. if (!strncasecmp(coretype,corename[i],20))
  448. {
  449. found = i;
  450. break;
  451. }
  452. }
  453. if (found < 0)
  454. {
  455. //strncpy(mname,coretype,20);
  456. snprintf(message, 128, "Core not found: %s\n",coretype);
  457. openblas_warning(1, message);
  458. return(NULL);
  459. }
  460. switch (found)
  461. {
  462. case 23: return (&gotoblas_ZEN);
  463. case 22: return (&gotoblas_EXCAVATOR);
  464. case 21: return (&gotoblas_STEAMROLLER);
  465. case 20: return (&gotoblas_HASWELL);
  466. case 19: return (&gotoblas_PILEDRIVER);
  467. case 18: return (&gotoblas_BULLDOZER);
  468. case 17: return (&gotoblas_BOBCAT);
  469. case 16: return (&gotoblas_SANDYBRIDGE);
  470. case 15: return (&gotoblas_NANO);
  471. case 14: return (&gotoblas_BARCELONA);
  472. case 13: return (&gotoblas_OPTERON);
  473. case 12: return (&gotoblas_OPTERON_SSE3);
  474. case 11: return (&gotoblas_ATHLON);
  475. case 10: return (&gotoblas_NEHALEM);
  476. case 9: return (&gotoblas_DUNNINGTON);
  477. case 8: return (&gotoblas_PENRYN);
  478. case 7: return (&gotoblas_CORE2);
  479. case 6: return (&gotoblas_ATOM);
  480. case 5: return (&gotoblas_BANIAS);
  481. case 4: return (&gotoblas_PRESCOTT);
  482. case 3: return (&gotoblas_NORTHWOOD);
  483. case 2: return (&gotoblas_COPPERMINE);
  484. case 1: return (&gotoblas_KATMAI);
  485. }
  486. return(NULL);
  487. }
  488. void gotoblas_dynamic_init(void) {
  489. char coremsg[128];
  490. char coren[22];
  491. char *p;
  492. if (gotoblas) return;
  493. p = getenv("OPENBLAS_CORETYPE");
  494. if ( p )
  495. {
  496. gotoblas = force_coretype(p);
  497. }
  498. else
  499. {
  500. gotoblas = get_coretype();
  501. }
  502. #ifdef ARCH_X86
  503. if (gotoblas == NULL) gotoblas = &gotoblas_KATMAI;
  504. #else
  505. if (gotoblas == NULL) gotoblas = &gotoblas_PRESCOTT;
  506. /* sanity check, if 64bit pointer we can't have a 32 bit cpu */
  507. if (sizeof(void*) == 8) {
  508. if (gotoblas == &gotoblas_KATMAI ||
  509. gotoblas == &gotoblas_COPPERMINE ||
  510. gotoblas == &gotoblas_NORTHWOOD ||
  511. gotoblas == &gotoblas_BANIAS ||
  512. gotoblas == &gotoblas_ATHLON)
  513. gotoblas = &gotoblas_PRESCOTT;
  514. }
  515. #endif
  516. if (gotoblas && gotoblas -> init) {
  517. strncpy(coren,gotoblas_corename(),20);
  518. sprintf(coremsg, "Core: %s\n",coren);
  519. openblas_warning(2, coremsg);
  520. gotoblas -> init();
  521. } else {
  522. openblas_warning(0, "OpenBLAS : Architecture Initialization failed. No initialization function found.\n");
  523. exit(1);
  524. }
  525. }
  526. void gotoblas_dynamic_quit(void) {
  527. gotoblas = NULL;
  528. }