diff --git a/driver/others/Makefile b/driver/others/Makefile index 506388f03..d7a965c9a 100644 --- a/driver/others/Makefile +++ b/driver/others/Makefile @@ -1,7 +1,7 @@ TOPDIR = ../.. include ../../Makefile.system -COMMONOBJS = memory.$(SUFFIX) xerbla.$(SUFFIX) c_abs.$(SUFFIX) z_abs.$(SUFFIX) openblas_set_num_threads.$(SUFFIX) openblas_get_config.$(SUFFIX) openblas_get_parallel.$(SUFFIX) +COMMONOBJS = memory.$(SUFFIX) xerbla.$(SUFFIX) c_abs.$(SUFFIX) z_abs.$(SUFFIX) openblas_set_num_threads.$(SUFFIX) openblas_get_config.$(SUFFIX) openblas_get_parallel.$(SUFFIX) openblas_error_handle.$(SUFFIX) COMMONOBJS += slamch.$(SUFFIX) slamc3.$(SUFFIX) dlamch.$(SUFFIX) dlamc3.$(SUFFIX) @@ -109,6 +109,9 @@ openblas_get_config.$(SUFFIX) : openblas_get_config.c openblas_get_parallel.$(SUFFIX) : openblas_get_parallel.c $(CC) $(CFLAGS) -c $< -o $(@F) +openblas_error_handle.$(SUFFIX) : openblas_error_handle.c + $(CC) $(CFLAGS) -c $< -o $(@F) + blasL1thread.$(SUFFIX) : blas_l1_thread.c ../../common.h ../../common_thread.h $(CC) $(CFLAGS) -c $< -o $(@F) diff --git a/driver/others/dynamic.c b/driver/others/dynamic.c index 52b984f09..905efb1c6 100644 --- a/driver/others/dynamic.c +++ b/driver/others/dynamic.c @@ -38,6 +38,7 @@ #include "common.h" + #ifdef ARCH_X86 #define EXTERN extern #else @@ -108,6 +109,11 @@ int support_avx(){ #endif } +extern void openblas_warning(int verbose, const char * msg); +#define FALLBACK_VERBOSE 1 +#define NEHALEM_FALLBACK "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n" +#define BARCELONA_FALLBACK "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Barcelona kernels as a fallback, which may give poorer performance.\n" + static int get_vendor(void){ int eax, ebx, ecx, edx; char vendor[13]; @@ -179,7 +185,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_SANDYBRIDGE; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. } } @@ -190,7 +196,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_SANDYBRIDGE; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. } } @@ -199,7 +205,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_HASWELL; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. } } @@ -210,7 +216,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_HASWELL; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. } } @@ -248,7 +254,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_BULLDOZER; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Barcelona kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK); return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels. } }else if(model == 2){ @@ -256,7 +262,7 @@ static gotoblas_t *get_coretype(void){ if(support_avx()) return &gotoblas_PILEDRIVER; else{ - fprintf(stderr, "OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Barcelona kernels as a fallback, which may give poorer performance.\n"); + openblas_warning(FALLBACK_VERBOSE, BARCELONA_FALLBACK); return &gotoblas_BARCELONA; //OS doesn't support AVX. Use old kernels. } } @@ -351,7 +357,7 @@ void gotoblas_dynamic_init(void) { if (gotoblas && gotoblas -> init) { gotoblas -> init(); } else { - fprintf(stderr, "OpenBLAS : Architecture Initialization failed. No initialization function found.\n"); + openblas_warning(0, "OpenBLAS : Architecture Initialization failed. No initialization function found.\n"); exit(1); } diff --git a/driver/others/openblas_error_handle.c b/driver/others/openblas_error_handle.c new file mode 100644 index 000000000..2d8b9bd92 --- /dev/null +++ b/driver/others/openblas_error_handle.c @@ -0,0 +1,51 @@ +/*************************************************************************** +Copyright (c) 2013, The OpenBLAS Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*****************************************************************************/ + +#include "common.h" + +int openblas_verbose() { + int ret=0; + char *p; + p = getenv("OPENBLAS_VERBOSE"); + if (p) ret = atoi(p); + if(ret<0) ret=0; + return ret; +} + +void openblas_warning(int verbose, const char * msg) { + int current_verbose; + current_verbose=openblas_verbose(); + if(current_verbose >= verbose){ + fprintf(stderr, "%s", msg); + } +}