mirror of https://github.com/pvnis/srsRAN_4G.git
Merge branch 'next' into enbmimo
commit
96a6d6ae9f
@ -1,161 +0,0 @@
|
||||
INCLUDE(FindPkgConfig)
|
||||
PKG_CHECK_MODULES(PC_VOLK volk QUIET)
|
||||
|
||||
FIND_PATH(
|
||||
VOLK_INCLUDE_DIRS
|
||||
NAMES volk/volk.h
|
||||
HINTS $ENV{VOLK_DIR}/include
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
${PC_VOLK_INCLUDE_DIR}
|
||||
PATHS /usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(
|
||||
VOLK_LIBRARIES
|
||||
NAMES volk
|
||||
HINTS $ENV{VOLK_DIR}/lib
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
${CMAKE_INSTALL_PREFIX}/lib64
|
||||
${PC_VOLK_LIBDIR}
|
||||
PATHS /usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VOLK DEFAULT_MSG VOLK_LIBRARIES VOLK_INCLUDE_DIRS)
|
||||
MARK_AS_ADVANCED(VOLK_LIBRARIES VOLK_INCLUDE_DIRS VOLK_DEFINITIONS)
|
||||
|
||||
IF(VOLK_FOUND)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${VOLK_LIBRARIES} m)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_16i_s32f_convert_32f HAVE_VOLK_CONVERT_IF_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_index_max_16u HAVE_VOLK_MAX_FUNCTION_16)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_index_max_32u HAVE_VOLK_MAX_FUNCTION_32)
|
||||
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)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_multiply_32fc HAVE_VOLK_MULT2_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_multiply_conjugate_32fc HAVE_VOLK_MULT2_CONJ_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_32f_multiply_32fc HAVE_VOLK_MULT_REAL_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_s32f_multiply_32f HAVE_VOLK_MULT_FLOAT_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_magnitude_32f HAVE_VOLK_MAG_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_magnitude_squared_32f HAVE_VOLK_MAG_SQUARE_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_divide_32f HAVE_VOLK_DIVIDE_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_dot_prod_32fc HAVE_VOLK_DOTPROD_FC_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_32f_dot_prod_32fc HAVE_VOLK_DOTPROD_CFC_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_conjugate_dot_prod_32fc HAVE_VOLK_DOTPROD_CONJ_FC_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_dot_prod_32f HAVE_VOLK_DOTPROD_F_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_s32f_atan2_32f HAVE_VOLK_ATAN_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_s32f_convert_16i HAVE_VOLK_CONVERT_FI_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_deinterleave_32f_x2 HAVE_VOLK_DEINTERLEAVE_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_interleave_32fc HAVE_VOLK_INTERLEAVE_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_subtract_32f HAVE_VOLK_SUB_FLOAT_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_add_32f HAVE_VOLK_ADD_FLOAT_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_x2_square_dist_32f HAVE_VOLK_SQUARE_DIST_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_deinterleave_real_32f HAVE_VOLK_DEINTERLEAVE_REAL_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_index_max_16u HAVE_VOLK_MAX_ABS_FUNCTION_16)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32fc_index_max_32u HAVE_VOLK_MAX_ABS_FUNCTION_32)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_32f_x2_multiply_32f HAVE_VOLK_MULT_REAL2_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_16i_max_star_16i HAVE_VOLK_MAX_STAR_S_FUNCTION)
|
||||
CHECK_FUNCTION_EXISTS_MATH(volk_8i_convert_16i HAVE_VOLK_CONVERT_CI_FUNCTION)
|
||||
|
||||
|
||||
|
||||
SET(VOLK_DEFINITIONS "HAVE_VOLK")
|
||||
IF(${HAVE_VOLK_CONVERT_IF_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONVERT_IF_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT_REAL2_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT_REAL2_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_CONVERT_CI_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONVERT_CI_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAX_STAR_S_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_STAR_S_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAX_ABS_FUNCTION_16})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_ABS_FUNCTION_16")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAX_ABS_FUNCTION_32})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_ABS_FUNCTION_32")
|
||||
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()
|
||||
IF(${HAVE_VOLK_MAG_SQUARE_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAG_SQUARE_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_SQUARE_DIST_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_SQUARE_DIST_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DEINTERLEAVE_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DEINTERLEAVE_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_INTERLEAVE_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_INTERLEAVE_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_SUB_FLOAT_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_SUB_FLOAT_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_ADD_FLOAT_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_ADD_FLOAT_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT2_CONJ_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT2_CONJ_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DEINTERLEAVE_REAL_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DEINTERLEAVE_REAL_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_CONVERT_FI_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONVERT_FI_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAX_FUNCTION_16})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_FUNCTION_16")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAX_FUNCTION_32})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAX_FUNCTION_32")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_ACC_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_ACC_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_CONJ_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_CONJ_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT2_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT2_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT_FLOAT_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT_FLOAT_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MULT_REAL_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MULT_REAL_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_MAG_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_MAG_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DIVIDE_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DIVIDE_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DOTPROD_FC_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DOTPROD_FC_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DOTPROD_CFC_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DOTPROD_CFC_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_DOTPROD_F_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_DOTPROD_F_FUNCTION")
|
||||
ENDIF()
|
||||
IF(${HAVE_VOLK_ATAN_FUNCTION})
|
||||
SET(VOLK_DEFINITIONS "${VOLK_DEFINITIONS}; HAVE_VOLK_ATAN_FUNCTION")
|
||||
ENDIF()
|
||||
ENDIF(VOLK_FOUND)
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,822 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsLTE library.
|
||||
*
|
||||
* srsLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <complex.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "srslte/phy/utils/mat.h"
|
||||
#include "srslte/phy/utils/simd.h"
|
||||
#include "srslte/phy/utils/vector.h"
|
||||
|
||||
|
||||
bool zf_solver = false;
|
||||
bool mmse_solver = false;
|
||||
bool verbose = false;
|
||||
|
||||
#define MAX_MSE (1e-3)
|
||||
#define NOF_REPETITIONS (1024)
|
||||
#define MAX_FUNCTIONS (64)
|
||||
#define MAX_BLOCKS (16)
|
||||
|
||||
#define RANDOM_F() ((float)rand())/((float)RAND_MAX)
|
||||
#define RANDOM_S() ((int16_t)(rand() && 0x800F))
|
||||
#define RANDOM_CF() (RANDOM_F() + _Complex_I*RANDOM_F())
|
||||
|
||||
#define TEST_CALL(TEST_CODE) gettimeofday(&start, NULL);\
|
||||
for (int i = 0; i < NOF_REPETITIONS; i++){TEST_CODE;}\
|
||||
gettimeofday(&end, NULL); \
|
||||
*timing = elapsed_us(&start, &end);
|
||||
|
||||
#define TEST(X, CODE) static bool test_##X (char *func_name, double *timing, uint32_t block_size) {\
|
||||
struct timeval start, end;\
|
||||
float mse = 0.0f;\
|
||||
bool passed;\
|
||||
strncpy(func_name, #X, 32);\
|
||||
CODE;\
|
||||
passed = (mse < MAX_MSE);\
|
||||
printf("%32s (%5d) ... %7.1f MSamp/s ... %3s Passed (%.6f)\n", func_name, block_size, \
|
||||
(double) block_size*NOF_REPETITIONS/ *timing, passed?"":"Not", mse);\
|
||||
return passed;\
|
||||
}
|
||||
|
||||
#define MALLOC(TYPE, NAME) TYPE *NAME = srslte_vec_malloc(sizeof(TYPE)*block_size)
|
||||
|
||||
|
||||
static double elapsed_us(struct timeval *ts_start, struct timeval *ts_end) {
|
||||
if (ts_end->tv_usec > ts_start->tv_usec) {
|
||||
return ((double) ts_end->tv_sec - (double) ts_start->tv_sec) * 1000000 +
|
||||
(double) ts_end->tv_usec - (double) ts_start->tv_usec;
|
||||
} else {
|
||||
return ((double) ts_end->tv_sec - (double) ts_start->tv_sec - 1) * 1000000 +
|
||||
((double) ts_end->tv_usec + 1000000) - (double) ts_start->tv_usec;
|
||||
}
|
||||
}
|
||||
|
||||
float squared_error (cf_t a, cf_t b) {
|
||||
float diff_re = __real__ a - __real__ b;
|
||||
float diff_im = __imag__ a - __imag__ b;
|
||||
return diff_re*diff_re + diff_im*diff_im;
|
||||
}
|
||||
|
||||
TEST(srslte_vec_acc_ff,
|
||||
MALLOC(float, x);
|
||||
float z;
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(z = srslte_vec_acc_ff(x, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold += x[i];
|
||||
}
|
||||
|
||||
mse += fabs(gold - z) / gold;
|
||||
|
||||
free(x);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_dot_prod_sss,
|
||||
MALLOC(int16_t, x);
|
||||
MALLOC(int16_t, y);
|
||||
int16_t z;
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_S();
|
||||
y[i] = RANDOM_S();
|
||||
}
|
||||
|
||||
TEST_CALL(z = srslte_vec_dot_prod_sss(x, y, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold += x[i] * y[i];
|
||||
}
|
||||
|
||||
mse += cabsf(gold - z) / cabsf(gold);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sum_sss,
|
||||
MALLOC(int16_t, x);
|
||||
MALLOC(int16_t, y);
|
||||
MALLOC(int16_t, z);
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_S();
|
||||
y[i] = RANDOM_S();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sum_sss(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] + y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sub_sss,
|
||||
MALLOC(int16_t, x);
|
||||
MALLOC(int16_t, y);
|
||||
MALLOC(int16_t, z);
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_S();
|
||||
y[i] = RANDOM_S();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sub_sss(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] - y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_sss,
|
||||
MALLOC(int16_t, x);
|
||||
MALLOC(int16_t, y);
|
||||
MALLOC(int16_t, z);
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_S();
|
||||
y[i] = RANDOM_S();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_sss(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_acc_cc,
|
||||
MALLOC(cf_t, x);
|
||||
cf_t z;
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(z = srslte_vec_acc_cc(x, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold += x[i];
|
||||
}
|
||||
|
||||
mse += cabsf(gold - z)/cabsf(gold);
|
||||
|
||||
free(x);
|
||||
)
|
||||
|
||||
|
||||
TEST(srslte_vec_sum_fff,
|
||||
MALLOC(float, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(float, z);
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
y[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sum_fff(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] + y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sub_fff,
|
||||
MALLOC(float, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(float, z);
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
y[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sub_fff(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] - y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_dot_prod_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, y);
|
||||
cf_t z;
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(z = srslte_vec_dot_prod_ccc(x, y, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold += x[i] * y[i];
|
||||
}
|
||||
|
||||
mse = cabsf(gold - z) / cabsf(gold);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_dot_prod_conj_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, y);
|
||||
cf_t z;
|
||||
|
||||
cf_t gold = 0.0f;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(z = srslte_vec_dot_prod_conj_ccc(x, y, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold += x[i] * conjf(y[i]);
|
||||
}
|
||||
|
||||
mse = cabsf(gold - z) / cabsf(gold);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, y);
|
||||
MALLOC(cf_t, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_ccc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_ccc_split,
|
||||
MALLOC(float, x_re);
|
||||
MALLOC(float, x_im);
|
||||
MALLOC(float, y_re);
|
||||
MALLOC(float, y_im);
|
||||
MALLOC(float, z_re);
|
||||
MALLOC(float, z_im);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x_re[i] = RANDOM_F();
|
||||
x_im[i] = RANDOM_F();
|
||||
y_re[i] = RANDOM_F();
|
||||
y_im[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_ccc_split(x_re, x_im, y_re, y_im, z_re, z_im, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = (x_re[i] + I * x_im[i]) * (y_re[i] + I * y_im[i]);
|
||||
mse += cabsf(gold - (z_re[i] + I*z_im[i]));
|
||||
}
|
||||
|
||||
free(x_re);
|
||||
free(x_im);
|
||||
free(y_re);
|
||||
free(y_im);
|
||||
free(z_re);
|
||||
free(z_im);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_conj_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, y);
|
||||
MALLOC(cf_t, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_conj_ccc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * conjf(y[i]);
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sc_prod_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, z);
|
||||
cf_t y = RANDOM_CF();
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sc_prod_ccc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y;
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_convert_fi,
|
||||
MALLOC(float, x);
|
||||
MALLOC(short, z);
|
||||
float scale = 1000.0f;
|
||||
|
||||
short gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = (float) RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_convert_fi(x, z, scale, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = (short) ((x[i] * scale));
|
||||
mse += cabsf((float)gold - (float) z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_fff,
|
||||
MALLOC(float, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(float, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_fff(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_prod_cfc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(cf_t, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_prod_cfc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sc_prod_fff,
|
||||
MALLOC(float, x);
|
||||
MALLOC(float, z);
|
||||
float y = RANDOM_F();
|
||||
|
||||
float gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sc_prod_fff(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * y;
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_abs_cf,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(float, z);
|
||||
float gold;
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_abs_cf(x, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = sqrtf(crealf(x[i]) * crealf(x[i]) + cimagf(x[i])*cimagf(x[i]));
|
||||
mse += cabsf(gold - z[i])/block_size;
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_abs_square_cf,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(float, z);
|
||||
float gold;
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_abs_square_cf(x, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = crealf(x[i]) * crealf(x[i]) + cimagf(x[i])*cimagf(x[i]);
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_sc_prod_cfc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, z);
|
||||
cf_t gold;
|
||||
float h = RANDOM_F();
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_sc_prod_cfc(x, h, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] * h;
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_div_ccc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(cf_t, y);
|
||||
MALLOC(cf_t, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_div_ccc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] / y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
mse /= block_size;
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
|
||||
TEST(srslte_vec_div_cfc,
|
||||
MALLOC(cf_t, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(cf_t, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
y[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_div_cfc(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] / y[i];
|
||||
mse += cabsf(gold - z[i])/cabsf(gold);
|
||||
}
|
||||
mse /= block_size;
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
|
||||
TEST(srslte_vec_div_fff,
|
||||
MALLOC(float, x);
|
||||
MALLOC(float, y);
|
||||
MALLOC(float, z);
|
||||
|
||||
cf_t gold;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
y[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
TEST_CALL(srslte_vec_div_fff(x, y, z, block_size))
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
gold = x[i] / y[i];
|
||||
mse += cabsf(gold - z[i]);
|
||||
}
|
||||
mse /= block_size;
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_max_fi,
|
||||
MALLOC(float, x);
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_F();
|
||||
}
|
||||
|
||||
uint32_t max_index = 0;
|
||||
TEST_CALL(max_index = srslte_vec_max_fi(x, block_size);)
|
||||
|
||||
float gold_value = -INFINITY;
|
||||
uint32_t gold_index = 0;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
if (gold_value < x[i]) {
|
||||
gold_value = x[i];
|
||||
gold_index = i;
|
||||
}
|
||||
}
|
||||
mse = (gold_index != max_index) ? 1:0;
|
||||
|
||||
free(x);
|
||||
)
|
||||
|
||||
TEST(srslte_vec_max_abs_ci,
|
||||
MALLOC(cf_t, x);
|
||||
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
x[i] = RANDOM_CF();
|
||||
}
|
||||
|
||||
uint32_t max_index = 0;
|
||||
TEST_CALL(max_index = srslte_vec_max_abs_ci(x, block_size);)
|
||||
|
||||
float gold_value = -INFINITY;
|
||||
uint32_t gold_index = 0;
|
||||
for (int i = 0; i < block_size; i++) {
|
||||
cf_t a = x[i];
|
||||
float abs2 = __real__ a * __real__ a + __imag__ a * __imag__ a;
|
||||
if (abs2 > gold_value) {
|
||||
gold_value = abs2;
|
||||
gold_index = (uint32_t)i;
|
||||
}
|
||||
}
|
||||
mse = (gold_index != max_index) ? 1:0;
|
||||
|
||||
free(x);
|
||||
)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char func_names[MAX_FUNCTIONS][32];
|
||||
double timmings[MAX_FUNCTIONS][MAX_BLOCKS];
|
||||
uint32_t sizes[32];
|
||||
uint32_t size_count = 0;
|
||||
uint32_t func_count = 0;
|
||||
bool passed[MAX_FUNCTIONS][MAX_BLOCKS];
|
||||
bool all_passed = true;
|
||||
|
||||
for (uint32_t block_size = 1; block_size <= 1024*8; block_size *= 2) {
|
||||
func_count = 0;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_acc_ff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_dot_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sum_sss(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sub_sss(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_sss(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_acc_cc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sum_fff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sub_fff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_dot_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_dot_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_convert_fi(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_ccc_split(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_prod_conj_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sc_prod_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sc_prod_fff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_abs_cf(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_abs_square_cf(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_sc_prod_cfc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_div_ccc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_div_cfc(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_div_fff(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_max_fi(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
passed[func_count][size_count] = test_srslte_vec_max_abs_ci(func_names[func_count], &timmings[func_count][size_count], block_size);
|
||||
func_count++;
|
||||
|
||||
sizes[size_count] = block_size;
|
||||
size_count++;
|
||||
}
|
||||
|
||||
char fname[68];
|
||||
FILE *f = NULL;
|
||||
void * p = popen("(date +%g%m%d && hostname) | tr '\\r\\n' '__'", "r");
|
||||
if (p) {
|
||||
fgets(fname, 64, p);
|
||||
strncpy(fname + strnlen(fname, 64) - 1, ".tsv", 4);
|
||||
f = fopen(fname, "w");
|
||||
if (f) printf("Saving benchmark results in '%s'\n", fname);
|
||||
}
|
||||
pclose(p);
|
||||
|
||||
|
||||
printf("\n");
|
||||
printf("%32s |", "Subroutine/MSps");
|
||||
if (f) fprintf(f, "Subroutine/MSps Vs Vector size\t");
|
||||
for (int i = 0; i < size_count; i++) {
|
||||
printf(" %7d", sizes[i]);
|
||||
if (f) fprintf(f, "%d\t", sizes[i]);
|
||||
}
|
||||
printf(" |\n");
|
||||
if (f) fprintf(f, "\n");
|
||||
|
||||
for (int j = 0; j < 32; j++) {
|
||||
printf("-");
|
||||
}
|
||||
printf("-+-");
|
||||
for (int j = 0; j < size_count; j++) {
|
||||
printf("--------");
|
||||
}
|
||||
printf("-|\n");
|
||||
|
||||
for (int i = 0; i < func_count; i++) {
|
||||
printf("%32s | ", func_names[i]);
|
||||
if (f) fprintf(f, "%s\t", func_names[i]);
|
||||
|
||||
for (int j = 0; j < size_count; j++) {
|
||||
printf(" %s%7.1f\x1b[0m", (passed[i][j])?"":"\x1B[31m", (double) NOF_REPETITIONS*(double)sizes[j]/timmings[i][j]);
|
||||
if (f) fprintf(f, "%.1f\t", (double) NOF_REPETITIONS*(double)sizes[j]/timmings[i][j]);
|
||||
|
||||
all_passed &= passed[i][j];
|
||||
}
|
||||
printf(" |\n");
|
||||
if (f) fprintf(f, "\n");
|
||||
}
|
||||
|
||||
if (f) fclose(f);
|
||||
|
||||
return (all_passed)?SRSLTE_SUCCESS:SRSLTE_ERROR;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright 2013-2017 Software Radio Systems Limited
|
||||
#
|
||||
# This file is part of srsLTE
|
||||
#
|
||||
# srsLTE is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# srsLTE is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# A copy of the GNU Affero General Public License can be found in
|
||||
# the LICENSE file in the top-level directory of this distribution
|
||||
# and at http://www.gnu.org/licenses/.
|
||||
#
|
||||
|
||||
add_executable(rrc_meas_test rrc_meas_test.cc)
|
||||
target_link_libraries(rrc_meas_test srslte_common srslte_phy srslte_asn1)
|
||||
add_test(rrc_meas_test rrc_meas_test)
|
@ -0,0 +1,91 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsUE library.
|
||||
*
|
||||
* srsUE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsUE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <srslte/srslte.h>
|
||||
#include "srslte/common/log_filter.h"
|
||||
#include "srslte/asn1/liblte_rrc.h"
|
||||
|
||||
|
||||
void basic_test() {
|
||||
srslte::log_filter log1("RRC");
|
||||
log1.set_level(srslte::LOG_LEVEL_DEBUG);
|
||||
log1.set_hex_limit(128);
|
||||
|
||||
LIBLTE_BIT_MSG_STRUCT bit_buf;
|
||||
LIBLTE_BIT_MSG_STRUCT bit_buf2;
|
||||
LIBLTE_BYTE_MSG_STRUCT byte_buf;
|
||||
LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
|
||||
|
||||
uint32_t rrc_message_len = 18;
|
||||
uint8_t rrc_message[] = {0x08, 0x10, 0x49, 0x3C, 0x0D, 0x97, 0x89, 0x83,
|
||||
0xC0, 0x84, 0x20, 0x82, 0x08, 0x21, 0x00, 0x01,
|
||||
0xBC, 0x48};
|
||||
|
||||
srslte_bit_unpack_vector(rrc_message, bit_buf.msg, rrc_message_len*8);
|
||||
bit_buf.N_bits = rrc_message_len*8;
|
||||
liblte_rrc_unpack_ul_dcch_msg((LIBLTE_BIT_MSG_STRUCT*)&bit_buf, &ul_dcch_msg);
|
||||
|
||||
assert(ul_dcch_msg.msg_type == LIBLTE_RRC_UL_DCCH_MSG_TYPE_MEASUREMENT_REPORT);
|
||||
LIBLTE_RRC_MEASUREMENT_REPORT_STRUCT *rep = &ul_dcch_msg.msg.measurement_report;
|
||||
assert(rep->meas_id == 1);
|
||||
assert(rep->pcell_rsrp_result == 73);
|
||||
assert(rep->pcell_rsrq_result == 15);
|
||||
assert(rep->have_meas_result_neigh_cells);
|
||||
assert(rep->meas_result_neigh_cells_choice == LIBLTE_RRC_MEAS_RESULT_LIST_EUTRA);
|
||||
LIBLTE_RRC_MEAS_RESULT_LIST_EUTRA_STRUCT *eutra = &rep->meas_result_neigh_cells.eutra;
|
||||
assert(eutra->n_result == 1);
|
||||
assert(eutra->result_eutra_list[0].phys_cell_id == 357);
|
||||
assert(eutra->result_eutra_list[0].have_cgi_info);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.have_plmn_identity_list);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.cell_global_id.plmn_id.mcc == 0xF898);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.cell_global_id.plmn_id.mnc == 0xFF78);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.cell_global_id.cell_id == 0x1084104);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.tracking_area_code == 0x1042);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.have_plmn_identity_list);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.n_plmn_identity_list == 1);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.plmn_identity_list[0].mcc == 0xFFFF);
|
||||
assert(eutra->result_eutra_list[0].cgi_info.plmn_identity_list[0].mnc == 0xFF00);
|
||||
assert(eutra->result_eutra_list[0].meas_result.have_rsrp);
|
||||
assert(eutra->result_eutra_list[0].meas_result.rsrp_result == 60);
|
||||
assert(eutra->result_eutra_list[0].meas_result.have_rsrp);
|
||||
assert(eutra->result_eutra_list[0].meas_result.rsrq_result == 18);
|
||||
|
||||
liblte_rrc_pack_ul_dcch_msg(&ul_dcch_msg, (LIBLTE_BIT_MSG_STRUCT*)&bit_buf2);
|
||||
srslte_bit_pack_vector(bit_buf2.msg, byte_buf.msg, bit_buf2.N_bits);
|
||||
byte_buf.N_bytes = (bit_buf2.N_bits+7)/8;
|
||||
log1.info_hex(byte_buf.msg, byte_buf.N_bytes, "UL_DCCH Packed message\n");
|
||||
|
||||
for(uint32_t i=0; i<rrc_message_len; i++) {
|
||||
assert(byte_buf.msg[i] == rrc_message[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
basic_test();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue