24.04
generic.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019-2021, 2023 Arm Limited.
3
*
4
* SPDX-License-Identifier: MIT
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in all
14
* copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
#ifdef __aarch64__
25
26
#include <cstddef>
27
#include "../../bfloat.hpp"
28
29
namespace
arm_gemm
{
30
31
void
a64_interleaved_bf16fp32_dot_8x12(
32
const
bfloat16
*Apanel,
33
const
bfloat16
*Bpanel,
34
float
*Cpanel,
35
int
ablocks,
36
int
bblocks,
37
int
K
) {
38
39
struct
KernelArgs {
40
size_t
K
= {};
41
const
bfloat16
*Bpanel = {};
42
size_t
bblocks = {};
43
} ka;
44
45
ka.K = (
K
/2) - 1;
46
ka.Bpanel = Bpanel;
47
ka.bblocks = bblocks;
48
49
__asm__ __volatile__(
50
"1:"
// Height loop
51
"ldr x23, [%x[args_ptr], %[offsetof_bblocks]]\n"
52
"ldr x22, [%x[args_ptr], %[offsetof_Bpanel]]\n"
53
"mov x21, %x[Apanel]\n"
54
"2:"
// Width loop
55
"ldr q4, [x22, #0x0]\n"
56
"ldr q5, [x22, #0x10]\n"
57
"mov %x[Apanel], x21\n"
58
"ldr q0, [%x[Apanel], #0x0]\n"
59
"ldr q1, [%x[Apanel], #0x10]\n"
60
"movi v8.16b, #0x0\n"
61
"ldr q6, [x22, #0x20]\n"
62
"ldr x20, [%x[args_ptr], %[offsetof_K]]\n"
63
"cmp x20, #0x2\n"
64
"movi v9.16b, #0x0\n"
65
"prfm pldl1keep, [%x[Apanel], #0x0]\n"
66
"movi v10.16b, #0x0\n"
67
"movi v11.16b, #0x0\n"
68
"prfm pldl1keep, [x22, #0x0]\n"
69
"movi v12.16b, #0x0\n"
70
"movi v13.16b, #0x0\n"
71
"prfm pldl1keep, [x22, #0x40]\n"
72
"movi v14.16b, #0x0\n"
73
"movi v15.16b, #0x0\n"
74
"prfm pldl1keep, [%x[Apanel], #0x40]\n"
75
"movi v16.16b, #0x0\n"
76
"movi v17.16b, #0x0\n"
77
"prfm pldl1keep, [x22, #0x80]\n"
78
"movi v18.16b, #0x0\n"
79
"movi v19.16b, #0x0\n"
80
"movi v20.16b, #0x0\n"
81
"movi v21.16b, #0x0\n"
82
"movi v22.16b, #0x0\n"
83
"movi v23.16b, #0x0\n"
84
"movi v24.16b, #0x0\n"
85
"movi v25.16b, #0x0\n"
86
"movi v26.16b, #0x0\n"
87
"movi v27.16b, #0x0\n"
88
"movi v28.16b, #0x0\n"
89
"movi v29.16b, #0x0\n"
90
"movi v30.16b, #0x0\n"
91
"movi v31.16b, #0x0\n"
92
"blt 4f\n"
93
"3:"
// main loop head
94
"ldr q3, [%x[Apanel], #0x20]\n"
95
"ldr q7, [%x[Apanel], #0x30]\n"
96
".inst 0x4f40f088 // bfdot v8.4s, v4.8h, v0.h[0]\n"
97
".inst 0x4f60f08b // bfdot v11.4s, v4.8h, v0.h[1]\n"
98
".inst 0x4f40f88e // bfdot v14.4s, v4.8h, v0.h[2]\n"
99
"sub x20, x20, #0x2\n"
100
".inst 0x4f60f891 // bfdot v17.4s, v4.8h, v0.h[3]\n"
101
".inst 0x4f41f094 // bfdot v20.4s, v4.8h, v1.h[0]\n"
102
"cmp x20, #0x2\n"
103
".inst 0x4f61f097 // bfdot v23.4s, v4.8h, v1.h[1]\n"
104
".inst 0x4f41f89a // bfdot v26.4s, v4.8h, v1.h[2]\n"
105
"prfm pldl1keep, [%x[Apanel], #0x80]\n"
106
".inst 0x4f61f89d // bfdot v29.4s, v4.8h, v1.h[3]\n"
107
"ldr q4, [x22, #0x30]\n"
108
".inst 0x4f40f0a9 // bfdot v9.4s, v5.8h, v0.h[0]\n"
109
".inst 0x4f60f0ac // bfdot v12.4s, v5.8h, v0.h[1]\n"
110
".inst 0x4f40f8af // bfdot v15.4s, v5.8h, v0.h[2]\n"
111
"add %x[Apanel], %x[Apanel], #0x40\n"
112
".inst 0x4f60f8b2 // bfdot v18.4s, v5.8h, v0.h[3]\n"
113
".inst 0x4f41f0b5 // bfdot v21.4s, v5.8h, v1.h[0]\n"
114
"prfm pldl1keep, [x22, #0x100]\n"
115
".inst 0x4f61f0b8 // bfdot v24.4s, v5.8h, v1.h[1]\n"
116
".inst 0x4f41f8bb // bfdot v27.4s, v5.8h, v1.h[2]\n"
117
"prfm pldl1keep, [x22, #0x140]\n"
118
".inst 0x4f61f8be // bfdot v30.4s, v5.8h, v1.h[3]\n"
119
"ldr q5, [x22, #0x40]\n"
120
".inst 0x4f40f0ca // bfdot v10.4s, v6.8h, v0.h[0]\n"
121
".inst 0x4f60f0cd // bfdot v13.4s, v6.8h, v0.h[1]\n"
122
".inst 0x4f40f8d0 // bfdot v16.4s, v6.8h, v0.h[2]\n"
123
".inst 0x4f60f8d3 // bfdot v19.4s, v6.8h, v0.h[3]\n"
124
"ldr q0, [%x[Apanel], #0x0]\n"
125
".inst 0x4f41f0d6 // bfdot v22.4s, v6.8h, v1.h[0]\n"
126
".inst 0x4f61f0d9 // bfdot v25.4s, v6.8h, v1.h[1]\n"
127
".inst 0x4f41f8dc // bfdot v28.4s, v6.8h, v1.h[2]\n"
128
".inst 0x4f61f8df // bfdot v31.4s, v6.8h, v1.h[3]\n"
129
"ldr q2, [x22, #0x50]\n"
130
"ldr q1, [%x[Apanel], #0x10]\n"
131
"add x22, x22, #0x60\n"
132
".inst 0x4f43f088 // bfdot v8.4s, v4.8h, v3.h[0]\n"
133
".inst 0x4f63f08b // bfdot v11.4s, v4.8h, v3.h[1]\n"
134
".inst 0x4f43f88e // bfdot v14.4s, v4.8h, v3.h[2]\n"
135
".inst 0x4f63f891 // bfdot v17.4s, v4.8h, v3.h[3]\n"
136
".inst 0x4f47f094 // bfdot v20.4s, v4.8h, v7.h[0]\n"
137
".inst 0x4f67f097 // bfdot v23.4s, v4.8h, v7.h[1]\n"
138
".inst 0x4f47f89a // bfdot v26.4s, v4.8h, v7.h[2]\n"
139
".inst 0x4f67f89d // bfdot v29.4s, v4.8h, v7.h[3]\n"
140
"ldr q4, [x22, #0x0]\n"
141
".inst 0x4f43f0a9 // bfdot v9.4s, v5.8h, v3.h[0]\n"
142
".inst 0x4f63f0ac // bfdot v12.4s, v5.8h, v3.h[1]\n"
143
".inst 0x4f43f8af // bfdot v15.4s, v5.8h, v3.h[2]\n"
144
".inst 0x4f63f8b2 // bfdot v18.4s, v5.8h, v3.h[3]\n"
145
".inst 0x4f47f0b5 // bfdot v21.4s, v5.8h, v7.h[0]\n"
146
".inst 0x4f67f0b8 // bfdot v24.4s, v5.8h, v7.h[1]\n"
147
".inst 0x4f47f8bb // bfdot v27.4s, v5.8h, v7.h[2]\n"
148
".inst 0x4f67f8be // bfdot v30.4s, v5.8h, v7.h[3]\n"
149
"ldr q5, [x22, #0x10]\n"
150
".inst 0x4f43f04a // bfdot v10.4s, v2.8h, v3.h[0]\n"
151
".inst 0x4f63f04d // bfdot v13.4s, v2.8h, v3.h[1]\n"
152
".inst 0x4f43f850 // bfdot v16.4s, v2.8h, v3.h[2]\n"
153
".inst 0x4f63f853 // bfdot v19.4s, v2.8h, v3.h[3]\n"
154
".inst 0x4f47f056 // bfdot v22.4s, v2.8h, v7.h[0]\n"
155
".inst 0x4f67f059 // bfdot v25.4s, v2.8h, v7.h[1]\n"
156
".inst 0x4f47f85c // bfdot v28.4s, v2.8h, v7.h[2]\n"
157
".inst 0x4f67f85f // bfdot v31.4s, v2.8h, v7.h[3]\n"
158
"ldr q6, [x22, #0x20]\n"
159
"bge 3b\n"
160
"4:"
// main loop skip
161
"add %x[Apanel], %x[Apanel], #0x20\n"
162
".inst 0x4f40f088 // bfdot v8.4s, v4.8h, v0.h[0]\n"
163
".inst 0x4f60f08b // bfdot v11.4s, v4.8h, v0.h[1]\n"
164
"add x22, x22, #0x30\n"
165
".inst 0x4f40f88e // bfdot v14.4s, v4.8h, v0.h[2]\n"
166
".inst 0x4f60f891 // bfdot v17.4s, v4.8h, v0.h[3]\n"
167
".inst 0x4f41f094 // bfdot v20.4s, v4.8h, v1.h[0]\n"
168
".inst 0x4f61f097 // bfdot v23.4s, v4.8h, v1.h[1]\n"
169
".inst 0x4f41f89a // bfdot v26.4s, v4.8h, v1.h[2]\n"
170
".inst 0x4f61f89d // bfdot v29.4s, v4.8h, v1.h[3]\n"
171
".inst 0x4f40f0a9 // bfdot v9.4s, v5.8h, v0.h[0]\n"
172
".inst 0x4f60f0ac // bfdot v12.4s, v5.8h, v0.h[1]\n"
173
".inst 0x4f40f8af // bfdot v15.4s, v5.8h, v0.h[2]\n"
174
".inst 0x4f60f8b2 // bfdot v18.4s, v5.8h, v0.h[3]\n"
175
".inst 0x4f41f0b5 // bfdot v21.4s, v5.8h, v1.h[0]\n"
176
".inst 0x4f61f0b8 // bfdot v24.4s, v5.8h, v1.h[1]\n"
177
".inst 0x4f41f8bb // bfdot v27.4s, v5.8h, v1.h[2]\n"
178
".inst 0x4f61f8be // bfdot v30.4s, v5.8h, v1.h[3]\n"
179
".inst 0x4f40f0ca // bfdot v10.4s, v6.8h, v0.h[0]\n"
180
".inst 0x4f60f0cd // bfdot v13.4s, v6.8h, v0.h[1]\n"
181
".inst 0x4f40f8d0 // bfdot v16.4s, v6.8h, v0.h[2]\n"
182
".inst 0x4f60f8d3 // bfdot v19.4s, v6.8h, v0.h[3]\n"
183
".inst 0x4f41f0d6 // bfdot v22.4s, v6.8h, v1.h[0]\n"
184
".inst 0x4f61f0d9 // bfdot v25.4s, v6.8h, v1.h[1]\n"
185
".inst 0x4f41f8dc // bfdot v28.4s, v6.8h, v1.h[2]\n"
186
".inst 0x4f61f8df // bfdot v31.4s, v6.8h, v1.h[3]\n"
187
"cbz x20, 5f\n"
188
"ldr q4, [%x[Apanel], #0x0]\n"
189
"ldr q3, [%x[Apanel], #0x10]\n"
190
"add %x[Apanel], %x[Apanel], #0x20\n"
191
"ldr q2, [x22, #0x0]\n"
192
"ldr q1, [x22, #0x10]\n"
193
".inst 0x4f44f048 // bfdot v8.4s, v2.8h, v4.h[0]\n"
194
"ldr q0, [x22, #0x20]\n"
195
".inst 0x4f64f04b // bfdot v11.4s, v2.8h, v4.h[1]\n"
196
".inst 0x4f44f84e // bfdot v14.4s, v2.8h, v4.h[2]\n"
197
".inst 0x4f64f851 // bfdot v17.4s, v2.8h, v4.h[3]\n"
198
".inst 0x4f43f054 // bfdot v20.4s, v2.8h, v3.h[0]\n"
199
"add x22, x22, #0x30\n"
200
".inst 0x4f63f057 // bfdot v23.4s, v2.8h, v3.h[1]\n"
201
".inst 0x4f43f85a // bfdot v26.4s, v2.8h, v3.h[2]\n"
202
".inst 0x4f63f85d // bfdot v29.4s, v2.8h, v3.h[3]\n"
203
".inst 0x4f44f029 // bfdot v9.4s, v1.8h, v4.h[0]\n"
204
".inst 0x4f64f02c // bfdot v12.4s, v1.8h, v4.h[1]\n"
205
".inst 0x4f44f82f // bfdot v15.4s, v1.8h, v4.h[2]\n"
206
".inst 0x4f64f832 // bfdot v18.4s, v1.8h, v4.h[3]\n"
207
".inst 0x4f43f035 // bfdot v21.4s, v1.8h, v3.h[0]\n"
208
".inst 0x4f63f038 // bfdot v24.4s, v1.8h, v3.h[1]\n"
209
".inst 0x4f43f83b // bfdot v27.4s, v1.8h, v3.h[2]\n"
210
".inst 0x4f63f83e // bfdot v30.4s, v1.8h, v3.h[3]\n"
211
".inst 0x4f44f00a // bfdot v10.4s, v0.8h, v4.h[0]\n"
212
".inst 0x4f64f00d // bfdot v13.4s, v0.8h, v4.h[1]\n"
213
".inst 0x4f44f810 // bfdot v16.4s, v0.8h, v4.h[2]\n"
214
".inst 0x4f64f813 // bfdot v19.4s, v0.8h, v4.h[3]\n"
215
".inst 0x4f43f016 // bfdot v22.4s, v0.8h, v3.h[0]\n"
216
".inst 0x4f63f019 // bfdot v25.4s, v0.8h, v3.h[1]\n"
217
".inst 0x4f43f81c // bfdot v28.4s, v0.8h, v3.h[2]\n"
218
".inst 0x4f63f81f // bfdot v31.4s, v0.8h, v3.h[3]\n"
219
"5:"
// multiply loop done
220
"subs x23, x23, #0x1\n"
221
"str q8, [%x[Cpanel], #0x0]\n"
222
"str q9, [%x[Cpanel], #0x10]\n"
223
"str q10, [%x[Cpanel], #0x20]\n"
224
"str q11, [%x[Cpanel], #0x30]\n"
225
"str q12, [%x[Cpanel], #0x40]\n"
226
"str q13, [%x[Cpanel], #0x50]\n"
227
"str q14, [%x[Cpanel], #0x60]\n"
228
"str q15, [%x[Cpanel], #0x70]\n"
229
"str q16, [%x[Cpanel], #0x80]\n"
230
"str q17, [%x[Cpanel], #0x90]\n"
231
"str q18, [%x[Cpanel], #0xa0]\n"
232
"str q19, [%x[Cpanel], #0xb0]\n"
233
"str q20, [%x[Cpanel], #0xc0]\n"
234
"str q21, [%x[Cpanel], #0xd0]\n"
235
"str q22, [%x[Cpanel], #0xe0]\n"
236
"str q23, [%x[Cpanel], #0xf0]\n"
237
"str q24, [%x[Cpanel], #0x100]\n"
238
"str q25, [%x[Cpanel], #0x110]\n"
239
"str q26, [%x[Cpanel], #0x120]\n"
240
"str q27, [%x[Cpanel], #0x130]\n"
241
"str q28, [%x[Cpanel], #0x140]\n"
242
"str q29, [%x[Cpanel], #0x150]\n"
243
"str q30, [%x[Cpanel], #0x160]\n"
244
"str q31, [%x[Cpanel], #0x170]\n"
245
"add %x[Cpanel], %x[Cpanel], #0x180\n"
246
"bgt 2b\n"
247
"subs %x[ablocks], %x[ablocks], #0x1\n"
248
"bne 1b\n"
249
: [Apanel]
"+&r"
(Apanel), [Cpanel]
"+&r"
(Cpanel), [ablocks]
"+&r"
(ablocks)
250
: [args_ptr]
"r"
(&ka), [offsetof_Bpanel]
"I"
(offsetof(KernelArgs, Bpanel)), [offsetof_K]
"I"
(offsetof(KernelArgs,
K
)), [offsetof_bblocks]
"I"
(offsetof(KernelArgs, bblocks))
251
:
"cc"
,
"memory"
,
"v0"
,
"v1"
,
"v2"
,
"v3"
,
"v4"
,
"v5"
,
"v6"
,
"v7"
,
"v8"
,
"v9"
,
"v10"
,
"v11"
,
"v12"
,
"v13"
,
"v14"
,
"v15"
,
"v16"
,
"v17"
,
"v18"
,
"v19"
,
"v20"
,
"v21"
,
"v22"
,
"v23"
,
"v24"
,
"v25"
,
"v26"
,
"v27"
,
"v28"
,
"v29"
,
"v30"
,
"v31"
,
"x20"
,
"x21"
,
"x22"
,
"x23"
252
);
253
}
254
255
}
// namespace arm_gemm
256
#endif // __aarch64__
arm_gemm
Definition:
barrier.hpp:30
arm_gemm::bfloat16
arm_compute::bfloat16 bfloat16
Definition:
bfloat.hpp:30
K
unsigned int K
Definition:
CpuGemmAssemblyDispatch.cpp:106
src
core
NEON
kernels
arm_gemm
kernels
a64_interleaved_bf16fp32_dot_8x12
generic.cpp
Generated on Mon Apr 29 2024 10:53:55 for Compute Library by
1.8.17