Debian Codegraph @

src/f32-rsum/gen/f32-rsum-avx-u24-acc3.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_u24_acc3(
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 __m256 vacc2 = _mm256_setzero_ps();
34 for (; batch >= 24 * sizeof(float); batch -= 24 * sizeof(float)) {
35 const __m256 vt0 = _mm256_loadu_ps(input);
36 const __m256 vt1 = _mm256_loadu_ps(input + 8);
37 const __m256 vt2 = _mm256_loadu_ps(input + 16);
38 input += 24;
39
40 vacc0 = _mm256_add_ps(vacc0, vt0);
41 vacc1 = _mm256_add_ps(vacc1, vt1);
42 vacc2 = _mm256_add_ps(vacc2, vt2);
43 }
44 vacc0 = _mm256_add_ps(vacc0, vacc1);
45 vacc0 = _mm256_add_ps(vacc0, vacc2);
46 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
47 const __m256 vt = _mm256_loadu_ps(input);
48 input += 8;
49
50 vacc0 = _mm256_add_ps(vacc0, vt);
51 }
52 if XNN_UNLIKELY(batch != 0) {
53 assert(batch >= 1 * sizeof(float));
54 assert(batch <= 7 * sizeof(float));
55 const __m256i vmask = _mm256_loadu_si256((const __m256i*) ((uintptr_t) &mask_table[7] - batch));
56 const __m256 vt = _mm256_maskload_ps(input, vmask);
57 vacc0 = _mm256_add_ps(vacc0, vt);
58 }
59 __m128 vacc = _mm_add_ps(_mm256_castps256_ps128(vacc0), _mm256_extractf128_ps(vacc0, 1));
60 vacc = _mm_add_ps(vacc, _mm_movehl_ps(vacc, vacc));
61 vacc = _mm_add_ss(vacc, _mm_movehdup_ps(vacc));
62 vacc = _mm_mul_ss(vacc, _mm_load_ss(&params->scalar.scale));
63 *output += _mm_cvtss_f32(vacc);
64 }