24.04
generic.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 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_mmla_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
/4) - 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 q2, [%x[Apanel], #0x20]\n"
62
"ldr x20, [%x[args_ptr], %[offsetof_K]]\n"
63
"cmp x20, #0x2\n"
64
"movi v9.16b, #0x0\n"
65
"movi v10.16b, #0x0\n"
66
"add x22, x22, #0x20\n"
67
"movi v11.16b, #0x0\n"
68
"movi v12.16b, #0x0\n"
69
"add %x[Apanel], %x[Apanel], #0x30\n"
70
"movi v13.16b, #0x0\n"
71
"movi v14.16b, #0x0\n"
72
"movi v15.16b, #0x0\n"
73
"movi v16.16b, #0x0\n"
74
"movi v17.16b, #0x0\n"
75
"movi v18.16b, #0x0\n"
76
"movi v19.16b, #0x0\n"
77
"movi v20.16b, #0x0\n"
78
"movi v21.16b, #0x0\n"
79
"movi v22.16b, #0x0\n"
80
"movi v23.16b, #0x0\n"
81
"movi v24.16b, #0x0\n"
82
"movi v25.16b, #0x0\n"
83
"movi v26.16b, #0x0\n"
84
"movi v27.16b, #0x0\n"
85
"movi v28.16b, #0x0\n"
86
"movi v29.16b, #0x0\n"
87
"movi v30.16b, #0x0\n"
88
"movi v31.16b, #0x0\n"
89
"blt 4f\n"
90
"3:"
// main loop head
91
"ldr q6, [%x[Apanel], #0x0]\n"
92
"ldr q7, [x22, #0x0]\n"
93
".inst 0x6e44ec08 // bfmmla v8.4s, v0.8h, v4.8h\n"
94
"ldr q3, [x22, #0x10]\n"
95
".inst 0x6e45ec0b // bfmmla v11.4s, v0.8h, v5.8h\n"
96
".inst 0x6e44ec2e // bfmmla v14.4s, v1.8h, v4.8h\n"
97
".inst 0x6e45ec31 // bfmmla v17.4s, v1.8h, v5.8h\n"
98
".inst 0x6e44ec54 // bfmmla v20.4s, v2.8h, v4.8h\n"
99
"sub x20, x20, #0x2\n"
100
".inst 0x6e45ec57 // bfmmla v23.4s, v2.8h, v5.8h\n"
101
".inst 0x6e44ecda // bfmmla v26.4s, v6.8h, v4.8h\n"
102
"ldr q4, [x22, #0x20]\n"
103
".inst 0x6e45ecdd // bfmmla v29.4s, v6.8h, v5.8h\n"
104
"ldr q5, [x22, #0x30]\n"
105
".inst 0x6e47ec09 // bfmmla v9.4s, v0.8h, v7.8h\n"
106
".inst 0x6e43ec0c // bfmmla v12.4s, v0.8h, v3.8h\n"
107
".inst 0x6e47ec2f // bfmmla v15.4s, v1.8h, v7.8h\n"
108
"cmp x20, #0x2\n"
109
".inst 0x6e43ec32 // bfmmla v18.4s, v1.8h, v3.8h\n"
110
".inst 0x6e47ec55 // bfmmla v21.4s, v2.8h, v7.8h\n"
111
".inst 0x6e43ec58 // bfmmla v24.4s, v2.8h, v3.8h\n"
112
".inst 0x6e47ecdb // bfmmla v27.4s, v6.8h, v7.8h\n"
113
"ldr q7, [x22, #0x40]\n"
114
".inst 0x6e43ecde // bfmmla v30.4s, v6.8h, v3.8h\n"
115
"ldr q3, [x22, #0x50]\n"
116
".inst 0x6e44ec0a // bfmmla v10.4s, v0.8h, v4.8h\n"
117
".inst 0x6e45ec0d // bfmmla v13.4s, v0.8h, v5.8h\n"
118
"ldr q0, [%x[Apanel], #0x10]\n"
119
".inst 0x6e44ec30 // bfmmla v16.4s, v1.8h, v4.8h\n"
120
".inst 0x6e45ec33 // bfmmla v19.4s, v1.8h, v5.8h\n"
121
"ldr q1, [%x[Apanel], #0x20]\n"
122
".inst 0x6e44ec56 // bfmmla v22.4s, v2.8h, v4.8h\n"
123
".inst 0x6e45ec59 // bfmmla v25.4s, v2.8h, v5.8h\n"
124
"ldr q2, [%x[Apanel], #0x30]\n"
125
".inst 0x6e44ecdc // bfmmla v28.4s, v6.8h, v4.8h\n"
126
"ldr q4, [x22, #0x60]\n"
127
".inst 0x6e45ecdf // bfmmla v31.4s, v6.8h, v5.8h\n"
128
"ldr q6, [%x[Apanel], #0x40]\n"
129
"ldr q5, [x22, #0x70]\n"
130
".inst 0x6e47ec08 // bfmmla v8.4s, v0.8h, v7.8h\n"
131
".inst 0x6e43ec0b // bfmmla v11.4s, v0.8h, v3.8h\n"
132
".inst 0x6e47ec2e // bfmmla v14.4s, v1.8h, v7.8h\n"
133
".inst 0x6e43ec31 // bfmmla v17.4s, v1.8h, v3.8h\n"
134
".inst 0x6e47ec54 // bfmmla v20.4s, v2.8h, v7.8h\n"
135
".inst 0x6e43ec57 // bfmmla v23.4s, v2.8h, v3.8h\n"
136
".inst 0x6e47ecda // bfmmla v26.4s, v6.8h, v7.8h\n"
137
"ldr q7, [x22, #0x80]\n"
138
".inst 0x6e43ecdd // bfmmla v29.4s, v6.8h, v3.8h\n"
139
"ldr q3, [x22, #0x90]\n"
140
".inst 0x6e44ec09 // bfmmla v9.4s, v0.8h, v4.8h\n"
141
".inst 0x6e45ec0c // bfmmla v12.4s, v0.8h, v5.8h\n"
142
".inst 0x6e44ec2f // bfmmla v15.4s, v1.8h, v4.8h\n"
143
".inst 0x6e45ec32 // bfmmla v18.4s, v1.8h, v5.8h\n"
144
".inst 0x6e44ec55 // bfmmla v21.4s, v2.8h, v4.8h\n"
145
".inst 0x6e45ec58 // bfmmla v24.4s, v2.8h, v5.8h\n"
146
".inst 0x6e44ecdb // bfmmla v27.4s, v6.8h, v4.8h\n"
147
"ldr q4, [x22, #0xa0]\n"
148
".inst 0x6e45ecde // bfmmla v30.4s, v6.8h, v5.8h\n"
149
"ldr q5, [x22, #0xb0]\n"
150
".inst 0x6e47ec0a // bfmmla v10.4s, v0.8h, v7.8h\n"
151
".inst 0x6e43ec0d // bfmmla v13.4s, v0.8h, v3.8h\n"
152
"ldr q0, [%x[Apanel], #0x50]\n"
153
".inst 0x6e47ec30 // bfmmla v16.4s, v1.8h, v7.8h\n"
154
".inst 0x6e43ec33 // bfmmla v19.4s, v1.8h, v3.8h\n"
155
"ldr q1, [%x[Apanel], #0x60]\n"
156
".inst 0x6e47ec56 // bfmmla v22.4s, v2.8h, v7.8h\n"
157
".inst 0x6e43ec59 // bfmmla v25.4s, v2.8h, v3.8h\n"
158
"ldr q2, [%x[Apanel], #0x70]\n"
159
".inst 0x6e47ecdc // bfmmla v28.4s, v6.8h, v7.8h\n"
160
".inst 0x6e43ecdf // bfmmla v31.4s, v6.8h, v3.8h\n"
161
"add %x[Apanel], %x[Apanel], #0x80\n"
162
"add x22, x22, #0xc0\n"
163
"bge 3b\n"
164
"4:"
// main loop skip
165
"ldr q3, [%x[Apanel], #0x0]\n"
166
"ldr q6, [x22, #0x0]\n"
167
".inst 0x6e44ec08 // bfmmla v8.4s, v0.8h, v4.8h\n"
168
"ldr q7, [x22, #0x10]\n"
169
".inst 0x6e45ec0b // bfmmla v11.4s, v0.8h, v5.8h\n"
170
".inst 0x6e44ec2e // bfmmla v14.4s, v1.8h, v4.8h\n"
171
".inst 0x6e45ec31 // bfmmla v17.4s, v1.8h, v5.8h\n"
172
".inst 0x6e44ec54 // bfmmla v20.4s, v2.8h, v4.8h\n"
173
"add %x[Apanel], %x[Apanel], #0x10\n"
174
".inst 0x6e45ec57 // bfmmla v23.4s, v2.8h, v5.8h\n"
175
".inst 0x6e44ec7a // bfmmla v26.4s, v3.8h, v4.8h\n"
176
"ldr q4, [x22, #0x20]\n"
177
".inst 0x6e45ec7d // bfmmla v29.4s, v3.8h, v5.8h\n"
178
"ldr q5, [x22, #0x30]\n"
179
".inst 0x6e46ec09 // bfmmla v9.4s, v0.8h, v6.8h\n"
180
".inst 0x6e47ec0c // bfmmla v12.4s, v0.8h, v7.8h\n"
181
".inst 0x6e46ec2f // bfmmla v15.4s, v1.8h, v6.8h\n"
182
"add x22, x22, #0x40\n"
183
".inst 0x6e47ec32 // bfmmla v18.4s, v1.8h, v7.8h\n"
184
".inst 0x6e46ec55 // bfmmla v21.4s, v2.8h, v6.8h\n"
185
".inst 0x6e47ec58 // bfmmla v24.4s, v2.8h, v7.8h\n"
186
".inst 0x6e46ec7b // bfmmla v27.4s, v3.8h, v6.8h\n"
187
".inst 0x6e47ec7e // bfmmla v30.4s, v3.8h, v7.8h\n"
188
".inst 0x6e44ec0a // bfmmla v10.4s, v0.8h, v4.8h\n"
189
".inst 0x6e45ec0d // bfmmla v13.4s, v0.8h, v5.8h\n"
190
".inst 0x6e44ec30 // bfmmla v16.4s, v1.8h, v4.8h\n"
191
".inst 0x6e45ec33 // bfmmla v19.4s, v1.8h, v5.8h\n"
192
".inst 0x6e44ec56 // bfmmla v22.4s, v2.8h, v4.8h\n"
193
".inst 0x6e45ec59 // bfmmla v25.4s, v2.8h, v5.8h\n"
194
".inst 0x6e44ec7c // bfmmla v28.4s, v3.8h, v4.8h\n"
195
".inst 0x6e45ec7f // bfmmla v31.4s, v3.8h, v5.8h\n"
196
"cbz x20, 5f\n"
197
"ldr q1, [x22, #0x0]\n"
198
"ldr q7, [%x[Apanel], #0x0]\n"
199
".inst 0x6e41ece8 // bfmmla v8.4s, v7.8h, v1.8h\n"
200
"ldr q6, [%x[Apanel], #0x10]\n"
201
"ldr q0, [x22, #0x10]\n"
202
".inst 0x6e40eceb // bfmmla v11.4s, v7.8h, v0.8h\n"
203
"ldr q5, [%x[Apanel], #0x20]\n"
204
"ldr q4, [%x[Apanel], #0x30]\n"
205
".inst 0x6e41ecce // bfmmla v14.4s, v6.8h, v1.8h\n"
206
"ldr q3, [x22, #0x20]\n"
207
"ldr q2, [x22, #0x30]\n"
208
".inst 0x6e40ecd1 // bfmmla v17.4s, v6.8h, v0.8h\n"
209
".inst 0x6e41ecb4 // bfmmla v20.4s, v5.8h, v1.8h\n"
210
".inst 0x6e40ecb7 // bfmmla v23.4s, v5.8h, v0.8h\n"
211
"add %x[Apanel], %x[Apanel], #0x40\n"
212
".inst 0x6e41ec9a // bfmmla v26.4s, v4.8h, v1.8h\n"
213
"ldr q1, [x22, #0x40]\n"
214
".inst 0x6e40ec9d // bfmmla v29.4s, v4.8h, v0.8h\n"
215
"ldr q0, [x22, #0x50]\n"
216
".inst 0x6e43ece9 // bfmmla v9.4s, v7.8h, v3.8h\n"
217
".inst 0x6e42ecec // bfmmla v12.4s, v7.8h, v2.8h\n"
218
".inst 0x6e43eccf // bfmmla v15.4s, v6.8h, v3.8h\n"
219
".inst 0x6e42ecd2 // bfmmla v18.4s, v6.8h, v2.8h\n"
220
"add x22, x22, #0x60\n"
221
".inst 0x6e43ecb5 // bfmmla v21.4s, v5.8h, v3.8h\n"
222
".inst 0x6e42ecb8 // bfmmla v24.4s, v5.8h, v2.8h\n"
223
".inst 0x6e43ec9b // bfmmla v27.4s, v4.8h, v3.8h\n"
224
".inst 0x6e42ec9e // bfmmla v30.4s, v4.8h, v2.8h\n"
225
".inst 0x6e41ecea // bfmmla v10.4s, v7.8h, v1.8h\n"
226
".inst 0x6e40eced // bfmmla v13.4s, v7.8h, v0.8h\n"
227
".inst 0x6e41ecd0 // bfmmla v16.4s, v6.8h, v1.8h\n"
228
".inst 0x6e40ecd3 // bfmmla v19.4s, v6.8h, v0.8h\n"
229
".inst 0x6e41ecb6 // bfmmla v22.4s, v5.8h, v1.8h\n"
230
".inst 0x6e40ecb9 // bfmmla v25.4s, v5.8h, v0.8h\n"
231
".inst 0x6e41ec9c // bfmmla v28.4s, v4.8h, v1.8h\n"
232
".inst 0x6e40ec9f // bfmmla v31.4s, v4.8h, v0.8h\n"
233
"5:"
// multiply loop done
234
"subs x23, x23, #0x1\n"
235
"uzp1 v0.2d, v8.2d, v11.2d\n"
236
"uzp2 v8.2d, v8.2d, v11.2d\n"
237
"uzp1 v1.2d, v9.2d, v12.2d\n"
238
"uzp2 v9.2d, v9.2d, v12.2d\n"
239
"str q0, [%x[Cpanel], #0x0]\n"
240
"uzp1 v0.2d, v10.2d, v13.2d\n"
241
"uzp2 v10.2d, v10.2d, v13.2d\n"
242
"str q1, [%x[Cpanel], #0x10]\n"
243
"str q0, [%x[Cpanel], #0x20]\n"
244
"uzp1 v0.2d, v14.2d, v17.2d\n"
245
"uzp2 v14.2d, v14.2d, v17.2d\n"
246
"str q8, [%x[Cpanel], #0x30]\n"
247
"uzp1 v2.2d, v15.2d, v18.2d\n"
248
"uzp2 v15.2d, v15.2d, v18.2d\n"
249
"str q9, [%x[Cpanel], #0x40]\n"
250
"uzp1 v17.2d, v16.2d, v19.2d\n"
251
"uzp2 v16.2d, v16.2d, v19.2d\n"
252
"str q10, [%x[Cpanel], #0x50]\n"
253
"uzp1 v1.2d, v20.2d, v23.2d\n"
254
"uzp2 v20.2d, v20.2d, v23.2d\n"
255
"str q0, [%x[Cpanel], #0x60]\n"
256
"uzp1 v0.2d, v21.2d, v24.2d\n"
257
"uzp2 v21.2d, v21.2d, v24.2d\n"
258
"str q2, [%x[Cpanel], #0x70]\n"
259
"uzp1 v23.2d, v22.2d, v25.2d\n"
260
"uzp2 v22.2d, v22.2d, v25.2d\n"
261
"str q17, [%x[Cpanel], #0x80]\n"
262
"uzp1 v19.2d, v26.2d, v29.2d\n"
263
"uzp2 v26.2d, v26.2d, v29.2d\n"
264
"str q14, [%x[Cpanel], #0x90]\n"
265
"uzp1 v18.2d, v27.2d, v30.2d\n"
266
"uzp2 v27.2d, v27.2d, v30.2d\n"
267
"str q15, [%x[Cpanel], #0xa0]\n"
268
"uzp1 v17.2d, v28.2d, v31.2d\n"
269
"uzp2 v28.2d, v28.2d, v31.2d\n"
270
"str q16, [%x[Cpanel], #0xb0]\n"
271
"str q1, [%x[Cpanel], #0xc0]\n"
272
"str q0, [%x[Cpanel], #0xd0]\n"
273
"str q23, [%x[Cpanel], #0xe0]\n"
274
"str q20, [%x[Cpanel], #0xf0]\n"
275
"str q21, [%x[Cpanel], #0x100]\n"
276
"str q22, [%x[Cpanel], #0x110]\n"
277
"str q19, [%x[Cpanel], #0x120]\n"
278
"str q18, [%x[Cpanel], #0x130]\n"
279
"str q17, [%x[Cpanel], #0x140]\n"
280
"str q26, [%x[Cpanel], #0x150]\n"
281
"str q27, [%x[Cpanel], #0x160]\n"
282
"str q28, [%x[Cpanel], #0x170]\n"
283
"add %x[Cpanel], %x[Cpanel], #0x180\n"
284
"bgt 2b\n"
285
"subs %x[ablocks], %x[ablocks], #0x1\n"
286
"bne 1b\n"
287
: [Apanel]
"+&r"
(Apanel), [Cpanel]
"+&r"
(Cpanel), [ablocks]
"+&r"
(ablocks)
288
: [args_ptr]
"r"
(&ka), [offsetof_Bpanel]
"I"
(offsetof(KernelArgs, Bpanel)), [offsetof_K]
"I"
(offsetof(KernelArgs,
K
)), [offsetof_bblocks]
"I"
(offsetof(KernelArgs, bblocks))
289
:
"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"
290
);
291
}
292
293
}
// namespace arm_gemm
294
#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_mmla_8x12
generic.cpp
Generated on Mon Apr 29 2024 10:53:55 for Compute Library by
1.8.17