From 552119c48429c76a701600d05d3a1f472a41c65c Mon Sep 17 00:00:00 2001 From: Zhang Xianyi Date: Tue, 8 Jul 2014 12:48:08 +0800 Subject: [PATCH] Fixed #407. Support outputing the CPU corename on runtime. The user can use char * openblas_get_config() or char * openblas_get_corename(). --- cblas.h | 3 +++ driver/others/openblas_get_config.c | 25 +++++++++++++++++++++++++ exports/gensymbol | 1 + getarch.c | 9 +++++++++ 4 files changed, 38 insertions(+) diff --git a/cblas.h b/cblas.h index 841ad63..ef072e6 100644 --- a/cblas.h +++ b/cblas.h @@ -16,6 +16,9 @@ void goto_set_num_threads(int num_threads); /*Get the build configure on runtime.*/ char* openblas_get_config(void); +/*Get the CPU corename on runtime.*/ +char* openblas_get_corename(void); + /* Get the parallelization type which is used by OpenBLAS */ int openblas_get_parallel(void); /* OpenBLAS is compiled for sequential use */ diff --git a/driver/others/openblas_get_config.c b/driver/others/openblas_get_config.c index d8da2e3..0fecbf9 100644 --- a/driver/others/openblas_get_config.c +++ b/driver/others/openblas_get_config.c @@ -32,6 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "common.h" +#include + static char* openblas_config_str="" #ifdef USE64BITINT "USE64BITINT " @@ -51,9 +53,32 @@ static char* openblas_config_str="" #ifdef NO_AFFINITY "NO_AFFINITY " #endif +#ifndef DYNAMIC_ARCH + CHAR_CORENAME +#endif ; +#ifdef DYNAMIC_ARCH +char *gotoblas_corename(); +static char tmp_config_str[256]; +#endif + + char* CNAME() { +#ifndef DYNAMIC_ARCH return openblas_config_str; +#else + strcpy(tmp_config_str, openblas_config_str); + strcat(tmp_config_str, gotoblas_corename()); + return tmp_config_str; +#endif } + +char* openblas_get_corename() { +#ifndef DYNAMIC_ARCH + return CHAR_CORENAME; +#else + return gotoblas_corename(); +#endif +} diff --git a/exports/gensymbol b/exports/gensymbol index 2b8d943..0769ae0 100644 --- a/exports/gensymbol +++ b/exports/gensymbol @@ -85,6 +85,7 @@ @misc_no_underscore_objs = ( goto_set_num_threads, openblas_get_config, + openblas_get_corename, ); @misc_underscore_objs = ( diff --git a/getarch.c b/getarch.c index 234f7e1..3e99142 100644 --- a/getarch.c +++ b/getarch.c @@ -952,6 +952,15 @@ int main(int argc, char *argv[]){ #else get_cpuconfig(); #endif + +#ifdef FORCE + printf("#define CHAR_CORENAME \"%s\"\n", CORENAME); +#else +#if defined(__i386__) || defined(__x86_64__) || defined(POWER) || defined(__mips__) || defined(__arm__) + printf("#define CHAR_CORENAME \"%s\"\n", get_corename()); +#endif +#endif + break; case '2' : /* SMP */ -- 2.7.4