Mercurial > vec
view test/test_benchmark_vec.c @ 38:fd42f9b1b95e
docs: update copyright for 2025, update the README with more info
I slightly edited vec.h however to use calloc directly rather
than malloc + memset.
author | Paper <paper@tflc.us> |
---|---|
date | Sat, 26 Apr 2025 02:54:44 -0400 |
parents | 4b5a557aa64f |
children |
line wrap: on
line source
#include "vec/vec.h" extern void test_benchmark_sample_minmax_vec_impl(int16_t *smpl, uint32_t length, int32_t *pmin, int32_t *pmax) { int32_t smin = INT32_MAX, smax = INT32_MIN; uint32_t len32; int i; vint16x32 min = vint16x32_splat(*pmin); vint16x32 max = vint16x32_splat(*pmax); VINT16x32_ALIGNED_ARRAY(mins); VINT16x32_ALIGNED_ARRAY(maxs); len32 = length / 32; while (len32--) { vint16x32 vec = vint16x32_load_aligned(smpl); min = vint16x32_min(vec, min); max = vint16x32_max(vec, max); smpl += 32; } vint16x32_store_aligned(min, mins); vint16x32_store_aligned(max, maxs); /* get the lowest minimum of what we have left */ for (i = 0; i < 32; i++) { if (mins[i] < smin) smin = mins[i]; if (maxs[i] > smax) smax = maxs[i]; } len32 = length % 32; while (len32--) { if (*smpl < smin) smin = *smpl; if (*smpl > smax) smax = *smpl; smpl++; } *pmin = smin; *pmax = smax; }