@@ -73,7 +73,7 @@ static DWORD blas_threads_id[MAX_CPU_NUMBER];
73
73
static volatile int thread_target ; // target num of live threads, volatile for cross-thread reads
74
74
75
75
//
76
- //
76
+ // Legacy code path
77
77
//
78
78
static void legacy_exec (void * func , int mode , blas_arg_t * args , void * sb ) {
79
79
@@ -369,11 +369,11 @@ int blas_thread_init(void) {
369
369
return 0 ;
370
370
}
371
371
372
- /*
373
- User can call one of two routines.
374
- exec_blas_async ... immediately returns after jobs are queued.
375
- exec_blas ... returns after jobs are finished.
376
- * /
372
+ //
373
+ // User can call one of two routines.
374
+ // exec_blas_async ... immediately returns after jobs are queued.
375
+ // exec_blas ... returns after jobs are finished.
376
+ / /
377
377
int exec_blas_async (BLASLONG pos , blas_queue_t * queue ) {
378
378
379
379
#if defined(SMP_SERVER )
@@ -471,27 +471,32 @@ int exec_blas(BLASLONG num, blas_queue_t *queue) {
471
471
472
472
if ((num <= 0 ) || (queue == NULL )) return 0 ;
473
473
474
- if ((num > 1 ) && queue -> next ) exec_blas_async (1 , queue -> next );
474
+ if ((num > 1 ) && queue -> next )
475
+ exec_blas_async (1 , queue -> next );
475
476
476
477
routine = queue -> routine ;
477
478
478
479
if (queue -> mode & BLAS_LEGACY ) {
479
480
legacy_exec (routine , queue -> mode , queue -> args , queue -> sb );
480
- } else
481
+ } else {
481
482
if (queue -> mode & BLAS_PTHREAD ) {
482
483
void (* pthreadcompat )(void * ) = queue -> routine ;
483
484
(pthreadcompat )(queue -> args );
484
485
} else
485
486
(routine )(queue -> args , queue -> range_m , queue -> range_n ,
486
- queue -> sa , queue -> sb , 0 );
487
+ queue -> sa , queue -> sb , 0 );
488
+ }
487
489
488
- if ((num > 1 ) && queue -> next ) exec_blas_async_wait (num - 1 , queue -> next );
490
+ if ((num > 1 ) && queue -> next )
491
+ exec_blas_async_wait (num - 1 , queue -> next );
489
492
490
493
return 0 ;
491
494
}
492
495
496
+ //
493
497
// Shutdown procedure, but user don't have to call this routine. The
494
498
// kernel automatically kill threads.
499
+ //
495
500
int BLASFUNC (blas_thread_shutdown )(void ) {
496
501
497
502
int i ;
@@ -502,7 +507,7 @@ int BLASFUNC(blas_thread_shutdown)(void) {
502
507
503
508
if (blas_server_avail ) {
504
509
505
- for (i = 0 ; i < blas_num_threads - 1 ; i ++ ) {
510
+ for (i = 0 ; i < blas_num_threads - 1 ; i ++ ) {
506
511
// Could also just use WaitForMultipleObjects
507
512
DWORD wait_thread_value = WaitForSingleObject (blas_threads [i ], 50 );
508
513
@@ -524,6 +529,9 @@ int BLASFUNC(blas_thread_shutdown)(void) {
524
529
return 0 ;
525
530
}
526
531
532
+ //
533
+ // Legacy function to set numbef of threads
534
+ //
527
535
void goto_set_num_threads (int num_threads )
528
536
{
529
537
long i ;
@@ -577,7 +585,7 @@ void goto_set_num_threads(int num_threads)
577
585
blas_server_avail = 1 ;
578
586
}
579
587
580
- for (i = (blas_num_threads > 0 ) ? blas_num_threads - 1 : 0 ; i < num_threads - 1 ; i ++ ) {
588
+ for (i = (blas_num_threads > 0 ) ? blas_num_threads - 1 : 0 ; i < num_threads - 1 ; i ++ ) {
581
589
//MT_TRACE("set_num_threads: creating thread [%d]\n", i);
582
590
583
591
blas_threads [i ] = CreateThread (NULL , 0 ,
@@ -593,6 +601,9 @@ void goto_set_num_threads(int num_threads)
593
601
blas_cpu_number = num_threads ;
594
602
}
595
603
604
+ //
605
+ // Openblas function to set thread count
606
+ //
596
607
void openblas_set_num_threads (int num )
597
608
{
598
609
goto_set_num_threads (num );
0 commit comments