Skip to content

Commit 19fefd1

Browse files
authored
Merge pull request #3703 from martin-frbg/omp_adaptive
Add env variable OMP_ADAPTIVE to control OMP threadpool behaviour
2 parents 2e51a61 + 80cdfed commit 19fefd1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

driver/others/blas_server_omp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){
403403
break;
404404
}
405405

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

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

413414
exec_threads(&queue[i], buf_index);
414415
}
416+
} else {
417+
#pragma omp parallel for schedule(OMP_SCHED)
418+
for (i = 0; i < num; i ++) {
419+
420+
#ifndef USE_SIMPLE_THREADED_LEVEL3
421+
queue[i].position = i;
422+
#endif
423+
424+
exec_threads(&queue[i], buf_index);
425+
}
426+
}
415427

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

driver/others/openblas_env.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ static int openblas_env_block_factor=0;
3939
static int openblas_env_openblas_num_threads=0;
4040
static int openblas_env_goto_num_threads=0;
4141
static int openblas_env_omp_num_threads=0;
42+
static int openblas_env_omp_adaptive=0;
4243

4344
int openblas_verbose() { return openblas_env_verbose;}
4445
unsigned int openblas_thread_timeout() { return openblas_env_thread_timeout;}
4546
int openblas_block_factor() { return openblas_env_block_factor;}
4647
int openblas_num_threads_env() { return openblas_env_openblas_num_threads;}
4748
int openblas_goto_num_threads_env() { return openblas_env_goto_num_threads;}
4849
int openblas_omp_num_threads_env() { return openblas_env_omp_num_threads;}
50+
int openblas_omp_adaptive_env() { return openblas_env_omp_adaptive;}
4951

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

84+
ret=0;
85+
if (readenv(p,"OMP_ADAPTIVE")) ret = atoi(p);
86+
if(ret<0) ret=0;
87+
openblas_env_omp_adaptive=ret;
88+
8289
}
8390

8491

0 commit comments

Comments
 (0)