| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <assert.h> |
| 11 |
|
| 12 |
#include <xmmintrin.h> |
| 13 |
|
| 14 |
#include "xnnpack/common.h" |
| 15 |
#include "xnnpack/vunary.h" |
| 16 |
|
| 17 |
|
| 18 |
void xnn_f32_vsqrt_ukernel__sse_sqrt_u16( |
| 19 |
size_t batch, |
| 20 |
const float* input, |
| 21 |
float* output, |
| 22 |
const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS |
| 23 |
{ |
| 24 |
assert(batch != 0); |
| 25 |
assert(batch % sizeof(float) == 0); |
| 26 |
assert(input != NULL); |
| 27 |
assert(output != NULL); |
| 28 |
|
| 29 |
for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) { |
| 30 |
const __m128 vx0123 = _mm_loadu_ps(input); |
| 31 |
const __m128 vx4567 = _mm_loadu_ps(input + 4); |
| 32 |
const __m128 vx89AB = _mm_loadu_ps(input + 8); |
| 33 |
const __m128 vxCDEF = _mm_loadu_ps(input + 12); |
| 34 |
input += 16; |
| 35 |
|
| 36 |
const __m128 vy0123 = _mm_sqrt_ps(vx0123); |
| 37 |
const __m128 vy4567 = _mm_sqrt_ps(vx4567); |
| 38 |
const __m128 vy89AB = _mm_sqrt_ps(vx89AB); |
| 39 |
const __m128 vyCDEF = _mm_sqrt_ps(vxCDEF); |
| 40 |
|
| 41 |
_mm_storeu_ps(output, vy0123); |
| 42 |
_mm_storeu_ps(output + 4, vy4567); |
| 43 |
_mm_storeu_ps(output + 8, vy89AB); |
| 44 |
_mm_storeu_ps(output + 12, vyCDEF); |
| 45 |
output += 16; |
| 46 |
} |
| 47 |
for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) { |
| 48 |
const __m128 vx = _mm_loadu_ps(input); |
| 49 |
input += 4; |
| 50 |
const __m128 vy = _mm_sqrt_ps(vx); |
| 51 |
_mm_storeu_ps(output, vy); |
| 52 |
output += 4; |
| 53 |
} |
| 54 |
if XNN_UNLIKELY(batch != 0) { |
| 55 |
const __m128 vx = _mm_loadu_ps(input); |
| 56 |
__m128 vy = _mm_sqrt_ps(vx); |
| 57 |
if (batch & (2 * sizeof(float))) { |
| 58 |
_mm_storel_pi((__m64*) output, vy); |
| 59 |
vy = _mm_movehl_ps(vy, vy); |
| 60 |
output += 2; |
| 61 |
} |
| 62 |
if (batch & (1 * sizeof(float))) { |
| 63 |
_mm_store_ss(output, vy); |
| 64 |
} |
| 65 |
} |
| 66 |
} |