Merge branch 'next' into novolk

master
Ismael Gomez 8 years ago
commit d7afb87b38

@ -112,11 +112,16 @@ if(CMAKE_COMPILER_IS_GNUCC)
else(${CMAKE_BUILD_TYPE} STREQUAL "Debug") else(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
find_package(SSE) find_package(SSE)
if(HAVE_AVX) if (HAVE_AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx2 -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
elseif(HAVE_SSE) elseif (HAVE_AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE") if(HAVE_AVX)
endif(HAVE_AVX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
elseif(HAVE_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -Ofast -funroll-loops -DLV_HAVE_SSE")
endif(HAVE_AVX)
endif (HAVE_AVX2)
endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug") endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")

@ -6,6 +6,7 @@ include(CheckCSourceRuns)
option(ENABLE_SSE "Enable compile-time SSE4.1 support." ON) option(ENABLE_SSE "Enable compile-time SSE4.1 support." ON)
option(ENABLE_AVX "Enable compile-time AVX support." ON) option(ENABLE_AVX "Enable compile-time AVX support." ON)
option(ENABLE_AVX2 "Enable compile-time AVX2 support." ON)
if (ENABLE_SSE) if (ENABLE_SSE)
# #
@ -53,6 +54,30 @@ if (ENABLE_SSE)
endif() endif()
endif() endif()
if (ENABLE_AVX2)
#
# Check compiler for AVX intrinsics
#
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG )
set(CMAKE_REQUIRED_FLAGS "-mavx2")
check_c_source_runs("
#include <immintrin.h>
int main()
{
__m256i a = _mm256_setzero_si256();
__m256i b = _mm256_abs_epi16(a);
return 0;
}"
HAVE_AVX2)
endif()
if (HAVE_AVX2)
message(STATUS "AVX2 is enabled - target CPU must support it")
endif()
endif()
endif() endif()
mark_as_advanced(HAVE_SSE, HAVE_AVX) mark_as_advanced(HAVE_SSE, HAVE_AVX, HAVE_AVX2)

@ -47,6 +47,8 @@
#define SRSLTE_RAR_GRANT_LEN 20 #define SRSLTE_RAR_GRANT_LEN 20
SRSLTE_API extern int harq_pid_len;
typedef enum { typedef enum {
SRSLTE_DCI_FORMAT0 = 0, SRSLTE_DCI_FORMAT0 = 0,
SRSLTE_DCI_FORMAT1, SRSLTE_DCI_FORMAT1,

@ -41,6 +41,8 @@
#include "dci_sz_table.h" #include "dci_sz_table.h"
int harq_pid_len = 3;
/* Unpacks a DCI message and configures the DL grant object /* Unpacks a DCI message and configures the DL grant object
*/ */
int srslte_dci_msg_to_dl_grant(srslte_dci_msg_t *msg, uint16_t msg_rnti, int srslte_dci_msg_to_dl_grant(srslte_dci_msg_t *msg, uint16_t msg_rnti,
@ -240,7 +242,7 @@ uint32_t dci_format0_sizeof_(uint32_t nof_prb) {
uint32_t dci_format1A_sizeof(uint32_t nof_prb) { uint32_t dci_format1A_sizeof(uint32_t nof_prb) {
uint32_t n; uint32_t n;
n = 1 + 1 + riv_nbits(nof_prb) + 5 + 3 + 1 + 2 + 2; n = 1 + 1 + riv_nbits(nof_prb) + 5 + harq_pid_len + 1 + 2 + 2;
while (n < dci_format0_sizeof_(nof_prb)) { while (n < dci_format0_sizeof_(nof_prb)) {
n++; n++;
} }
@ -260,7 +262,7 @@ uint32_t dci_format0_sizeof(uint32_t nof_prb) {
uint32_t dci_format1_sizeof(uint32_t nof_prb) { uint32_t dci_format1_sizeof(uint32_t nof_prb) {
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb)) + 5 + 3 + 1 + 2 uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb)) + 5 + harq_pid_len + 1 + 2
+ 2; + 2;
if (nof_prb > 10) { if (nof_prb > 10) {
n++; n++;
@ -316,7 +318,7 @@ uint32_t precoding_bits_f2(uint32_t nof_ports) {
} }
uint32_t dci_format2_sizeof(uint32_t nof_prb, uint32_t nof_ports) { uint32_t dci_format2_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2)+precoding_bits_f2(nof_ports); uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2)+precoding_bits_f2(nof_ports);
if (nof_prb > 10) { if (nof_prb > 10) {
n++; n++;
} }
@ -336,7 +338,7 @@ uint32_t precoding_bits_f2a(uint32_t nof_ports) {
} }
uint32_t dci_format2A_sizeof(uint32_t nof_prb, uint32_t nof_ports) { uint32_t dci_format2A_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2)+precoding_bits_f2a(nof_ports); uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2)+precoding_bits_f2a(nof_ports);
if (nof_prb > 10) { if (nof_prb > 10) {
n++; n++;
} }
@ -348,7 +350,7 @@ uint32_t dci_format2A_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
} }
uint32_t dci_format2B_sizeof(uint32_t nof_prb, uint32_t nof_ports) { uint32_t dci_format2B_sizeof(uint32_t nof_prb, uint32_t nof_ports) {
uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+3+1+2*(5+1+2); uint32_t n = (uint32_t) ceilf((float) nof_prb / srslte_ra_type0_P(nof_prb))+2+harq_pid_len+1+2*(5+1+2);
if (nof_prb > 10) { if (nof_prb > 10) {
n++; n++;
} }
@ -455,7 +457,7 @@ int dci_format0_pack(srslte_ra_ul_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
*y++ = data->cqi_request; *y++ = data->cqi_request;
// Padding with zeros // Padding with zeros
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb); uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -474,7 +476,7 @@ int dci_format0_unpack(srslte_dci_msg_t *msg, srslte_ra_ul_dci_t *data, uint32_t
uint32_t n_ul_hop; uint32_t n_ul_hop;
/* Make sure it's a SRSLTE_DCI_FORMAT0 message */ /* Make sure it's a SRSLTE_DCI_FORMAT0 message */
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb)) { if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1)) {
fprintf(stderr, "Invalid message length for format 0\n"); fprintf(stderr, "Invalid message length for format 0\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -556,7 +558,7 @@ int dci_format1_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
srslte_bit_unpack(data->mcs_idx, &y, 5); srslte_bit_unpack(data->mcs_idx, &y, 5);
/* harq process number */ /* harq process number */
srslte_bit_unpack(data->harq_process, &y, 3); srslte_bit_unpack(data->harq_process, &y, harq_pid_len);
*y++ = data->ndi; *y++ = data->ndi;
@ -567,7 +569,7 @@ int dci_format1_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t n
srslte_bit_unpack(data->tpc_pucch, &y, 2); srslte_bit_unpack(data->tpc_pucch, &y, 2);
// Padding with zeros // Padding with zeros
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb); uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -582,7 +584,7 @@ int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t
uint8_t *y = msg->data; uint8_t *y = msg->data;
/* Make sure it's a SRSLTE_DCI_FORMAT1 message */ /* Make sure it's a SRSLTE_DCI_FORMAT1 message */
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb)) { if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1)) {
fprintf(stderr, "Invalid message length for format 1\n"); fprintf(stderr, "Invalid message length for format 1\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -615,7 +617,7 @@ int dci_format1_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t
data->mcs_idx = srslte_bit_pack(&y, 5); data->mcs_idx = srslte_bit_pack(&y, 5);
/* harq process number */ /* harq process number */
data->harq_process = srslte_bit_pack(&y, 3); data->harq_process = srslte_bit_pack(&y, harq_pid_len);
data->ndi = *y++ ? true : false; data->ndi = *y++ ? true : false;
// rv version // rv version
@ -687,7 +689,7 @@ int dci_format1As_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t
// in format1A, MCS = TBS according to 7.1.7.2 of 36.213 // in format1A, MCS = TBS according to 7.1.7.2 of 36.213
srslte_bit_unpack(data->mcs_idx, &y, 5); srslte_bit_unpack(data->mcs_idx, &y, 5);
srslte_bit_unpack(data->harq_process, &y, 3); srslte_bit_unpack(data->harq_process, &y, harq_pid_len);
if (crc_is_crnti) { if (crc_is_crnti) {
if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) {
@ -712,7 +714,7 @@ int dci_format1As_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t
} }
// Padding with zeros // Padding with zeros
uint32_t n = srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb); uint32_t n = srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1);
while (y - msg->data < n) { while (y - msg->data < n) {
*y++ = 0; *y++ = 0;
} }
@ -731,7 +733,7 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
uint8_t *y = msg->data; uint8_t *y = msg->data;
/* Make sure it's a SRSLTE_DCI_FORMAT0 message */ /* Make sure it's a SRSLTE_DCI_FORMAT0 message */
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb)) { if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1)) {
fprintf(stderr, "Invalid message length for format 1A\n"); fprintf(stderr, "Invalid message length for format 1A\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -788,7 +790,7 @@ int dci_format1As_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
// unpack MCS // unpack MCS
data->mcs_idx = srslte_bit_pack(&y, 5); data->mcs_idx = srslte_bit_pack(&y, 5);
data->harq_process = srslte_bit_pack(&y, 3); data->harq_process = srslte_bit_pack(&y, harq_pid_len);
if (!crc_is_crnti) { if (!crc_is_crnti) {
if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { if (nof_prb >= 50 && data->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) {
@ -848,7 +850,7 @@ int dci_format1B_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_
// unpack MCS, Harq pid and ndi // unpack MCS, Harq pid and ndi
data->mcs_idx = srslte_bit_pack(&y, 5); data->mcs_idx = srslte_bit_pack(&y, 5);
data->harq_process = srslte_bit_pack(&y, 3); data->harq_process = srslte_bit_pack(&y, harq_pid_len);
data->ndi = *y++ ? true : false; data->ndi = *y++ ? true : false;
data->rv_idx = srslte_bit_pack(&y, 2); data->rv_idx = srslte_bit_pack(&y, 2);
@ -924,7 +926,7 @@ int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
/* pack bits */ /* pack bits */
uint8_t *y = msg->data; uint8_t *y = msg->data;
if (msg->nof_bits != srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1C, nof_prb)) { if (msg->nof_bits != srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb, 1)) {
fprintf(stderr, "Invalid message length for format 1C\n"); fprintf(stderr, "Invalid message length for format 1C\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -989,7 +991,7 @@ int dci_format1D_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_
// unpack MCS, Harq pid and ndi // unpack MCS, Harq pid and ndi
data->mcs_idx = srslte_bit_pack(&y, 5); data->mcs_idx = srslte_bit_pack(&y, 5);
data->harq_process = srslte_bit_pack(&y, 3); data->harq_process = srslte_bit_pack(&y, harq_pid_len);
data->ndi = *y++ ? true : false; data->ndi = *y++ ? true : false;
data->rv_idx = srslte_bit_pack(&y, 2); data->rv_idx = srslte_bit_pack(&y, 2);
@ -1038,7 +1040,7 @@ int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32
y+=2; y+=2;
/* harq process number */ /* harq process number */
data->harq_process = srslte_bit_pack(&y, 3); data->harq_process = srslte_bit_pack(&y, harq_pid_len);
// Transpor block to codeword swap flag // Transpor block to codeword swap flag
if (msg->format == SRSLTE_DCI_FORMAT2B) { if (msg->format == SRSLTE_DCI_FORMAT2B) {
@ -1202,16 +1204,16 @@ int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, srslte_dci_msg_type_t *type,
uint16_t msg_rnti) uint16_t msg_rnti)
{ {
DEBUG("Get message type: nof_bits=%d, msg_rnti=0x%x\n", msg->nof_bits, msg_rnti); DEBUG("Get message type: nof_bits=%d, msg_rnti=0x%x\n", msg->nof_bits, msg_rnti);
if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT0, nof_prb) if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT0, nof_prb, 1)
&& !msg->data[0]) { && !msg->data[0]) {
type->type = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED; type->type = SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED;
type->format = SRSLTE_DCI_FORMAT0; type->format = SRSLTE_DCI_FORMAT0;
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1, nof_prb)) { } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1, nof_prb, 1)) {
type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported type->type = SRSLTE_DCI_MSG_TYPE_PDSCH_SCHED; // only these 2 types supported
type->format = SRSLTE_DCI_FORMAT1; type->format = SRSLTE_DCI_FORMAT1;
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1A, nof_prb)) { } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1A, nof_prb, 1)) {
/* The RNTI is not the only condition. Also some fields in the packet. /* The RNTI is not the only condition. Also some fields in the packet.
* if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) { * if (msg_rnti >= SRSLTE_CRNTI_START && msg_rnti <= SRSLTE_CRNTI_END) {
type->type = SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH; type->type = SRSLTE_DCI_MSG_TYPE_RA_PROC_PDCCH;
@ -1222,7 +1224,7 @@ int srslte_dci_msg_get_type(srslte_dci_msg_t *msg, srslte_dci_msg_type_t *type,
type->format = SRSLTE_DCI_FORMAT1A; type->format = SRSLTE_DCI_FORMAT1A;
//} //}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else if (msg->nof_bits == srslte_dci_format_sizeof_lut(SRSLTE_DCI_FORMAT1C, nof_prb)) { } else if (msg->nof_bits == srslte_dci_format_sizeof(SRSLTE_DCI_FORMAT1C, nof_prb, 1)) {
if (msg_rnti == SRSLTE_MRNTI) { if (msg_rnti == SRSLTE_MRNTI) {
type->type = SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE; type->type = SRSLTE_DCI_MSG_TYPE_MCCH_CHANGE;
type->format = SRSLTE_DCI_FORMAT1C; type->format = SRSLTE_DCI_FORMAT1C;

@ -340,7 +340,7 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t *q,
} else { } else {
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;
uint32_t nof_bits = srslte_dci_format_sizeof_lut(format, q->cell.nof_prb); uint32_t nof_bits = srslte_dci_format_sizeof(format, q->cell.nof_prb, q->cell.nof_ports);
uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(location->L); uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(location->L);
double mean = 0; double mean = 0;

@ -33,8 +33,10 @@ if(RF_FOUND)
list(APPEND SOURCES_RF rf_blade_imp.c) list(APPEND SOURCES_RF rf_blade_imp.c)
endif (BLADERF_FOUND) endif (BLADERF_FOUND)
add_compile_options(-march=native -mfpmath=sse -mno-avx -msse4.1)
add_library(srslte_rf SHARED ${SOURCES_RF}) add_library(srslte_rf SHARED ${SOURCES_RF})
if (UHD_FOUND) if (UHD_FOUND)
target_link_libraries(srslte_rf ${UHD_LIBRARIES}) target_link_libraries(srslte_rf ${UHD_LIBRARIES})
endif (UHD_FOUND) endif (UHD_FOUND)
@ -43,5 +45,6 @@ if(RF_FOUND)
target_link_libraries(srslte_rf ${BLADERF_LIBRARIES}) target_link_libraries(srslte_rf ${BLADERF_LIBRARIES})
endif (BLADERF_FOUND) endif (BLADERF_FOUND)
INSTALL(TARGETS srslte_rf DESTINATION ${LIBRARY_DIR})
SRSLTE_SET_PIC(srslte_rf) SRSLTE_SET_PIC(srslte_rf)
endif(RF_FOUND) endif(RF_FOUND)
Loading…
Cancel
Save