Skip to content

Commit 5192651

Browse files
authored
Add CriticalSection handling instead of mutexes for Windows
1 parent 2e6fae2 commit 5192651

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

driver/level3/level3_thread.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,12 @@ static int gemm_driver(blas_arg_t *args, BLASLONG *range_m, BLASLONG
515515
BLASLONG nthreads_m, BLASLONG nthreads_n) {
516516

517517
#ifndef USE_OPENMP
518+
#ifndef OS_WINDOWS
518519
static pthread_mutex_t level3_lock = PTHREAD_MUTEX_INITIALIZER;
520+
#else
521+
CRITICAL_SECTION level3_lock;
522+
InitializeCriticalSection((PCRITICAL_SECTION)&level3_lock;
523+
#endif
519524
#endif
520525

521526
blas_arg_t newarg;
@@ -559,7 +564,11 @@ static pthread_mutex_t level3_lock = PTHREAD_MUTEX_INITIALIZER;
559564
#endif
560565

561566
#ifndef USE_OPENMP
567+
#ifndef OS_WINDOWS
562568
pthread_mutex_lock(&level3_lock);
569+
#else
570+
EnterCriticalSection((PCRITICAL_SECTION)&level3_lock);
571+
#endif
563572
#endif
564573

565574
#ifdef USE_ALLOC_HEAP
@@ -680,7 +689,11 @@ pthread_mutex_lock(&level3_lock);
680689
#endif
681690

682691
#ifndef USE_OPENMP
692+
#ifndef OS_WINDOWS
683693
pthread_mutex_unlock(&level3_lock);
694+
#else
695+
LeaveCriticalSection((PCRITICAL_SECTION)&level3_lock);
696+
#endif
684697
#endif
685698

686699
return 0;

0 commit comments

Comments
 (0)