Browse Source

Refs #153. Restore the original CPU affinity when calling openblas_set_num_threads(1).

Please read the issue on github.com for the detail.
tags/v0.2.5
Zhang Xianyi 13 years ago
parent
commit
538c764d2b
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      driver/others/blas_server.c

+ 20
- 0
driver/others/blas_server.c View File

@@ -770,6 +770,19 @@ void goto_set_num_threads(int num_threads) {

if (num_threads < 1) num_threads = blas_num_threads;

#ifndef NO_AFFINITY
if (num_threads == 1) {
if (blas_cpu_number == 1){
//OpenBLAS is already single thread.
return;
}else{
//From multi-threads to single thread
//Restore the original affinity mask
gotoblas_set_affinity(-1);
}
}
#endif

if (num_threads > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER;

if (num_threads > blas_num_threads) {
@@ -800,6 +813,13 @@ void goto_set_num_threads(int num_threads) {
UNLOCK_COMMAND(&server_lock);
}

#ifndef NO_AFFINITY
if(blas_cpu_number == 1 && num_threads > 1){
//Restore the thread 0 affinity.
gotoblas_set_affinity(0);
}
#endif

blas_cpu_number = num_threads;

#if defined(ARCH_MIPS64)


Loading…
Cancel
Save