Skip to content

Commit 86dda5c

Browse files
authored
Add option USE_LOCKING for SMP-like locking in USE_THREAD=0 builds
1 parent 1e52572 commit 86dda5c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

driver/others/memory.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,13 +2062,13 @@ static void *alloc_mmap(void *address){
20622062
}
20632063

20642064
if (map_address != (void *)-1) {
2065-
#if defined(SMP) && !defined(USE_OPENMP)
2065+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
20662066
LOCK_COMMAND(&alloc_lock);
20672067
#endif
20682068
release_info[release_pos].address = map_address;
20692069
release_info[release_pos].func = alloc_mmap_free;
20702070
release_pos ++;
2071-
#if defined(SMP) && !defined(USE_OPENMP)
2071+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
20722072
UNLOCK_COMMAND(&alloc_lock);
20732073
#endif
20742074
}
@@ -2214,13 +2214,13 @@ static void *alloc_mmap(void *address){
22142214
#endif
22152215

22162216
if (map_address != (void *)-1) {
2217-
#if defined(SMP) && !defined(USE_OPENMP)
2217+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
22182218
LOCK_COMMAND(&alloc_lock);
22192219
#endif
22202220
release_info[release_pos].address = map_address;
22212221
release_info[release_pos].func = alloc_mmap_free;
22222222
release_pos ++;
2223-
#if defined(SMP) && !defined(USE_OPENMP)
2223+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
22242224
UNLOCK_COMMAND(&alloc_lock);
22252225
#endif
22262226
}
@@ -2701,7 +2701,7 @@ void *blas_memory_alloc(int procpos){
27012701

27022702
position = 0;
27032703

2704-
#if defined(SMP) && !defined(USE_OPENMP)
2704+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27052705
LOCK_COMMAND(&alloc_lock);
27062706
#endif
27072707
do {
@@ -2718,7 +2718,7 @@ void *blas_memory_alloc(int procpos){
27182718
position ++;
27192719

27202720
} while (position < NUM_BUFFERS);
2721-
#if defined(SMP) && !defined(USE_OPENMP)
2721+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27222722
UNLOCK_COMMAND(&alloc_lock);
27232723
#endif
27242724
goto error;
@@ -2730,7 +2730,7 @@ void *blas_memory_alloc(int procpos){
27302730
#endif
27312731

27322732
memory[position].used = 1;
2733-
#if defined(SMP) && !defined(USE_OPENMP)
2733+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27342734
UNLOCK_COMMAND(&alloc_lock);
27352735
#else
27362736
blas_unlock(&memory[position].lock);
@@ -2779,11 +2779,11 @@ void *blas_memory_alloc(int procpos){
27792779

27802780
} while ((BLASLONG)map_address == -1);
27812781

2782-
#if defined(SMP) && !defined(USE_OPENMP)
2782+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27832783
LOCK_COMMAND(&alloc_lock);
27842784
#endif
27852785
memory[position].addr = map_address;
2786-
#if defined(SMP) && !defined(USE_OPENMP)
2786+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27872787
UNLOCK_COMMAND(&alloc_lock);
27882788
#endif
27892789

@@ -2839,7 +2839,7 @@ void blas_memory_free(void *free_area){
28392839
#endif
28402840

28412841
position = 0;
2842-
#if defined(SMP) && !defined(USE_OPENMP)
2842+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
28432843
LOCK_COMMAND(&alloc_lock);
28442844
#endif
28452845
while ((position < NUM_BUFFERS) && (memory[position].addr != free_area))
@@ -2855,7 +2855,7 @@ void blas_memory_free(void *free_area){
28552855
WMB;
28562856

28572857
memory[position].used = 0;
2858-
#if defined(SMP) && !defined(USE_OPENMP)
2858+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
28592859
UNLOCK_COMMAND(&alloc_lock);
28602860
#endif
28612861

@@ -2872,7 +2872,7 @@ void blas_memory_free(void *free_area){
28722872
for (position = 0; position < NUM_BUFFERS; position++)
28732873
printf("%4ld %p : %d\n", position, memory[position].addr, memory[position].used);
28742874
#endif
2875-
#if defined(SMP) && !defined(USE_OPENMP)
2875+
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
28762876
UNLOCK_COMMAND(&alloc_lock);
28772877
#endif
28782878
return;
@@ -2924,7 +2924,7 @@ void blas_shutdown(void){
29242924

29252925
#if defined(OS_LINUX) && !defined(NO_WARMUP)
29262926

2927-
#ifdef SMP
2927+
#if defined(SMP) || defined(USE_LOCKING)
29282928
#if defined(USE_PTHREAD_LOCK)
29292929
static pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER;
29302930
#elif defined(USE_PTHREAD_SPINLOCK)
@@ -2949,7 +2949,7 @@ static void _touch_memory(blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n,
29492949
if (hot_alloc != 2) {
29502950
#endif
29512951

2952-
#ifdef SMP
2952+
#if defined(SMP) || defined(USE_LOCKING)
29532953
LOCK_COMMAND(&init_lock);
29542954
#endif
29552955

@@ -2959,7 +2959,7 @@ static void _touch_memory(blas_arg_t *arg, BLASLONG *range_m, BLASLONG *range_n,
29592959
size -= PAGESIZE;
29602960
}
29612961

2962-
#ifdef SMP
2962+
#if defined(SMP) || defined(USE_LOCKING)
29632963
UNLOCK_COMMAND(&init_lock);
29642964
#endif
29652965

0 commit comments

Comments
 (0)