Skip to content

Commit 0f105dd

Browse files
sgemm/strmm
1 parent 853a18b commit 0f105dd

File tree

6 files changed

+8256
-6
lines changed

6 files changed

+8256
-6
lines changed

CONTRIBUTORS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,7 @@ In chronological order:
167167
* [2017-02-26] ztrmm kernel for IBM z13
168168
* [2017-03-13] strmm and ctrmm kernel for IBM z13
169169
* [2017-09-01] initial Blas Level-1,2 (double precision) for IBM z13
170-
170+
* [2018-03-07] added missing Blas Level 1-2 (double precision) simd codes
171+
* [2019-02-01] added missing Blas Level-1,2 (single precision) simd codes
172+
* [2019-03-14] power9 dgemm/dtrmm kernel
173+
* [2019-04-29] power9 sgemm/strmm kernel

kernel/power/KERNEL.POWER9

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
#CGEMM_BETA = ../generic/zgemm_beta.c
44
#ZGEMM_BETA = ../generic/zgemm_beta.c
55

6-
STRMMKERNEL = strmm_kernel_16x8_power8.S
6+
STRMMKERNEL = sgemm_kernel_power9.S
77
DTRMMKERNEL = dgemm_kernel_power9.S
88
CTRMMKERNEL = ctrmm_kernel_8x4_power8.S
99
ZTRMMKERNEL = ztrmm_kernel_8x2_power8.S
1010

11-
SGEMMKERNEL = sgemm_kernel_16x8_power8.S
11+
SGEMMKERNEL = sgemm_kernel_power9.S
1212
SGEMMINCOPY = ../generic/gemm_ncopy_16.c
1313
SGEMMITCOPY = sgemm_tcopy_16_power8.S
1414
SGEMMONCOPY = ../generic/gemm_ncopy_8.c
15-
SGEMMOTCOPY = sgemm_tcopy_8_power8.S
15+
SGEMMOTCOPY = sgemm_tcopy_8_power8.S
1616
SGEMMINCOPYOBJ = sgemm_incopy.o
1717
SGEMMITCOPYOBJ = sgemm_itcopy.o
1818
SGEMMONCOPYOBJ = sgemm_oncopy.o

kernel/power/sgemm_kernel_power9.S

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
/***************************************************************************
2+
Copyright (c) 2013-2019, 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 ASSEMBLER
29+
#include "common.h"
30+
#include "def_vsx.h"
31+
32+
33+
#define LOAD ld
34+
#define STACKSIZE (512 )
35+
36+
#define M r3
37+
#define N r4
38+
#define K r5
39+
40+
41+
#define A r7
42+
#define B r8
43+
#define C r9
44+
#define LDC r10
45+
#define OFFSET r6
46+
47+
48+
49+
#define alpha_r vs20
50+
#define save_permute_1 vs21
51+
#define save_permute_2 vs22
52+
#define permute_mask vs23
53+
#define o0 0
54+
55+
56+
#define T1 r11
57+
#define T2 r12
58+
#define T3 r14
59+
#define T4 r15
60+
#define T5 r16
61+
#define T6 r17
62+
#define L r18
63+
#define T7 r19
64+
#define T8 r20
65+
#define TEMP_REG r21
66+
#define I r22
67+
#define J r23
68+
#define AO r24
69+
#define BO r25
70+
#define CO r26
71+
#define T9 r27
72+
#define T10 r28
73+
#define T11 r29
74+
75+
#define T12 r30
76+
#define T13 r31
77+
78+
#include "sgemm_macros_power9.S"
79+
80+
.equ perm_const1, 0x0405060700010203
81+
.equ perm_const2, 0x0c0d0e0f08090a0b
82+
.equ save_permute_11, 0x1415161718191a1b
83+
.equ save_permute_12, 0x0405060708090a0b
84+
.equ save_permute_21, 0x101112131c1d1e1f
85+
.equ save_permute_22, 0x000102030c0d0e0f
86+
87+
88+
#ifndef NEEDPARAM
89+
90+
PROLOGUE
91+
PROFCODE
92+
93+
addi SP, SP, -STACKSIZE
94+
li r0, 0
95+
96+
stfd f14, 0(SP)
97+
stfd f15, 8(SP)
98+
stfd f16, 16(SP)
99+
stfd f17, 24(SP)
100+
101+
stfd f18, 32(SP)
102+
stfd f19, 40(SP)
103+
stfd f20, 48(SP)
104+
stfd f21, 56(SP)
105+
106+
stfd f22, 64(SP)
107+
stfd f23, 72(SP)
108+
stfd f24, 80(SP)
109+
stfd f25, 88(SP)
110+
111+
stfd f26, 96(SP)
112+
stfd f27, 104(SP)
113+
stfd f28, 112(SP)
114+
stfd f29, 120(SP)
115+
116+
stfd f30, 128(SP)
117+
stfd f31, 136(SP)
118+
119+
120+
std r31, 144(SP)
121+
std r30, 152(SP)
122+
std r29, 160(SP)
123+
std r28, 168(SP)
124+
std r27, 176(SP)
125+
std r26, 184(SP)
126+
std r25, 192(SP)
127+
std r24, 200(SP)
128+
std r23, 208(SP)
129+
std r22, 216(SP)
130+
std r21, 224(SP)
131+
std r20, 232(SP)
132+
std r19, 240(SP)
133+
std r18, 248(SP)
134+
std r17, 256(SP)
135+
std r16, 264(SP)
136+
std r15, 272(SP)
137+
std r14, 280(SP)
138+
139+
140+
stxv v20, 288(SP)
141+
stxv v21, 304(SP)
142+
stxv v22, 320(SP)
143+
stxv v23, 336(SP)
144+
stxv v24, 352(SP)
145+
stxv v25, 368(SP)
146+
stxv v26, 384(SP)
147+
stxv v27, 400(SP)
148+
stxv v28, 416(SP)
149+
stxv v29, 432(SP)
150+
stxv v30, 448(SP)
151+
stxv v31, 464(SP)
152+
153+
154+
155+
#if defined(TRMMKERNEL)
156+
ld OFFSET, FRAMESLOT(0) + STACKSIZE(SP)
157+
#endif
158+
slwi LDC, LDC, 2
159+
160+
161+
/* cmpwi cr0, M, 0
162+
ble .L999_H1
163+
cmpwi cr0, N, 0
164+
ble .L999_H1
165+
cmpwi cr0, K, 0
166+
ble .L999_H1
167+
*/
168+
169+
170+
/*alpha is stored in f1. convert to single and splat*/
171+
xscvdpspn alpha_r,vs1
172+
xxspltw alpha_r,alpha_r,0
173+
174+
175+
/*load reverse permute mask for big endian
176+
uint128 = 0xc0d0e0f08090a0b0405060700010203
177+
*/
178+
179+
lis T2, perm_const2@highest
180+
ori T2, T2, perm_const2@higher
181+
rldicr T2, T2, 32, 31
182+
oris T2, T2, perm_const2@h
183+
ori T2, T2, perm_const2@l
184+
185+
lis T1, perm_const1@highest
186+
ori T1, T1, perm_const1@higher
187+
rldicr T1, T1, 32, 31
188+
oris T1, T1, perm_const1@h
189+
ori T1, T1, perm_const1@l
190+
191+
mtvsrdd permute_mask,T2,T1
192+
193+
lis T2, save_permute_12@highest
194+
ori T2, T2, save_permute_12@higher
195+
rldicr T2, T2, 32, 31
196+
oris T2, T2, save_permute_12@h
197+
ori T2, T2, save_permute_12@l
198+
199+
lis T1, save_permute_11@highest
200+
ori T1, T1, save_permute_11@higher
201+
rldicr T1, T1, 32, 31
202+
oris T1, T1, save_permute_11@h
203+
ori T1, T1, save_permute_11@l
204+
205+
mtvsrdd save_permute_1,T2,T1
206+
207+
lis T2, save_permute_22@highest
208+
ori T2, T2, save_permute_22@higher
209+
rldicr T2, T2, 32, 31
210+
oris T2, T2, save_permute_22@h
211+
ori T2, T2, save_permute_22@l
212+
213+
lis T1, save_permute_21@highest
214+
ori T1, T1, save_permute_21@higher
215+
rldicr T1, T1, 32, 31
216+
oris T1, T1, save_permute_21@h
217+
ori T1, T1, save_permute_21@l
218+
219+
mtvsrdd save_permute_2,T2,T1
220+
221+
#include "sgemm_logic_power9.S"
222+
223+
.L999:
224+
addi r3, 0, 0
225+
226+
lfd f14, 0(SP)
227+
lfd f15, 8(SP)
228+
lfd f16, 16(SP)
229+
lfd f17, 24(SP)
230+
231+
lfd f18, 32(SP)
232+
lfd f19, 40(SP)
233+
lfd f20, 48(SP)
234+
lfd f21, 56(SP)
235+
236+
lfd f22, 64(SP)
237+
lfd f23, 72(SP)
238+
lfd f24, 80(SP)
239+
lfd f25, 88(SP)
240+
241+
lfd f26, 96(SP)
242+
lfd f27, 104(SP)
243+
lfd f28, 112(SP)
244+
lfd f29, 120(SP)
245+
246+
lfd f30, 128(SP)
247+
lfd f31, 136(SP)
248+
249+
ld r31, 144(SP)
250+
ld r30, 152(SP)
251+
ld r29, 160(SP)
252+
ld r28, 168(SP)
253+
ld r27, 176(SP)
254+
ld r26, 184(SP)
255+
ld r25, 192(SP)
256+
ld r24, 200(SP)
257+
ld r23, 208(SP)
258+
ld r22, 216(SP)
259+
ld r21, 224(SP)
260+
ld r20, 232(SP)
261+
ld r19, 240(SP)
262+
ld r18, 248(SP)
263+
ld r17, 256(SP)
264+
ld r16, 264(SP)
265+
ld r15, 272(SP)
266+
ld r14, 280(SP)
267+
268+
lxv v20, 288(SP)
269+
lxv v21, 304(SP)
270+
lxv v22, 320(SP)
271+
lxv v23, 336(SP)
272+
lxv v24, 352(SP)
273+
lxv v25, 368(SP)
274+
lxv v26, 384(SP)
275+
lxv v27, 400(SP)
276+
lxv v28, 416(SP)
277+
lxv v29, 432(SP)
278+
lxv v30, 448(SP)
279+
lxv v31, 464(SP)
280+
281+
282+
addi SP, SP, STACKSIZE
283+
blr
284+
285+
EPILOGUE
286+
#endif

0 commit comments

Comments
 (0)