1 // Auto-generated file. Do not edit!
2 // Template: src/f16-f32-vcvt/f16c.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/vcvt.h>
16
17
xnn_f16_f32_vcvt_ukernel__f16c_x8(size_t n,const void * input,float * output,const union xnn_f16_f32_cvt_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f16_f32_vcvt_ukernel__f16c_x8(
19 size_t n,
20 const void* input,
21 float* output,
22 const union xnn_f16_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
23 {
24 assert(n != 0);
25 assert(n % sizeof(uint16_t) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const uint16_t* i = (const uint16_t*) input;
30 for (; n >= 8 * sizeof(uint16_t); n -= 8 * sizeof(uint16_t)) {
31 const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i));
32 i += 8;
33
34 _mm256_storeu_ps(output, vacc);
35 output += 8;
36 }
37 if XNN_UNLIKELY(n != 0) {
38 assert(n >= 1 * sizeof(uint16_t));
39 assert(n <= 7 * sizeof(uint16_t));
40 const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i));
41
42 __m128 vacc_lo = _mm256_castps256_ps128(vacc);
43 if (n & (4 * sizeof(uint16_t))) {
44 _mm_storeu_ps(output, vacc_lo);
45 vacc_lo = _mm256_extractf128_ps(vacc, 1);
46 output += 4;
47 }
48 if (n & (2 * sizeof(uint16_t))) {
49 _mm_storel_pi((__m64*) output, vacc_lo);
50 vacc_lo = _mm_movehl_ps(vacc_lo, vacc_lo);
51 output += 2;
52 }
53 if (n & (1 * sizeof(uint16_t))) {
54 _mm_store_ss(output, vacc_lo);
55 }
56 }
57 }
58