more cleanup

This commit is contained in:
Mark Seminatore 2024-02-08 13:50:15 -08:00
parent 42cb567f0f
commit 98c56a7314
1 changed files with 23 additions and 12 deletions

View File

@ -73,7 +73,7 @@ static DWORD blas_threads_id[MAX_CPU_NUMBER];
static volatile int thread_target; // target num of live threads, volatile for cross-thread reads static volatile int thread_target; // target num of live threads, volatile for cross-thread reads
// //
// // Legacy code path
// //
static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb) { static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb) {
@ -369,11 +369,11 @@ int blas_thread_init(void) {
return 0; return 0;
} }
/* //
User can call one of two routines. // User can call one of two routines.
exec_blas_async ... immediately returns after jobs are queued. // exec_blas_async ... immediately returns after jobs are queued.
exec_blas ... returns after jobs are finished. // exec_blas ... returns after jobs are finished.
*/ //
int exec_blas_async(BLASLONG pos, blas_queue_t *queue) { int exec_blas_async(BLASLONG pos, blas_queue_t *queue) {
#if defined(SMP_SERVER) #if defined(SMP_SERVER)
@ -471,27 +471,32 @@ int exec_blas(BLASLONG num, blas_queue_t *queue) {
if ((num <= 0) || (queue == NULL)) return 0; if ((num <= 0) || (queue == NULL)) return 0;
if ((num > 1) && queue -> next) exec_blas_async(1, queue -> next); if ((num > 1) && queue -> next)
exec_blas_async(1, queue -> next);
routine = queue -> routine; routine = queue -> routine;
if (queue -> mode & BLAS_LEGACY) { if (queue -> mode & BLAS_LEGACY) {
legacy_exec(routine, queue -> mode, queue -> args, queue -> sb); legacy_exec(routine, queue -> mode, queue -> args, queue -> sb);
} else } else {
if (queue -> mode & BLAS_PTHREAD) { if (queue -> mode & BLAS_PTHREAD) {
void (*pthreadcompat)(void *) = queue -> routine; void (*pthreadcompat)(void *) = queue -> routine;
(pthreadcompat)(queue -> args); (pthreadcompat)(queue -> args);
} else } else
(routine)(queue -> args, queue -> range_m, queue -> range_n, (routine)(queue -> args, queue -> range_m, queue -> range_n,
queue -> sa, queue -> sb, 0); queue -> sa, queue -> sb, 0);
}
if ((num > 1) && queue -> next) exec_blas_async_wait(num - 1, queue -> next); if ((num > 1) && queue -> next)
exec_blas_async_wait(num - 1, queue -> next);
return 0; return 0;
} }
//
// Shutdown procedure, but user don't have to call this routine. The // Shutdown procedure, but user don't have to call this routine. The
// kernel automatically kill threads. // kernel automatically kill threads.
//
int BLASFUNC(blas_thread_shutdown)(void) { int BLASFUNC(blas_thread_shutdown)(void) {
int i; int i;
@ -524,6 +529,9 @@ int BLASFUNC(blas_thread_shutdown)(void) {
return 0; return 0;
} }
//
// Legacy function to set numbef of threads
//
void goto_set_num_threads(int num_threads) void goto_set_num_threads(int num_threads)
{ {
long i; long i;
@ -593,6 +601,9 @@ void goto_set_num_threads(int num_threads)
blas_cpu_number = num_threads; blas_cpu_number = num_threads;
} }
//
// Openblas function to set thread count
//
void openblas_set_num_threads(int num) void openblas_set_num_threads(int num)
{ {
goto_set_num_threads(num); goto_set_num_threads(num);