Skip to content

Commit 05a0ea2

Browse files
committed
Merge branch 'risc-v' into develop
2 parents 6dd71af + 7037849 commit 05a0ea2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+19586
-1
lines changed

Makefile.prebuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ ifeq ($(TARGET), I6500)
4141
TARGET_FLAGS = -mips64r6
4242
endif
4343

44+
ifeq ($(TARGET), C910V)
45+
TARGET_FLAGS = -march=rv64gcvxthead -mabi=lp64v
46+
endif
47+
4448
all: getarch_2nd
4549
./getarch_2nd 0 >> $(TARGET_MAKE)
4650
./getarch_2nd 1 >> $(TARGET_CONF)

Makefile.riscv64

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ifeq ($(CORE), C910V)
2+
CCOMMON_OPT += -march=rv64gcvxthead -mabi=lp64v
3+
FCOMMON_OPT += -march=rv64gcvxthead -mabi=lp64v -static
4+
endif

Makefile.system

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,10 @@ endif
751751
endif
752752
endif
753753

754-
754+
ifeq ($(ARCH), riscv64)
755+
NO_BINARY_MODE = 1
756+
BINARY_DEFINED = 1
757+
endif
755758

756759

757760
#
@@ -833,7 +836,9 @@ endif
833836
ifndef BINARY_DEFINED
834837
ifneq ($(OSNAME), AIX)
835838
ifdef BINARY64
839+
ifneq ($(ARCH), riscv64)
836840
CCOMMON_OPT += -m64
841+
endif
837842
else
838843
CCOMMON_OPT += -m32
839844
endif
@@ -954,8 +959,10 @@ endif
954959
else
955960
ifdef BINARY64
956961
ifneq ($(OSNAME), AIX)
962+
ifneq ($(ARCH), riscv64)
957963
FCOMMON_OPT += -m64
958964
endif
965+
endif
959966
ifdef INTERFACE64
960967
ifneq ($(INTERFACE64), 0)
961968
FCOMMON_OPT += -fdefault-integer-8

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ Please read `GotoBLAS_01Readme.txt` for older CPU models already supported by th
172172
- **Z13**: Optimized Level-3 BLAS and Level-1,2
173173
- **Z14**: Optimized Level-3 BLAS and (single precision) Level-1,2
174174

175+
#### RISC-V
176+
177+
- **C910V**: Optimized Leve-3 BLAS (real) and Level-1,2 by RISC-V Vector extension 0.7.1.
178+
```sh
179+
make HOSTCC=gcc TARGET=C910V CC=riscv64-unknown-linux-gnu-gcc FC=riscv64-unknown-linux-gnu-gfortran
180+
```
181+
175182
### Support for multiple targets in a single library
176183

177184
OpenBLAS can be built for multiple targets with runtime detection of the target cpu by specifiying `DYNAMIC_ARCH=1` in Makefile.rule, on the gmake command line or as `-DDYNAMIC_ARCH=TRUE` in cmake.

TargetList.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,8 @@ VORTEX
104104
ZARCH_GENERIC
105105
Z13
106106
Z14
107+
108+
10.RISC-V 64:
109+
RISCV64_GENERIC
110+
C910V
111+

c_check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ $architecture = ia64 if ($data =~ /ARCH_IA64/);
9292
$architecture = arm if ($data =~ /ARCH_ARM/);
9393
$architecture = arm64 if ($data =~ /ARCH_ARM64/);
9494
$architecture = zarch if ($data =~ /ARCH_ZARCH/);
95+
$architecture = riscv64 if ($data =~ /ARCH_RISCV64/);
9596

9697
$defined = 0;
9798

@@ -136,6 +137,11 @@ if (($architecture eq "x86") && ($os ne Darwin) && ($os ne SunOS)) {
136137
$binary =32;
137138
}
138139

140+
if ($architecture eq "riscv64") {
141+
$defined = 1;
142+
$binary = 64;
143+
}
144+
139145
if ($compiler eq "PGI") {
140146
$compiler_name .= " -tp p7" if ($binary eq "32");
141147
$compiler_name .= " -tp p7-64" if ($binary eq "64");

common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ please https://github.com/xianyi/OpenBLAS/issues/246
437437
#include "common_mips.h"
438438
#endif
439439

440+
441+
#ifdef ARCH_RISCV64
442+
#include "common_riscv64.h"
443+
#endif
444+
440445
#ifdef ARCH_MIPS64
441446
#include "common_mips64.h"
442447
#endif

common_riscv64.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*****************************************************************************
2+
Copyright (c) 2011-2014, 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+
/*********************************************************************/
34+
/* Copyright 2009, 2010 The University of Texas at Austin. */
35+
/* All rights reserved. */
36+
/* */
37+
/* Redistribution and use in source and binary forms, with or */
38+
/* without modification, are permitted provided that the following */
39+
/* conditions are met: */
40+
/* */
41+
/* 1. Redistributions of source code must retain the above */
42+
/* copyright notice, this list of conditions and the following */
43+
/* disclaimer. */
44+
/* */
45+
/* 2. Redistributions in binary form must reproduce the above */
46+
/* copyright notice, this list of conditions and the following */
47+
/* disclaimer in the documentation and/or other materials */
48+
/* provided with the distribution. */
49+
/* */
50+
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
51+
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
52+
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
53+
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
54+
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
55+
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
56+
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
57+
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
58+
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
59+
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
60+
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
61+
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
62+
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
63+
/* POSSIBILITY OF SUCH DAMAGE. */
64+
/* */
65+
/* The views and conclusions contained in the software and */
66+
/* documentation are those of the authors and should not be */
67+
/* interpreted as representing official policies, either expressed */
68+
/* or implied, of The University of Texas at Austin. */
69+
/*********************************************************************/
70+
71+
#ifndef COMMON_RISCV64
72+
#define COMMON_RISCV64
73+
74+
#define MB __sync_synchronize()
75+
#define WMB __sync_synchronize()
76+
#define RMB __sync_synchronize()
77+
78+
#define INLINE inline
79+
80+
#ifndef ASSEMBLER
81+
82+
83+
static inline int blas_quickdivide(blasint x, blasint y){
84+
return x / y;
85+
}
86+
87+
#endif
88+
89+
90+
91+
#define BUFFER_SIZE ( 32 << 20)
92+
#define SEEK_ADDRESS
93+
94+
#if defined(C910V)
95+
#include <riscv-vector.h>
96+
#endif
97+
98+
#endif

cpuid_riscv64.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*****************************************************************************
2+
Copyright (c) 2011-2014, 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+
34+
35+
/*********************************************************************/
36+
/* Copyright 2009, 2010 The University of Texas at Austin. */
37+
/* All rights reserved. */
38+
/* */
39+
/* Redistribution and use in source and binary forms, with or */
40+
/* without modification, are permitted provided that the following */
41+
/* conditions are met: */
42+
/* */
43+
/* 1. Redistributions of source code must retain the above */
44+
/* copyright notice, this list of conditions and the following */
45+
/* disclaimer. */
46+
/* */
47+
/* 2. Redistributions in binary form must reproduce the above */
48+
/* copyright notice, this list of conditions and the following */
49+
/* disclaimer in the documentation and/or other materials */
50+
/* provided with the distribution. */
51+
/* */
52+
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
53+
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
54+
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
55+
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
56+
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
57+
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
58+
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
59+
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
60+
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
61+
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
62+
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
63+
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
64+
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
65+
/* POSSIBILITY OF SUCH DAMAGE. */
66+
/* */
67+
/* The views and conclusions contained in the software and */
68+
/* documentation are those of the authors and should not be */
69+
/* interpreted as representing official policies, either expressed */
70+
/* or implied, of The University of Texas at Austin. */
71+
/*********************************************************************/
72+
73+
#define CPU_UNKNOWN 0
74+
#define CPU_C910V 1
75+
76+
static char *cpuname[] = {
77+
"UNKOWN",
78+
"C910V"
79+
};
80+
81+
int detect(void){
82+
return CPU_UNKNOWN;
83+
}
84+
85+
char *get_corename(void){
86+
return cpuname[detect()];
87+
}
88+
89+
void get_architecture(void){
90+
printf("RISCV64");
91+
}
92+
93+
void get_subarchitecture(void){
94+
}
95+
96+
void get_subdirname(void){
97+
printf("riscv64");
98+
}
99+
100+
void get_cpuconfig(void){
101+
printf("#define UNKNOWN\n");
102+
printf("#define L1_DATA_SIZE 65536\n");
103+
printf("#define L1_DATA_LINESIZE 32\n");
104+
printf("#define L2_SIZE 512488\n");
105+
printf("#define L2_LINESIZE 32\n");
106+
printf("#define DTB_DEFAULT_ENTRIES 64\n");
107+
printf("#define DTB_SIZE 4096\n");
108+
printf("#define L2_ASSOCIATIVE 4\n");
109+
}
110+
111+
void get_libname(void){
112+
printf("riscv64\n");
113+
}

ctest.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ ARCH_ARM
153153
ARCH_ARM64
154154
#endif
155155

156+
#if defined(__riscv)
157+
ARCH_RISCV64
158+
#endif
159+
156160
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
157161
HAVE_C11
158162
#endif
163+

0 commit comments

Comments
 (0)