Fixed #10. Supported GOTO_NUM_THREADS & GOTO_THREADS_TIMEOUT environment variables.

This commit is contained in:
Xianyi Zhang
2011-02-24 15:16:21 +08:00
parent cd2cbabecc
commit 128418f49b
5 changed files with 35 additions and 5 deletions

View File

@@ -525,7 +525,16 @@ int blas_thread_init(void){
if (thread_timeout < 4) thread_timeout = 4;
if (thread_timeout > 30) thread_timeout = 30;
thread_timeout = (1 << thread_timeout);
}
}else{
p = getenv("GOTO_THREAD_TIMEOUT");
if (p) {
thread_timeout = atoi(p);
if (thread_timeout < 4) thread_timeout = 4;
if (thread_timeout > 30) thread_timeout = 30;
thread_timeout = (1 << thread_timeout);
}
}
for(i = 0; i < blas_num_threads - 1; i++){
@@ -790,6 +799,11 @@ void goto_set_num_threads(int num_threads) {
}
void openblas_set_num_threads(int num_threads) {
goto_set_num_threads(num_threads);
}
/* Compatible function with pthread_create / join */
int gotoblas_pthread(int numthreads, void *function, void *args, int stride) {

View File

@@ -581,6 +581,7 @@ void gotoblas_affinity_init(void) {
numprocs = 0;
#else
numprocs = readenv("OPENBLAS_NUM_THREADS");
if (numprocs == 0) numprocs = readenv("GOTO_NUM_THREADS");
#endif
if (numprocs == 0) numprocs = readenv("OMP_NUM_THREADS");
@@ -666,7 +667,7 @@ void gotoblas_affinity_init(void) {
setup_mempolicy();
if (readenv("OPENBLAS_MAIN_FREE")) {
if (readenv("OPENBLAS_MAIN_FREE") || readenv("GOTOBLAS_MAIN_FREE")) {
sched_setaffinity(0, sizeof(cpu_orig_mask), &cpu_orig_mask[0]);
}

View File

@@ -231,6 +231,13 @@ int blas_get_cpu_number(void){
p = getenv("OPENBLAS_NUM_THREADS");
if (p) blas_goto_num = atoi(p);
if (blas_goto_num < 0) blas_goto_num = 0;
if (blas_goto_num == 0) {
p = getenv("GOTO_NUM_THREADS");
if (p) blas_goto_num = atoi(p);
if (blas_goto_num < 0) blas_goto_num = 0;
}
#endif
blas_omp_num = 0;