diff --git a/cmake/modules/FindVolk.cmake b/cmake/modules/FindVolk.cmake index a6b045ecd..dfcef3b91 100644 --- a/cmake/modules/FindVolk.cmake +++ b/cmake/modules/FindVolk.cmake @@ -30,6 +30,7 @@ FIND_LIBRARY( IF(NOT ${VOLK_LIBRARIES} STREQUAL "") SET(CMAKE_REQUIRED_LIBRARIES ${VOLK_LIBRARIES} m) CHECK_FUNCTION_EXISTS_MATH(volk_32f_index_max_16u HAVE_VOLK_MAX_FUNCTION) + CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_max_32f HAVE_VOLK_MAX_VEC_FUNCTION) CHECK_FUNCTION_EXISTS_MATH(volk_32f_accumulator_s32f HAVE_VOLK_ACC_FUNCTION) CHECK_FUNCTION_EXISTS_MATH(volk_32fc_s32fc_multiply_32fc HAVE_VOLK_MULT_FUNCTION) CHECK_FUNCTION_EXISTS_MATH(volk_32fc_conjugate_32fc HAVE_VOLK_CONJ_FUNCTION) @@ -60,6 +61,9 @@ IF(NOT ${VOLK_LIBRARIES} STREQUAL "") IF(${HAVE_VOLK_MAX_ABS_FUNCTION}) SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_ABS_FUNCTION") ENDIF() + IF(${HAVE_VOLK_MAX_VEC_FUNCTION}) + SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_VEC_FUNCTION") + ENDIF() IF(${HAVE_VOLK_DOTPROD_CONJ_FC_FUNCTION}) SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DOTPROD_CONJ_FC_FUNCTION") ENDIF() diff --git a/lte/phy/include/liblte/phy/utils/vector.h b/lte/phy/include/liblte/phy/utils/vector.h index 186329b4b..ed6fa8a09 100644 --- a/lte/phy/include/liblte/phy/utils/vector.h +++ b/lte/phy/include/liblte/phy/utils/vector.h @@ -124,6 +124,9 @@ LIBLTE_API float vec_avg_power_cf(cf_t *x, uint32_t len); LIBLTE_API uint32_t vec_max_fi(float *x, uint32_t len); LIBLTE_API uint32_t vec_max_abs_ci(cf_t *x, uint32_t len); +/* maximum between two vectors */ +LIBLTE_API void vec_max_fff(float *x, float *y, float *z, uint32_t len); + /* quantify vector of floats and convert to uint8_t */ LIBLTE_API void vec_quant_fuc(float *in, uint8_t *out, float gain, float offset, float clip, uint32_t len); diff --git a/lte/phy/lib/fec/test/turbodecoder_test.c b/lte/phy/lib/fec/test/turbodecoder_test.c index 748fc7ec1..eca44ccb4 100644 --- a/lte/phy/lib/fec/test/turbodecoder_test.c +++ b/lte/phy/lib/fec/test/turbodecoder_test.c @@ -162,29 +162,29 @@ int main(int argc, char **argv) { printf(" EbNo: %.2f\n", ebno_db); } - data_tx = malloc(frame_length * sizeof(uint8_t)); + data_tx = vec_malloc(frame_length * sizeof(uint8_t)); if (!data_tx) { perror("malloc"); exit(-1); } - data_rx = malloc(frame_length * sizeof(uint8_t)); + data_rx = vec_malloc(frame_length * sizeof(uint8_t)); if (!data_rx) { perror("malloc"); exit(-1); } - symbols = malloc(coded_length * sizeof(uint8_t)); + symbols = vec_malloc(coded_length * sizeof(uint8_t)); if (!symbols) { perror("malloc"); exit(-1); } - llr = malloc(coded_length * sizeof(float)); + llr = vec_malloc(coded_length * sizeof(float)); if (!llr) { perror("malloc"); exit(-1); } - llr_c = malloc(coded_length * sizeof(uint8_t)); + llr_c = vec_malloc(coded_length * sizeof(uint8_t)); if (!llr_c) { perror("malloc"); exit(-1); diff --git a/lte/phy/lib/utils/src/vector.c b/lte/phy/lib/utils/src/vector.c index d78836b33..d695a4de6 100644 --- a/lte/phy/lib/utils/src/vector.c +++ b/lte/phy/lib/utils/src/vector.c @@ -533,6 +533,21 @@ uint32_t vec_max_fi(float *x, uint32_t len) { #endif } +void vec_max_fff(float *x, float *y, float *z, uint32_t len) { +#ifdef HAVE_VOLK_MAX_VEC_FUNCTION + volk_32f_x2_max_32f(z,x,y,len); +#else + uint32_t i; + for (i=0;i y[i]) { + z[i] = x[i]; + } else { + z[i] = y[i]; + } + } +#endif +} + uint32_t vec_max_abs_ci(cf_t *x, uint32_t len) { #ifdef HAVE_VOLK_MAX_ABS_FUNCTION