Skip to content

Commit a50b29c

Browse files
committed
Provide a fallback MIPS64_GENERIC target
It is really dangerous to fallback to Loongson core on other MIPS64 processors. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
1 parent b633eb7 commit a50b29c

File tree

7 files changed

+77
-37
lines changed

7 files changed

+77
-37
lines changed

Makefile.system

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ endif
677677
endif
678678

679679
ifeq ($(ARCH), mips64)
680-
DYNAMIC_CORE = LOONGSON3R3 LOONGSON3R4
680+
DYNAMIC_CORE = LOONGSON3R3 LOONGSON3R4 MIPS64_GENERIC
681681
endif
682682

683683
ifeq ($(ARCH), loongarch64)
@@ -856,6 +856,11 @@ CCOMMON_OPT += -mabi=32
856856
BINARY_DEFINED = 1
857857
endif
858858

859+
ifneq (, $(filter $(CORE), MIPS64_GENERIC))
860+
CCOMMON_OPT += -DNO_MSA
861+
FCOMMON_OPT += -DNO_MSA
862+
endif
863+
859864
ifneq (, $(filter $(CORE),LOONGSON3R3 LOONGSON3R4))
860865
CCOMMON_OPT += -march=loongson3a
861866
FCOMMON_OPT += -march=loongson3a

TargetList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ MIPS1004K
6565
MIPS24K
6666

6767
4.MIPS64 CPU:
68+
MIPS64_GENERIC
6869
SICORTEX
6970
LOONGSON3A
7071
LOONGSON3B

cpuid_mips64.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7070
/* or implied, of The University of Texas at Austin. */
7171
/*********************************************************************/
7272

73-
#define CPU_UNKNOWN 0
74-
#define CPU_SICORTEX 1
75-
#define CPU_LOONGSON3R3 2
76-
#define CPU_LOONGSON3R4 3
77-
#define CPU_I6400 4
78-
#define CPU_P6600 5
79-
#define CPU_I6500 6
73+
#define CPU_UNKNOWN 0
74+
#define CPU_MIPS64_GENERIC 1
75+
#define CPU_SICORTEX 2
76+
#define CPU_LOONGSON3R3 3
77+
#define CPU_LOONGSON3R4 4
78+
#define CPU_I6400 5
79+
#define CPU_P6600 6
80+
#define CPU_I6500 7
8081

8182
static char *cpuname[] = {
8283
"UNKNOWN",
84+
"MIPS64_GENERIC"
8385
"SICORTEX",
8486
"LOONGSON3R3",
8587
"LOONGSON3R4",
@@ -113,8 +115,11 @@ int detect(void){
113115
return CPU_SICORTEX;
114116
}
115117
}
118+
119+
return CPU_MIPS64_GENERIC;
120+
#else
121+
return CPU_UNKNOWN;
116122
#endif
117-
return CPU_UNKNOWN;
118123
}
119124

120125
char *get_corename(void){
@@ -136,9 +141,11 @@ void get_subarchitecture(void){
136141
printf("P6600");
137142
}else if(detect()==CPU_I6500){
138143
printf("I6500");
139-
}else{
144+
}else if(detect()==CPU_SICORTEX){
140145
printf("SICORTEX");
141-
}
146+
}else{
147+
printf("MIPS64_GENERIC");
148+
}
142149
}
143150

144151
void get_subdirname(void){
@@ -215,8 +222,8 @@ void get_libname(void){
215222
printf("p6600\n");
216223
}else if(detect()==CPU_I6500) {
217224
printf("i6500\n");
218-
}else{
219-
printf("mips64\n");
225+
}else {
226+
printf("mips64_generic\n");
220227
}
221228
}
222229

driver/others/dynamic_mips64.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,23 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4949

5050
extern gotoblas_t gotoblas_LOONGSON3R3;
5151
extern gotoblas_t gotoblas_LOONGSON3R4;
52+
extern gotoblas_t gotoblas_MIPS64_GENERIC;
5253

5354
extern void openblas_warning(int verbose, const char * msg);
5455

55-
#define NUM_CORETYPES 2
56+
#define NUM_CORETYPES 3
5657

5758
static char *corename[] = {
59+
"MIPS64_GENERIC"
5860
"loongson3r3",
5961
"loongson3r4",
6062
"UNKNOWN"
6163
};
6264

6365
char *gotoblas_corename(void) {
64-
if (gotoblas == &gotoblas_LOONGSON3R3) return corename[0];
65-
if (gotoblas == &gotoblas_LOONGSON3R4) return corename[1];
66+
if (gotoblas == &gotoblas_MIPS64_GENERIC) return corename[0];
67+
if (gotoblas == &gotoblas_LOONGSON3R3) return corename[1];
68+
if (gotoblas == &gotoblas_LOONGSON3R4) return corename[2];
6669
return corename[NUM_CORETYPES];
6770
}
6871

@@ -82,8 +85,9 @@ static gotoblas_t *force_coretype(char *coretype) {
8285

8386
switch (found)
8487
{
85-
case 0: return (&gotoblas_LOONGSON3R3);
86-
case 1: return (&gotoblas_LOONGSON3R4);
88+
case 0: return (&gotoblas_MIPS64_GENERIC);
89+
case 1: return (&gotoblas_LOONGSON3R3);
90+
case 2: return (&gotoblas_LOONGSON3R4);
8791
}
8892
snprintf(message, 128, "Core not found: %s\n", coretype);
8993
openblas_warning(1, message);
@@ -173,9 +177,9 @@ void gotoblas_dynamic_init(void) {
173177

174178
if (gotoblas == NULL)
175179
{
176-
snprintf(coremsg, 128, "Falling back to loongson3r3 core\n");
180+
snprintf(coremsg, 128, "Falling back to MIPS64_GENEIRC\n");
177181
openblas_warning(1, coremsg);
178-
gotoblas = &gotoblas_LOONGSON3R3;
182+
gotoblas = &gotoblas_MIPS64_GENERIC;
179183
}
180184

181185
if (gotoblas && gotoblas->init) {

getarch.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131131
/* #define FORCE_PPC440 */
132132
/* #define FORCE_PPC440FP2 */
133133
/* #define FORCE_CELL */
134+
/* #define FORCE_MIPS64_GENERIC */
134135
/* #define FORCE_SICORTEX */
135136
/* #define FORCE_LOONGSON3R3 */
136137
/* #define FORCE_LOONGSON3R4 */
@@ -915,6 +916,20 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
915916
#define CORENAME "CELL"
916917
#endif
917918

919+
#ifdef FORCE_MIPS64_GENERIC
920+
#define FORCE
921+
#define ARCHITECTURE "MIPS"
922+
#define SUBARCHITECTURE "MIPS64_GENERIC"
923+
#define SUBDIRNAME "mips64"
924+
#define ARCHCONFIG "-DMIPS64_GENERIC " \
925+
"-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
926+
"-DL2_SIZE=1048576 -DL2_LINESIZE=32 " \
927+
"-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
928+
#define LIBNAME "mips64_generic"
929+
#define CORENAME "MIPS64_GENERIC"
930+
#else
931+
#endif
932+
918933
#ifdef FORCE_SICORTEX
919934
#define FORCE
920935
#define ARCHITECTURE "MIPS"

kernel/mips64/KERNEL

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,50 +42,58 @@ endif
4242

4343
ifndef SGEMMKERNEL
4444
SGEMMKERNEL = gemm_kernel.S
45+
ifneq ($(SGEMM_UNROLL_M), $(SGEMM_UNROLL_N))
4546
SGEMMINCOPY = ../generic/gemm_ncopy_2.c
4647
SGEMMITCOPY = ../generic/gemm_tcopy_2.c
48+
SGEMMINCOPYOBJ = sgemm_incopy$(TSUFFIX).$(SUFFIX)
49+
SGEMMITCOPYOBJ = sgemm_itcopy$(TSUFFIX).$(SUFFIX)
50+
endif
4751
SGEMMONCOPY = ../generic/gemm_ncopy_8.c
4852
SGEMMOTCOPY = ../generic/gemm_tcopy_8.c
49-
SGEMMINCOPYOBJ = sgemm_incopy.o
50-
SGEMMITCOPYOBJ = sgemm_itcopy.o
51-
SGEMMONCOPYOBJ = sgemm_oncopy.o
52-
SGEMMOTCOPYOBJ = sgemm_otcopy.o
53+
SGEMMONCOPYOBJ = sgemm_oncopy$(TSUFFIX).$(SUFFIX)
54+
SGEMMOTCOPYOBJ = sgemm_otcopy$(TSUFFIX).$(SUFFIX)
5355
endif
5456

5557
ifndef DGEMMKERNEL
5658
DGEMMKERNEL = gemm_kernel.S
59+
ifneq ($(DGEMM_UNROLL_M), $(DGEMM_UNROLL_N))
5760
DGEMMINCOPY = ../generic/gemm_ncopy_2.c
5861
DGEMMITCOPY = ../generic/gemm_tcopy_2.c
62+
DGEMMINCOPYOBJ = dgemm_incopy$(TSUFFIX).$(SUFFIX)
63+
DGEMMITCOPYOBJ = dgemm_itcopy$(TSUFFIX).$(SUFFIX)
64+
endif
5965
DGEMMONCOPY = ../generic/gemm_ncopy_8.c
6066
DGEMMOTCOPY = ../generic/gemm_tcopy_8.c
61-
DGEMMINCOPYOBJ = dgemm_incopy.o
62-
DGEMMITCOPYOBJ = dgemm_itcopy.o
63-
DGEMMONCOPYOBJ = dgemm_oncopy.o
64-
DGEMMOTCOPYOBJ = dgemm_otcopy.o
67+
DGEMMONCOPYOBJ = dgemm_oncopy$(TSUFFIX).$(SUFFIX)
68+
DGEMMOTCOPYOBJ = dgemm_otcopy$(TSUFFIX).$(SUFFIX)
6569
endif
6670

6771
ifndef CGEMMKERNEL
6872
CGEMMKERNEL = zgemm_kernel.S
73+
ifneq ($(CGEMM_UNROLL_M), $(CGEMM_UNROLL_N))
6974
CGEMMINCOPY = ../generic/zgemm_ncopy_1.c
7075
CGEMMITCOPY = ../generic/zgemm_tcopy_1.c
76+
CGEMMINCOPYOBJ = cgemm_incopy$(TSUFFIX).$(SUFFIX)
77+
CGEMMITCOPYOBJ = cgemm_itcopy$(TSUFFIX).$(SUFFIX)
78+
endif
7179
CGEMMONCOPY = ../generic/zgemm_ncopy_4.c
7280
CGEMMOTCOPY = ../generic/zgemm_tcopy_4.c
73-
CGEMMINCOPYOBJ = cgemm_incopy.o
74-
CGEMMITCOPYOBJ = cgemm_itcopy.o
75-
CGEMMONCOPYOBJ = cgemm_oncopy.o
76-
CGEMMOTCOPYOBJ = cgemm_otcopy.o
81+
CGEMMONCOPYOBJ = cgemm_oncopy$(TSUFFIX).$(SUFFIX)
82+
CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
7783
endif
7884

7985
ifndef ZGEMMKERNEL
8086
ZGEMMKERNEL = zgemm_kernel.S
87+
ifneq ($(ZGEMM_UNROLL_M), $(ZGEMM_UNROLL_N))
8188
ZGEMMINCOPY = ../generic/zgemm_ncopy_1.c
8289
ZGEMMITCOPY = ../generic/zgemm_tcopy_1.c
90+
ZGEMMINCOPYOBJ = zgemm_incopy$(TSUFFIX).$(SUFFIX)
91+
ZGEMMITCOPYOBJ = zgemm_itcopy$(TSUFFIX).$(SUFFIX)
92+
endif
8393
ZGEMMONCOPY = ../generic/zgemm_ncopy_4.c
8494
ZGEMMOTCOPY = ../generic/zgemm_tcopy_4.c
85-
ZGEMMINCOPYOBJ = zgemm_incopy.o
86-
ZGEMMITCOPYOBJ = zgemm_itcopy.o
87-
ZGEMMONCOPYOBJ = zgemm_oncopy.o
88-
ZGEMMOTCOPYOBJ = zgemm_otcopy.o
95+
ZGEMMONCOPYOBJ = zgemm_oncopy$(TSUFFIX).$(SUFFIX)
96+
ZGEMMOTCOPYOBJ = zgemm_otcopy$(TSUFFIX).$(SUFFIX)
8997
endif
9098

9199
ifndef SGEMM_BETA

param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29452945
#define SYMV_P 16
29462946
#endif
29472947

2948-
#if defined(P5600) || defined(MIPS1004K) || defined(MIPS24K) || defined(I6400) || defined(P6600) || defined(I6500)
2948+
#if defined(MIPS64_GENERIC) || defined(P5600) || defined(MIPS1004K) || defined(MIPS24K) || defined(I6400) || defined(P6600) || defined(I6500)
29492949
#define SNUMOPT 2
29502950
#define DNUMOPT 2
29512951

0 commit comments

Comments
 (0)