| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/f32-igemm/avx-broadcast.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 <immintrin.h> |
| 13 |
|
| 14 |
#include "xnnpack/igemm.h" |
| 15 |
|
| 16 |
|
| 17 |
void xnn_f32_igemm_minmax_ukernel_1x8__avx_broadcast( |
| 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 __m256 vmin = _mm256_set1_ps(params->scalar.min); |
| 46 |
const __m256 vmax = _mm256_set1_ps(params->scalar.max); |
| 47 |
XNN_FORCE_REALIZATION(vmin); |
| 48 |
XNN_FORCE_REALIZATION(vmax); |
| 49 |
|
| 50 |
do { |
| 51 |
__m256 vacc0x01234567 = _mm256_load_ps(w); |
| 52 |
w += 8; |
| 53 |
|
| 54 |
size_t p = ks; |
| 55 |
do { |
| 56 |
const float* restrict a0 = a[0]; |
| 57 |
assert(a0 != NULL); |
| 58 |
if XNN_UNPREDICTABLE(a0 != zero) { |
| 59 |
a0 = (const float*) ((uintptr_t) a0 + a_offset); |
| 60 |
} |
| 61 |
a += 1; |
| 62 |
|
| 63 |
size_t k = kc; |
| 64 |
do { |
| 65 |
const __m256 vb01234567 = _mm256_load_ps(w); |
| 66 |
w += 8; |
| 67 |
|
| 68 |
const __m256 va0 = _mm256_broadcast_ss(a0); |
| 69 |
a0 += 1; |
| 70 |
|
| 71 |
vacc0x01234567 = _mm256_add_ps(vacc0x01234567, _mm256_mul_ps(va0, vb01234567)); |
| 72 |
k -= sizeof(float); |
| 73 |
} while (k != 0); |
| 74 |
p -= 1 * sizeof(void*); |
| 75 |
} while (p != 0); |
| 76 |
|
| 77 |
vacc0x01234567 = _mm256_max_ps(vmin, vacc0x01234567); |
| 78 |
|
| 79 |
vacc0x01234567 = _mm256_min_ps(vmax, vacc0x01234567); |
| 80 |
|
| 81 |
if XNN_LIKELY(nc >= 8) { |
| 82 |
_mm256_storeu_ps(c0, vacc0x01234567); |
| 83 |
c0 = (float*) ((uintptr_t) c0 + cn_stride); |
| 84 |
|
| 85 |
a = (const float**restrict) ((uintptr_t) a - ks); |
| 86 |
nc -= 8; |
| 87 |
} else { |
| 88 |
__m128 vacc0x0123 = _mm256_castps256_ps128(vacc0x01234567); |
| 89 |
if (nc & 4) { |
| 90 |
_mm_storeu_ps(c0, vacc0x0123); |
| 91 |
|
| 92 |
vacc0x0123 = _mm256_extractf128_ps(vacc0x01234567, 1); |
| 93 |
|
| 94 |
c0 += 4; |
| 95 |
} |
| 96 |
if (nc & 2) { |
| 97 |
_mm_storel_pi((__m64*) c0, vacc0x0123); |
| 98 |
|
| 99 |
vacc0x0123 = _mm_movehl_ps(vacc0x0123, vacc0x0123); |
| 100 |
|
| 101 |
c0 += 2; |
| 102 |
} |
| 103 |
if (nc & 1) { |
| 104 |
_mm_store_ss(c0, vacc0x0123); |
| 105 |
} |
| 106 |
|
| 107 |
nc = 0; |
| 108 |
} |
| 109 |
} while (nc != 0); |
| 110 |
} |