Debian Codegraph @

src/f32-vbinary/gen/f32-vrsubc-avx512f-u32.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vbinary/vopc-avx512f.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
11 #include <assert.h>
12
13 #include <immintrin.h>
14
15 #include "xnnpack/common.h"
16 #include "xnnpack/intrinsics-polyfill.h"
17 #include "xnnpack/vbinary.h"
18
19
20 void xnn_f32_vrsubc_ukernel__avx512f_u32(
21 size_t batch,
22 const float* input_a,
23 const float* input_b,
24 float* output,
25 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
26 {
27 assert(batch != 0);
28 assert(batch % sizeof(float) == 0);
29 assert(input_a != NULL);
30 assert(input_b != NULL);
31 assert(output != NULL);
32
33 const __m512 vb = _mm512_set1_ps(*input_b);
34
35 for (; batch >= 32 * sizeof(float); batch -= 32 * sizeof(float)) {
36 const __m512 va0 = _mm512_loadu_ps(input_a);
37 __m512 va1 = _mm512_loadu_ps(input_a + 16);
38 input_a += 32;
39
40 __m512 vacc0 = _mm512_sub_ps(vb, va0);
41 __m512 vacc1 = _mm512_sub_ps(vb, va1);
42
43
44 _mm512_storeu_ps(output, vacc0);
45 _mm512_storeu_ps(output + 16, vacc1);
46 output += 32;
47 }
48 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
49 const __m512 va = _mm512_loadu_ps(input_a);
50 input_a += 16;
51
52 __m512 vacc = _mm512_sub_ps(vb, va);
53
54 _mm512_storeu_ps(output, vacc);
55 output += 16;
56 }
57 if XNN_UNLIKELY(batch != 0) {
58 assert(batch >= 1 * sizeof(float));
59 assert(batch <= 15 * sizeof(float));
60 // Prepare mask for valid 32-bit elements (depends on batch).
61 batch >>= XNN_LOG2_SIZEOF_FLOAT;
62 const __mmask16 vmask = _cvtu32_mask16((uint32_t) ((UINT32_C(1) << batch) - UINT32_C(1)));
63
64 __m512 va = _mm512_maskz_loadu_ps(vmask, input_a);
65 __m512 vacc = _mm512_sub_ps(vb, va);
66
67 _mm512_mask_storeu_ps(output, vmask, vacc);
68 }
69 }