Skip to content

Commit ec89466

Browse files
committed
Add CSKY support
1 parent 13c764e commit ec89466

15 files changed

+325
-4
lines changed

Diff for: CONTRIBUTORS.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,7 @@ In chronological order:
218218
* [2022-08] Fix building from sources for QNX
219219

220220
* Mark Seminatore <https://github.com/mseminatore>
221-
* [2023-11-09] Improve Windows threading performance scaling
221+
* [2023-11-09] Improve Windows threading performance scaling
222+
223+
* Dirreke <https://github.com/mseminatore>
224+
* [2024-01-16] Add basic support for the CSKY architecture

Diff for: Makefile.csky

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ifeq ($(CORE), CK860FV)
2+
CCOMMON_OPT += -march=ck860v -mcpu=ck860fv -mfdivdu -mhard-float
3+
FCOMMON_OPT += -march=ck860v -mcpu=ck860fv -mfdivdu -mhard-float -static
4+
endif

Diff for: Makefile.prebuild

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ ifeq ($(TARGET), C910V)
5555
TARGET_FLAGS = -march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d
5656
endif
5757

58+
ifeq ($(TARGET), CK860FV)
59+
TARGET_FLAGS = -march=ck860v -mcpu=ck860fv -mfdivdu -mhard-float
60+
endif
61+
5862
all: getarch_2nd
5963
./getarch_2nd 0 >> $(TARGET_MAKE)
6064
./getarch_2nd 1 >> $(TARGET_CONF)

Diff for: Makefile.system

+5
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,11 @@ endif
873873
endif
874874
endif
875875

876+
ifeq ($(ARCH), csky)
877+
NO_BINARY_MODE = 1
878+
BINARY_DEFINED = 1
879+
endif
880+
876881
#
877882
# C Compiler dependent settings
878883
#

Diff for: TargetList.txt

+4
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,7 @@ E2K
133133
EV4
134134
EV5
135135
EV6
136+
137+
14.CSKY
138+
CSKY
139+
CK860FV

Diff for: c_check

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ case "$data" in
9191
*ARCH_ZARCH*) architecture=zarch ;;
9292
*ARCH_RISCV64*) architecture=riscv64 ;;
9393
*ARCH_LOONGARCH64*) architecture=loongarch64 ;;
94+
*ARCH_CSKY*) architecture=csky ;;
9495
esac
9596

9697
defined=0
@@ -236,6 +237,7 @@ case "$data" in
236237
*ARCH_ARM*) architecture=arm ;;
237238
*ARCH_ZARCH*) architecture=zarch ;;
238239
*ARCH_LOONGARCH64*) architecture=loongarch64 ;;
240+
*ARCH_CSKY*) architecture=csky ;;
239241
esac
240242

241243
binformat='bin32'

Diff for: c_check.pl

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
$architecture = zarch if ($data =~ /ARCH_ZARCH/);
9898
$architecture = riscv64 if ($data =~ /ARCH_RISCV64/);
9999
$architecture = loongarch64 if ($data =~ /ARCH_LOONGARCH64/);
100+
$architecture = csky if ($data =~ /ARCH_CSKY/);
100101

101102
$defined = 0;
102103

@@ -156,6 +157,11 @@
156157
$binary = 64;
157158
}
158159

160+
if ($architecture eq "csky") {
161+
$defined = 1;
162+
$binary = 32;
163+
}
164+
159165
if ($compiler eq "PGI") {
160166
$compiler_name .= " -tp p7" if ($binary eq "32");
161167
$compiler_name .= " -tp p7-64" if ($binary eq "64");
@@ -284,6 +290,7 @@
284290
$architecture = arm64 if ($data =~ /ARCH_ARM64/);
285291
$architecture = zarch if ($data =~ /ARCH_ZARCH/);
286292
$architecture = loongarch64 if ($data =~ /ARCH_LOONGARCH64/);
293+
$architecture = csky if ($data =~ /ARCH_CSKY/);
287294

288295
$binformat = bin32;
289296
$binformat = bin64 if ($data =~ /BINARY_64/);

Diff for: common.h

+4
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ please https://github.com/xianyi/OpenBLAS/issues/246
482482
#include "common_e2k.h"
483483
#endif
484484

485+
#ifdef ARCH_CSKY
486+
#include "common_csky.h"
487+
#endif
488+
485489
#ifndef ASSEMBLER
486490
#ifdef OS_WINDOWSSTORE
487491
typedef char env_var_t[MAX_PATH];

Diff for: common_csky.h

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*****************************************************************************
2+
Copyright (c) 2011-2015, The OpenBLAS Project
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are
7+
met:
8+
9+
1. Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright
13+
notice, this list of conditions and the following disclaimer in
14+
the documentation and/or other materials provided with the
15+
distribution.
16+
3. Neither the name of the OpenBLAS project nor the names of
17+
its contributors may be used to endorse or promote products
18+
derived from this software without specific prior written
19+
permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
**********************************************************************************/
32+
33+
#ifndef COMMON_CSKY
34+
#define COMMON_CSKY
35+
36+
#define MB __sync_synchronize()
37+
#define WMB __sync_synchronize()
38+
#define RMB __sync_synchronize()
39+
40+
#define INLINE inline
41+
42+
#ifndef ASSEMBLER
43+
44+
45+
static inline int blas_quickdivide(blasint x, blasint y){
46+
return x / y;
47+
}
48+
49+
#endif
50+
51+
52+
53+
#define BUFFER_SIZE ( 32 << 20)
54+
#define SEEK_ADDRESS
55+
56+
#endif

Diff for: ctest.c

+4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ HAVE_C11
173173
ARCH_E2K
174174
#endif
175175

176+
#if defined(__csky__)
177+
ARCH_CSKY
178+
#endif
179+
176180
#if defined(__EMSCRIPTEN__)
177181
ARCH_RISCV64
178182
OS_WINDOWS

Diff for: getarch.c

+31-3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
150150
/* #define FORCE_EV4 */
151151
/* #define FORCE_EV5 */
152152
/* #define FORCE_EV6 */
153+
/* #define FORCE_CSKY */
154+
/* #define FORCE_CK860FV */
153155
/* #define FORCE_GENERIC */
154156

155157
#ifdef FORCE_P2
@@ -1692,6 +1694,33 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16921694
#define CORENAME "generic"
16931695
#endif
16941696

1697+
#ifdef FORCE_CSKY
1698+
#define FORCE
1699+
#define ARCHITECTURE "CSKY"
1700+
#define SUBARCHITECTURE "CSKY"
1701+
#define SUBDIRNAME "csky"
1702+
#define ARCHCONFIG "-DCSKY" \
1703+
"-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
1704+
"-DL2_SIZE=524288 -DL2_LINESIZE=32 " \
1705+
"-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
1706+
#define LIBNAME "csky"
1707+
#define CORENAME "CSKY"
1708+
#endif
1709+
1710+
#ifdef FORCE_CK860FV
1711+
#define FORCE
1712+
#define ARCHITECTURE "CSKY"
1713+
#define SUBARCHITECTURE "CK860V"
1714+
#define SUBDIRNAME "csky"
1715+
#define ARCHCONFIG "-DCK860FV " \
1716+
"-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
1717+
"-DL2_SIZE=524288 -DL2_LINESIZE=32 " \
1718+
"-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
1719+
#define LIBNAME "ck860fv"
1720+
#define CORENAME "CK860FV"
1721+
#endif
1722+
1723+
16951724
#ifndef FORCE
16961725

16971726
#ifdef USER_TARGET
@@ -1766,7 +1795,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17661795
#define OPENBLAS_SUPPORTED
17671796
#endif
17681797

1769-
17701798
#ifndef OPENBLAS_SUPPORTED
17711799
#error "This arch/CPU is not supported by OpenBLAS."
17721800
#endif
@@ -1831,7 +1859,7 @@ int main(int argc, char *argv[]){
18311859
#ifdef FORCE
18321860
printf("CORE=%s\n", CORENAME);
18331861
#else
1834-
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) || defined(ZARCH) || defined(sparc) || defined(__loongarch__) || defined(__riscv) || defined(__alpha__)
1862+
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) || defined(ZARCH) || defined(sparc) || defined(__loongarch__) || defined(__riscv) || defined(__alpha__) || defined(__csky__)
18351863
printf("CORE=%s\n", get_corename());
18361864
#endif
18371865
#endif
@@ -1979,7 +2007,7 @@ printf("ELF_VERSION=2\n");
19792007
#ifdef FORCE
19802008
printf("#define CHAR_CORENAME \"%s\"\n", CORENAME);
19812009
#else
1982-
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) || defined(ZARCH) || defined(sparc) || defined(__loongarch__) || defined(__riscv)
2010+
#if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) || defined(ZARCH) || defined(sparc) || defined(__loongarch__) || defined(__riscv) || defined(__csky__)
19832011
printf("#define CHAR_CORENAME \"%s\"\n", get_corename());
19842012
#endif
19852013
#endif

Diff for: kernel/csky/KERNEL

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
SAMAXKERNEL = ../arm/amax.c
2+
DAMAXKERNEL = ../arm/amax.c
3+
CAMAXKERNEL = ../arm/zamax.c
4+
ZAMAXKERNEL = ../arm/zamax.c
5+
6+
SAMINKERNEL = ../arm/amin.c
7+
DAMINKERNEL = ../arm/amin.c
8+
CAMINKERNEL = ../arm/zamin.c
9+
ZAMINKERNEL = ../arm/zamin.c
10+
11+
SMAXKERNEL = ../arm/max.c
12+
DMAXKERNEL = ../arm/max.c
13+
14+
SMINKERNEL = ../arm/min.c
15+
DMINKERNEL = ../arm/min.c
16+
17+
ISAMAXKERNEL = ../arm/iamax.c
18+
IDAMAXKERNEL = ../arm/iamax.c
19+
ICAMAXKERNEL = ../arm/izamax.c
20+
IZAMAXKERNEL = ../arm/izamax.c
21+
22+
ISAMINKERNEL = ../arm/iamin.c
23+
IDAMINKERNEL = ../arm/iamin.c
24+
ICAMINKERNEL = ../arm/izamin.c
25+
IZAMINKERNEL = ../arm/izamin.c
26+
27+
ISMAXKERNEL = ../arm/imax.c
28+
IDMAXKERNEL = ../arm/imax.c
29+
30+
ISMINKERNEL = ../arm/imin.c
31+
IDMINKERNEL = ../arm/imin.c
32+
33+
SASUMKERNEL = ../arm/asum.c
34+
DASUMKERNEL = ../arm/asum.c
35+
CASUMKERNEL = ../arm/zasum.c
36+
ZASUMKERNEL = ../arm/zasum.c
37+
38+
SSUMKERNEL = ../arm/sum.c
39+
DSUMKERNEL = ../arm/sum.c
40+
CSUMKERNEL = ../arm/zsum.c
41+
ZSUMKERNEL = ../arm/zsum.c
42+
43+
SAXPYKERNEL = ../arm/axpy.c
44+
DAXPYKERNEL = ../arm/axpy.c
45+
CAXPYKERNEL = ../arm/zaxpy.c
46+
ZAXPYKERNEL = ../arm/zaxpy.c
47+
48+
SCOPYKERNEL = ../arm/copy.c
49+
DCOPYKERNEL = ../arm/copy.c
50+
CCOPYKERNEL = ../arm/zcopy.c
51+
ZCOPYKERNEL = ../arm/zcopy.c
52+
53+
SDOTKERNEL = ../arm/dot.c
54+
DDOTKERNEL = ../arm/dot.c
55+
CDOTKERNEL = ../arm/zdot.c
56+
ZDOTKERNEL = ../arm/zdot.c
57+
DSDOTKERNEL = ../generic/dot.c
58+
59+
SNRM2KERNEL = ../arm/nrm2.c
60+
DNRM2KERNEL = ../arm/nrm2.c
61+
CNRM2KERNEL = ../arm/znrm2.c
62+
ZNRM2KERNEL = ../arm/znrm2.c
63+
64+
SROTKERNEL = ../arm/rot.c
65+
DROTKERNEL = ../arm/rot.c
66+
CROTKERNEL = ../arm/zrot.c
67+
ZROTKERNEL = ../arm/zrot.c
68+
69+
SSCALKERNEL = ../arm/scal.c
70+
DSCALKERNEL = ../arm/scal.c
71+
CSCALKERNEL = ../arm/zscal.c
72+
ZSCALKERNEL = ../arm/zscal.c
73+
74+
SSWAPKERNEL = ../arm/swap.c
75+
DSWAPKERNEL = ../arm/swap.c
76+
CSWAPKERNEL = ../arm/zswap.c
77+
ZSWAPKERNEL = ../arm/zswap.c
78+
79+
SGEMVNKERNEL = ../arm/gemv_n.c
80+
DGEMVNKERNEL = ../arm/gemv_n.c
81+
CGEMVNKERNEL = ../arm/zgemv_n.c
82+
ZGEMVNKERNEL = ../arm/zgemv_n.c
83+
84+
SGEMVTKERNEL = ../arm/gemv_t.c
85+
DGEMVTKERNEL = ../arm/gemv_t.c
86+
CGEMVTKERNEL = ../arm/zgemv_t.c
87+
ZGEMVTKERNEL = ../arm/zgemv_t.c
88+
89+
STRMMKERNEL = ../generic/trmmkernel_2x2.c
90+
DTRMMKERNEL = ../generic/trmmkernel_2x2.c
91+
CTRMMKERNEL = ../generic/ztrmmkernel_2x2.c
92+
ZTRMMKERNEL = ../generic/ztrmmkernel_2x2.c
93+
94+
SGEMMKERNEL = ../generic/gemmkernel_2x2.c
95+
SGEMMONCOPY = ../generic/gemm_ncopy_2.c
96+
SGEMMOTCOPY = ../generic/gemm_tcopy_2.c
97+
SGEMMONCOPYOBJ = sgemm_oncopy$(TSUFFIX).$(SUFFIX)
98+
SGEMMOTCOPYOBJ = sgemm_otcopy$(TSUFFIX).$(SUFFIX)
99+
100+
DGEMMKERNEL = ../generic/gemmkernel_2x2.c
101+
DGEMMONCOPY = ../generic/gemm_ncopy_2.c
102+
DGEMMOTCOPY = ../generic/gemm_tcopy_2.c
103+
DGEMMONCOPYOBJ = dgemm_oncopy$(TSUFFIX).$(SUFFIX)
104+
DGEMMOTCOPYOBJ = dgemm_otcopy$(TSUFFIX).$(SUFFIX)
105+
106+
CGEMMKERNEL = ../generic/zgemmkernel_2x2.c
107+
CGEMMONCOPY = ../generic/zgemm_ncopy_2.c
108+
CGEMMOTCOPY = ../generic/zgemm_tcopy_2.c
109+
CGEMMONCOPYOBJ = cgemm_oncopy$(TSUFFIX).$(SUFFIX)
110+
CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)
111+
112+
ZGEMMKERNEL = ../generic/zgemmkernel_2x2.c
113+
ZGEMMONCOPY = ../generic/zgemm_ncopy_2.c
114+
ZGEMMOTCOPY = ../generic/zgemm_tcopy_2.c
115+
ZGEMMONCOPYOBJ = zgemm_oncopy$(TSUFFIX).$(SUFFIX)
116+
ZGEMMOTCOPYOBJ = zgemm_otcopy$(TSUFFIX).$(SUFFIX)
117+
118+
STRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
119+
STRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
120+
STRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
121+
STRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
122+
123+
DTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
124+
DTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
125+
DTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
126+
DTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
127+
128+
CTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
129+
CTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
130+
CTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
131+
CTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
132+
133+
ZTRSMKERNEL_LN = ../generic/trsm_kernel_LN.c
134+
ZTRSMKERNEL_LT = ../generic/trsm_kernel_LT.c
135+
ZTRSMKERNEL_RN = ../generic/trsm_kernel_RN.c
136+
ZTRSMKERNEL_RT = ../generic/trsm_kernel_RT.c
137+
138+
139+
SCABS_KERNEL = ../generic/cabs.c
140+
DCABS_KERNEL = ../generic/cabs.c
141+
QCABS_KERNEL = ../generic/cabs.c
142+
LSAME_KERNEL = ../generic/lsame.c
143+
144+
SGEMM_BETA = ../generic/gemm_beta.c
145+
DGEMM_BETA = ../generic/gemm_beta.c
146+
CGEMM_BETA = ../generic/zgemm_beta.c
147+
ZGEMM_BETA = ../generic/zgemm_beta.c
148+
149+

Diff for: kernel/csky/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
clean ::

0 commit comments

Comments
 (0)