Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore some unconditional locks from 0.2.19 #1465

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions driver/others/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,7 @@ void *blas_memory_alloc(int procpos){
};
void *(**func)(void *address);

#if defined(SMP) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock);
#endif

if (!memory_initialized) {

Expand Down Expand Up @@ -1052,9 +1050,7 @@ void *blas_memory_alloc(int procpos){
memory_initialized = 1;

}
#if defined(SMP) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock);
#endif

#ifdef DEBUG
printf("Alloc Start ...\n");
Expand All @@ -1071,14 +1067,15 @@ void *blas_memory_alloc(int procpos){
if (!memory[position].used && (memory[position].pos == mypos)) {
#if defined(SMP) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock);
#endif
/* blas_lock(&memory[position].lock);*/

#else
blas_lock(&memory[position].lock);
#endif
if (!memory[position].used) goto allocation;
#if defined(SMP) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock);
#else
blas_unlock(&memory[position].lock);
#endif
/* blas_unlock(&memory[position].lock);*/
}

position ++;
Expand All @@ -1094,14 +1091,15 @@ void *blas_memory_alloc(int procpos){
/* if (!memory[position].used) { */
#if defined(SMP) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock);
#endif
/* blas_lock(&memory[position].lock);*/

#else
blas_lock(&memory[position].lock);
#endif
if (!memory[position].used) goto allocation;
#if defined(SMP) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock);
#endif
/* blas_unlock(&memory[position].lock);*/
#else
blas_unlock(&memory[position].lock);
#endif
/* } */

position ++;
Expand All @@ -1119,10 +1117,10 @@ void *blas_memory_alloc(int procpos){
memory[position].used = 1;
#if defined(SMP) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock);
#else
blas_unlock(&memory[position].lock);
#endif

/* blas_unlock(&memory[position].lock);*/


if (!memory[position].addr) {
do {
#ifdef DEBUG
Expand Down Expand Up @@ -1190,9 +1188,7 @@ void *blas_memory_alloc(int procpos){

if (memory_initialized == 1) {

#if defined(SMP) && !defined(USE_OPENMP)
LOCK_COMMAND(&alloc_lock);
#endif

if (memory_initialized == 1) {

Expand All @@ -1201,9 +1197,8 @@ void *blas_memory_alloc(int procpos){
memory_initialized = 2;
}

#if defined(SMP) && !defined(USE_OPENMP)
UNLOCK_COMMAND(&alloc_lock);
#endif

}
#endif

Expand Down