Skip to content

Commit af480b0

Browse files
authored
Restore locking optimizations for OpenMP case
restore another accidentally dropped part of #1468 that was missed in #2004 to address performance regression reported in #1461
1 parent 69edc5b commit af480b0

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
@@ -2647,21 +2647,26 @@ void *blas_memory_alloc(int procpos){
26472647

26482648
position = 0;
26492649

2650+
#if defined(SMP) && !defined(USE_OPENMP)
26502651
LOCK_COMMAND(&alloc_lock);
2652+
#endif
26512653
do {
2652-
/* if (!memory[position].used) { */
2653-
/* blas_lock(&memory[position].lock);*/
2654-
2654+
#if defined(USE_OPENMP)
2655+
if (!memory[position].used) {
2656+
blas_lock(&memory[position].lock);
2657+
#endif
26552658
if (!memory[position].used) goto allocation;
26562659

2657-
/* blas_unlock(&memory[position].lock);*/
2658-
/* } */
2659-
2660+
#if defined(USE_OPENMP)
2661+
blas_unlock(&memory[position].lock);
2662+
}
2663+
#endif
26602664
position ++;
26612665

26622666
} while (position < NUM_BUFFERS);
2663-
UNLOCK_COMMAND(&alloc_lock);
2664-
2667+
#if defined(SMP) && !defined(USE_OPENMP)
2668+
UNLOCK_COMMAND(&alloc_lock);
2669+
#endif
26652670
goto error;
26662671

26672672
allocation :
@@ -2671,9 +2676,11 @@ void *blas_memory_alloc(int procpos){
26712676
#endif
26722677

26732678
memory[position].used = 1;
2674-
2679+
#if defined(SMP) && !defined(USE_OPENMP)
26752680
UNLOCK_COMMAND(&alloc_lock);
2676-
2681+
#else
2682+
blas_unlock(&memory[position].lock);
2683+
#endif
26772684
if (!memory[position].addr) {
26782685
do {
26792686
#ifdef DEBUG

0 commit comments

Comments
 (0)