Debian Codegraph @

src/f32-igemm/gen/f32-igemm-1x32-minmax-avx512f-broadcast.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/avx512-broadcast.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 <immintrin.h>
13
14 #include "xnnpack/igemm.h"
15 #include "xnnpack/intrinsics-polyfill.h"
16
17
18 void xnn_f32_igemm_minmax_ukernel_1x32__avx512f_broadcast(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 size_t ks,
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 size_t a_offset,
29 const float* zero,
30 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
31 {
32 assert(mr != 0);
33 assert(mr <= 1);
34 assert(nc != 0);
35 assert(kc != 0);
36 assert(kc % sizeof(float) == 0);
37 assert(ks != 0);
38 assert(ks % (1 * sizeof(void*)) == 0);
39 assert(a_offset % sizeof(float) == 0);
40 assert(a != NULL);
41 assert(w != NULL);
42 assert(c != NULL);
43
44 float* c0 = c;
45
46 do {
47 __m512 vacc0x0 = _mm512_load_ps(w);
48 __m512 vacc0x1 = _mm512_load_ps(w + 16);
49 w += 32;
50
51 size_t p = ks;
52 do {
53 const float* restrict a0 = a[0];
54 assert(a0 != NULL);
55 if XNN_UNPREDICTABLE(a0 != zero) {
56 a0 = (const float*) ((uintptr_t) a0 + a_offset);
57 }
58 a += 1;
59
60 size_t k = kc;
61 do {
62 const __m512 vb0 = _mm512_load_ps(w);
63 const __m512 vb1 = _mm512_load_ps(w + 16);
64 w += 32;
65
66 const __m512 va0 = _mm512_set1_ps(*a0);
67 vacc0x0 = _mm512_fmadd_ps(va0, vb0, vacc0x0);
68 vacc0x1 = _mm512_fmadd_ps(va0, vb1, vacc0x1);
69
70 a0 += 1;
71
72 k -= sizeof(float);
73 } while (k != 0);
74 p -= 1 * sizeof(void*);
75 } while (p != 0);
76
77 const __m512 vmin = _mm512_set1_ps(params->scalar.min);
78 vacc0x0 = _mm512_max_ps(vmin, vacc0x0);
79 vacc0x1 = _mm512_max_ps(vmin, vacc0x1);
80
81 const __m512 vmax = _mm512_set1_ps(params->scalar.max);
82 vacc0x0 = _mm512_min_ps(vmax, vacc0x0);
83 vacc0x1 = _mm512_min_ps(vmax, vacc0x1);
84
85 if XNN_LIKELY(nc >= 32) {
86 _mm512_storeu_ps(c0, vacc0x0);
87 _mm512_storeu_ps(c0 + 16, vacc0x1);
88 c0 = (float*) ((uintptr_t) c0 + cn_stride);
89
90 a = (const float**restrict) ((uintptr_t) a - ks);
91 nc -= 32;
92 } else {
93 // NC remainder (1..31)
94 assert(nc >= 1);
95 assert(nc <= 31);
96 // Prepare mask for valid 32-bit elements (depends on nc).
97 const __mmask16 vmask0 = _cvtu32_mask16((uint32_t) (((UINT64_C(1) << nc) - 1) >> 0));
98 const __mmask16 vmask1 = _cvtu32_mask16((uint32_t) (((UINT64_C(1) << nc) - 1) >> 16));
99
100 _mm512_mask_storeu_ps(c0 + 0, vmask0, vacc0x0);
101 _mm512_mask_storeu_ps(c0 + 16, vmask1, vacc0x1);
102 nc = 0;
103 }
104 } while (nc != 0);
105 }