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
xnn_f32_igemm_minmax_ukernel_1x8__wasmsimd_arm_loadsplat(size_t mr,size_t nc,size_t kc,size_t ks,const float ** restrict a,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const float * zero,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_igemm_minmax_ukernel_1x8__wasmsimd_arm_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 union xnn_f32_minmax_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 const v128_t vmin = wasm_v32x4_load_splat(¶ms->scalar.min);
46 const v128_t vmax = wasm_v32x4_load_splat(¶ms->scalar.max);
47 do {
48 v128_t vacc0x0123 = wasm_v128_load(w);
49 v128_t vacc0x4567 = wasm_v128_load(w + 4);
50 w += 8;
51
52 size_t p = ks;
53 do {
54 const float* restrict a0 = a[0];
55 assert(a0 != NULL);
56 if XNN_UNPREDICTABLE(a0 != zero) {
57 a0 = (const float*) ((uintptr_t) a0 + a_offset);
58 }
59 a += 1;
60
61 size_t k = kc;
62 do {
63 const v128_t vb0123 = wasm_v128_load(w);
64 const v128_t vb4567 = wasm_v128_load(w + 4);
65 w += 8;
66
67 const v128_t va0 = wasm_v32x4_load_splat(a0);
68 a0 += 1;
69
70 vacc0x0123 = wasm_f32x4_add(vacc0x0123, wasm_f32x4_mul(va0, vb0123));
71 vacc0x4567 = wasm_f32x4_add(vacc0x4567, wasm_f32x4_mul(va0, vb4567));
72 k -= sizeof(float);
73 } while (k != 0);
74 p -= 1 * sizeof(void*);
75 } while (p != 0);
76
77 vacc0x0123 = wasm_f32x4_max(vacc0x0123, vmin);
78 vacc0x4567 = wasm_f32x4_max(vacc0x4567, vmin);
79
80 vacc0x0123 = wasm_f32x4_min(vacc0x0123, vmax);
81 vacc0x4567 = wasm_f32x4_min(vacc0x4567, vmax);
82
83 if XNN_LIKELY(nc >= 8) {
84 wasm_v128_store(c0, vacc0x0123);
85 wasm_v128_store(c0 + 4, vacc0x4567);
86 c0 = (float*) ((uintptr_t) c0 + cn_stride);
87
88 a = (const float**restrict) ((uintptr_t) a - ks);
89 nc -= 8;
90 } else {
91 if (nc & 4) {
92 wasm_v128_store(c0, vacc0x0123);
93
94 vacc0x0123 = vacc0x4567;
95
96 c0 += 4;
97 }
98 if (nc & 2) {
99 *((double*) c0) = wasm_f64x2_extract_lane(vacc0x0123, 0);
100
101 vacc0x0123 = wasm_v32x4_shuffle(vacc0x0123, vacc0x0123, 2, 3, 2, 3);
102
103 c0 += 2;
104 }
105 if (nc & 1) {
106 *c0 = wasm_f32x4_extract_lane(vacc0x0123, 0);
107 }
108
109 nc = 0;
110 }
111 } while (nc != 0);
112 }
113