|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2011-2016, The OpenBLAS Project |
| 3 | +All rights reserved. |
| 4 | +
|
| 5 | +Redistribution and use in source and binary forms, with or without |
| 6 | +modification, are permitted provided that the following conditions are |
| 7 | +met: |
| 8 | +
|
| 9 | + 1. Redistributions of source code must retain the above copyright |
| 10 | + notice, this list of conditions and the following disclaimer. |
| 11 | +
|
| 12 | + 2. Redistributions in binary form must reproduce the above copyright |
| 13 | + notice, this list of conditions and the following disclaimer in |
| 14 | + the documentation and/or other materials provided with the |
| 15 | + distribution. |
| 16 | +
|
| 17 | + 3. Neither the name of the OpenBLAS project nor the names of |
| 18 | + its contributors may be used to endorse or promote products |
| 19 | + derived from this software without specific prior written permission. |
| 20 | +
|
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE |
| 25 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 28 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 29 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 30 | +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | +
|
| 32 | +*****************************************************************************/ |
| 33 | + |
| 34 | +#include "common.h" |
| 35 | + |
| 36 | +static int openblas_env_verbose=0; |
| 37 | +static unsigned int openblas_env_thread_timeout=0; |
| 38 | +static int openblas_env_block_factor=0; |
| 39 | +static int openblas_env_openblas_num_threads=0; |
| 40 | +static int openblas_env_goto_num_threads=0; |
| 41 | +static int openblas_env_omp_num_threads=0; |
| 42 | + |
| 43 | +int openblas_verbose() { return openblas_env_verbose;} |
| 44 | +unsigned int openblas_thread_timeout() { return openblas_env_thread_timeout;} |
| 45 | +int openblas_block_factor() { return openblas_env_block_factor;} |
| 46 | +int openblas_num_threads_env() { return openblas_env_openblas_num_threads;} |
| 47 | +int openblas_goto_num_threads_env() { return openblas_env_goto_num_threads;} |
| 48 | +int openblas_omp_num_threads_env() { return openblas_env_omp_num_threads;} |
| 49 | + |
| 50 | +void openblas_read_env() { |
| 51 | + int ret=0; |
| 52 | + env_var_t p; |
| 53 | + if (readenv(p,"OPENBLAS_VERBOSE")) ret = atoi(p); |
| 54 | + if(ret<0) ret=0; |
| 55 | + openblas_env_verbose=ret; |
| 56 | + |
| 57 | + ret=0; |
| 58 | + if (readenv(p,"OPENBLAS_BLOCK_FACTOR")) ret = atoi(p); |
| 59 | + if(ret<0) ret=0; |
| 60 | + openblas_env_block_factor=ret; |
| 61 | + |
| 62 | + ret=0; |
| 63 | + if (readenv(p,"OPENBLAS_THREAD_TIMEOUT")) ret = atoi(p); |
| 64 | + if(ret<0) ret=0; |
| 65 | + openblas_env_thread_timeout=(unsigned int)ret; |
| 66 | + |
| 67 | + ret=0; |
| 68 | + if (readenv(p,"OPENBLAS_NUM_THREADS")) ret = atoi(p); |
| 69 | + if(ret<0) ret=0; |
| 70 | + openblas_env_openblas_num_threads=ret; |
| 71 | + |
| 72 | + ret=0; |
| 73 | + if (readenv(p,"GOTO_NUM_THREADS")) ret = atoi(p); |
| 74 | + if(ret<0) ret=0; |
| 75 | + openblas_env_goto_num_threads=ret; |
| 76 | + |
| 77 | + ret=0; |
| 78 | + if (readenv(p,"OMP_NUM_THREADS")) ret = atoi(p); |
| 79 | + if(ret<0) ret=0; |
| 80 | + openblas_env_omp_num_threads=ret; |
| 81 | + |
| 82 | +} |
| 83 | + |
| 84 | + |
0 commit comments