58#ifndef INCLUDED_volk_32f_index_max_16u_a_H
59#define INCLUDED_volk_32f_index_max_16u_a_H
72 num_points = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
75 const uint32_t eighthPoints = num_points / 8;
77 float* inputPtr = (
float*)src0;
79 __m256 indexIncrementValues = _mm256_set1_ps(8);
80 __m256 currentIndexes = _mm256_set_ps(-1, -2, -3, -4, -5, -6, -7, -8);
84 __m256 maxValues = _mm256_set1_ps(max);
85 __m256 maxValuesIndex = _mm256_setzero_ps();
86 __m256 compareResults;
92 for (; number < eighthPoints; number++) {
94 currentValues = _mm256_load_ps(inputPtr);
96 currentIndexes = _mm256_add_ps(currentIndexes, indexIncrementValues);
98 compareResults = _mm256_cmp_ps(currentValues, maxValues, _CMP_GT_OS);
100 maxValuesIndex = _mm256_blendv_ps(maxValuesIndex, currentIndexes, compareResults);
101 maxValues = _mm256_blendv_ps(maxValues, currentValues, compareResults);
105 _mm256_store_ps(maxValuesBuffer, maxValues);
106 _mm256_store_ps(maxIndexesBuffer, maxValuesIndex);
108 for (number = 0; number < 8; number++) {
109 if (maxValuesBuffer[number] > max) {
110 index = maxIndexesBuffer[number];
111 max = maxValuesBuffer[number];
112 }
else if (maxValuesBuffer[number] == max) {
113 if (index > maxIndexesBuffer[number])
114 index = maxIndexesBuffer[number];
118 number = eighthPoints * 8;
119 for (; number < num_points; number++) {
120 if (src0[number] > max) {
125 target[0] = (uint16_t)index;
131#include <smmintrin.h>
134volk_32f_index_max_16u_a_sse4_1(uint16_t* target,
const float* src0, uint32_t num_points)
136 num_points = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
139 const uint32_t quarterPoints = num_points / 4;
141 float* inputPtr = (
float*)src0;
143 __m128 indexIncrementValues = _mm_set1_ps(4);
144 __m128 currentIndexes = _mm_set_ps(-1, -2, -3, -4);
148 __m128 maxValues = _mm_set1_ps(max);
149 __m128 maxValuesIndex = _mm_setzero_ps();
150 __m128 compareResults;
151 __m128 currentValues;
156 for (; number < quarterPoints; number++) {
158 currentValues = _mm_load_ps(inputPtr);
160 currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
162 compareResults = _mm_cmpgt_ps(currentValues, maxValues);
164 maxValuesIndex = _mm_blendv_ps(maxValuesIndex, currentIndexes, compareResults);
165 maxValues = _mm_blendv_ps(maxValues, currentValues, compareResults);
169 _mm_store_ps(maxValuesBuffer, maxValues);
170 _mm_store_ps(maxIndexesBuffer, maxValuesIndex);
172 for (number = 0; number < 4; number++) {
173 if (maxValuesBuffer[number] > max) {
174 index = maxIndexesBuffer[number];
175 max = maxValuesBuffer[number];
176 }
else if (maxValuesBuffer[number] == max) {
177 if (index > maxIndexesBuffer[number])
178 index = maxIndexesBuffer[number];
182 number = quarterPoints * 4;
183 for (; number < num_points; number++) {
184 if (src0[number] > max) {
189 target[0] = (uint16_t)index;
197#include <xmmintrin.h>
202 num_points = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
205 const uint32_t quarterPoints = num_points / 4;
207 float* inputPtr = (
float*)src0;
209 __m128 indexIncrementValues = _mm_set1_ps(4);
210 __m128 currentIndexes = _mm_set_ps(-1, -2, -3, -4);
214 __m128 maxValues = _mm_set1_ps(max);
215 __m128 maxValuesIndex = _mm_setzero_ps();
216 __m128 compareResults;
217 __m128 currentValues;
222 for (; number < quarterPoints; number++) {
224 currentValues = _mm_load_ps(inputPtr);
226 currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
228 compareResults = _mm_cmpgt_ps(currentValues, maxValues);
230 maxValuesIndex = _mm_or_ps(_mm_and_ps(compareResults, currentIndexes),
231 _mm_andnot_ps(compareResults, maxValuesIndex));
232 maxValues = _mm_or_ps(_mm_and_ps(compareResults, currentValues),
233 _mm_andnot_ps(compareResults, maxValues));
237 _mm_store_ps(maxValuesBuffer, maxValues);
238 _mm_store_ps(maxIndexesBuffer, maxValuesIndex);
240 for (number = 0; number < 4; number++) {
241 if (maxValuesBuffer[number] > max) {
242 index = maxIndexesBuffer[number];
243 max = maxValuesBuffer[number];
244 }
else if (maxValuesBuffer[number] == max) {
245 if (index > maxIndexesBuffer[number])
246 index = maxIndexesBuffer[number];
250 number = quarterPoints * 4;
251 for (; number < num_points; number++) {
252 if (src0[number] > max) {
257 target[0] = (uint16_t)index;
263#ifdef LV_HAVE_GENERIC
268 num_points = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
275 for (;
i < num_points; ++
i) {
290#ifndef INCLUDED_volk_32f_index_max_16u_u_H
291#define INCLUDED_volk_32f_index_max_16u_u_H
299#include <immintrin.h>
304 num_points = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
307 const uint32_t eighthPoints = num_points / 8;
309 float* inputPtr = (
float*)src0;
311 __m256 indexIncrementValues = _mm256_set1_ps(8);
312 __m256 currentIndexes = _mm256_set_ps(-1, -2, -3, -4, -5, -6, -7, -8);
316 __m256 maxValues = _mm256_set1_ps(max);
317 __m256 maxValuesIndex = _mm256_setzero_ps();
318 __m256 compareResults;
319 __m256 currentValues;
324 for (; number < eighthPoints; number++) {
326 currentValues = _mm256_loadu_ps(inputPtr);
328 currentIndexes = _mm256_add_ps(currentIndexes, indexIncrementValues);
330 compareResults = _mm256_cmp_ps(currentValues, maxValues, _CMP_GT_OS);
332 maxValuesIndex = _mm256_blendv_ps(maxValuesIndex, currentIndexes, compareResults);
333 maxValues = _mm256_blendv_ps(maxValues, currentValues, compareResults);
337 _mm256_storeu_ps(maxValuesBuffer, maxValues);
338 _mm256_storeu_ps(maxIndexesBuffer, maxValuesIndex);
340 for (number = 0; number < 8; number++) {
341 if (maxValuesBuffer[number] > max) {
342 index = maxIndexesBuffer[number];
343 max = maxValuesBuffer[number];
344 }
else if (maxValuesBuffer[number] == max) {
345 if (index > maxIndexesBuffer[number])
346 index = maxIndexesBuffer[number];
350 number = eighthPoints * 8;
351 for (; number < num_points; number++) {
352 if (src0[number] > max) {
357 target[0] = (uint16_t)index;
364#include <riscv_vector.h>
367volk_32f_index_max_16u_rvv(uint16_t* target,
const float* src0, uint32_t num_points)
369 vfloat32m8_t vmax = __riscv_vfmv_v_f_f32m8(-FLT_MAX, __riscv_vsetvlmax_e32m8());
370 vuint16m4_t vmaxi = __riscv_vmv_v_x_u16m4(0, __riscv_vsetvlmax_e16m4());
371 vuint16m4_t vidx = __riscv_vid_v_u16m4(__riscv_vsetvlmax_e16m4());
372 size_t n = (num_points > USHRT_MAX) ? USHRT_MAX : num_points;
373 for (
size_t vl; n > 0; n -= vl, src0 += vl) {
374 vl = __riscv_vsetvl_e32m8(n);
375 vfloat32m8_t v = __riscv_vle32_v_f32m8(src0, vl);
376 vbool4_t m = __riscv_vmfgt(v, vmax, vl);
377 vmax = __riscv_vfmax_tu(vmax, vmax, v, vl);
378 vmaxi = __riscv_vmerge_tu(vmaxi, vmaxi, vidx, m, vl);
379 vidx = __riscv_vadd(vidx, vl, __riscv_vsetvlmax_e16m4());
381 size_t vl = __riscv_vsetvlmax_e32m8();
382 float max = __riscv_vfmv_f(__riscv_vfredmax(
RISCV_SHRINK8(vfmax, f, 32, vmax),
383 __riscv_vfmv_v_f_f32m1(-FLT_MAX, 1),
384 __riscv_vsetvlmax_e32m1()));
385 vbool4_t m = __riscv_vmfeq(vmax, max, vl);
386 *target = __riscv_vmv_x(__riscv_vslidedown(vmaxi, __riscv_vfirst(m, vl), vl));
static void volk_32f_index_max_16u_u_avx(uint16_t *target, const float *src0, uint32_t num_points)
Definition volk_32f_index_max_16u.h:302
static void volk_32f_index_max_16u_a_avx(uint16_t *target, const float *src0, uint32_t num_points)
Definition volk_32f_index_max_16u.h:70
static void volk_32f_index_max_16u_generic(uint16_t *target, const float *src0, uint32_t num_points)
Definition volk_32f_index_max_16u.h:266
static void volk_32f_index_max_16u_a_sse(uint16_t *target, const float *src0, uint32_t num_points)
Definition volk_32f_index_max_16u.h:200
#define __VOLK_ATTR_ALIGNED(x)
Definition volk_common.h:62
for i
Definition volk_config_fixed.tmpl.h:13
#define RISCV_SHRINK8(op, T, S, v)
Definition volk_rvv_intrinsics.h:33