Refs #153. Restore the original CPU affinity when calling openblas_set_num_threads(1).
Please read the issue on github.com for the detail.
This commit is contained in:
parent
0f26a21624
commit
538c764d2b
|
@ -770,6 +770,19 @@ void goto_set_num_threads(int num_threads) {
|
||||||
|
|
||||||
if (num_threads < 1) num_threads = blas_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 > MAX_CPU_NUMBER) num_threads = MAX_CPU_NUMBER;
|
||||||
|
|
||||||
if (num_threads > blas_num_threads) {
|
if (num_threads > blas_num_threads) {
|
||||||
|
@ -800,6 +813,13 @@ void goto_set_num_threads(int num_threads) {
|
||||||
UNLOCK_COMMAND(&server_lock);
|
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;
|
blas_cpu_number = num_threads;
|
||||||
|
|
||||||
#if defined(ARCH_MIPS64)
|
#if defined(ARCH_MIPS64)
|
||||||
|
|
Loading…
Reference in New Issue