Skip to content

Commit e3ff4cd

Browse files
authored
Merge pull request #9 from xianyi/develop
rebase
2 parents 3612d9a + 0745ba4 commit e3ff4cd

14 files changed

+1737
-8
lines changed

driver/others/dynamic_power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static gotoblas_t *get_coretype(void) {
202202
return &gotoblas_POWER10;
203203
#endif
204204
/* Fall back to the POWER9 implementation if the toolchain is too old or the MMA feature is not set */
205-
#if (!defined __GNUC__) || ( __GNUC__ >= 6)
205+
#if (!defined __GNUC__) || ( __GNUC__ >= 11) || (__GNUC__ == 10 && __GNUC_MINOR__ >= 2)
206206
if (__builtin_cpu_is("power10"))
207207
return &gotoblas_POWER9;
208208
#endif

interface/gemm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
246246

247247
#ifdef SMP
248248
double MNK;
249+
#if defined(USE_SIMPLE_THREADED_LEVEL3) || !defined(NO_AFFINITY)
249250
#ifndef COMPLEX
250251
#ifdef XDOUBLE
251252
int mode = BLAS_XDOUBLE | BLAS_REAL;
@@ -264,6 +265,7 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
264265
#endif
265266
#endif
266267
#endif
268+
#endif
267269

268270
#if defined(SMP) && !defined(NO_AFFINITY) && !defined(USE_SIMPLE_THREADED_LEVEL3)
269271
int nodes;
@@ -417,8 +419,10 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
417419
sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
418420

419421
#ifdef SMP
422+
#if defined(USE_SIMPLE_THREADED_LEVEL3) || !defined(NO_AFFINITY)
420423
mode |= (transa << BLAS_TRANSA_SHIFT);
421424
mode |= (transb << BLAS_TRANSB_SHIFT);
425+
#endif
422426

423427
MNK = (double) args.m * (double) args.n * (double) args.k;
424428
if ( MNK <= (SMP_THRESHOLD_MIN * (double) GEMM_MULTITHREAD_THRESHOLD) )

interface/rotmg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ void CNAME(FLOAT *dd1, FLOAT *dd2, FLOAT *dx1, FLOAT dy1, FLOAT *dparam){
107107
dq1 = dp1 * *dx1;
108108
if(ABS(dq1) > ABS(dq2))
109109
{
110-
dflag = ZERO;
111110
dh11 = ONE;
112111
dh22 = ONE;
113112
dh21 = - dy1 / *dx1;

kernel/power/drot.c

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

4040
#pragma GCC optimize "O1"
4141

42-
#if defined(POWER8) || defined(POWER9) || defined(POWER10)
4342
#if defined(__VEC__) || defined(__ALTIVEC__)
43+
#if defined(POWER8) || defined(POWER9)
4444
#include "drot_microk_power8.c"
45+
#elif defined(POWER10)
46+
#include "drot_microk_power10.c"
4547
#endif
4648
#endif
4749

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

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

125145
while(i < n)
126146
{

kernel/power/drot_microk_power10.c

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
#define HAVE_KERNEL_16 1
29+
30+
static void drot_kernel_16 (long n, double *x, double *y, double c, double s)
31+
{
32+
__asm__
33+
(
34+
XXSPLTD_S(36,%x5,0) // load c to both dwords
35+
XXSPLTD_S(37,%x6,0) // load s to both dwords
36+
"lxvp 32, 0(%3) \n\t" // load x
37+
"lxvp 34, 32(%3) \n\t"
38+
"lxvp 48, 0(%4) \n\t" // load y
39+
"lxvp 50, 32(%4) \n\t"
40+
41+
"addic. %2, %2, -8 \n\t"
42+
"ble two%= \n\t"
43+
44+
".align 5 \n"
45+
"one%=: \n\t"
46+
47+
"xvmuldp 40, 32, 36 \n\t" // c * x
48+
"xvmuldp 41, 33, 36 \n\t"
49+
"xvmuldp 42, 34, 36 \n\t"
50+
"xvmuldp 43, 35, 36 \n\t"
51+
52+
"xvmuldp 44, 32, 37 \n\t" // s * x
53+
"xvmuldp 45, 33, 37 \n\t"
54+
"xvmuldp 46, 34, 37 \n\t"
55+
"xvmuldp 47, 35, 37 \n\t"
56+
57+
"lxvp 32, 64(%3) \n\t" // load x
58+
"lxvp 34, 96(%3) \n\t"
59+
"xvmuldp 52, 48, 36 \n\t" // c * y
60+
"xvmuldp 53, 49, 36 \n\t"
61+
"xvmuldp 54, 50, 36 \n\t"
62+
"xvmuldp 55, 51, 36 \n\t"
63+
64+
"xvmuldp 38, 48, 37 \n\t" // s * y
65+
"xvmuldp 39, 49, 37 \n\t"
66+
"xvmuldp 56, 50, 37 \n\t"
67+
"xvmuldp 57, 51, 37 \n\t"
68+
69+
"lxvp 48, 64(%4) \n\t" // load y
70+
"lxvp 50, 96(%4) \n\t"
71+
72+
"xvadddp 40, 40, 38 \n\t" // c * x + s * y
73+
"xvadddp 41, 41, 39 \n\t" // c * x + s * y
74+
"xvadddp 42, 42, 56 \n\t" // c * x + s * y
75+
"xvadddp 43, 43, 57 \n\t" // c * x + s * y
76+
77+
"stxvp 40, 0(%3) \n\t" // store x
78+
"stxvp 42, 32(%3) \n\t"
79+
80+
"xvsubdp 52, 52, 44 \n\t" // c * y - s * x
81+
"xvsubdp 53, 53, 45 \n\t" // c * y - s * x
82+
"xvsubdp 54, 54, 46 \n\t" // c * y - s * x
83+
"xvsubdp 55, 55, 47 \n\t" // c * y - s * x
84+
85+
"stxvp 52, 0(%4) \n\t" // store y
86+
"stxvp 54, 32(%4) \n\t"
87+
88+
"addi %3, %3, 64 \n\t"
89+
"addi %4, %4, 64 \n\t"
90+
91+
"addic. %2, %2, -8 \n\t"
92+
"bgt one%= \n"
93+
94+
"two%=: \n\t"
95+
96+
"xvmuldp 40, 32, 36 \n\t" // c * x
97+
"xvmuldp 41, 33, 36 \n\t"
98+
"xvmuldp 42, 34, 36 \n\t"
99+
"xvmuldp 43, 35, 36 \n\t"
100+
101+
"xvmuldp 52, 48, 36 \n\t" // c * y
102+
"xvmuldp 53, 49, 36 \n\t"
103+
"xvmuldp 54, 50, 36 \n\t"
104+
"xvmuldp 55, 51, 36 \n\t"
105+
106+
"xvmuldp 44, 32, 37 \n\t" // s * x
107+
"xvmuldp 45, 33, 37 \n\t"
108+
"xvmuldp 46, 34, 37 \n\t"
109+
"xvmuldp 47, 35, 37 \n\t"
110+
111+
"xvmuldp 38, 48, 37 \n\t" // s * y
112+
"xvmuldp 39, 49, 37 \n\t"
113+
"xvmuldp 56, 50, 37 \n\t"
114+
"xvmuldp 57, 51, 37 \n\t"
115+
116+
"xvadddp 40, 40, 38 \n\t" // c * x + s * y
117+
"xvadddp 41, 41, 39 \n\t" // c * x + s * y
118+
"xvadddp 42, 42, 56 \n\t" // c * x + s * y
119+
"xvadddp 43, 43, 57 \n\t" // c * x + s * y
120+
121+
"stxvp 40, 0(%3) \n\t" // store x
122+
"stxvp 42, 32(%3) \n\t"
123+
"xvsubdp 52, 52, 44 \n\t" // c * y - s * x
124+
"xvsubdp 53, 53, 45 \n\t" // c * y - s * x
125+
"xvsubdp 54, 54, 46 \n\t" // c * y - s * x
126+
"xvsubdp 55, 55, 47 \n\t" // c * y - s * x
127+
128+
"stxvp 52, 0(%4) \n\t" // store y
129+
"stxvp 54, 32(%4) \n\t"
130+
131+
"#n=%2 x=%0=%3 y=%1=%4 c=%5 s=%6\n"
132+
:
133+
"+m" (*x),
134+
"+m" (*y),
135+
"+r" (n), // 2
136+
"+b" (x), // 3
137+
"+b" (y) // 4
138+
:
139+
"d" (c), // 5
140+
"d" (s) // 6
141+
:
142+
"cr0",
143+
"vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
144+
"vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
145+
"vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55",
146+
"vs56","vs57"
147+
);
148+
}

kernel/power/dscal.c

Lines changed: 35 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 "dscal_microk_power8.c"
41+
#elif defined(POWER10)
42+
#include "dscal_microk_power10.c"
4143
#endif
4244
#endif
4345

@@ -100,12 +102,28 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x, BLAS
100102
if ( da == 0.0 )
101103
{
102104

105+
#if defined(POWER10)
106+
if ( n >= 16 )
107+
{
108+
BLASLONG align = ((32 - ((uintptr_t)x & (uintptr_t)0x1F)) >> 3) & 0x3;
109+
for (j = 0; j < align; j++) {
110+
x[j] = 0.0;
111+
}
112+
}
113+
BLASLONG n1 = (n-j) & -16;
114+
if ( n1 > 0 )
115+
{
116+
dscal_kernel_8_zero(n1, &x[j]);
117+
j+=n1;
118+
}
119+
#else
103120
BLASLONG n1 = n & -16;
104121
if ( n1 > 0 )
105122
{
106123
dscal_kernel_8_zero(n1, x);
107124
j=n1;
108125
}
126+
#endif
109127

110128
while(j < n)
111129
{
@@ -118,12 +136,28 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x, BLAS
118136
else
119137
{
120138

139+
#if defined(POWER10)
140+
if ( n >= 16 )
141+
{
142+
BLASLONG align = ((32 - ((uintptr_t)x & (uintptr_t)0x1F)) >> 3) & 0x3;
143+
for (j = 0; j < align; j++) {
144+
x[j] = da * x[j];
145+
}
146+
}
147+
BLASLONG n1 = (n-j) & -16;
148+
if ( n1 > 0 )
149+
{
150+
dscal_kernel_8(n1, &x[j], da);
151+
j+=n1;
152+
}
153+
#else
121154
BLASLONG n1 = n & -16;
122155
if ( n1 > 0 )
123156
{
124157
dscal_kernel_8(n1, x, da);
125158
j=n1;
126159
}
160+
#endif
127161
while(j < n)
128162
{
129163

0 commit comments

Comments
 (0)