Debian Codegraph @

src/f16-vbinary/gen/f16-vdiv-f16c-u16.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-vbinary/vop-f16c.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 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/intrinsics-polyfill.h"
16 #include "xnnpack/vbinary.h"
17
18
19 void xnn_f16_vdiv_ukernel__f16c_u16(
20 size_t batch,
21 const xnn_float16* restrict input_a,
22 const xnn_float16* restrict input_b,
23 xnn_float16* restrict output,
24 const struct xnn_f16_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
25 {
26 assert(batch != 0);
27 assert(batch % sizeof(uint16_t) == 0);
28 assert(input_a != NULL);
29 assert(input_b != NULL);
30 assert(output != NULL);
31
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 for (; batch >= 16 * sizeof(uint16_t); batch -= 16 * sizeof(uint16_t)) {
37 const __m256 va01234567 = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) a));
38 const __m256 vb01234567 = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) b));
39 const __m256 va456789AB = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) (a + 8)));
40 const __m256 vb456789AB = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) (b + 8)));
41 a += 16;
42 b += 16;
43
44 __m256 vy01234567 = _mm256_cvtph_ps(_mm256_cvtps_ph(_mm256_div_ps(va01234567, vb01234567), _MM_FROUND_TO_NEAREST_INT));
45 __m256 vy456789AB = _mm256_cvtph_ps(_mm256_cvtps_ph(_mm256_div_ps(va456789AB, vb456789AB), _MM_FROUND_TO_NEAREST_INT));
46
47
48 _mm_storeu_si128((__m128i*) o, _mm256_cvtps_ph(vy01234567, _MM_FROUND_TO_NEAREST_INT));
49 _mm_storeu_si128((__m128i*) (o + 8), _mm256_cvtps_ph(vy456789AB, _MM_FROUND_TO_NEAREST_INT));
50 o += 16;
51 }
52 for (; batch >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) {
53 const __m256 va = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) a));
54 const __m256 vb = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) b));
55 a += 8;
56 b += 8;
57
58 __m256 vy = _mm256_cvtph_ps(_mm256_cvtps_ph(_mm256_div_ps(va, vb), _MM_FROUND_TO_NEAREST_INT));
59
60 _mm_storeu_si128((__m128i*) o, _mm256_cvtps_ph(vy, _MM_FROUND_TO_NEAREST_INT));
61 o += 8;
62 }
63 if XNN_UNLIKELY(batch != 0) {
64 const __m256 va = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) a));
65 const __m256 vb = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) b));
66
67 __m256 vy = _mm256_cvtph_ps(_mm256_cvtps_ph(_mm256_div_ps(va, vb), _MM_FROUND_TO_NEAREST_INT));
68
69 __m128i vh = _mm256_cvtps_ph(vy, _MM_FROUND_TO_NEAREST_INT);
70 if (batch & (4 * sizeof(uint16_t))) {
71 _mm_storel_epi64((__m128i*) o, vh);
72 vh = _mm_unpackhi_epi64(vh, vh);
73 o += 4;
74 }
75 if (batch & (2 * sizeof(uint16_t))) {
76 _mm_storeu_si32(o, vh);
77 vh = _mm_srli_epi64(vh, 32);
78 o += 2;
79 }
80 if (batch & (1 * sizeof(uint16_t))) {
81 *o = (uint16_t) _mm_extract_epi16(vh, 0);
82 }
83 }
84 }