Browse Source

Add CriticalSection handling instead of mutexes for Windows

tags/v0.3.4
Martin Kroeker GitHub 6 years ago
parent
commit
5192651706
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      driver/level3/level3_thread.c

+ 13
- 0
driver/level3/level3_thread.c View File

@@ -515,7 +515,12 @@ static int gemm_driver(blas_arg_t *args, BLASLONG *range_m, BLASLONG
BLASLONG nthreads_m, BLASLONG nthreads_n) {

#ifndef USE_OPENMP
#ifndef OS_WINDOWS
static pthread_mutex_t level3_lock = PTHREAD_MUTEX_INITIALIZER;
#else
CRITICAL_SECTION level3_lock;
InitializeCriticalSection((PCRITICAL_SECTION)&level3_lock;
#endif
#endif

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

#ifndef USE_OPENMP
#ifndef OS_WINDOWS
pthread_mutex_lock(&level3_lock);
#else
EnterCriticalSection((PCRITICAL_SECTION)&level3_lock);
#endif
#endif

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

#ifndef USE_OPENMP
#ifndef OS_WINDOWS
pthread_mutex_unlock(&level3_lock);
#else
LeaveCriticalSection((PCRITICAL_SECTION)&level3_lock);
#endif
#endif

return 0;


Loading…
Cancel
Save