Skip to content

Commit 018dec8

Browse files
authored
Merge pull request #7 from xianyi/develop
rebase
2 parents 9b3965b + 5d6209e commit 018dec8

13 files changed

+330
-24
lines changed

Makefile.system

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ ifeq ($(ARCH), amd64)
2121
override ARCH=x86_64
2222
else ifeq ($(ARCH), powerpc64)
2323
override ARCH=power
24+
else ifeq ($(ARCH), powerpc64le)
25+
override ARCH=power
2426
else ifeq ($(ARCH), powerpc)
2527
override ARCH=power
2628
else ifeq ($(ARCH), i386)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ Drone CI: [![Build Status](https://cloud.drone.io/api/badges/xianyi/OpenBLAS/sta
1313

1414
## Introduction
1515

16-
OpenBLAS is an optimized Basic Linear Algebra Subprograms library based on GotoBLAS2 1.13 BSD version.
16+
OpenBLAS is an optimized BLAS (Basic Linear Algebra Subprograms) library based on GotoBLAS2 1.13 BSD version.
1717

1818
Please read the documentation on the OpenBLAS wiki pages: <https://github.com/xianyi/OpenBLAS/wiki>.
1919

20+
For a general introduction to the BLAS routines, please refer to the extensive documentation of their reference implementation hosted at netlib:
21+
<https://www.netlib.org/blas>. On that site you will likewise find documentation for the reference implementation of the higher-level library LAPACK - the **L**inear **A**lgebra **Pack**age that comes included with OpenBLAS. If you are looking for a general primer or refresher on Linear Algebra, the set of six
22+
20-minute lecture videos by Prof. Gilbert Strang on either MIT OpenCourseWare <https://ocw.mit.edu/resources/res-18-010-a-2020-vision-of-linear-algebra-spring-2020/> or Youtube <https://www.youtube.com/playlist?list=PLUl4u3cNGP61iQEFiWLE21EJCxwmWvvek> may be helpful.
23+
2024
## Binary Packages
2125

2226
We provide official binary packages for the following platform:

getarch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13751375

13761376
#ifdef __riscv
13771377
#include "cpuid_riscv64.c"
1378+
#define OPENBLAS_SUPPORTED
13781379
#endif
13791380

13801381
#ifdef __arm__

kernel/arm64/KERNEL.NEOVERSEN1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ IDAMAXKERNEL = iamax_thunderx2t99.c
9191
ICAMAXKERNEL = izamax_thunderx2t99.c
9292
IZAMAXKERNEL = izamax_thunderx2t99.c
9393

94-
SNRM2KERNEL = nrm2.S
95-
DNRM2KERNEL = nrm2.S
96-
CNRM2KERNEL = znrm2.S
97-
ZNRM2KERNEL = znrm2.S
94+
SNRM2KERNEL = scnrm2_thunderx2t99.c
95+
DNRM2KERNEL = dznrm2_thunderx2t99.c
96+
CNRM2KERNEL = scnrm2_thunderx2t99.c
97+
ZNRM2KERNEL = dznrm2_thunderx2t99.c
9898

9999
DDOTKERNEL = dot_thunderx2t99.c
100100
SDOTKERNEL = dot_thunderx2t99.c

kernel/arm64/KERNEL.THUNDERX2T99

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ IDAMAXKERNEL = iamax_thunderx2t99.c
153153
ICAMAXKERNEL = izamax_thunderx2t99.c
154154
IZAMAXKERNEL = izamax_thunderx2t99.c
155155

156-
SNRM2KERNEL = nrm2.S
157-
CNRM2KERNEL = nrm2.S
156+
SNRM2KERNEL = scnrm2_thunderx2t99.c
157+
CNRM2KERNEL = scnrm2_thunderx2t99.c
158158
#DNRM2KERNEL = dznrm2_thunderx2t99_fast.c
159159
#ZNRM2KERNEL = dznrm2_thunderx2t99_fast.c
160-
DNRM2KERNEL = znrm2.S
161-
ZNRM2KERNEL = znrm2.S
160+
DNRM2KERNEL = dznrm2_thunderx2t99.c
161+
ZNRM2KERNEL = dznrm2_thunderx2t99.c
162162

163163

164164
DDOTKERNEL = dot_thunderx2t99.c

kernel/arm64/KERNEL.THUNDERX3T110

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,13 @@ IDAMAXKERNEL = iamax_thunderx2t99.c
153153
ICAMAXKERNEL = izamax_thunderx2t99.c
154154
IZAMAXKERNEL = izamax_thunderx2t99.c
155155

156-
#SNRM2KERNEL = scnrm2_thunderx2t99.c
157-
#CNRM2KERNEL = scnrm2_thunderx2t99.c
158-
##DNRM2KERNEL = dznrm2_thunderx2t99_fast.c
159-
##ZNRM2KERNEL = dznrm2_thunderx2t99_fast.c
160-
#DNRM2KERNEL = dznrm2_thunderx2t99.c
161-
#ZNRM2KERNEL = dznrm2_thunderx2t99.c
162-
SNRM2KERNEL = nrm2.S
163-
DNRM2KERNEL = nrm2.S
164-
CNRM2KERNEL = znrm2.S
165-
ZNRM2KERNEL = znrm2.S
156+
SNRM2KERNEL = scnrm2_thunderx2t99.c
157+
CNRM2KERNEL = scnrm2_thunderx2t99.c
158+
#DNRM2KERNEL = dznrm2_thunderx2t99_fast.c
159+
#ZNRM2KERNEL = dznrm2_thunderx2t99_fast.c
160+
DNRM2KERNEL = dznrm2_thunderx2t99.c
161+
ZNRM2KERNEL = dznrm2_thunderx2t99.c
162+
166163

167164
DDOTKERNEL = dot_thunderx2t99.c
168165
SDOTKERNEL = dot_thunderx2t99.c

kernel/arm64/dznrm2_thunderx2t99.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern int blas_level1_thread_with_return_value(int mode, BLASLONG m, BLASLONG n
5858
#define CUR_MAXINV "d8"
5959
#define CUR_MAXINV_V "v8.2d"
6060
#define CUR_MAX_V "v8.2d"
61+
#define REGINF "d9"
6162

6263
static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
6364
double *ssq, double *scale)
@@ -79,8 +80,10 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
7980
" ble 9f //nrm2_kernel_L999 \n"
8081

8182
"1: //nrm2_kernel_F_BEGIN: \n"
83+
" mov x6, #0x7FF0000000000000 //+Infinity \n"
8284
" fmov "REGZERO", xzr \n"
8385
" fmov "REGONE", #1.0 \n"
86+
" fmov "REGINF", x6 \n"
8487
" lsl "INC_X", "INC_X", #"INC_SHIFT" \n"
8588
" mov "J", "N" \n"
8689
" cmp "J", xzr \n"
@@ -104,6 +107,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
104107
" ldr d4, ["X"] \n"
105108
" fabs d4, d4 \n"
106109
" fmax "CUR_MAX", "SCALE", d4 \n"
110+
" fcmp "CUR_MAX", "REGINF" \n"
111+
" beq 10f \n"
107112
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
108113
" fmul "SCALE", "SCALE", "SCALE" \n"
109114
" fmul "SSQ", "SSQ", "SCALE" \n"
@@ -116,6 +121,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
116121
" ldr d3, ["X", #8] \n"
117122
" fabs d3, d3 \n"
118123
" fmax "CUR_MAX", "SCALE", d3 \n"
124+
" fcmp "CUR_MAX", "REGINF" \n"
125+
" beq 10f \n"
119126
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
120127
" fmul "SCALE", "SCALE", "SCALE" \n"
121128
" fmul "SSQ", "SSQ", "SCALE" \n"
@@ -158,6 +165,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
158165
" fmaxp v24.2d, v24.2d, v26.2d \n"
159166
" fmaxp v24.2d, v24.2d, v24.2d \n"
160167
" fmax "CUR_MAX", "SCALE", d24 \n"
168+
" fcmp "CUR_MAX", "REGINF" \n"
169+
" beq 10f \n"
161170
" fdiv "CUR_MAXINV", "REGONE", "CUR_MAX" \n"
162171
" //dup "CUR_MAX_V", v7.d[0] \n"
163172
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
@@ -217,6 +226,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
217226
" fmaxp v24.2d, v24.2d, v26.2d \n"
218227
" fmaxp v24.2d, v24.2d, v24.2d \n"
219228
" fmax "CUR_MAX", "SCALE", d24 \n"
229+
" fcmp "CUR_MAX", "REGINF" \n"
230+
" beq 10f \n"
220231
" fdiv "CUR_MAXINV", "REGONE", "CUR_MAX" \n"
221232
" //dup "CUR_MAX_V", v7.d[0] \n"
222233
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
@@ -265,6 +276,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
265276
" ldr d4, ["X"] \n"
266277
" fabs d4, d4 \n"
267278
" fmax "CUR_MAX", "SCALE", d4 \n"
279+
" fcmp "CUR_MAX", "REGINF" \n"
280+
" beq 10f \n"
268281
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
269282
" fmul "SCALE", "SCALE", "SCALE" \n"
270283
" fmul "SSQ", "SSQ", "SCALE" \n"
@@ -276,6 +289,8 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
276289
" ldr d3, ["X", #8] \n"
277290
" fabs d3, d3 \n"
278291
" fmax "CUR_MAX", "SCALE", d3 \n"
292+
" fcmp "CUR_MAX", "REGINF" \n"
293+
" beq 10f \n"
279294
" fdiv "SCALE", "SCALE", "CUR_MAX" \n"
280295
" fmul "SCALE", "SCALE", "SCALE" \n"
281296
" fmul "SSQ", "SSQ", "SCALE" \n"
@@ -291,6 +306,11 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
291306
"9: //nrm2_kernel_L999: \n"
292307
" str "SSQ", [%[SSQ_]] \n"
293308
" str "SCALE", [%[SCALE_]] \n"
309+
" b 11f \n"
310+
"10: \n"
311+
" str "REGINF", [%[SSQ_]] \n"
312+
" str "REGINF", [%[SCALE_]] \n"
313+
"11: \n"
294314

295315
:
296316
: [SSQ_] "r" (ssq), //%0
@@ -300,7 +320,7 @@ static void nrm2_compute(BLASLONG n, FLOAT *x, BLASLONG inc_x,
300320
[INCX_] "r" (inc_x) //%4
301321
: "cc",
302322
"memory",
303-
"x0", "x1", "x2", "x3", "x4", "x5",
323+
"x0", "x1", "x2", "x3", "x4", "x5", "x6",
304324
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"
305325
);
306326

@@ -359,6 +379,12 @@ FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x)
359379
cur_ssq = *ptr;
360380
cur_scale = *(ptr + 1);
361381

382+
if (cur_ssq == INFINITY) {
383+
ssq = INFINITY;
384+
scale = INFINITY;
385+
break;
386+
}
387+
362388
if (cur_scale != 0) {
363389
if (cur_scale > scale) {
364390
scale = (scale / cur_scale);

kernel/power/cswap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
#include "common.h"
3737

3838

39-
#if defined(POWER8) || defined(POWER9) || defined(POWER10)
4039
#if defined(__VEC__) || defined(__ALTIVEC__)
40+
#if defined(POWER8) || defined(POWER9)
4141
#include "cswap_microk_power8.c"
42+
#elif defined(POWER10)
43+
#include "cswap_microk_power10.c"
4244
#endif
4345
#endif
4446

kernel/power/cswap_microk_power10.c

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/***************************************************************************
2+
Copyright (c) 2021, The OpenBLAS Project
3+
All rights reserved.
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in
11+
the documentation and/or other materials provided with the
12+
distribution.
13+
3. Neither the name of the OpenBLAS project nor the names of
14+
its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*****************************************************************************/
27+
28+
#if defined(DOUBLE)
29+
#define HAVE_KERNEL_16 1
30+
static void zswap_kernel_16 (long n, double *x, double *y)
31+
#else
32+
#define HAVE_KERNEL_32 1
33+
static void cswap_kernel_32 (long n, float *x, float *y)
34+
#endif
35+
{
36+
__asm__
37+
(
38+
".align 5 \n"
39+
"one%=: \n\t"
40+
"lxvp 32, 0(%4) \n\t"
41+
"lxvp 34, 32(%4) \n\t"
42+
"lxvp 36, 64(%4) \n\t"
43+
"lxvp 38, 96(%4) \n\t"
44+
45+
"lxvp 40, 128(%4) \n\t"
46+
"lxvp 42, 160(%4) \n\t"
47+
"lxvp 44, 192(%4) \n\t"
48+
"lxvp 46, 224(%4) \n\t"
49+
50+
"lxvp 48, 0(%3) \n\t"
51+
"lxvp 50, 32(%3) \n\t"
52+
"lxvp 52, 64(%3) \n\t"
53+
"lxvp 54, 96(%3) \n\t"
54+
55+
"lxvp 56, 128(%3) \n\t"
56+
"lxvp 58, 160(%3) \n\t"
57+
"lxvp 60, 192(%3) \n\t"
58+
"lxvp 62, 224(%3) \n\t"
59+
60+
61+
"stxv 33, 0(%3) \n\t"
62+
"stxv 32, 16(%3) \n\t"
63+
"stxv 35, 32(%3) \n\t"
64+
"stxv 34, 48(%3) \n\t"
65+
"stxv 37, 64(%3) \n\t"
66+
"stxv 36, 80(%3) \n\t"
67+
"stxv 39, 96(%3) \n\t"
68+
"stxv 38, 112(%3) \n\t"
69+
70+
"addi %3, %3, 128 \n\t"
71+
72+
"stxv 41, 0(%3) \n\t"
73+
"stxv 40, 16(%3) \n\t"
74+
"stxv 43, 32(%3) \n\t"
75+
"stxv 42, 48(%3) \n\t"
76+
"stxv 45, 64(%3) \n\t"
77+
"stxv 44, 80(%3) \n\t"
78+
"stxv 47, 96(%3) \n\t"
79+
"stxv 46, 112(%3) \n\t"
80+
81+
"addi %3, %3, 128 \n\t"
82+
83+
"stxv 49, 0(%4) \n\t"
84+
"stxv 48, 16(%4) \n\t"
85+
"stxv 51, 32(%4) \n\t"
86+
"stxv 50, 48(%4) \n\t"
87+
"stxv 53, 64(%4) \n\t"
88+
"stxv 52, 80(%4) \n\t"
89+
"stxv 55, 96(%4) \n\t"
90+
"stxv 54, 112(%4) \n\t"
91+
92+
"addi %4, %4, 128 \n\t"
93+
94+
"stxv 57, 0(%4) \n\t"
95+
"stxv 56, 16(%4) \n\t"
96+
"stxv 59, 32(%4) \n\t"
97+
"stxv 58, 48(%4) \n\t"
98+
"stxv 61, 64(%4) \n\t"
99+
"stxv 60, 80(%4) \n\t"
100+
"stxv 63, 96(%4) \n\t"
101+
"stxv 62, 112(%4) \n\t"
102+
103+
"addi %4, %4, 128 \n\t"
104+
105+
#if defined(DOUBLE)
106+
"addic. %2, %2, -16 \n\t"
107+
#else
108+
"addic. %2, %2, -32 \n\t"
109+
#endif
110+
"bgt one%= \n"
111+
112+
"#n=%2 x=%0=%3 y=%1=%4"
113+
:
114+
"+m" (*x),
115+
"+m" (*y),
116+
"+r" (n), // 2
117+
"+b" (x), // 3
118+
"+b" (y) // 4
119+
:
120+
:
121+
"cr0",
122+
"vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
123+
"vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
124+
"vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55",
125+
"vs56","vs57","vs58","vs59","vs60","vs61","vs62","vs63"
126+
);
127+
}

kernel/power/dswap.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535

3636
#include "common.h"
3737

38-
#if defined(POWER8) || defined(POWER9) || defined(POWER10)
3938
#if defined(__VEC__) || defined(__ALTIVEC__)
39+
#if defined(POWER8) || defined(POWER9)
4040
#include "dswap_microk_power8.c"
41+
#elif defined(POWER10)
42+
#include "swap_microk_power10.c"
4143
#endif
4244
#endif
4345

@@ -115,12 +117,30 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT dummy3, FLOAT *x,
115117
if ( (inc_x == 1) && (inc_y == 1 ))
116118
{
117119

120+
#if defined(POWER10)
121+
if ( n >= 32 )
122+
{
123+
BLASLONG align = ((32 - ((uintptr_t)y & (uintptr_t)0x1F)) >> 3) & 0x3;
124+
for (i = 0; i < align; i++) {
125+
temp = y[i];
126+
y[i] = x[i];
127+
x[i] = temp;
128+
}
129+
}
130+
BLASLONG n1 = (n-i) & -32;
131+
if ( n1 > 0 )
132+
{
133+
dswap_kernel_32(n1,&x[i], &y[i]);
134+
i+=n1;
135+
}
136+
#else
118137
BLASLONG n1 = n & -32;
119138
if ( n1 > 0 )
120139
{
121140
dswap_kernel_32(n1, x, y);
122141
i=n1;
123142
}
143+
#endif
124144

125145
while(i < n)
126146
{

0 commit comments

Comments
 (0)