1 // Auto-generated file. Do not edit!
2 // Template: src/f32-gemm/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/gemm.h>
15
16
xnn_f32_gemm_minmax_ukernel_1x8__wasmsimd_arm_loadsplat(size_t mr,size_t nc,size_t kc,const float * restrict a,size_t a_stride,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_gemm_minmax_ukernel_1x8__wasmsimd_arm_loadsplat(
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 union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
28 {
29 assert(mr != 0);
30 assert(mr <= 1);
31 assert(nc != 0);
32 assert(kc != 0);
33 assert(kc % sizeof(float) == 0);
34 assert(a != NULL);
35 assert(w != NULL);
36 assert(c != NULL);
37
38 const float* a0 = a;
39 float* c0 = c;
40
41 const v128_t vmin = wasm_v32x4_load_splat(¶ms->scalar.min);
42 const v128_t vmax = wasm_v32x4_load_splat(¶ms->scalar.max);
43 do {
44 v128_t vacc0x0123 = wasm_v128_load(w + 0);
45 v128_t vacc0x4567 = wasm_v128_load(w + 4);
46 w += 8;
47
48 size_t k = kc;
49 do {
50 const v128_t va0 = wasm_v32x4_load_splat(a0);
51 a0 += 1;
52
53 const v128_t vb0123 = wasm_v128_load(w);
54 const v128_t vb4567 = wasm_v128_load(w + 4);
55 w += 8;
56
57 vacc0x0123 = wasm_f32x4_add(vacc0x0123, wasm_f32x4_mul(va0, vb0123));
58 vacc0x4567 = wasm_f32x4_add(vacc0x4567, wasm_f32x4_mul(va0, vb4567));
59
60 k -= sizeof(float);
61 } while (k != 0);
62
63 vacc0x0123 = wasm_f32x4_max(vacc0x0123, vmin);
64 vacc0x4567 = wasm_f32x4_max(vacc0x4567, vmin);
65
66 vacc0x0123 = wasm_f32x4_min(vacc0x0123, vmax);
67 vacc0x4567 = wasm_f32x4_min(vacc0x4567, vmax);
68
69 if XNN_LIKELY(nc >= 8) {
70 wasm_v128_store(c0, vacc0x0123);
71 wasm_v128_store(c0 + 4, vacc0x4567);
72 c0 = (float*) ((uintptr_t) c0 + cn_stride);
73
74 a0 = (const float*) ((uintptr_t) a0 - kc);
75
76 nc -= 8;
77 } else {
78 if (nc & 4) {
79 wasm_v128_store(c0, vacc0x0123);
80
81 vacc0x0123 = vacc0x4567;
82
83 c0 += 4;
84 }
85 if (nc & 2) {
86 *((double*) c0) = wasm_f64x2_extract_lane(vacc0x0123, 0);
87
88 vacc0x0123 = wasm_v32x4_shuffle(vacc0x0123, vacc0x0123, 2, 3, 2, 3);
89
90 c0 += 2;
91 }
92 if (nc & 1) {
93 *c0 = wasm_f32x4_extract_lane(vacc0x0123, 0);
94 }
95
96 nc = 0;
97 }
98 } while (nc != 0);
99 }
100