xref: /aosp_15_r20/external/XNNPACK/src/math/roundz-wasmsimd-native.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Copyright 2021 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #include <assert.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
10 #include <wasm_simd128.h>
11 
12 #include <xnnpack/math-stubs.h>
13 
14 
xnn_math_f32_roundz__wasmsimd_native(size_t n,const float * input,float * output)15 void xnn_math_f32_roundz__wasmsimd_native(
16     size_t n,
17     const float* input,
18     float* output)
19 {
20   assert(n % (4 * sizeof(float)) == 0);
21 
22   for (; n != 0; n -= 4 * sizeof(float)) {
23     const v128_t vx = wasm_v128_load(input);
24     input += 4;
25 
26     const v128_t vy = wasm_f32x4_trunc(vx);
27 
28     wasm_v128_store(output, vy);
29     output += 4;
30   }
31 }
32