Debian Codegraph @

src/x8-lut/gen/x8-lut-avx512skx-vpshufb-u192.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/avx512skx-vpshufb.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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 <immintrin.h>
13
14 #include "xnnpack/intrinsics-polyfill.h"
15 #include "xnnpack/lut.h"
16 #include "xnnpack/common.h"
17
18
19 void xnn_x8_lut_ukernel__avx512skx_vpshufb_u192(
20 size_t batch,
21 const uint8_t* input,
22 uint8_t* output,
23 const uint8_t table[restrict XNN_MIN_ELEMENTS(256)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(uint8_t) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const __m512i vt0 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) table));
31 const __m512i vt1 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 16)));
32 const __m512i vt2 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 32)));
33 const __m512i vt3 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 48)));
34 const __m512i vt4 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 64)));
35 const __m512i vt5 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 80)));
36 const __m512i vt6 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 96)));
37 const __m512i vt7 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 112)));
38 const __m512i vt8 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 128)));
39 const __m512i vt9 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 144)));
40 const __m512i vtA = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 160)));
41 const __m512i vtB = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 176)));
42 const __m512i vtC = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 192)));
43 const __m512i vtD = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 208)));
44 const __m512i vtE = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 224)));
45 const __m512i vtF = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 240)));
46
47 const __m512i vtable0 = vt0;
48 const __m512i vtable1 = _mm512_xor_si512(vt0, vt1);
49 const __m512i vtable2 = _mm512_xor_si512(vt1, vt2);
50 const __m512i vtable3 = _mm512_xor_si512(vt2, vt3);
51 const __m512i vtable4 = _mm512_xor_si512(vt3, vt4);
52 const __m512i vtable5 = _mm512_xor_si512(vt4, vt5);
53 const __m512i vtable6 = _mm512_xor_si512(vt5, vt6);
54 const __m512i vtable7 = _mm512_xor_si512(vt6, vt7);
55 const __m512i vtable8 = _mm512_xor_si512(_mm512_xor_si512(vt7, vt8), vtable0);
56 const __m512i vtable9 = _mm512_xor_si512(_mm512_xor_si512(vt8, vt9), vtable1);
57 const __m512i vtableA = _mm512_xor_si512(_mm512_xor_si512(vt9, vtA), vtable2);
58 const __m512i vtableB = _mm512_xor_si512(_mm512_xor_si512(vtA, vtB), vtable3);
59 const __m512i vtableC = _mm512_xor_si512(_mm512_xor_si512(vtB, vtC), vtable4);
60 const __m512i vtableD = _mm512_xor_si512(_mm512_xor_si512(vtC, vtD), vtable5);
61 const __m512i vtableE = _mm512_xor_si512(_mm512_xor_si512(vtD, vtE), vtable6);
62 const __m512i vtableF = _mm512_xor_si512(_mm512_xor_si512(vtE, vtF), vtable7);
63
64 const __m512i voffset = _mm512_set1_epi8(16);
65 for (; batch >= 192 * sizeof(uint8_t); batch -= 192 * sizeof(uint8_t)) {
66 __m512i vx0 = _mm512_loadu_si512(input);
67 __m512i vx1 = _mm512_loadu_si512(input + 64);
68 __m512i vx2 = _mm512_loadu_si512(input + 128);
69 input += 192;
70
71 __m512i vy0 = _mm512_shuffle_epi8(vtable0, vx0);
72 __m512i vy1 = _mm512_shuffle_epi8(vtable0, vx1);
73 __m512i vy2 = _mm512_shuffle_epi8(vtable0, vx2);
74
75 vx0 = _mm512_sub_epi8(vx0, voffset);
76 vx1 = _mm512_sub_epi8(vx1, voffset);
77 vx2 = _mm512_sub_epi8(vx2, voffset);
78 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable1, vx0));
79 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable1, vx1));
80 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable1, vx2));
81 vx0 = _mm512_sub_epi8(vx0, voffset);
82 vx1 = _mm512_sub_epi8(vx1, voffset);
83 vx2 = _mm512_sub_epi8(vx2, voffset);
84 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable2, vx0));
85 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable2, vx1));
86 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable2, vx2));
87 vx0 = _mm512_sub_epi8(vx0, voffset);
88 vx1 = _mm512_sub_epi8(vx1, voffset);
89 vx2 = _mm512_sub_epi8(vx2, voffset);
90 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable3, vx0));
91 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable3, vx1));
92 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable3, vx2));
93 vx0 = _mm512_sub_epi8(vx0, voffset);
94 vx1 = _mm512_sub_epi8(vx1, voffset);
95 vx2 = _mm512_sub_epi8(vx2, voffset);
96 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable4, vx0));
97 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable4, vx1));
98 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable4, vx2));
99 vx0 = _mm512_sub_epi8(vx0, voffset);
100 vx1 = _mm512_sub_epi8(vx1, voffset);
101 vx2 = _mm512_sub_epi8(vx2, voffset);
102 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable5, vx0));
103 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable5, vx1));
104 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable5, vx2));
105 vx0 = _mm512_sub_epi8(vx0, voffset);
106 vx1 = _mm512_sub_epi8(vx1, voffset);
107 vx2 = _mm512_sub_epi8(vx2, voffset);
108 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable6, vx0));
109 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable6, vx1));
110 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable6, vx2));
111 vx0 = _mm512_sub_epi8(vx0, voffset);
112 vx1 = _mm512_sub_epi8(vx1, voffset);
113 vx2 = _mm512_sub_epi8(vx2, voffset);
114 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable7, vx0));
115 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable7, vx1));
116 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable7, vx2));
117 vx0 = _mm512_sub_epi8(vx0, voffset);
118 vx1 = _mm512_sub_epi8(vx1, voffset);
119 vx2 = _mm512_sub_epi8(vx2, voffset);
120 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable8, vx0));
121 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable8, vx1));
122 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable8, vx2));
123
124 vx0 = _mm512_subs_epi8(vx0, voffset);
125 vx1 = _mm512_subs_epi8(vx1, voffset);
126 vx2 = _mm512_subs_epi8(vx2, voffset);
127 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtable9, vx0));
128 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtable9, vx1));
129 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtable9, vx2));
130 vx0 = _mm512_subs_epi8(vx0, voffset);
131 vx1 = _mm512_subs_epi8(vx1, voffset);
132 vx2 = _mm512_subs_epi8(vx2, voffset);
133 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableA, vx0));
134 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableA, vx1));
135 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableA, vx2));
136 vx0 = _mm512_subs_epi8(vx0, voffset);
137 vx1 = _mm512_subs_epi8(vx1, voffset);
138 vx2 = _mm512_subs_epi8(vx2, voffset);
139 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableB, vx0));
140 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableB, vx1));
141 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableB, vx2));
142 vx0 = _mm512_subs_epi8(vx0, voffset);
143 vx1 = _mm512_subs_epi8(vx1, voffset);
144 vx2 = _mm512_subs_epi8(vx2, voffset);
145 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableC, vx0));
146 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableC, vx1));
147 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableC, vx2));
148 vx0 = _mm512_subs_epi8(vx0, voffset);
149 vx1 = _mm512_subs_epi8(vx1, voffset);
150 vx2 = _mm512_subs_epi8(vx2, voffset);
151 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableD, vx0));
152 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableD, vx1));
153 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableD, vx2));
154 vx0 = _mm512_subs_epi8(vx0, voffset);
155 vx1 = _mm512_subs_epi8(vx1, voffset);
156 vx2 = _mm512_subs_epi8(vx2, voffset);
157 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableE, vx0));
158 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableE, vx1));
159 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableE, vx2));
160 vx0 = _mm512_subs_epi8(vx0, voffset);
161 vx1 = _mm512_subs_epi8(vx1, voffset);
162 vx2 = _mm512_subs_epi8(vx2, voffset);
163 vy0 = _mm512_xor_si512(vy0, _mm512_shuffle_epi8(vtableF, vx0));
164 vy1 = _mm512_xor_si512(vy1, _mm512_shuffle_epi8(vtableF, vx1));
165 vy2 = _mm512_xor_si512(vy2, _mm512_shuffle_epi8(vtableF, vx2));
166
167 _mm512_storeu_si512(output, vy0);
168 _mm512_storeu_si512(output + 64, vy1);
169 _mm512_storeu_si512(output + 128, vy2);
170 output += 192;
171 }
172 for (; batch >= 64 * sizeof(uint8_t); batch -= 64 * sizeof(uint8_t)) {
173 __m512i vx = _mm512_loadu_si512(input);
174 input += 64;
175
176 __m512i vy = _mm512_shuffle_epi8(vtable0, vx);
177
178 vx = _mm512_sub_epi8(vx, voffset);
179 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable1, vx));
180 vx = _mm512_sub_epi8(vx, voffset);
181 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable2, vx));
182 vx = _mm512_sub_epi8(vx, voffset);
183 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable3, vx));
184 vx = _mm512_sub_epi8(vx, voffset);
185 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable4, vx));
186 vx = _mm512_sub_epi8(vx, voffset);
187 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable5, vx));
188 vx = _mm512_sub_epi8(vx, voffset);
189 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable6, vx));
190 vx = _mm512_sub_epi8(vx, voffset);
191 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable7, vx));
192 vx = _mm512_sub_epi8(vx, voffset);
193 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable8, vx));
194
195 vx = _mm512_subs_epi8(vx, voffset);
196 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable9, vx));
197 vx = _mm512_subs_epi8(vx, voffset);
198 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableA, vx));
199 vx = _mm512_subs_epi8(vx, voffset);
200 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableB, vx));
201 vx = _mm512_subs_epi8(vx, voffset);
202 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableC, vx));
203 vx = _mm512_subs_epi8(vx, voffset);
204 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableD, vx));
205 vx = _mm512_subs_epi8(vx, voffset);
206 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableE, vx));
207 vx = _mm512_subs_epi8(vx, voffset);
208 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableF, vx));
209
210 _mm512_storeu_si512(output, vy);
211 output += 64;
212 }
213 if XNN_UNLIKELY(batch != 0) {
214 assert(batch < 64);
215 const __mmask64 vmask = _cvtu64_mask64((uint64_t) ((UINT64_C(1) << batch) - UINT64_C(1)));
216
217 __m512i vx = _mm512_maskz_loadu_epi8(vmask, input);
218
219 __m512i vy = _mm512_shuffle_epi8(vtable0, vx);
220
221 vx = _mm512_sub_epi8(vx, voffset);
222 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable1, vx));
223 vx = _mm512_sub_epi8(vx, voffset);
224 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable2, vx));
225 vx = _mm512_sub_epi8(vx, voffset);
226 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable3, vx));
227 vx = _mm512_sub_epi8(vx, voffset);
228 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable4, vx));
229 vx = _mm512_sub_epi8(vx, voffset);
230 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable5, vx));
231 vx = _mm512_sub_epi8(vx, voffset);
232 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable6, vx));
233 vx = _mm512_sub_epi8(vx, voffset);
234 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable7, vx));
235 vx = _mm512_sub_epi8(vx, voffset);
236 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable8, vx));
237
238 vx = _mm512_subs_epi8(vx, voffset);
239 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable9, vx));
240 vx = _mm512_subs_epi8(vx, voffset);
241 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableA, vx));
242 vx = _mm512_subs_epi8(vx, voffset);
243 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableB, vx));
244 vx = _mm512_subs_epi8(vx, voffset);
245 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableC, vx));
246 vx = _mm512_subs_epi8(vx, voffset);
247 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableD, vx));
248 vx = _mm512_subs_epi8(vx, voffset);
249 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableE, vx));
250 vx = _mm512_subs_epi8(vx, voffset);
251 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableF, vx));
252
253 _mm512_mask_storeu_epi8(output, vmask, vy);
254 }
255 }