clean up whitespace

This commit is contained in:
Mark Seminatore 2024-01-29 22:33:47 -08:00
parent 6bd7c54af5
commit 0d7fe5ea61
1 changed files with 85 additions and 107 deletions

View File

@ -72,16 +72,6 @@ static HANDLE blas_threads [MAX_CPU_NUMBER];
static DWORD blas_threads_id[MAX_CPU_NUMBER];
static volatile int thread_target; // target num of live threads, volatile for cross-thread reads
#if defined (__GNUC__) && (__GNUC__ < 6)
#define WIN_CAS(dest, exch, comp) __sync_val_compare_and_swap(dest, comp, exch)
#else
#if defined(_WIN64)
#define WIN_CAS(dest, exch, comp) InterlockedCompareExchange64(dest, exch, comp)
#else
#define WIN_CAS(dest, exch, comp) InterlockedCompareExchange(dest, exch, comp)
#endif
#endif
static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
if (!(mode & BLAS_COMPLEX)) {
@ -205,9 +195,8 @@ static void legacy_exec(void *func, int mode, blas_arg_t *args, void *sb){
}
}
/* This is a main routine of threads. Each thread waits until job is */
/* queued. */
// This is a main routine of threads. Each thread waits until job is
// queued.
static DWORD WINAPI blas_thread_server(void *arg) {
/* Thread identifier */
@ -230,15 +219,13 @@ static DWORD WINAPI blas_thread_server(void *arg){
// event raised when work is added to the queue
WaitForSingleObject(kickoff_event, INFINITE);
if (cpu > thread_target - 2)
{
if (cpu > thread_target - 2) {
//MT_TRACE("thread [%d] exiting.\n", cpu);
break; // excess thread, so worker thread exits
}
MT_TRACE("Server[%2ld] Got it.\n", cpu);
#if 1
EnterCriticalSection(&queue_lock);
queue = work_queue;
@ -246,19 +233,6 @@ static DWORD WINAPI blas_thread_server(void *arg){
work_queue = work_queue->next;
LeaveCriticalSection(&queue_lock);
#else
volatile blas_queue_t* queue_next;
INT_PTR prev_value;
do {
queue = (volatile blas_queue_t*)work_queue;
if (!queue)
break;
queue_next = (volatile blas_queue_t*)queue->next;
prev_value = WIN_CAS((INT_PTR*)&work_queue, (INT_PTR)queue_next, (INT_PTR)queue);
} while (prev_value != queue);
#endif
if (queue) {
int (*routine)(blas_arg_t *, void *, void *, void *, void *, BLASLONG) = queue -> routine;
@ -280,7 +254,8 @@ static DWORD WINAPI blas_thread_server(void *arg){
main_status[cpu] = MAIN_RUNNING1;
#endif
if (sa == NULL) sa = (void *)((BLASLONG)buffer + GEMM_OFFSET_A);
if (sa == NULL)
sa = (void *)((BLASLONG)buffer + GEMM_OFFSET_A);
if (sb == NULL) {
if (!(queue -> mode & BLAS_COMPLEX)) {
@ -332,7 +307,6 @@ static DWORD WINAPI blas_thread_server(void *arg){
#endif
if (!(queue -> mode & BLAS_LEGACY)) {
(routine)(queue -> args, queue -> range_m, queue -> range_n, sa, sb, queue -> position);
} else {
legacy_exec(routine, queue -> mode, queue -> args, sb);
@ -355,7 +329,9 @@ static DWORD WINAPI blas_thread_server(void *arg){
return 0;
}
/* Initializing routine */
//
// Initializing routine
//
int blas_thread_init(void) {
BLASLONG i;
@ -391,12 +367,9 @@ int blas_thread_init(void){
/*
User can call one of two routines.
exec_blas_async ... immediately returns after jobs are queued.
exec_blas ... returns after jobs are finished.
*/
int exec_blas_async(BLASLONG pos, blas_queue_t *queue) {
#if defined(SMP_SERVER)
@ -447,12 +420,16 @@ int exec_blas_async(BLASLONG pos, blas_queue_t *queue){
return 0;
}
//
// Join. Wait for all queued tasks to complete
//
int exec_blas_async_wait(BLASLONG num, blas_queue_t *queue) {
MT_TRACE("Synchronization Waiting.\n");
while (num) {
MT_TRACE("Waiting Queue ..\n");
while (!queue->finished)
YIELDING;
@ -474,7 +451,9 @@ int exec_blas_async_wait(BLASLONG num, blas_queue_t *queue){
return 0;
}
/* Execute Threads */
//
// Execute Threads
//
int exec_blas(BLASLONG num, blas_queue_t *queue) {
#if defined(SMP_SERVER) && defined(OS_CYGWIN_NT)
@ -507,9 +486,8 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){
return 0;
}
/* Shutdown procedure, but user don't have to call this routine. The */
/* kernel automatically kill threads. */
// Shutdown procedure, but user don't have to call this routine. The
// kernel automatically kill threads.
int BLASFUNC(blas_thread_shutdown)(void){
int i;