Skip to content

Commit 98c56a7

Browse files
committed
more cleanup
1 parent 42cb567 commit 98c56a7

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

driver/others/blas_server_win32.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static DWORD blas_threads_id[MAX_CPU_NUMBER];
7373
static volatile int thread_target; // target num of live threads, volatile for cross-thread reads
7474

7575
//
76-
//
76+
// Legacy code path
7777
//
7878
static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb) {
7979

@@ -369,11 +369,11 @@ int blas_thread_init(void) {
369369
return 0;
370370
}
371371

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+
//
377377
int exec_blas_async(BLASLONG pos, blas_queue_t *queue) {
378378

379379
#if defined(SMP_SERVER)
@@ -471,27 +471,32 @@ int exec_blas(BLASLONG num, blas_queue_t *queue) {
471471

472472
if ((num <= 0) || (queue == NULL)) return 0;
473473

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);
475476

476477
routine = queue -> routine;
477478

478479
if (queue -> mode & BLAS_LEGACY) {
479480
legacy_exec(routine, queue -> mode, queue -> args, queue -> sb);
480-
} else
481+
} else {
481482
if (queue -> mode & BLAS_PTHREAD) {
482483
void (*pthreadcompat)(void *) = queue -> routine;
483484
(pthreadcompat)(queue -> args);
484485
} else
485486
(routine)(queue -> args, queue -> range_m, queue -> range_n,
486-
queue -> sa, queue -> sb, 0);
487+
queue -> sa, queue -> sb, 0);
488+
}
487489

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);
489492

490493
return 0;
491494
}
492495

496+
//
493497
// Shutdown procedure, but user don't have to call this routine. The
494498
// kernel automatically kill threads.
499+
//
495500
int BLASFUNC(blas_thread_shutdown)(void) {
496501

497502
int i;
@@ -502,7 +507,7 @@ int BLASFUNC(blas_thread_shutdown)(void) {
502507

503508
if (blas_server_avail) {
504509

505-
for(i = 0; i < blas_num_threads - 1; i++) {
510+
for (i = 0; i < blas_num_threads - 1; i++) {
506511
// Could also just use WaitForMultipleObjects
507512
DWORD wait_thread_value = WaitForSingleObject(blas_threads[i], 50);
508513

@@ -524,6 +529,9 @@ int BLASFUNC(blas_thread_shutdown)(void) {
524529
return 0;
525530
}
526531

532+
//
533+
// Legacy function to set numbef of threads
534+
//
527535
void goto_set_num_threads(int num_threads)
528536
{
529537
long i;
@@ -577,7 +585,7 @@ void goto_set_num_threads(int num_threads)
577585
blas_server_avail = 1;
578586
}
579587

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++) {
581589
//MT_TRACE("set_num_threads: creating thread [%d]\n", i);
582590

583591
blas_threads[i] = CreateThread(NULL, 0,
@@ -593,6 +601,9 @@ void goto_set_num_threads(int num_threads)
593601
blas_cpu_number = num_threads;
594602
}
595603

604+
//
605+
// Openblas function to set thread count
606+
//
596607
void openblas_set_num_threads(int num)
597608
{
598609
goto_set_num_threads(num);

0 commit comments

Comments
 (0)