| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/f16-f32-vcvt/avx512skx.c.in |
| 3 |
// Generator: tools/xngen |
| 4 |
// |
| 5 |
// Copyright 2021 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/common.h" |
| 15 |
#include "xnnpack/intrinsics-polyfill.h" |
| 16 |
#include "xnnpack/vcvt.h" |
| 17 |
|
| 18 |
|
| 19 |
void xnn_f16_f32_vcvt_ukernel__avx512skx_u32( |
| 20 |
size_t batch, |
| 21 |
const xnn_float16* input, |
| 22 |
float* output, |
| 23 |
const void* params) |
| 24 |
{ |
| 25 |
assert(batch != 0); |
| 26 |
assert(batch % sizeof(uint16_t) == 0); |
| 27 |
assert(input != NULL); |
| 28 |
assert(output != NULL); |
| 29 |
|
| 30 |
const uint16_t* i = (const uint16_t*) input; |
| 31 |
for (; batch >= 32 * sizeof(uint16_t); batch -= 32 * sizeof(uint16_t)) { |
| 32 |
const __m512 vacc0 = _mm512_cvtph_ps(_mm256_loadu_si256((const __m256i*) i)); |
| 33 |
const __m512 vacc1 = _mm512_cvtph_ps(_mm256_loadu_si256((const __m256i*) (i + 16))); |
| 34 |
i += 32; |
| 35 |
|
| 36 |
_mm512_storeu_ps(output, vacc0); |
| 37 |
_mm512_storeu_ps(output + 16, vacc1); |
| 38 |
output += 32; |
| 39 |
} |
| 40 |
for (; batch >= 16 * sizeof(uint16_t); batch -= 16 * sizeof(uint16_t)) { |
| 41 |
const __m512 vacc = _mm512_cvtph_ps(_mm256_loadu_si256((const __m256i*) i)); |
| 42 |
i += 16; |
| 43 |
|
| 44 |
_mm512_storeu_ps(output, vacc); |
| 45 |
output += 16; |
| 46 |
} |
| 47 |
if XNN_UNLIKELY(batch != 0) { |
| 48 |
assert(batch >= 1 * sizeof(uint16_t)); |
| 49 |
assert(batch <= 15 * sizeof(uint16_t)); |
| 50 |
|
| 51 |
// Prepare mask for valid 32-bit elements (depends on batch). |
| 52 |
batch >>= XNN_LOG2_SIZEOF_HALF; |
| 53 |
const __mmask16 vmask = _cvtu32_mask16((uint32_t) ((UINT32_C(1) << batch) - UINT32_C(1))); |
| 54 |
|
| 55 |
const __m512 vacc = _mm512_cvtph_ps(_mm256_maskz_loadu_epi16(vmask, i)); |
| 56 |
|
| 57 |
_mm512_mask_storeu_ps(output, vmask, vacc); |
| 58 |
} |
| 59 |
} |