Fixed #407. Support outputing the CPU corename on runtime.

The user can use char * openblas_get_config() or char * openblas_get_corename().
This commit is contained in:
Zhang Xianyi 2014-07-08 12:48:08 +08:00
parent 94d3cfaa10
commit 552119c484
4 changed files with 38 additions and 0 deletions

View File

@ -16,6 +16,9 @@ void goto_set_num_threads(int num_threads);
/*Get the build configure on runtime.*/ /*Get the build configure on runtime.*/
char* openblas_get_config(void); 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 */ /* Get the parallelization type which is used by OpenBLAS */
int openblas_get_parallel(void); int openblas_get_parallel(void);
/* OpenBLAS is compiled for sequential use */ /* OpenBLAS is compiled for sequential use */

View File

@ -32,6 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "common.h" #include "common.h"
#include <string.h>
static char* openblas_config_str="" static char* openblas_config_str=""
#ifdef USE64BITINT #ifdef USE64BITINT
"USE64BITINT " "USE64BITINT "
@ -50,10 +52,33 @@ static char* openblas_config_str=""
#endif #endif
#ifdef NO_AFFINITY #ifdef NO_AFFINITY
"NO_AFFINITY " "NO_AFFINITY "
#endif
#ifndef DYNAMIC_ARCH
CHAR_CORENAME
#endif #endif
; ;
#ifdef DYNAMIC_ARCH
char *gotoblas_corename();
static char tmp_config_str[256];
#endif
char* CNAME() { char* CNAME() {
#ifndef DYNAMIC_ARCH
return openblas_config_str; 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
}

View File

@ -85,6 +85,7 @@
@misc_no_underscore_objs = ( @misc_no_underscore_objs = (
goto_set_num_threads, goto_set_num_threads,
openblas_get_config, openblas_get_config,
openblas_get_corename,
); );
@misc_underscore_objs = ( @misc_underscore_objs = (

View File

@ -952,6 +952,15 @@ int main(int argc, char *argv[]){
#else #else
get_cpuconfig(); get_cpuconfig();
#endif #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; break;
case '2' : /* SMP */ case '2' : /* SMP */