Skip to content

Commit 0f863f9

Browse files
authored
Merge pull request #112 from xianyi/develop
rebase
2 parents 0269922 + 437702e commit 0f863f9

File tree

127 files changed

+20068
-76
lines changed

Some content is hidden

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

127 files changed

+20068
-76
lines changed

Makefile.install

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ OPENBLAS_INCLUDE_DIR := $(PREFIX)/include
99
OPENBLAS_LIBRARY_DIR := $(PREFIX)/lib
1010
OPENBLAS_BINARY_DIR := $(PREFIX)/bin
1111
OPENBLAS_BUILD_DIR := $(CURDIR)
12-
OPENBLAS_CMAKE_DIR := $(OPENBLAS_LIBRARY_DIR)/cmake/openblas
12+
OPENBLAS_CMAKE_DIR := $(OPENBLAS_LIBRARY_DIR)/cmake/$(LIBSONAMEBASE)
1313
OPENBLAS_CMAKE_CONFIG := OpenBLASConfig.cmake
1414
OPENBLAS_CMAKE_CONFIG_VERSION := OpenBLASConfigVersion.cmake
1515
OPENBLAS_PKGCONFIG_DIR := $(OPENBLAS_LIBRARY_DIR)/pkgconfig
@@ -150,13 +150,13 @@ endif
150150
endif
151151

152152
#Generating openblas.pc
153-
@echo Generating openblas.pc in "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)"
154-
@echo 'libdir='$(OPENBLAS_LIBRARY_DIR) > "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
155-
@echo 'includedir='$(OPENBLAS_INCLUDE_DIR) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
156-
@echo 'openblas_config= USE_64BITINT='$(USE_64BITINT) 'DYNAMIC_ARCH='$(DYNAMIC_ARCH) 'DYNAMIC_OLDER='$(DYNAMIC_OLDER) 'NO_CBLAS='$(NO_CBLAS) 'NO_LAPACK='$(NO_LAPACK) 'NO_LAPACKE='$(NO_LAPACKE) 'NO_AFFINITY='$(NO_AFFINITY) 'USE_OPENMP='$(USE_OPENMP) $(CORE) 'MAX_THREADS='$(NUM_THREADS)>> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
157-
@echo 'version='$(VERSION) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
158-
@echo 'extralib='$(PKG_EXTRALIB) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
159-
@cat openblas.pc.in >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/openblas.pc"
153+
@echo Generating $(LIBSONAMEBASE).pc in "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)"
154+
@echo 'libdir='$(OPENBLAS_LIBRARY_DIR) > "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
155+
@echo 'includedir='$(OPENBLAS_INCLUDE_DIR) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
156+
@echo 'openblas_config= USE_64BITINT='$(USE_64BITINT) 'DYNAMIC_ARCH='$(DYNAMIC_ARCH) 'DYNAMIC_OLDER='$(DYNAMIC_OLDER) 'NO_CBLAS='$(NO_CBLAS) 'NO_LAPACK='$(NO_LAPACK) 'NO_LAPACKE='$(NO_LAPACKE) 'NO_AFFINITY='$(NO_AFFINITY) 'USE_OPENMP='$(USE_OPENMP) $(CORE) 'MAX_THREADS='$(NUM_THREADS)>> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
157+
@echo 'version='$(VERSION) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
158+
@echo 'extralib='$(PKG_EXTRALIB) >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
159+
@cat openblas.pc.in >> "$(DESTDIR)$(OPENBLAS_PKGCONFIG_DIR)/$(LIBSONAMEBASE).pc"
160160

161161

162162
#Generating OpenBLASConfig.cmake

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: 14 additions & 3 deletions
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
@@ -1285,10 +1292,14 @@ ifndef SYMBOLSUFFIX
12851292
SYMBOLSUFFIX =
12861293
endif
12871294

1295+
ifndef LIBSONAMEBASE
1296+
LIBSONAMEBASE = openblas
1297+
endif
1298+
12881299
ifndef LIBNAMESUFFIX
1289-
LIBNAMEBASE = $(SYMBOLPREFIX)openblas$(SYMBOLSUFFIX)
1300+
LIBNAMEBASE = $(SYMBOLPREFIX)$(LIBSONAMEBASE)$(SYMBOLSUFFIX)
12901301
else
1291-
LIBNAMEBASE = $(SYMBOLPREFIX)openblas$(SYMBOLSUFFIX)_$(LIBNAMESUFFIX)
1302+
LIBNAMEBASE = $(SYMBOLPREFIX)$(LIBSONAMEBASE)$(SYMBOLSUFFIX)_$(LIBNAMESUFFIX)
12921303
endif
12931304

12941305
ifeq ($(OSNAME), CYGWIN_NT)

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");

cmake/cc.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ if (NOT DYNAMIC_ARCH)
124124
if (HAVE_AVX)
125125
set (CCOMMON_OPT "${CCOMMON_OPT} -mavx")
126126
endif ()
127+
if (HAVE_FMA3)
128+
set (CCOMMON_OPT "${CCOMMON_OPT} -mfma")
129+
endif ()
127130
if (HAVE_SSE)
128131
set (CCOMMON_OPT "${CCOMMON_OPT} -msse")
129132
endif ()

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

0 commit comments

Comments
 (0)