Skip to content

Commit 552119c

Browse files
committed
Fixed #407. Support outputing the CPU corename on runtime.
The user can use char * openblas_get_config() or char * openblas_get_corename().
1 parent 94d3cfa commit 552119c

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

cblas.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ void goto_set_num_threads(int num_threads);
1616
/*Get the build configure on runtime.*/
1717
char* openblas_get_config(void);
1818

19+
/*Get the CPU corename on runtime.*/
20+
char* openblas_get_corename(void);
21+
1922
/* Get the parallelization type which is used by OpenBLAS */
2023
int openblas_get_parallel(void);
2124
/* OpenBLAS is compiled for sequential use */

driver/others/openblas_get_config.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232

3333
#include "common.h"
3434

35+
#include <string.h>
36+
3537
static char* openblas_config_str=""
3638
#ifdef USE64BITINT
3739
"USE64BITINT "
@@ -50,10 +52,33 @@ static char* openblas_config_str=""
5052
#endif
5153
#ifdef NO_AFFINITY
5254
"NO_AFFINITY "
55+
#endif
56+
#ifndef DYNAMIC_ARCH
57+
CHAR_CORENAME
5358
#endif
5459
;
5560

61+
#ifdef DYNAMIC_ARCH
62+
char *gotoblas_corename();
63+
static char tmp_config_str[256];
64+
#endif
65+
66+
5667
char* CNAME() {
68+
#ifndef DYNAMIC_ARCH
5769
return openblas_config_str;
70+
#else
71+
strcpy(tmp_config_str, openblas_config_str);
72+
strcat(tmp_config_str, gotoblas_corename());
73+
return tmp_config_str;
74+
#endif
5875
}
5976

77+
78+
char* openblas_get_corename() {
79+
#ifndef DYNAMIC_ARCH
80+
return CHAR_CORENAME;
81+
#else
82+
return gotoblas_corename();
83+
#endif
84+
}

exports/gensymbol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
@misc_no_underscore_objs = (
8686
goto_set_num_threads,
8787
openblas_get_config,
88+
openblas_get_corename,
8889
);
8990

9091
@misc_underscore_objs = (

getarch.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,15 @@ int main(int argc, char *argv[]){
952952
#else
953953
get_cpuconfig();
954954
#endif
955+
956+
#ifdef FORCE
957+
printf("#define CHAR_CORENAME \"%s\"\n", CORENAME);
958+
#else
959+
#if defined(__i386__) || defined(__x86_64__) || defined(POWER) || defined(__mips__) || defined(__arm__)
960+
printf("#define CHAR_CORENAME \"%s\"\n", get_corename());
961+
#endif
962+
#endif
963+
955964
break;
956965

957966
case '2' : /* SMP */

0 commit comments

Comments
 (0)