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