Debian Codegraph @

src/f32-igemm/gen/f32-igemm-1x8-wasmsimd-loadsplat.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/wasmsimd-loadsplat.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 <wasm_simd128.h>
13
14 #include "xnnpack/igemm.h"
15
16
17 void xnn_f32_igemm_ukernel_1x8__wasmsimd_loadsplat(
18 size_t mr,
19 size_t nc,
20 size_t kc,
21 size_t ks,
22 const float** restrict a,
23 const float* restrict w,
24 float* restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 size_t a_offset,
28 const float* zero,
29 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
30 {
31 assert(mr != 0);
32 assert(mr <= 1);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(float) == 0);
36 assert(ks != 0);
37 assert(ks % (1 * sizeof(void*)) == 0);
38 assert(a_offset % sizeof(float) == 0);
39 assert(a != NULL);
40 assert(w != NULL);
41 assert(c != NULL);
42
43 float* c0 = c;
44
45 do {
46 v128_t vacc0x0123 = wasm_v128_load(w);
47 v128_t vacc0x4567 = wasm_v128_load(w + 4);
48 w += 8;
49
50 size_t p = ks;
51 do {
52 const float* restrict a0 = a[0];
53 assert(a0 != NULL);
54 if XNN_UNPREDICTABLE(a0 != zero) {
55 a0 = (const float*) ((uintptr_t) a0 + a_offset);
56 }
57 a += 1;
58
59 size_t k = kc;
60 do {
61 const v128_t vb0123 = wasm_v128_load(w);
62 const v128_t vb4567 = wasm_v128_load(w + 4);
63 w += 8;
64
65 const v128_t va0 = wasm_v128_load32_splat(a0);
66 a0 += 1;
67
68 vacc0x0123 = wasm_f32x4_add(wasm_f32x4_mul(va0, vb0123), vacc0x0123);
69 vacc0x4567 = wasm_f32x4_add(wasm_f32x4_mul(va0, vb4567), vacc0x4567);
70 k -= sizeof(float);
71 } while (k != 0);
72 p -= 1 * sizeof(void*);
73 } while (p != 0);
74
75
76 if XNN_LIKELY(nc >= 8) {
77 wasm_v128_store(c0, vacc0x0123);
78 wasm_v128_store(c0 + 4, vacc0x4567);
79 c0 = (float*) ((uintptr_t) c0 + cn_stride);
80
81 a = (const float**restrict) ((uintptr_t) a - ks);
82 nc -= 8;
83 } else {
84 if (nc & 4) {
85 wasm_v128_store(c0, vacc0x0123);
86
87 vacc0x0123 = vacc0x4567;
88
89 c0 += 4;
90 }
91 if (nc & 2) {
92 wasm_v128_store64_lane(c0, vacc0x0123, 0);
93
94 vacc0x0123 = wasm_v64x2_shuffle(vacc0x0123, vacc0x0123, 1, 1);
95
96 c0 += 2;
97 }
98 if (nc & 1) {
99 wasm_v128_store32_lane(c0, vacc0x0123, 0);
100 }
101
102 nc = 0;
103 }
104 } while (nc != 0);
105 }