blob: 3f07e254dd5f4370874df27492d6a7fac062b3dd [file] [log] [blame]
XNNPACK Teamb455b122019-09-27 18:10:33 -07001// Auto-generated file. Do not edit!
2// Template: src/f32-gemm/sse-load1.c.in
3// Generator: tools/xngen
4//
5// Copyright 2019 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 <xmmintrin.h>
13
14#include <xnnpack/gemm.h>
15
16
17void xnn_f32_gemminc_ukernel_1x8__sse_load1(
18 size_t mr,
19 size_t nc,
20 size_t kc,
21 const float*restrict a,
22 size_t a_stride,
23 const float*restrict w,
24 float*restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 const float*restrict acc,
Marat Dukhaneb09a6b2020-04-08 17:34:32 -070028 const union xnn_f32_minmax_params params[restrict static 1])
XNNPACK Teamb455b122019-09-27 18:10:33 -070029{
30 assert(mr != 0);
31 assert(mr <= 1);
32 assert(nc != 0);
33 assert(kc != 0);
34 assert(kc % sizeof(float) == 0);
35 assert(a != NULL);
36 assert(w != NULL);
37 assert(c != NULL);
38 assert(acc != NULL);
39
40 const float* a0 = a;
41 float* c0 = c;
42
43 do {
44 __m128 vacc0x0123 = _mm_load_ps(acc + 0);
45 __m128 vacc0x4567 = _mm_load_ps(acc + 4);
46 acc += 8;
47
48 size_t k = kc;
49 do {
50 const __m128 va0 = _mm_load1_ps(a0);
51 a0 += 1;
52
53 const __m128 vb0123 = _mm_load_ps(w);
54 const __m128 vb4567 = _mm_load_ps(w + 4);
55 w += 8;
56
57 vacc0x0123 = _mm_add_ps(vacc0x0123, _mm_mul_ps(va0, vb0123));
58 vacc0x4567 = _mm_add_ps(vacc0x4567, _mm_mul_ps(va0, vb4567));
59
60 k -= sizeof(float);
61 } while (k != 0);
62
63 const __m128 vmax = _mm_load_ps(params->sse.max);
64 vacc0x0123 = _mm_min_ps(vacc0x0123, vmax);
65 vacc0x4567 = _mm_min_ps(vacc0x4567, vmax);
66
67 const __m128 vmin = _mm_load_ps(params->sse.min);
68 vacc0x0123 = _mm_max_ps(vacc0x0123, vmin);
69 vacc0x4567 = _mm_max_ps(vacc0x4567, vmin);
70
71 if XNN_LIKELY(nc >= 8) {
72 _mm_storeu_ps(c0, vacc0x0123);
73 _mm_storeu_ps(c0 + 4, vacc0x4567);
74 c0 = (float*) ((uintptr_t) c0 + cn_stride);
75
76 a0 = (const float*) ((uintptr_t) a0 - kc);
77
78 nc -= 8;
79 } else {
80 if (nc & 4) {
81 _mm_storeu_ps(c0, vacc0x0123);
82
83 vacc0x0123 = vacc0x4567;
84
85 c0 += 4;
86 }
87 if (nc & 2) {
88 _mm_storel_pi((__m64*) c0, vacc0x0123);
89
90 vacc0x0123 = _mm_movehl_ps(vacc0x0123, vacc0x0123);
91
92 c0 += 2;
93 }
94 if (nc & 1) {
95 _mm_store_ss(c0, vacc0x0123);
96 }
97
98 nc = 0;
99 }
100 } while (nc != 0);
101}