Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions driver/others/blas_server_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,16 @@ static DWORD WINAPI blas_thread_server(void *arg){
BLASLONG cpu = (BLASLONG)arg;
#endif

void *buffer, *sa, *sb;
void *buffer = NULL, *sa, *sb;
blas_queue_t *queue;
DWORD action;
HANDLE handles[] = {pool.filled, pool.killed};

/* Each server needs each buffer */
buffer = blas_memory_alloc(2);
/* Each server needs its own buffer, but allocate it on first use rather
than at thread start: on Windows the allocation is committed up front
(VirtualAlloc with MEM_COMMIT), so an eager buffer per idle thread adds
BUFFER_SIZE * (threads - 1) to the commit charge of every process that
merely loads the library. The pthreads server allocates lazily too. */

#ifdef SMP_DEBUG
fprintf(STDERR, "Server[%2ld] Thread is started!\n", cpu);
Expand Down Expand Up @@ -267,7 +270,10 @@ 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) {
if (buffer == NULL) buffer = blas_memory_alloc(2);
sa = (void *)((BLASLONG)buffer + GEMM_OFFSET_A);
}

if (sb == NULL) {
if (!(queue -> mode & BLAS_COMPLEX)){
Expand Down Expand Up @@ -348,7 +354,7 @@ static DWORD WINAPI blas_thread_server(void *arg){
fprintf(STDERR, "Server[%2ld] Shutdown!\n", cpu);
#endif

blas_memory_free(buffer);
if (buffer != NULL) blas_memory_free(buffer);

return 0;
}
Expand Down
Loading