Debian Codegraph @

src/f32-vsqrt/gen/f32-vsqrt-avx-sqrt-u32.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vsqrt/avx-sqrt.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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/vunary.h"
16
17
18 void xnn_f32_vsqrt_ukernel__avx_sqrt_u32(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 static const int32_t mask_table[14] = {-1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0};
25
26 assert(batch != 0);
27 assert(batch % sizeof(float) == 0);
28 assert(input != NULL);
29 assert(output != NULL);
30
31 for (; batch >= 32 * sizeof(float); batch -= 32 * sizeof(float)) {
32 const __m256 vx01234567 = _mm256_loadu_ps(input);
33 const __m256 vx89ABCDEF = _mm256_loadu_ps(input + 8);
34 const __m256 vxGHIJKLMN = _mm256_loadu_ps(input + 16);
35 const __m256 vxOPQRSTUV = _mm256_loadu_ps(input + 24);
36 input += 32;
37
38 const __m256 vy01234567 = _mm256_sqrt_ps(vx01234567);
39 const __m256 vy89ABCDEF = _mm256_sqrt_ps(vx89ABCDEF);
40 const __m256 vyGHIJKLMN = _mm256_sqrt_ps(vxGHIJKLMN);
41 const __m256 vyOPQRSTUV = _mm256_sqrt_ps(vxOPQRSTUV);
42
43 _mm256_storeu_ps(output, vy01234567);
44 _mm256_storeu_ps(output + 8, vy89ABCDEF);
45 _mm256_storeu_ps(output + 16, vyGHIJKLMN);
46 _mm256_storeu_ps(output + 24, vyOPQRSTUV);
47 output += 32;
48 }
49 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
50 const __m256 vx = _mm256_loadu_ps(input);
51 input += 8;
52 const __m256 vy = _mm256_sqrt_ps(vx);
53 _mm256_storeu_ps(output, vy);
54 output += 8;
55 }
56 if XNN_UNLIKELY(batch != 0) {
57 assert(batch >= 1 * sizeof(float));
58 assert(batch <= 7 * sizeof(float));
59 const __m256i vmask = _mm256_loadu_si256((const __m256i*) ((uintptr_t) &mask_table[7] - batch));
60
61 const __m256 vx = _mm256_maskload_ps(input, vmask);
62 const __m256 vy = _mm256_sqrt_ps(vx);
63
64 __m128 vy_lo = _mm256_castps256_ps128(vy);
65 if (batch & (4 * sizeof(float))) {
66 _mm_storeu_ps(output, vy_lo);
67 vy_lo = _mm256_extractf128_ps(vy, 1);
68 output += 4;
69 }
70 if (batch & (2 * sizeof(float))) {
71 _mm_storel_pi((__m64*) output, vy_lo);
72 vy_lo = _mm_movehl_ps(vy_lo, vy_lo);
73 output += 2;
74 }
75 if (batch & (1 * sizeof(float))) {
76 _mm_store_ss(output, vy_lo);
77 }
78 }
79 }