Add option USE_LOCKING for SMP-like locking in USE_THREAD=0 builds

This commit is contained in:
Martin Kroeker 2019-05-15 23:21:20 +02:00 committed by GitHub
parent 1e52572be3
commit 86dda5c2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 15 deletions

View File

@ -2062,13 +2062,13 @@ static void *alloc_mmap(void *address){
} }
if (map_address != (void *)-1) { if (map_address != (void *)-1) {
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
#endif #endif
release_info[release_pos].address = map_address; release_info[release_pos].address = map_address;
release_info[release_pos].func = alloc_mmap_free; release_info[release_pos].func = alloc_mmap_free;
release_pos ++; release_pos ++;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
} }
@ -2214,13 +2214,13 @@ static void *alloc_mmap(void *address){
#endif #endif
if (map_address != (void *)-1) { if (map_address != (void *)-1) {
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
#endif #endif
release_info[release_pos].address = map_address; release_info[release_pos].address = map_address;
release_info[release_pos].func = alloc_mmap_free; release_info[release_pos].func = alloc_mmap_free;
release_pos ++; release_pos ++;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
} }
@ -2701,7 +2701,7 @@ void *blas_memory_alloc(int procpos){
position = 0; position = 0;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
#endif #endif
do { do {
@ -2718,7 +2718,7 @@ void *blas_memory_alloc(int procpos){
position ++; position ++;
} while (position < NUM_BUFFERS); } while (position < NUM_BUFFERS);
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
goto error; goto error;
@ -2730,7 +2730,7 @@ void *blas_memory_alloc(int procpos){
#endif #endif
memory[position].used = 1; memory[position].used = 1;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#else #else
blas_unlock(&memory[position].lock); blas_unlock(&memory[position].lock);
@ -2779,11 +2779,11 @@ void *blas_memory_alloc(int procpos){
} while ((BLASLONG)map_address == -1); } while ((BLASLONG)map_address == -1);
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
#endif #endif
memory[position].addr = map_address; memory[position].addr = map_address;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
@ -2839,7 +2839,7 @@ void blas_memory_free(void *free_area){
#endif #endif
position = 0; position = 0;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
#endif #endif
while ((position < NUM_BUFFERS) && (memory[position].addr != free_area)) while ((position < NUM_BUFFERS) && (memory[position].addr != free_area))
@ -2855,7 +2855,7 @@ void blas_memory_free(void *free_area){
WMB; WMB;
memory[position].used = 0; memory[position].used = 0;
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
@ -2872,7 +2872,7 @@ void blas_memory_free(void *free_area){
for (position = 0; position < NUM_BUFFERS; position++) for (position = 0; position < NUM_BUFFERS; position++)
printf("%4ld %p : %d\n", position, memory[position].addr, memory[position].used); printf("%4ld %p : %d\n", position, memory[position].addr, memory[position].used);
#endif #endif
#if defined(SMP) && !defined(USE_OPENMP) #if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock); UNLOCK_COMMAND(&alloc_lock);
#endif #endif
return; return;
@ -2924,7 +2924,7 @@ void blas_shutdown(void){
#if defined(OS_LINUX) && !defined(NO_WARMUP) #if defined(OS_LINUX) && !defined(NO_WARMUP)
#ifdef SMP #if defined(SMP) || defined(USE_LOCKING)
#if defined(USE_PTHREAD_LOCK) #if defined(USE_PTHREAD_LOCK)
static pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER;
#elif defined(USE_PTHREAD_SPINLOCK) #elif defined(USE_PTHREAD_SPINLOCK)
@ -2949,7 +2949,7 @@ static void _touch_memory(blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n,
if (hot_alloc != 2) { if (hot_alloc != 2) {
#endif #endif
#ifdef SMP #if defined(SMP) || defined(USE_LOCKING)
LOCK_COMMAND(&init_lock); LOCK_COMMAND(&init_lock);
#endif #endif
@ -2959,7 +2959,7 @@ static void _touch_memory(blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n,
size -= PAGESIZE; size -= PAGESIZE;
} }
#ifdef SMP #if defined(SMP) || defined(USE_LOCKING)
UNLOCK_COMMAND(&init_lock); UNLOCK_COMMAND(&init_lock);
#endif #endif