Skip to content

Commit 6c83b87

Browse files
authored
Merge pull request #2040 from martin-frbg/locks2002
Restore locking optimizations for OpenMP case
2 parents edb8143 + af480b0 commit 6c83b87

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

driver/others/memory.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,21 +2694,26 @@ void *blas_memory_alloc(int procpos){
26942694

26952695
position = 0;
26962696

2697+
#if defined(SMP) && !defined(USE_OPENMP)
26972698
LOCK_COMMAND(&alloc_lock);
2699+
#endif
26982700
do {
2699-
/* if (!memory[position].used) { */
2700-
/* blas_lock(&memory[position].lock);*/
2701-
2701+
#if defined(USE_OPENMP)
2702+
if (!memory[position].used) {
2703+
blas_lock(&memory[position].lock);
2704+
#endif
27022705
if (!memory[position].used) goto allocation;
27032706

2704-
/* blas_unlock(&memory[position].lock);*/
2705-
/* } */
2706-
2707+
#if defined(USE_OPENMP)
2708+
blas_unlock(&memory[position].lock);
2709+
}
2710+
#endif
27072711
position ++;
27082712

27092713
} while (position < NUM_BUFFERS);
2710-
UNLOCK_COMMAND(&alloc_lock);
2711-
2714+
#if defined(SMP) && !defined(USE_OPENMP)
2715+
UNLOCK_COMMAND(&alloc_lock);
2716+
#endif
27122717
goto error;
27132718

27142719
allocation :
@@ -2718,9 +2723,11 @@ void *blas_memory_alloc(int procpos){
27182723
#endif
27192724

27202725
memory[position].used = 1;
2721-
2726+
#if defined(SMP) && !defined(USE_OPENMP)
27222727
UNLOCK_COMMAND(&alloc_lock);
2723-
2728+
#else
2729+
blas_unlock(&memory[position].lock);
2730+
#endif
27242731
if (!memory[position].addr) {
27252732
do {
27262733
#ifdef DEBUG

0 commit comments

Comments
 (0)