Browse Source

Merge pull request #3703 from martin-frbg/omp_adaptive

Add env variable OMP_ADAPTIVE to control OMP threadpool behaviour
tags/v0.3.21
Martin Kroeker GitHub 3 years ago
parent
commit
19fefd100e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions
  1. +12
    -0
      driver/others/blas_server_omp.c
  2. +7
    -0
      driver/others/openblas_env.c

+ 12
- 0
driver/others/blas_server_omp.c View File

@@ -403,6 +403,7 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){
break;
}

if (openblas_omp_adaptive_env() != 0) {
#pragma omp parallel for num_threads(num) schedule(OMP_SCHED)
for (i = 0; i < num; i ++) {

@@ -412,6 +413,17 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){

exec_threads(&queue[i], buf_index);
}
} else {
#pragma omp parallel for schedule(OMP_SCHED)
for (i = 0; i < num; i ++) {

#ifndef USE_SIMPLE_THREADED_LEVEL3
queue[i].position = i;
#endif

exec_threads(&queue[i], buf_index);
}
}

#ifdef HAVE_C11
atomic_store(&blas_buffer_inuse[buf_index], false);


+ 7
- 0
driver/others/openblas_env.c View File

@@ -39,6 +39,7 @@ static int openblas_env_block_factor=0;
static int openblas_env_openblas_num_threads=0;
static int openblas_env_goto_num_threads=0;
static int openblas_env_omp_num_threads=0;
static int openblas_env_omp_adaptive=0;

int openblas_verbose() { return openblas_env_verbose;}
unsigned int openblas_thread_timeout() { return openblas_env_thread_timeout;}
@@ -46,6 +47,7 @@ int openblas_block_factor() { return openblas_env_block_factor;}
int openblas_num_threads_env() { return openblas_env_openblas_num_threads;}
int openblas_goto_num_threads_env() { return openblas_env_goto_num_threads;}
int openblas_omp_num_threads_env() { return openblas_env_omp_num_threads;}
int openblas_omp_adaptive_env() { return openblas_env_omp_adaptive;}

void openblas_read_env() {
int ret=0;
@@ -79,6 +81,11 @@ void openblas_read_env() {
if(ret<0) ret=0;
openblas_env_omp_num_threads=ret;

ret=0;
if (readenv(p,"OMP_ADAPTIVE")) ret = atoi(p);
if(ret<0) ret=0;
openblas_env_omp_adaptive=ret;

}



Loading…
Cancel
Save