Debian Codegraph @

src/f16-vbinary/gen/f16-vmul-avx512fp16-u32.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-vbinary/vop-avx512fp16.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
12 #include <immintrin.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/vbinary.h"
16
17
18 void xnn_f16_vmul_ukernel__avx512fp16_u32(
19 size_t batch,
20 const xnn_float16* restrict input_a,
21 const xnn_float16* restrict input_b,
22 xnn_float16* restrict output,
23 const struct xnn_f16_default_params params[restrict XNN_MIN_ELEMENTS(1)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(uint16_t) == 0);
27 assert(input_a != NULL);
28 assert(input_b != NULL);
29 assert(output != NULL);
30
31 #if defined(__AVX512FP16__)
32 const uint16_t* a = (const uint16_t*) input_a;
33 const uint16_t* b = (const uint16_t*) input_b;
34 uint16_t* o = (uint16_t*) output;
35
36
37 for (; batch >= 32 * sizeof(uint16_t); batch -= 32 * sizeof(uint16_t)) {
38 const __m512h va = _mm512_loadu_ph(a);
39 a += 32;
40
41 __m512h vacc = _mm512_mul_ph(va, _mm512_loadu_ph(b));
42 b += 32;
43
44
45 _mm512_storeu_ph(o, vacc);
46 o += 32;
47 }
48 if XNN_UNLIKELY(batch != 0) {
49 assert(batch >= 1 * sizeof(uint16_t));
50 assert(batch <= 31 * sizeof(uint16_t));
51 // Prepare mask for valid 16-bit elements (depends on batch).
52 batch >>= XNN_LOG2_SIZEOF_HALF;
53 const __mmask32 vmask = _cvtu32_mask32((uint32_t) ((UINT32_C(1) << batch) - UINT32_C(1)));
54
55 const __m512h va = _mm512_castsi512_ph(_mm512_maskz_loadu_epi16(vmask, a));
56
57 __m512h vacc = _mm512_maskz_mul_ph(vmask, va, _mm512_castsi512_ph(_mm512_maskz_loadu_epi16(vmask, b)));
58
59
60 _mm512_mask_storeu_epi16(o, vmask, _mm512_castph_si512(vacc));
61 }
62 #endif // defined(__AVX512FP16__)
63 }