|
|
|
@ -1092,6 +1092,63 @@ uint32_t srslte_vec_max_fi_simd(const float *x, const int len) {
|
|
|
|
|
return max_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t srslte_vec_max_abs_fi_simd(const float *x, const int len) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
float max_value = -INFINITY;
|
|
|
|
|
uint32_t max_index = 0;
|
|
|
|
|
|
|
|
|
|
#if SRSLTE_SIMD_I_SIZE
|
|
|
|
|
__attribute__ ((aligned (SRSLTE_SIMD_I_SIZE*sizeof(int)))) int indexes_buffer[SRSLTE_SIMD_I_SIZE] = {0};
|
|
|
|
|
__attribute__ ((aligned (SRSLTE_SIMD_I_SIZE*sizeof(float)))) float values_buffer[SRSLTE_SIMD_I_SIZE] = {0};
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) indexes_buffer[k] = k;
|
|
|
|
|
simd_i_t simd_inc = srslte_simd_i_set1(SRSLTE_SIMD_I_SIZE);
|
|
|
|
|
simd_i_t simd_indexes = srslte_simd_i_load(indexes_buffer);
|
|
|
|
|
simd_i_t simd_max_indexes = srslte_simd_i_set1(0);
|
|
|
|
|
|
|
|
|
|
simd_f_t simd_max_values = srslte_simd_f_set1(-INFINITY);
|
|
|
|
|
|
|
|
|
|
if (SRSLTE_IS_ALIGNED(x)) {
|
|
|
|
|
for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) {
|
|
|
|
|
simd_f_t a = srslte_simd_f_abs(srslte_simd_f_load(&x[i]));
|
|
|
|
|
simd_sel_t res = srslte_simd_f_max(a, simd_max_values);
|
|
|
|
|
simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res);
|
|
|
|
|
simd_max_values = (simd_f_t) srslte_simd_i_select((simd_i_t) simd_max_values, (simd_i_t) a, res);
|
|
|
|
|
simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (; i < len - SRSLTE_SIMD_I_SIZE + 1; i += SRSLTE_SIMD_I_SIZE) {
|
|
|
|
|
simd_f_t a = srslte_simd_f_abs(srslte_simd_f_loadu(&x[i]));
|
|
|
|
|
simd_sel_t res = srslte_simd_f_max(a, simd_max_values);
|
|
|
|
|
simd_max_indexes = srslte_simd_i_select(simd_max_indexes, simd_indexes, res);
|
|
|
|
|
simd_max_values = (simd_f_t) srslte_simd_i_select((simd_i_t) simd_max_values, (simd_i_t) a, res);
|
|
|
|
|
simd_indexes = srslte_simd_i_add(simd_indexes, simd_inc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srslte_simd_i_store(indexes_buffer, simd_max_indexes);
|
|
|
|
|
srslte_simd_f_store(values_buffer, simd_max_values);
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < SRSLTE_SIMD_I_SIZE; k++) {
|
|
|
|
|
if (values_buffer[k] > max_value) {
|
|
|
|
|
max_value = values_buffer[k];
|
|
|
|
|
max_index = (uint32_t) indexes_buffer[k];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* SRSLTE_SIMD_I_SIZE */
|
|
|
|
|
|
|
|
|
|
for (; i < len; i++) {
|
|
|
|
|
float a = fabsf(x[i]);
|
|
|
|
|
if (a > max_value) {
|
|
|
|
|
max_value = a;
|
|
|
|
|
max_index = (uint32_t)i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return max_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t srslte_vec_max_ci_simd(const cf_t *x, const int len) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|