Debian Codegraph @

src/f32-vcopysign/gen/f32-vcopysignc-avx.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vcopysign/copysignc.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 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 #include <stddef.h>
12 #include <stdint.h>
13
14 #include "xnnpack/simd/f32-avx.h"
15
16 #include "xnnpack/common.h"
17 #include "xnnpack/microparams.h"
18 #include "xnnpack/vunary.h"
19
20
21 void xnn_f32_vcopysignc_ukernel__avx_u8(
22 size_t batch,
23 const float* mag,
24 const float* sign,
25 float* output,
26 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
27 {
28 assert(batch != 0);
29 assert(batch % sizeof(float) == 0);
30 assert(mag != NULL);
31 assert(sign != NULL);
32 assert(output != NULL);
33 assert(xnn_simd_size_f32 == 8);
34
35 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
36 xnn_simd_f32_t vsign = xnn_set1_f32(*sign);
37 vsign = xnn_and_f32(vsign, vsign_mask);
38
39 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
40 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
41 mag += xnn_simd_size_f32;
42
43 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
44
45 xnn_storeu_f32(output, vy);
46 output += xnn_simd_size_f32;
47 }
48 if XNN_UNLIKELY(batch != 0) {
49 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT));
50
51 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
52
53 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
54 }
55 }
56
57 void xnn_f32_vcopysignc_ukernel__avx_u16(
58 size_t batch,
59 const float* mag,
60 const float* sign,
61 float* output,
62 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
63 {
64 assert(batch != 0);
65 assert(batch % sizeof(float) == 0);
66 assert(mag != NULL);
67 assert(sign != NULL);
68 assert(output != NULL);
69 assert(xnn_simd_size_f32 == 8);
70
71 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
72 xnn_simd_f32_t vsign = xnn_set1_f32(*sign);
73 vsign = xnn_and_f32(vsign, vsign_mask);
74
75 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
76
77 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
78 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
79 mag += 16;
80
81 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign, vmag_0);
82 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign, vmag_1);
83
84 xnn_storeu_f32(output, vy_0);
85 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
86 output += 16;
87 }
88 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
89 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
90 mag += xnn_simd_size_f32;
91
92 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
93
94 xnn_storeu_f32(output, vy);
95 output += xnn_simd_size_f32;
96 }
97 if XNN_UNLIKELY(batch != 0) {
98 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT));
99
100 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
101
102 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
103 }
104 }
105
106 void xnn_f32_vcopysignc_ukernel__avx_u24(
107 size_t batch,
108 const float* mag,
109 const float* sign,
110 float* output,
111 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
112 {
113 assert(batch != 0);
114 assert(batch % sizeof(float) == 0);
115 assert(mag != NULL);
116 assert(sign != NULL);
117 assert(output != NULL);
118 assert(xnn_simd_size_f32 == 8);
119
120 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
121 xnn_simd_f32_t vsign = xnn_set1_f32(*sign);
122 vsign = xnn_and_f32(vsign, vsign_mask);
123
124 for (; batch >= 24 * sizeof(float); batch -= 24 * sizeof(float)) {
125
126 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
127 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
128 xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32));
129 mag += 24;
130
131 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign, vmag_0);
132 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign, vmag_1);
133 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign, vmag_2);
134
135 xnn_storeu_f32(output, vy_0);
136 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
137 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
138 output += 24;
139 }
140 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
141 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
142 mag += xnn_simd_size_f32;
143
144 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
145
146 xnn_storeu_f32(output, vy);
147 output += xnn_simd_size_f32;
148 }
149 if XNN_UNLIKELY(batch != 0) {
150 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT));
151
152 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
153
154 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
155 }
156 }
157
158 void xnn_f32_vcopysignc_ukernel__avx_u32(
159 size_t batch,
160 const float* mag,
161 const float* sign,
162 float* output,
163 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
164 {
165 assert(batch != 0);
166 assert(batch % sizeof(float) == 0);
167 assert(mag != NULL);
168 assert(sign != NULL);
169 assert(output != NULL);
170 assert(xnn_simd_size_f32 == 8);
171
172 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
173 xnn_simd_f32_t vsign = xnn_set1_f32(*sign);
174 vsign = xnn_and_f32(vsign, vsign_mask);
175
176 for (; batch >= 32 * sizeof(float); batch -= 32 * sizeof(float)) {
177
178 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
179 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
180 xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32));
181 xnn_simd_f32_t vmag_3 = xnn_abs_f32(xnn_loadu_f32(mag + 3 * xnn_simd_size_f32));
182 mag += 32;
183
184 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign, vmag_0);
185 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign, vmag_1);
186 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign, vmag_2);
187 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign, vmag_3);
188
189 xnn_storeu_f32(output, vy_0);
190 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
191 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
192 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
193 output += 32;
194 }
195 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
196 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
197 mag += xnn_simd_size_f32;
198
199 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
200
201 xnn_storeu_f32(output, vy);
202 output += xnn_simd_size_f32;
203 }
204 if XNN_UNLIKELY(batch != 0) {
205 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT));
206
207 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
208
209 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
210 }
211 }