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.

blas_server_win32.c 18 kB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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 <stdio.h>
  39. #include <stdlib.h>
  40. #include "common.h"
  41. #if !defined(unlikely)
  42. #ifdef __GNUC__
  43. #define unlikely(x) __builtin_expect(!!(x), 0)
  44. #else
  45. #define unlikely(x) (x)
  46. #endif
  47. #endif
  48. #ifdef SMP_DEBUG
  49. # define MT_TRACE(...) fprintf(stderr, __VA_ARGS__)
  50. #else
  51. # define MT_TRACE(...)
  52. #endif
  53. /* This is a thread implementation for Win32 lazy implementation */
  54. /* Thread server common information */
  55. static blas_queue_t *work_queue = NULL;
  56. static HANDLE kickoff_event = NULL;
  57. static CRITICAL_SECTION queue_lock;
  58. /* We need this global for checking if initialization is finished. */
  59. int blas_server_avail = 0;
  60. int blas_omp_threads_local = 1;
  61. /* Local Variables */
  62. static BLASULONG server_lock = 0;
  63. static HANDLE blas_threads [MAX_CPU_NUMBER];
  64. static DWORD blas_threads_id[MAX_CPU_NUMBER];
  65. static volatile int thread_target; // target num of live threads, volatile for cross-thread reads
  66. //
  67. // Legacy code path
  68. //
  69. static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb) {
  70. if (!(mode & BLAS_COMPLEX)) {
  71. #ifdef EXPRECISION
  72. if ((mode & BLAS_PREC) == BLAS_XDOUBLE){
  73. /* REAL / Extended Double */
  74. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, xdouble,
  75. xdouble *, BLASLONG, xdouble *, BLASLONG,
  76. xdouble *, BLASLONG, void *) = func;
  77. afunc(args -> m, args -> n, args -> k,
  78. ((xdouble *)args -> alpha)[0],
  79. args -> a, args -> lda,
  80. args -> b, args -> ldb,
  81. args -> c, args -> ldc, sb);
  82. } else
  83. #endif
  84. if ((mode & BLAS_PREC) == BLAS_DOUBLE) {
  85. /* REAL / Double */
  86. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double,
  87. double *, BLASLONG, double *, BLASLONG,
  88. double *, BLASLONG, void *) = func;
  89. afunc(args -> m, args -> n, args -> k,
  90. ((double *)args -> alpha)[0],
  91. args -> a, args -> lda,
  92. args -> b, args -> ldb,
  93. args -> c, args -> ldc, sb);
  94. } else if ((mode & BLAS_PREC) == BLAS_SINGLE) {
  95. /* REAL / Single */
  96. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float,
  97. float *, BLASLONG, float *, BLASLONG,
  98. float *, BLASLONG, void *) = func;
  99. afunc(args -> m, args -> n, args -> k,
  100. ((float *)args -> alpha)[0],
  101. args -> a, args -> lda,
  102. args -> b, args -> ldb,
  103. args -> c, args -> ldc, sb);
  104. #ifdef BUILD_BFLOAT16
  105. } else if ((mode & BLAS_PREC) == BLAS_BFLOAT16) {
  106. /* REAL / BFLOAT16 */
  107. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, bfloat16,
  108. bfloat16 *, BLASLONG, bfloat16 *, BLASLONG,
  109. bfloat16 *, BLASLONG, void *) = func;
  110. afunc(args -> m, args -> n, args -> k,
  111. ((bfloat16 *)args -> alpha)[0],
  112. args -> a, args -> lda,
  113. args -> b, args -> ldb,
  114. args -> c, args -> ldc, sb);
  115. } else if ((mode & BLAS_PREC) == BLAS_STOBF16) {
  116. /* REAL / BLAS_STOBF16 */
  117. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float,
  118. float *, BLASLONG, bfloat16 *, BLASLONG,
  119. float *, BLASLONG, void *) = func;
  120. afunc(args -> m, args -> n, args -> k,
  121. ((float *)args -> alpha)[0],
  122. args -> a, args -> lda,
  123. args -> b, args -> ldb,
  124. args -> c, args -> ldc, sb);
  125. } else if ((mode & BLAS_PREC) == BLAS_DTOBF16) {
  126. /* REAL / BLAS_DTOBF16 */
  127. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double,
  128. double *, BLASLONG, bfloat16 *, BLASLONG,
  129. double *, BLASLONG, void *) = func;
  130. afunc(args -> m, args -> n, args -> k,
  131. ((double *)args -> alpha)[0],
  132. args -> a, args -> lda,
  133. args -> b, args -> ldb,
  134. args -> c, args -> ldc, sb);
  135. #endif
  136. } else {
  137. /* REAL / Other types in future */
  138. }
  139. } else {
  140. #ifdef EXPRECISION
  141. if ((mode & BLAS_PREC) == BLAS_XDOUBLE) {
  142. /* COMPLEX / Extended Double */
  143. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, xdouble, xdouble,
  144. xdouble *, BLASLONG, xdouble *, BLASLONG,
  145. xdouble *, BLASLONG, void *) = func;
  146. afunc(args -> m, args -> n, args -> k,
  147. ((xdouble *)args -> alpha)[0],
  148. ((xdouble *)args -> alpha)[1],
  149. args -> a, args -> lda,
  150. args -> b, args -> ldb,
  151. args -> c, args -> ldc, sb);
  152. } else
  153. #endif
  154. if ((mode & BLAS_PREC) == BLAS_DOUBLE) {
  155. /* COMPLEX / Double */
  156. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, double, double,
  157. double *, BLASLONG, double *, BLASLONG,
  158. double *, BLASLONG, void *) = func;
  159. afunc(args -> m, args -> n, args -> k,
  160. ((double *)args -> alpha)[0],
  161. ((double *)args -> alpha)[1],
  162. args -> a, args -> lda,
  163. args -> b, args -> ldb,
  164. args -> c, args -> ldc, sb);
  165. } else if ((mode & BLAS_PREC) == BLAS_SINGLE) {
  166. /* COMPLEX / Single */
  167. void (*afunc)(BLASLONG, BLASLONG, BLASLONG, float, float,
  168. float *, BLASLONG, float *, BLASLONG,
  169. float *, BLASLONG, void *) = func;
  170. afunc(args -> m, args -> n, args -> k,
  171. ((float *)args -> alpha)[0],
  172. ((float *)args -> alpha)[1],
  173. args -> a, args -> lda,
  174. args -> b, args -> ldb,
  175. args -> c, args -> ldc, sb);
  176. } else {
  177. /* COMPLEX / Other types in future */
  178. }
  179. }
  180. }
  181. //
  182. // This is a main routine of threads. Each thread waits until job is queued.
  183. //
  184. static DWORD WINAPI blas_thread_server(void *arg) {
  185. /* Thread identifier */
  186. BLASLONG cpu = (BLASLONG)arg;
  187. void *buffer, *sa, *sb;
  188. blas_queue_t *queue;
  189. /* Each server needs each buffer */
  190. buffer = blas_memory_alloc(2);
  191. MT_TRACE("Server[%2ld] Thread is started!\n", cpu);
  192. while (1) {
  193. /* Waiting for Queue */
  194. MT_TRACE("Server[%2ld] Waiting for Queue.\n", cpu);
  195. // event raised when work is added to the queue
  196. WaitForSingleObject(kickoff_event, INFINITE);
  197. if (cpu > thread_target - 2) {
  198. //MT_TRACE("thread [%d] exiting.\n", cpu);
  199. break; // excess thread, so worker thread exits
  200. }
  201. MT_TRACE("Server[%2ld] Got it.\n", cpu);
  202. EnterCriticalSection(&queue_lock);
  203. queue = work_queue;
  204. if (queue)
  205. work_queue = work_queue->next;
  206. LeaveCriticalSection(&queue_lock);
  207. if (queue) {
  208. int (*routine)(blas_arg_t *, void *, void *, void *, void *, BLASLONG) = queue -> routine;
  209. sa = queue -> sa;
  210. sb = queue -> sb;
  211. #ifdef CONSISTENT_FPCSR
  212. __asm__ __volatile__ ("ldmxcsr %0" : : "m" (queue -> sse_mode));
  213. __asm__ __volatile__ ("fldcw %0" : : "m" (queue -> x87_mode));
  214. #endif
  215. MT_TRACE("Server[%2ld] Started. Mode = 0x%03x M = %3ld N=%3ld K=%3ld\n",
  216. cpu, queue->mode, queue-> args ->m, queue->args->n, queue->args->k);
  217. // fprintf(stderr, "queue start[%ld]!!!\n", cpu);
  218. #ifdef MONITOR
  219. main_status[cpu] = MAIN_RUNNING1;
  220. #endif
  221. if (sa == NULL)
  222. sa = (void *)((BLASLONG)buffer + GEMM_OFFSET_A);
  223. if (sb == NULL) {
  224. if (!(queue -> mode & BLAS_COMPLEX)) {
  225. #ifdef EXPRECISION
  226. if ((queue -> mode & BLAS_PREC) == BLAS_XDOUBLE) {
  227. sb = (void *)(((BLASLONG)sa + ((XGEMM_P * XGEMM_Q * sizeof(xdouble)
  228. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  229. } else
  230. #endif
  231. if ((queue -> mode & BLAS_PREC) == BLAS_DOUBLE) {
  232. #ifdef BUILD_DOUBLE
  233. sb = (void *)(((BLASLONG)sa + ((DGEMM_P * DGEMM_Q * sizeof(double)
  234. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  235. #endif
  236. } else if ((queue -> mode & BLAS_PREC) == BLAS_SINGLE) {
  237. #ifdef BUILD_SINGLE
  238. sb = (void *)(((BLASLONG)sa + ((SGEMM_P * SGEMM_Q * sizeof(float)
  239. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  240. #endif
  241. } else {
  242. /* Other types in future */
  243. }
  244. } else {
  245. #ifdef EXPRECISION
  246. if ((queue -> mode & BLAS_PREC) == BLAS_XDOUBLE){
  247. sb = (void *)(((BLASLONG)sa + ((XGEMM_P * XGEMM_Q * 2 * sizeof(xdouble)
  248. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  249. } else
  250. #endif
  251. if ((queue -> mode & BLAS_PREC) == BLAS_DOUBLE){
  252. #ifdef BUILD_COMPLEX16
  253. sb = (void *)(((BLASLONG)sa + ((ZGEMM_P * ZGEMM_Q * 2 * sizeof(double)
  254. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  255. #endif
  256. } else if ((queue -> mode & BLAS_PREC) == BLAS_SINGLE) {
  257. #ifdef BUILD_COMPLEX
  258. sb = (void *)(((BLASLONG)sa + ((CGEMM_P * CGEMM_Q * 2 * sizeof(float)
  259. + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
  260. #endif
  261. } else {
  262. /* Other types in future */
  263. }
  264. }
  265. queue->sb=sb;
  266. }
  267. #ifdef MONITOR
  268. main_status[cpu] = MAIN_RUNNING2;
  269. #endif
  270. if (!(queue -> mode & BLAS_LEGACY)) {
  271. (routine)(queue -> args, queue -> range_m, queue -> range_n, sa, sb, queue -> position);
  272. } else {
  273. legacy_exec(routine, queue -> mode, queue -> args, sb);
  274. }
  275. } else {
  276. continue; //if queue == NULL
  277. }
  278. MT_TRACE("Server[%2ld] Finished!\n", cpu);
  279. queue->finished = 1;
  280. }
  281. /* Shutdown procedure */
  282. MT_TRACE("Server[%2ld] Shutdown!\n", cpu);
  283. blas_memory_free(buffer);
  284. return 0;
  285. }
  286. //
  287. // Initializing routine
  288. //
  289. int blas_thread_init(void) {
  290. BLASLONG i;
  291. if (blas_server_avail || (blas_cpu_number <= 1)) return 0;
  292. LOCK_COMMAND(&server_lock);
  293. MT_TRACE("Initializing Thread(Num. threads = %d)\n", blas_cpu_number);
  294. if (!blas_server_avail) {
  295. // create the kickoff Event
  296. kickoff_event = CreateEvent(NULL, TRUE, FALSE, NULL);
  297. thread_target = blas_cpu_number;
  298. InitializeCriticalSection(&queue_lock);
  299. for(i = 0; i < blas_cpu_number - 1; i++) {
  300. //MT_TRACE("thread_init: creating thread [%d]\n", i);
  301. blas_threads[i] = CreateThread(NULL, 0,
  302. blas_thread_server, (void *)i,
  303. 0, &blas_threads_id[i]);
  304. }
  305. blas_server_avail = 1;
  306. }
  307. UNLOCK_COMMAND(&server_lock);
  308. return 0;
  309. }
  310. //
  311. // User can call one of two routines.
  312. // exec_blas_async ... immediately returns after jobs are queued.
  313. // exec_blas ... returns after jobs are finished.
  314. //
  315. int exec_blas_async(BLASLONG pos, blas_queue_t *queue) {
  316. #if defined(SMP_SERVER)
  317. // Handle lazy re-init of the thread-pool after a POSIX fork
  318. // on Cygwin or as delayed init when a static library is used
  319. if (unlikely(blas_server_avail == 0)) blas_thread_init();
  320. #endif
  321. blas_queue_t *current;
  322. current = queue;
  323. while (current) {
  324. current -> position = pos;
  325. #ifdef CONSISTENT_FPCSR
  326. __asm__ __volatile__ ("fnstcw %0" : "=m" (current -> x87_mode));
  327. __asm__ __volatile__ ("stmxcsr %0" : "=m" (current -> sse_mode));
  328. #endif
  329. current->finished = 0;
  330. current = current -> next;
  331. pos ++;
  332. }
  333. EnterCriticalSection(&queue_lock);
  334. if (!work_queue)
  335. {
  336. work_queue = queue;
  337. }
  338. else
  339. {
  340. blas_queue_t *next_item = work_queue;
  341. // find the end of the work queue
  342. while (next_item)
  343. next_item = next_item->next;
  344. // add new work to the end
  345. next_item = queue;
  346. }
  347. LeaveCriticalSection(&queue_lock);
  348. SetEvent(kickoff_event);
  349. return 0;
  350. }
  351. //
  352. // Join. Wait for all queued tasks to complete
  353. //
  354. int exec_blas_async_wait(BLASLONG num, blas_queue_t *queue) {
  355. MT_TRACE("Synchronization Waiting.\n");
  356. while (num) {
  357. MT_TRACE("Waiting Queue ..\n");
  358. while (!queue->finished)
  359. YIELDING;
  360. queue = queue->next;
  361. num--;
  362. }
  363. MT_TRACE("Completely Done.\n\n");
  364. // if work was added to the queue after this batch we can't sleep the worker threads
  365. // by resetting the event
  366. EnterCriticalSection(&queue_lock);
  367. if (work_queue == NULL)
  368. ResetEvent(kickoff_event);
  369. LeaveCriticalSection(&queue_lock);
  370. return 0;
  371. }
  372. //
  373. // Execute Threads
  374. //
  375. int exec_blas(BLASLONG num, blas_queue_t *queue) {
  376. #if defined(SMP_SERVER) && defined(OS_CYGWIN_NT)
  377. // Handle lazy re-init of the thread-pool after a POSIX fork
  378. if (unlikely(blas_server_avail == 0)) blas_thread_init();
  379. #endif
  380. #ifndef ALL_THREADED
  381. int (*routine)(blas_arg_t *, void *, void *, double *, double *, BLASLONG);
  382. #endif
  383. if ((num <= 0) || (queue == NULL)) return 0;
  384. if ((num > 1) && queue -> next)
  385. exec_blas_async(1, queue -> next);
  386. routine = queue -> routine;
  387. if (queue -> mode & BLAS_LEGACY) {
  388. legacy_exec(routine, queue -> mode, queue -> args, queue -> sb);
  389. } else {
  390. if (queue -> mode & BLAS_PTHREAD) {
  391. void (*pthreadcompat)(void *) = queue -> routine;
  392. (pthreadcompat)(queue -> args);
  393. } else
  394. (routine)(queue -> args, queue -> range_m, queue -> range_n,
  395. queue -> sa, queue -> sb, 0);
  396. }
  397. if ((num > 1) && queue -> next)
  398. exec_blas_async_wait(num - 1, queue -> next);
  399. return 0;
  400. }
  401. //
  402. // Shutdown procedure, but user don't have to call this routine. The
  403. // kernel automatically kill threads.
  404. //
  405. int BLASFUNC(blas_thread_shutdown)(void) {
  406. int i;
  407. if (!blas_server_avail) return 0;
  408. LOCK_COMMAND(&server_lock);
  409. if (blas_server_avail) {
  410. for (i = 0; i < blas_num_threads - 1; i++) {
  411. // Could also just use WaitForMultipleObjects
  412. DWORD wait_thread_value = WaitForSingleObject(blas_threads[i], 50);
  413. #ifndef OS_WINDOWSSTORE
  414. // TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
  415. if (WAIT_OBJECT_0 != wait_thread_value) {
  416. TerminateThread(blas_threads[i],0);
  417. }
  418. #endif
  419. CloseHandle(blas_threads[i]);
  420. }
  421. blas_server_avail = 0;
  422. }
  423. UNLOCK_COMMAND(&server_lock);
  424. return 0;
  425. }
  426. //
  427. // Legacy function to set numbef of threads
  428. //
  429. void goto_set_num_threads(int num_threads)
  430. {
  431. long i;
  432. #if defined(SMP_SERVER) && defined(OS_CYGWIN_NT)
  433. // Handle lazy re-init of the thread-pool after a POSIX fork
  434. if (unlikely(blas_server_avail == 0)) blas_thread_init();
  435. #endif
  436. if (num_threads < 1) num_threads = blas_cpu_number;
  437. if (num_threads > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER;
  438. if (blas_server_avail && num_threads < blas_num_threads) {
  439. LOCK_COMMAND(&server_lock);
  440. thread_target = num_threads;
  441. SetEvent(kickoff_event);
  442. for (i = num_threads - 1; i < blas_num_threads - 1; i++) {
  443. //MT_TRACE("set_num_threads: waiting on thread [%d] to quit.\n", i);
  444. WaitForSingleObject(blas_threads[i], INFINITE);
  445. //MT_TRACE("set_num_threads: thread [%d] has quit.\n", i);
  446. CloseHandle(blas_threads[i]);
  447. }
  448. blas_num_threads = num_threads;
  449. ResetEvent(kickoff_event);
  450. UNLOCK_COMMAND(&server_lock);
  451. }
  452. if (num_threads > blas_num_threads) {
  453. LOCK_COMMAND(&server_lock);
  454. thread_target = num_threads;
  455. //increased_threads = 1;
  456. if (!blas_server_avail) {
  457. // create the kickoff Event
  458. kickoff_event = CreateEvent(NULL, TRUE, FALSE, NULL);
  459. InitializeCriticalSection(&queue_lock);
  460. blas_server_avail = 1;
  461. }
  462. for (i = (blas_num_threads > 0) ? blas_num_threads - 1 : 0; i < num_threads - 1; i++) {
  463. //MT_TRACE("set_num_threads: creating thread [%d]\n", i);
  464. blas_threads[i] = CreateThread(NULL, 0,
  465. blas_thread_server, (void *)i,
  466. 0, &blas_threads_id[i]);
  467. }
  468. blas_num_threads = num_threads;
  469. UNLOCK_COMMAND(&server_lock);
  470. }
  471. blas_cpu_number = num_threads;
  472. }
  473. //
  474. // Openblas function to set thread count
  475. //
  476. void openblas_set_num_threads(int num)
  477. {
  478. goto_set_num_threads(num);
  479. }