Debian Codegraph @

src/f32-ppmm/gen/f32-ppmm-8x8-minmax-neon-prfm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-ppmm/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2019 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <arm_neon.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/ppmm.h"
16 #include "xnnpack/prefetch.h"
17
18
19 void xnn_f32_ppmm_minmax_ukernel_8x8__neon_prfm(
20 size_t mr,
21 size_t nc,
22 size_t kc,
23 const float* restrict a,
24 const float* restrict w,
25 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
29 {
30 assert(mr != 0);
31 assert(mr <= 8);
32 assert(nc != 0);
33 assert(kc != 0);
34 assert(kc % sizeof(float) == 0);
35
36 #if XNN_ARCH_ARM64
37 const float32x4x2_t vminmax = vld2q_dup_f32(&params->scalar.min);
38 const float32x4_t vmin = vminmax.val[0];
39 const float32x4_t vmax = vminmax.val[1];
40 #else
41 const float32x2x2_t vminmax = vld2_dup_f32(&params->scalar.min);
42 const float32x4_t vmin = vcombine_f32(vminmax.val[0], vminmax.val[0]);
43 const float32x4_t vmax = vcombine_f32(vminmax.val[1], vminmax.val[1]);
44 #endif
45
46 float* c0 = c;
47 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
48 if XNN_UNPREDICTABLE(mr < 2) {
49 c1 = c0;
50 }
51 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
52 if XNN_UNPREDICTABLE(mr <= 2) {
53 c2 = c1;
54 }
55 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
56 if XNN_UNPREDICTABLE(mr < 4) {
57 c3 = c2;
58 }
59 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
60 if XNN_UNPREDICTABLE(mr <= 4) {
61 c4 = c3;
62 }
63 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
64 if XNN_UNPREDICTABLE(mr < 6) {
65 c5 = c4;
66 }
67 float* c6 = (float*) ((uintptr_t) c5 + cm_stride);
68 if XNN_UNPREDICTABLE(mr <= 6) {
69 c6 = c5;
70 }
71 float* c7 = (float*) ((uintptr_t) c6 + cm_stride);
72 if XNN_UNPREDICTABLE(mr != 8) {
73 c7 = c6;
74 }
75
76 xnn_prefetch_to_l1((const int8_t*) w + 0);
77 xnn_prefetch_to_l1((const int8_t*) w + 64);
78 xnn_prefetch_to_l1((const int8_t*) w + 128);
79 xnn_prefetch_to_l1((const int8_t*) w + 192);
80
81 do {
82 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
83 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
84 float32x4_t vacc1x0123 = vacc0x0123;
85 float32x4_t vacc1x4567 = vacc0x4567;
86 float32x4_t vacc2x0123 = vacc0x0123;
87 float32x4_t vacc2x4567 = vacc0x4567;
88 float32x4_t vacc3x0123 = vacc0x0123;
89 float32x4_t vacc3x4567 = vacc0x4567;
90 float32x4_t vacc4x0123 = vacc0x0123;
91 float32x4_t vacc4x4567 = vacc0x4567;
92 float32x4_t vacc5x0123 = vacc0x0123;
93 float32x4_t vacc5x4567 = vacc0x4567;
94 float32x4_t vacc6x0123 = vacc0x0123;
95 float32x4_t vacc6x4567 = vacc0x4567;
96 float32x4_t vacc7x0123 = vacc0x0123;
97 float32x4_t vacc7x4567 = vacc0x4567;
98
99 size_t k = kc;
100 do {
101 const float32x4_t va0123 = vld1q_f32(a); a += 4;
102 const float32x4_t va4567 = vld1q_f32(a); a += 4;
103
104 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
105 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
106
107 vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123, vget_low_f32(va0123), 0);
108 vacc1x0123 = vmlaq_lane_f32(vacc1x0123, vb0123, vget_low_f32(va0123), 1);
109 vacc2x0123 = vmlaq_lane_f32(vacc2x0123, vb0123, vget_high_f32(va0123), 0);
110 vacc3x0123 = vmlaq_lane_f32(vacc3x0123, vb0123, vget_high_f32(va0123), 1);
111 vacc4x0123 = vmlaq_lane_f32(vacc4x0123, vb0123, vget_low_f32(va4567), 0);
112 vacc5x0123 = vmlaq_lane_f32(vacc5x0123, vb0123, vget_low_f32(va4567), 1);
113 vacc6x0123 = vmlaq_lane_f32(vacc6x0123, vb0123, vget_high_f32(va4567), 0);
114 vacc7x0123 = vmlaq_lane_f32(vacc7x0123, vb0123, vget_high_f32(va4567), 1);
115 xnn_prefetch_to_l1((const int8_t*) w + 192);
116 vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567, vget_low_f32(va0123), 0);
117 vacc1x4567 = vmlaq_lane_f32(vacc1x4567, vb4567, vget_low_f32(va0123), 1);
118 vacc2x4567 = vmlaq_lane_f32(vacc2x4567, vb4567, vget_high_f32(va0123), 0);
119 vacc3x4567 = vmlaq_lane_f32(vacc3x4567, vb4567, vget_high_f32(va0123), 1);
120 vacc4x4567 = vmlaq_lane_f32(vacc4x4567, vb4567, vget_low_f32(va4567), 0);
121 vacc5x4567 = vmlaq_lane_f32(vacc5x4567, vb4567, vget_low_f32(va4567), 1);
122 vacc6x4567 = vmlaq_lane_f32(vacc6x4567, vb4567, vget_high_f32(va4567), 0);
123 vacc7x4567 = vmlaq_lane_f32(vacc7x4567, vb4567, vget_high_f32(va4567), 1);
124
125 k -= sizeof(float);
126 } while (k != 0);
127
128 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
129 vacc1x0123 = vminq_f32(vacc1x0123, vmax);
130 vacc2x0123 = vminq_f32(vacc2x0123, vmax);
131 vacc3x0123 = vminq_f32(vacc3x0123, vmax);
132 vacc4x0123 = vminq_f32(vacc4x0123, vmax);
133 vacc5x0123 = vminq_f32(vacc5x0123, vmax);
134 vacc6x0123 = vminq_f32(vacc6x0123, vmax);
135 vacc7x0123 = vminq_f32(vacc7x0123, vmax);
136 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
137 vacc1x4567 = vminq_f32(vacc1x4567, vmax);
138 vacc2x4567 = vminq_f32(vacc2x4567, vmax);
139 vacc3x4567 = vminq_f32(vacc3x4567, vmax);
140 vacc4x4567 = vminq_f32(vacc4x4567, vmax);
141 vacc5x4567 = vminq_f32(vacc5x4567, vmax);
142 vacc6x4567 = vminq_f32(vacc6x4567, vmax);
143 vacc7x4567 = vminq_f32(vacc7x4567, vmax);
144
145 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
146 vacc1x0123 = vmaxq_f32(vacc1x0123, vmin);
147 vacc2x0123 = vmaxq_f32(vacc2x0123, vmin);
148 vacc3x0123 = vmaxq_f32(vacc3x0123, vmin);
149 vacc4x0123 = vmaxq_f32(vacc4x0123, vmin);
150 vacc5x0123 = vmaxq_f32(vacc5x0123, vmin);
151 vacc6x0123 = vmaxq_f32(vacc6x0123, vmin);
152 vacc7x0123 = vmaxq_f32(vacc7x0123, vmin);
153 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
154 vacc1x4567 = vmaxq_f32(vacc1x4567, vmin);
155 vacc2x4567 = vmaxq_f32(vacc2x4567, vmin);
156 vacc3x4567 = vmaxq_f32(vacc3x4567, vmin);
157 vacc4x4567 = vmaxq_f32(vacc4x4567, vmin);
158 vacc5x4567 = vmaxq_f32(vacc5x4567, vmin);
159 vacc6x4567 = vmaxq_f32(vacc6x4567, vmin);
160 vacc7x4567 = vmaxq_f32(vacc7x4567, vmin);
161
162 if XNN_LIKELY(nc >= 8) {
163 vst1q_f32(c7, vacc7x0123);
164 vst1q_f32(c7 + 4, vacc7x4567);
165 c7 = (float*) ((uintptr_t) c7 + cn_stride);
166 vst1q_f32(c6, vacc6x0123);
167 vst1q_f32(c6 + 4, vacc6x4567);
168 c6 = (float*) ((uintptr_t) c6 + cn_stride);
169 vst1q_f32(c5, vacc5x0123);
170 vst1q_f32(c5 + 4, vacc5x4567);
171 c5 = (float*) ((uintptr_t) c5 + cn_stride);
172 vst1q_f32(c4, vacc4x0123);
173 vst1q_f32(c4 + 4, vacc4x4567);
174 c4 = (float*) ((uintptr_t) c4 + cn_stride);
175 vst1q_f32(c3, vacc3x0123);
176 vst1q_f32(c3 + 4, vacc3x4567);
177 c3 = (float*) ((uintptr_t) c3 + cn_stride);
178 vst1q_f32(c2, vacc2x0123);
179 vst1q_f32(c2 + 4, vacc2x4567);
180 c2 = (float*) ((uintptr_t) c2 + cn_stride);
181 vst1q_f32(c1, vacc1x0123);
182 vst1q_f32(c1 + 4, vacc1x4567);
183 c1 = (float*) ((uintptr_t) c1 + cn_stride);
184 vst1q_f32(c0, vacc0x0123);
185 vst1q_f32(c0 + 4, vacc0x4567);
186 c0 = (float*) ((uintptr_t) c0 + cn_stride);
187
188 a = (const float*) ((uintptr_t) a - kc * 8);
189
190 nc -= 8;
191 } else {
192 if (nc & 4) {
193 vst1q_f32(c7, vacc7x0123); c7 += 4;
194 vst1q_f32(c6, vacc6x0123); c6 += 4;
195 vst1q_f32(c5, vacc5x0123); c5 += 4;
196 vst1q_f32(c4, vacc4x0123); c4 += 4;
197 vst1q_f32(c3, vacc3x0123); c3 += 4;
198 vst1q_f32(c2, vacc2x0123); c2 += 4;
199 vst1q_f32(c1, vacc1x0123); c1 += 4;
200 vst1q_f32(c0, vacc0x0123); c0 += 4;
201
202 vacc7x0123 = vacc7x4567;
203 vacc6x0123 = vacc6x4567;
204 vacc5x0123 = vacc5x4567;
205 vacc4x0123 = vacc4x4567;
206 vacc3x0123 = vacc3x4567;
207 vacc2x0123 = vacc2x4567;
208 vacc1x0123 = vacc1x4567;
209 vacc0x0123 = vacc0x4567;
210 }
211 float32x2_t vacc7x01 = vget_low_f32(vacc7x0123);
212 float32x2_t vacc6x01 = vget_low_f32(vacc6x0123);
213 float32x2_t vacc5x01 = vget_low_f32(vacc5x0123);
214 float32x2_t vacc4x01 = vget_low_f32(vacc4x0123);
215 float32x2_t vacc3x01 = vget_low_f32(vacc3x0123);
216 float32x2_t vacc2x01 = vget_low_f32(vacc2x0123);
217 float32x2_t vacc1x01 = vget_low_f32(vacc1x0123);
218 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
219 if (nc & 2) {
220 vst1_f32(c7, vacc7x01); c7 += 2;
221 vst1_f32(c6, vacc6x01); c6 += 2;
222 vst1_f32(c5, vacc5x01); c5 += 2;
223 vst1_f32(c4, vacc4x01); c4 += 2;
224 vst1_f32(c3, vacc3x01); c3 += 2;
225 vst1_f32(c2, vacc2x01); c2 += 2;
226 vst1_f32(c1, vacc1x01); c1 += 2;
227 vst1_f32(c0, vacc0x01); c0 += 2;
228
229 vacc7x01 = vget_high_f32(vacc7x0123);
230 vacc6x01 = vget_high_f32(vacc6x0123);
231 vacc5x01 = vget_high_f32(vacc5x0123);
232 vacc4x01 = vget_high_f32(vacc4x0123);
233 vacc3x01 = vget_high_f32(vacc3x0123);
234 vacc2x01 = vget_high_f32(vacc2x0123);
235 vacc1x01 = vget_high_f32(vacc1x0123);
236 vacc0x01 = vget_high_f32(vacc0x0123);
237 }
238 if (nc & 1) {
239 vst1_lane_f32(c7, vacc7x01, 0);
240 vst1_lane_f32(c6, vacc6x01, 0);
241 vst1_lane_f32(c5, vacc5x01, 0);
242 vst1_lane_f32(c4, vacc4x01, 0);
243 vst1_lane_f32(c3, vacc3x01, 0);
244 vst1_lane_f32(c2, vacc2x01, 0);
245 vst1_lane_f32(c1, vacc1x01, 0);
246 vst1_lane_f32(c0, vacc0x01, 0);
247 }
248
249 nc = 0;
250 }
251 } while (nc != 0);
252 }