XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/f32-gemm/psimd-splat.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 <psimd.h> |
| 13 | |
| 14 | #include <xnnpack/gemm.h> |
| 15 | |
| 16 | |
Marat Dukhan | de06f49 | 2020-04-09 00:19:31 -0700 | [diff] [blame] | 17 | void xnn_f32_gemm_minmax_ukernel_1x8__psimd_splat( |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 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, |
Marat Dukhan | f196d01 | 2020-04-15 11:50:03 -0700 | [diff] [blame^] | 27 | const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 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 | do { |
| 42 | psimd_f32 vacc0x0123 = psimd_load_f32(w + 0); |
| 43 | psimd_f32 vacc0x4567 = psimd_load_f32(w + 4); |
| 44 | w += 8; |
| 45 | |
| 46 | size_t k = kc; |
| 47 | while (k >= 4 * sizeof(float)) { |
| 48 | const psimd_f32 va0 = psimd_load_f32(a0); |
| 49 | a0 += 4; |
| 50 | |
| 51 | const psimd_f32 va0c0 = psimd_splat0_f32(va0); |
| 52 | |
| 53 | const psimd_f32 vb0123c0 = psimd_load_f32(w + 0); |
| 54 | const psimd_f32 vb4567c0 = psimd_load_f32(w + 4); |
| 55 | |
| 56 | vacc0x0123 = psimd_qfma_f32(vacc0x0123, va0c0, vb0123c0); |
| 57 | vacc0x4567 = psimd_qfma_f32(vacc0x4567, va0c0, vb4567c0); |
| 58 | const psimd_f32 va0c1 = psimd_splat1_f32(va0); |
| 59 | |
| 60 | const psimd_f32 vb0123c1 = psimd_load_f32(w + 8); |
| 61 | const psimd_f32 vb4567c1 = psimd_load_f32(w + 12); |
| 62 | |
| 63 | vacc0x0123 = psimd_qfma_f32(vacc0x0123, va0c1, vb0123c1); |
| 64 | vacc0x4567 = psimd_qfma_f32(vacc0x4567, va0c1, vb4567c1); |
| 65 | const psimd_f32 va0c2 = psimd_splat2_f32(va0); |
| 66 | |
| 67 | const psimd_f32 vb0123c2 = psimd_load_f32(w + 16); |
| 68 | const psimd_f32 vb4567c2 = psimd_load_f32(w + 20); |
| 69 | |
| 70 | vacc0x0123 = psimd_qfma_f32(vacc0x0123, va0c2, vb0123c2); |
| 71 | vacc0x4567 = psimd_qfma_f32(vacc0x4567, va0c2, vb4567c2); |
| 72 | const psimd_f32 va0c3 = psimd_splat3_f32(va0); |
| 73 | |
| 74 | const psimd_f32 vb0123c3 = psimd_load_f32(w + 24); |
| 75 | const psimd_f32 vb4567c3 = psimd_load_f32(w + 28); |
| 76 | |
| 77 | vacc0x0123 = psimd_qfma_f32(vacc0x0123, va0c3, vb0123c3); |
| 78 | vacc0x4567 = psimd_qfma_f32(vacc0x4567, va0c3, vb4567c3); |
| 79 | |
| 80 | w += 32; |
| 81 | k -= 4 * sizeof(float); |
| 82 | } |
| 83 | if XNN_UNLIKELY(k != 0) { |
| 84 | do { |
| 85 | const psimd_f32 va0 = psimd_load_splat_f32(a0); |
| 86 | a0 += 1; |
| 87 | |
| 88 | const psimd_f32 vb0123 = psimd_load_f32(w); |
| 89 | const psimd_f32 vb4567 = psimd_load_f32(w + 4); |
| 90 | w += 8; |
| 91 | |
| 92 | vacc0x0123 = psimd_qfma_f32(vacc0x0123, va0, vb0123); |
| 93 | vacc0x4567 = psimd_qfma_f32(vacc0x4567, va0, vb4567); |
| 94 | |
| 95 | k -= sizeof(float); |
| 96 | } while (k != 0); |
| 97 | } |
| 98 | |
| 99 | const psimd_f32 vmax = psimd_load_splat_f32(¶ms->scalar.max); |
| 100 | vacc0x0123 = psimd_min_f32(vacc0x0123, vmax); |
| 101 | vacc0x4567 = psimd_min_f32(vacc0x4567, vmax); |
| 102 | |
| 103 | const psimd_f32 vmin = psimd_load_splat_f32(¶ms->scalar.min); |
| 104 | vacc0x0123 = psimd_max_f32(vacc0x0123, vmin); |
| 105 | vacc0x4567 = psimd_max_f32(vacc0x4567, vmin); |
| 106 | |
| 107 | if XNN_LIKELY(nc >= 8) { |
| 108 | psimd_store_f32(c0, vacc0x0123); |
| 109 | psimd_store_f32(c0 + 4, vacc0x4567); |
| 110 | c0 = (float*) ((uintptr_t) c0 + cn_stride); |
| 111 | |
| 112 | a0 = (const float*) ((uintptr_t) a0 - kc); |
| 113 | |
| 114 | nc -= 8; |
| 115 | } else { |
| 116 | if (nc & 4) { |
| 117 | psimd_store_f32(c0, vacc0x0123); |
| 118 | |
| 119 | vacc0x0123 = vacc0x4567; |
| 120 | |
| 121 | c0 += 4; |
| 122 | } |
| 123 | if (nc & 2) { |
| 124 | psimd_store2_f32(c0, vacc0x0123); |
| 125 | |
| 126 | vacc0x0123 = psimd_concat_hi_f32(vacc0x0123, vacc0x0123); |
| 127 | |
| 128 | c0 += 2; |
| 129 | } |
| 130 | if (nc & 1) { |
| 131 | psimd_store1_f32(c0, vacc0x0123); |
| 132 | } |
| 133 | |
| 134 | nc = 0; |
| 135 | } |
| 136 | } while (nc != 0); |
| 137 | } |