Debian Codegraph @

src/f32-rsum/gen/f32-rsum-avx-u16-acc2.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rsum/avx.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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/reduce.h"
16
17
18 void xnn_f32_rsum_ukernel__avx_u16_acc2(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_scale_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 __m256 vacc0 = _mm256_setzero_ps();
32 __m256 vacc1 = _mm256_setzero_ps();
33 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
34 const __m256 vt0 = _mm256_loadu_ps(input);
35 const __m256 vt1 = _mm256_loadu_ps(input + 8);
36 input += 16;
37
38 vacc0 = _mm256_add_ps(vacc0, vt0);
39 vacc1 = _mm256_add_ps(vacc1, vt1);
40 }
41 vacc0 = _mm256_add_ps(vacc0, vacc1);
42 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
43 const __m256 vt = _mm256_loadu_ps(input);
44 input += 8;
45
46 vacc0 = _mm256_add_ps(vacc0, vt);
47 }
48 if XNN_UNLIKELY(batch != 0) {
49 assert(batch >= 1 * sizeof(float));
50 assert(batch <= 7 * sizeof(float));
51 const __m256i vmask = _mm256_loadu_si256((const __m256i*) ((uintptr_t) &mask_table[7] - batch));
52 const __m256 vt = _mm256_maskload_ps(input, vmask);
53 vacc0 = _mm256_add_ps(vacc0, vt);
54 }
55 __m128 vacc = _mm_add_ps(_mm256_castps256_ps128(vacc0), _mm256_extractf128_ps(vacc0, 1));
56 vacc = _mm_add_ps(vacc, _mm_movehl_ps(vacc, vacc));
57 vacc = _mm_add_ss(vacc, _mm_movehdup_ps(vacc));
58 vacc = _mm_mul_ss(vacc, _mm_load_ss(&params->scalar.scale));
59 *output += _mm_cvtss_f32(vacc);
60 }