Merge pull request #1299 from martin-frbg/race_fixes
Fix thread data races uncovered by gcc thread sanitizer
This commit is contained in:
commit
f66d908282
|
@ -669,9 +669,15 @@ int exec_blas_async(BLASLONG pos, blas_queue_t *queue){
|
|||
} while (1);
|
||||
|
||||
} else {
|
||||
while(thread_status[i].queue) {
|
||||
pthread_mutex_lock (&thread_status[i].lock);
|
||||
tsiq = thread_status[i].queue;
|
||||
pthread_mutex_unlock (&thread_status[i].lock);
|
||||
while(tsiq) {
|
||||
i ++;
|
||||
if (i >= blas_num_threads - 1) i = 0;
|
||||
pthread_mutex_lock (&thread_status[i].lock);
|
||||
tsiq = thread_status[i].queue;
|
||||
pthread_mutex_unlock (&thread_status[i].lock);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -960,14 +966,10 @@ int BLASFUNC(blas_thread_shutdown)(void){
|
|||
|
||||
for (i = 0; i < blas_num_threads - 1; i++) {
|
||||
|
||||
blas_lock(&exec_queue_lock);
|
||||
pthread_mutex_lock (&thread_status[i].lock);
|
||||
|
||||
thread_status[i].queue = (blas_queue_t *)-1;
|
||||
|
||||
blas_unlock(&exec_queue_lock);
|
||||
|
||||
pthread_mutex_lock (&thread_status[i].lock);
|
||||
|
||||
thread_status[i].status = THREAD_STATUS_WAKEUP;
|
||||
|
||||
pthread_cond_signal (&thread_status[i].wakeup);
|
||||
|
|
|
@ -1056,12 +1056,13 @@ void *blas_memory_alloc(int procpos){
|
|||
|
||||
do {
|
||||
if (!memory[position].used && (memory[position].pos == mypos)) {
|
||||
|
||||
blas_lock(&memory[position].lock);
|
||||
LOCK_COMMAND(&alloc_lock);
|
||||
/* blas_lock(&memory[position].lock);*/
|
||||
|
||||
if (!memory[position].used) goto allocation;
|
||||
|
||||
blas_unlock(&memory[position].lock);
|
||||
UNLOCK_COMMAND(&alloc_lock);
|
||||
/* blas_unlock(&memory[position].lock);*/
|
||||
}
|
||||
|
||||
position ++;
|
||||
|
@ -1075,12 +1076,13 @@ void *blas_memory_alloc(int procpos){
|
|||
|
||||
do {
|
||||
/* if (!memory[position].used) { */
|
||||
|
||||
blas_lock(&memory[position].lock);
|
||||
LOCK_COMMAND(&alloc_lock);
|
||||
/* blas_lock(&memory[position].lock);*/
|
||||
|
||||
if (!memory[position].used) goto allocation;
|
||||
|
||||
blas_unlock(&memory[position].lock);
|
||||
|
||||
UNLOCK_COMMAND(&alloc_lock);
|
||||
/* blas_unlock(&memory[position].lock);*/
|
||||
/* } */
|
||||
|
||||
position ++;
|
||||
|
@ -1097,7 +1099,8 @@ void *blas_memory_alloc(int procpos){
|
|||
|
||||
memory[position].used = 1;
|
||||
|
||||
blas_unlock(&memory[position].lock);
|
||||
UNLOCK_COMMAND(&alloc_lock);
|
||||
/* blas_unlock(&memory[position].lock);*/
|
||||
|
||||
if (!memory[position].addr) {
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue