Debian Codegraph @

src/f32-ppmm/gen/f32-ppmm-4x8-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_4x8__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 <= 4);
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
60 xnn_prefetch_to_l1((const int8_t*) w + 0);
61 xnn_prefetch_to_l1((const int8_t*) w + 64);
62 xnn_prefetch_to_l1((const int8_t*) w + 128);
63 xnn_prefetch_to_l1((const int8_t*) w + 192);
64
65 do {
66 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
67 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
68 float32x4_t vacc1x0123 = vacc0x0123;
69 float32x4_t vacc1x4567 = vacc0x4567;
70 float32x4_t vacc2x0123 = vacc0x0123;
71 float32x4_t vacc2x4567 = vacc0x4567;
72 float32x4_t vacc3x0123 = vacc0x0123;
73 float32x4_t vacc3x4567 = vacc0x4567;
74
75 size_t k = kc;
76 do {
77 const float32x4_t va0123 = vld1q_f32(a); a += 4;
78
79 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
80 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
81
82 vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123, vget_low_f32(va0123), 0);
83 vacc1x0123 = vmlaq_lane_f32(vacc1x0123, vb0123, vget_low_f32(va0123), 1);
84 vacc2x0123 = vmlaq_lane_f32(vacc2x0123, vb0123, vget_high_f32(va0123), 0);
85 vacc3x0123 = vmlaq_lane_f32(vacc3x0123, vb0123, vget_high_f32(va0123), 1);
86 xnn_prefetch_to_l1((const int8_t*) w + 192);
87 vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567, vget_low_f32(va0123), 0);
88 vacc1x4567 = vmlaq_lane_f32(vacc1x4567, vb4567, vget_low_f32(va0123), 1);
89 vacc2x4567 = vmlaq_lane_f32(vacc2x4567, vb4567, vget_high_f32(va0123), 0);
90 vacc3x4567 = vmlaq_lane_f32(vacc3x4567, vb4567, vget_high_f32(va0123), 1);
91
92 k -= sizeof(float);
93 } while (k != 0);
94
95 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
96 vacc1x0123 = vminq_f32(vacc1x0123, vmax);
97 vacc2x0123 = vminq_f32(vacc2x0123, vmax);
98 vacc3x0123 = vminq_f32(vacc3x0123, vmax);
99 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
100 vacc1x4567 = vminq_f32(vacc1x4567, vmax);
101 vacc2x4567 = vminq_f32(vacc2x4567, vmax);
102 vacc3x4567 = vminq_f32(vacc3x4567, vmax);
103
104 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
105 vacc1x0123 = vmaxq_f32(vacc1x0123, vmin);
106 vacc2x0123 = vmaxq_f32(vacc2x0123, vmin);
107 vacc3x0123 = vmaxq_f32(vacc3x0123, vmin);
108 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
109 vacc1x4567 = vmaxq_f32(vacc1x4567, vmin);
110 vacc2x4567 = vmaxq_f32(vacc2x4567, vmin);
111 vacc3x4567 = vmaxq_f32(vacc3x4567, vmin);
112
113 if XNN_LIKELY(nc >= 8) {
114 vst1q_f32(c3, vacc3x0123);
115 vst1q_f32(c3 + 4, vacc3x4567);
116 c3 = (float*) ((uintptr_t) c3 + cn_stride);
117 vst1q_f32(c2, vacc2x0123);
118 vst1q_f32(c2 + 4, vacc2x4567);
119 c2 = (float*) ((uintptr_t) c2 + cn_stride);
120 vst1q_f32(c1, vacc1x0123);
121 vst1q_f32(c1 + 4, vacc1x4567);
122 c1 = (float*) ((uintptr_t) c1 + cn_stride);
123 vst1q_f32(c0, vacc0x0123);
124 vst1q_f32(c0 + 4, vacc0x4567);
125 c0 = (float*) ((uintptr_t) c0 + cn_stride);
126
127 a = (const float*) ((uintptr_t) a - kc * 4);
128
129 nc -= 8;
130 } else {
131 if (nc & 4) {
132 vst1q_f32(c3, vacc3x0123); c3 += 4;
133 vst1q_f32(c2, vacc2x0123); c2 += 4;
134 vst1q_f32(c1, vacc1x0123); c1 += 4;
135 vst1q_f32(c0, vacc0x0123); c0 += 4;
136
137 vacc3x0123 = vacc3x4567;
138 vacc2x0123 = vacc2x4567;
139 vacc1x0123 = vacc1x4567;
140 vacc0x0123 = vacc0x4567;
141 }
142 float32x2_t vacc3x01 = vget_low_f32(vacc3x0123);
143 float32x2_t vacc2x01 = vget_low_f32(vacc2x0123);
144 float32x2_t vacc1x01 = vget_low_f32(vacc1x0123);
145 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
146 if (nc & 2) {
147 vst1_f32(c3, vacc3x01); c3 += 2;
148 vst1_f32(c2, vacc2x01); c2 += 2;
149 vst1_f32(c1, vacc1x01); c1 += 2;
150 vst1_f32(c0, vacc0x01); c0 += 2;
151
152 vacc3x01 = vget_high_f32(vacc3x0123);
153 vacc2x01 = vget_high_f32(vacc2x0123);
154 vacc1x01 = vget_high_f32(vacc1x0123);
155 vacc0x01 = vget_high_f32(vacc0x0123);
156 }
157 if (nc & 1) {
158 vst1_lane_f32(c3, vacc3x01, 0);
159 vst1_lane_f32(c2, vacc2x01, 0);
160 vst1_lane_f32(c1, vacc1x01, 0);
161 vst1_lane_f32(c0, vacc0x01, 0);
162 }
163
164 nc = 0;
165 }
166 } while (nc != 0);
167 }