From eb5c33ded11b3e10b709cc473187bf7fef8566c8 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 7 Dec 2018 18:18:17 +0100 Subject: [PATCH 1/9] WIP: Replacing buffers, ldpctest passes, free does not work, TODO: implementation into softmodem --- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 11 +- .../PHY/CODING/nrLDPC_decoder/nrLDPC_bnProc.h | 13 ++- .../PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h | 20 +++- .../CODING/nrLDPC_decoder/nrLDPC_decoder.c | 108 +++++++++--------- .../CODING/nrLDPC_decoder/nrLDPC_decoder.h | 3 +- .../PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h | 12 +- .../CODING/nrLDPC_decoder/nrLDPC_init_mem.h | 89 +++++++++++++++ .../PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h | 32 ++++-- .../nrLDPC_tools/nrLDPC_debug.h | 14 +-- .../PHY/CODING/nrLDPC_decoder/nrLDPC_types.h | 12 ++ openair1/PHY/INIT/nr_init_ue.c | 3 + openair1/PHY/defs_nr_UE.h | 4 + 12 files changed, 239 insertions(+), 82 deletions(-) create mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 14652e339c..717501f232 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -157,7 +157,9 @@ int test_ldpc(short No_iteration, //double code_rate_actual_vec[8] = {0.2, 0.33333, 0.4, 0.5, 0.66667, 0.73333, 0.81481, 0.88}; t_nrLDPC_dec_params decParams; - + t_nrLDPC_procBuf nrLDPC_procBuf; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = &nrLDPC_procBuf; + t_nrLDPC_time_stats decoder_profiler; t_nrLDPC_time_stats* p_decoder_profiler =&decoder_profiler ; @@ -210,6 +212,9 @@ int test_ldpc(short No_iteration, reset_meas(&decoder_profiler.llr2bit); //reset_meas(&decoder_profiler.total); + // Allocate LDPC decoder buffers + p_nrLDPC_procBuf = nrLDPC_init_mem(); + for (j=0;jnumBnInBnGroups; const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* llrRes = p_procBuf->llrRes; + int8_t* llrProcBuf = p_procBuf->llrProcBuf; + __m128i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m128i* p_llrProcBuf; @@ -1676,7 +1681,7 @@ static inline void nrLDPC_bnProcPc(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { // BN Processing calculating the values to send back to the CNs for next iteration // bnProcBufRes contains the sum of all edges to each BN at the start of each group @@ -1685,6 +1690,10 @@ static inline void nrLDPC_bnProc(t_nrLDPC_lut* p_lut, uint16_t Z) const uint32_t* lut_startAddrBnGroups = p_lut->startAddrBnGroups; const uint16_t* lut_startAddrBnGroupsLlr = p_lut->startAddrBnGroupsLlr; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* llrRes = p_procBuf->llrRes; + __m256i* p_bnProcBuf; __m256i* p_bnProcBufRes; __m256i* p_llrRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h index 300624ae76..5b96d6226e 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h @@ -36,11 +36,14 @@ \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -362,11 +365,14 @@ static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -858,11 +864,14 @@ static inline void nrLDPC_cnProc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; @@ -1490,11 +1499,14 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param Z Lifting size \return 32-bit parity check indicator */ -static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + __m256i* p_cnProcBuf; __m256i* p_cnProcBufRes; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c index fbdb9a3fa4..bbcd34c368 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c @@ -45,20 +45,22 @@ #include "nrLDPC_tools/nrLDPC_debug.h" #endif -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler); -int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_time_stats* p_profiler) +int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler) { uint32_t numLLR; uint32_t numIter = 0; t_nrLDPC_lut lut; t_nrLDPC_lut* p_lut = &lut; + printf("p_procBuf->cnProcBuf = %p\n", p_procBuf->cnProcBuf); + // Initialize decoder core(s) with correct LUTs numLLR = nrLDPC_init(p_decParams, p_lut); // Launch LDPC decoder core for one segment - numIter = nrLDPC_decoder_core(p_llr, p_out, numLLR, p_lut, p_decParams, p_profiler); + numIter = nrLDPC_decoder_core(p_llr, p_out, p_procBuf, numLLR, p_lut, p_decParams, p_profiler); return numIter; } @@ -72,7 +74,7 @@ int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* \param p_decParams LDPC decoder parameters \param p_profiler LDPC profiler statistics */ -static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) +static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler) { uint16_t Z = p_decParams->Z; uint8_t BG = p_decParams->BG; @@ -93,7 +95,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ else { // Use LLR processing buffer as temporary output buffer - p_llrOut = (int8_t*) llrProcBuf; + p_llrOut = p_procBuf->llrProcBuf; } @@ -101,27 +103,27 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llr2llrProcBuf); #endif - nrLDPC_llr2llrProcBuf(p_lut, p_llr, Z, BG); + nrLDPC_llr2llrProcBuf(p_lut, p_llr, p_procBuf, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2llrProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_PROC, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llr2CnProcBuf); #endif - nrLDPC_llr2CnProcBuf(p_lut, p_llr, numLLR, Z, BG); + nrLDPC_llr2CnProcBuf(p_lut, p_llr, p_procBuf, numLLR, Z, BG); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llr2CnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // First iteration @@ -132,11 +134,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); @@ -144,7 +146,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_CN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL @@ -152,11 +154,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); @@ -164,34 +166,34 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_LLR_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE nrLDPC_debug_initBuffer2File(nrLDPC_buffers_BN_PROC_RES); - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -200,18 +202,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check not necessary here since it will fail @@ -231,18 +233,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif // Send CN results back to BNs @@ -251,43 +253,43 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN Processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -296,18 +298,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check @@ -317,11 +319,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); } else { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProcPc); @@ -342,18 +344,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cnProc_BG1(p_lut, Z); + nrLDPC_cnProc_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cnProc_BG2(p_lut, Z); + nrLDPC_cnProc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC_RES, p_procBuf); #endif // Send CN results back to BNs @@ -362,31 +364,31 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_cn2bnProcBuf_BG1(p_lut, Z); + nrLDPC_cn2bnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_cn2bnProcBuf(p_lut, Z); + nrLDPC_cn2bnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cn2bnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC, p_procBuf); #endif // BN Processing #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProcPc); #endif - nrLDPC_bnProcPc(p_lut, Z); + nrLDPC_bnProcPc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProcPc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_LLR_RES, p_procBuf); #endif // If parity check not enabled, no need to send the BN proc results @@ -395,13 +397,13 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->bnProc); #endif - nrLDPC_bnProc(p_lut, Z); + nrLDPC_bnProc(p_lut, p_procBuf, Z); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bnProc); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_BN_PROC_RES, p_procBuf); #endif // BN results to CN processing buffer @@ -410,18 +412,18 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - nrLDPC_bn2cnProcBuf_BG1(p_lut, Z); + nrLDPC_bn2cnProcBuf_BG1(p_lut, p_procBuf, Z); } else { - nrLDPC_bn2cnProcBuf(p_lut, Z); + nrLDPC_bn2cnProcBuf(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->bn2cnProcBuf); #endif #ifdef NR_LDPC_DEBUG_MODE - nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC); + nrLDPC_debug_writeBuffer2File(nrLDPC_buffers_CN_PROC, p_procBuf); #endif // Parity Check @@ -430,11 +432,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #endif if (BG == 1) { - pcRes = nrLDPC_cnProcPc_BG1(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG1(p_lut, p_procBuf, Z); } else { - pcRes = nrLDPC_cnProcPc_BG2(p_lut, Z); + pcRes = nrLDPC_cnProcPc_BG2(p_lut, p_procBuf, Z); } #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->cnProcPc); @@ -454,7 +456,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, uint32_ #ifdef NR_LDPC_PROFILER_DETAIL start_meas(&p_profiler->llrRes2llrOut); #endif - nrLDPC_llrRes2llrOut(p_lut, p_llrOut, numLLR); + nrLDPC_llrRes2llrOut(p_lut, p_llrOut, p_procBuf, numLLR); #ifdef NR_LDPC_PROFILER_DETAIL stop_meas(&p_profiler->llrRes2llrOut); #endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h index e1dff38723..4d2401db83 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h @@ -32,6 +32,7 @@ #define __NR_LDPC_DECODER__H__ #include "nrLDPC_types.h" +#include "nrLDPC_init_mem.h" /** \brief LDPC decoder @@ -40,6 +41,6 @@ \param p_llrOut Output vector \param p_profiler LDPC profiler statistics */ -int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_llrOut, t_nrLDPC_time_stats* p_profiler); +int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_llrOut, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler); #endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h index 6dbd38e681..abab93fb42 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h @@ -104,19 +104,19 @@ // Aligned on 32 bytes = 256 bits for AVX2 /** CN processing buffer */ -static int8_t cnProcBuf [NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); +//static int8_t cnProcBuf [NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); /** Buffer for CN processing results */ -static int8_t cnProcBufRes[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); +//static int8_t cnProcBufRes[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); /** BN processing buffer */ -static int8_t bnProcBuf [NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); +//static int8_t bnProcBuf [NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); /** Buffer for BN processing results */ -static int8_t bnProcBufRes[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); +//static int8_t bnProcBufRes[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); /** Buffer for LLR results */ -static int8_t llrRes [NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); +//static int8_t llrRes [NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); /** LLR processing buffer */ -static int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); +//static int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); /** Start addresses for the cnProcBuf for each CN group in BG1*/ static const uint32_t lut_startAddrCnGroups_BG1[NR_LDPC_NUM_CN_GROUPS_BG1] = {0, 1152, 8832, 43392, 61824, 75264, 81408, 88320, 92160}; diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h new file mode 100644 index 0000000000..87949f81dd --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h @@ -0,0 +1,89 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*!\file nrLDPC_init_mem.h + * \brief Defines the function to initialize the LDPC decoder and sets correct LUTs. + * \author Sebastian Wagner (TCL Communications) Email: + * \date 07-12-2018 + * \version 1.0 + * \note + * \warning + */ + +#ifndef __NR_LDPC_INIT_MEM__H__ +#define __NR_LDPC_INIT_MEM__H__ + +#include +#include "nrLDPC_defs.h" +#include "nrLDPC_types.h" + +#ifndef malloc32_clear +/** + \brief Allocates 32 byte aligned memory and initializes to zero + \param size Input size in bytes + \return Pointer to memory +*/ +static inline void* malloc32_clear(size_t size) +{ + void* ptr = (void*) memalign(32, size+32); + memset(ptr, 0, size); + return ptr; +} +#endif + +/** + \brief Allocates and initializes the internal decoder processing buffers + \param p_decParams Pointer to decoder parameters + \param p_lut Pointer to decoder LUTs + \return Number of LLR values +*/ +static inline t_nrLDPC_procBuf* nrLDPC_init_mem(void) +{ + t_nrLDPC_procBuf procBuf; + t_nrLDPC_procBuf* p_procBuf = &procBuf; + + p_procBuf->cnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->cnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->llrRes = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); + p_procBuf->llrProcBuf = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); + + int i; + for (i=0;i<10;i++) + { + printf("p_procBuf->cnProcBuf[%d] = %d\n",i,p_procBuf->cnProcBuf[i]); + printf("p_procBuf->cnProcBuf[%d] = %d\n",NR_LDPC_SIZE_CN_PROC_BUF - i - 1,p_procBuf->cnProcBuf[NR_LDPC_SIZE_CN_PROC_BUF - i - 1]); + } + + return(p_procBuf); +} + +static inline void nrLDPC_free_mem(t_nrLDPC_procBuf* p_procBuf) +{ + free(p_procBuf->cnProcBuf); + free(p_procBuf->cnProcBufRes); + free(p_procBuf->bnProcBuf); + free(p_procBuf->bnProcBufRes); + free(p_procBuf->llrRes); + free(p_procBuf->llrProcBuf); +} +#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h index 3e6c4c0c7c..f3431eba24 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h @@ -41,13 +41,15 @@ \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t Z, uint8_t BG) { const uint16_t* lut_llr2llrProcBuf = p_lut->llr2llrProcBuf; uint32_t i; const uint8_t numBn2CnG1 = p_lut->numBnInBnGroups[0]; uint32_t colG1 = NR_LDPC_START_COL_PARITY_BG1*Z; + int8_t* llrProcBuf = p_procBuf->llrProcBuf; + if (BG == 2) { colG1 = NR_LDPC_START_COL_PARITY_BG2*Z; @@ -74,11 +76,13 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint1 \param Z Lifting size \param BG Base graph */ -static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16_t numLLR, uint16_t Z, uint8_t BG) +static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrLDPC_procBuf* p_procBuf, uint16_t numLLR, uint16_t Z, uint8_t BG) { const uint32_t* lut_llr2CnProcBuf = p_lut->llr2CnProcBuf; const uint8_t* lut_numEdgesPerBn = p_lut->numEdgesPerBn; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t curLLR; uint8_t numEdges; uint32_t i; @@ -123,12 +127,15 @@ static inline void nrLDPC_llr2CnProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, uint16 \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + const uint32_t* p_lut_cn2bn; int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; @@ -245,12 +252,15 @@ static inline void nrLDPC_cn2bnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBufRes = p_procBuf->cnProcBufRes; + int8_t* bnProcBuf = p_procBuf->bnProcBuf; + const uint32_t* p_lut_cn2bn; int8_t* p_cnProcBufRes; uint32_t bitOffsetInGroup; @@ -418,12 +428,15 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* p_cnProcBuf; const uint32_t* p_lut_cn2bn; uint32_t bitOffsetInGroup; @@ -543,12 +556,15 @@ static inline void nrLDPC_bn2cnProcBuf(t_nrLDPC_lut* p_lut, uint16_t Z) \param p_lut Pointer to decoder LUTs \param Z Lifting size */ -static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) +static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_procBuf, uint16_t Z) { const uint32_t* lut_cn2bnProcBuf = p_lut->cn2bnProcBuf; const uint8_t* lut_numCnInCnGroups = p_lut->numCnInCnGroups; const uint32_t* lut_startAddrCnGroups = p_lut->startAddrCnGroups; + int8_t* cnProcBuf = p_procBuf->cnProcBuf; + int8_t* bnProcBufRes = p_procBuf->bnProcBufRes; + int8_t* p_cnProcBuf; const uint32_t* p_lut_cn2bn; uint32_t bitOffsetInGroup; @@ -720,11 +736,13 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, uint16_t Z) \param llrOut Pointer to output LLRs \param numLLR Number of LLR values */ -static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, uint16_t numLLR) +static inline void nrLDPC_llrRes2llrOut(t_nrLDPC_lut* p_lut, int8_t* llrOut, t_nrLDPC_procBuf* p_procBuf, uint16_t numLLR) { const uint16_t* lut_llr2llrProcBuf = p_lut->llr2llrProcBuf; uint32_t i; + int8_t* llrRes = p_procBuf->llrRes; + for (i=0; illrProcBuf, NR_LDPC_MAX_NUM_LLR); break; } case nrLDPC_buffers_CN_PROC: { - nrLDPC_writeFile("cnProcBuf.txt", cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBuf.txt", p_procBuf->cnProcBuf, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_CN_PROC_RES: { - nrLDPC_writeFile("cnProcBufRes.txt", cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF); + nrLDPC_writeFile("cnProcBufRes.txt", p_procBuf->cnProcBufRes, NR_LDPC_SIZE_CN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC: { - nrLDPC_writeFile("bnProcBuf.txt", bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBuf.txt", p_procBuf->bnProcBuf, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_BN_PROC_RES: { - nrLDPC_writeFile("bnProcBufRes.txt", bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF); + nrLDPC_writeFile("bnProcBufRes.txt", p_procBuf->bnProcBufRes, NR_LDPC_SIZE_BN_PROC_BUF); break; } case nrLDPC_buffers_LLR_RES: { - nrLDPC_writeFile("llrRes.txt", llrRes, NR_LDPC_MAX_NUM_LLR); + nrLDPC_writeFile("llrRes.txt", p_procBuf->llrRes, NR_LDPC_MAX_NUM_LLR); break; } } diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index 3c5128d1a1..ae32f6ffb6 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -88,4 +88,16 @@ typedef struct nrLDPC_time_stats { time_stats_t total; /**< Statistics for total processing time */ } t_nrLDPC_time_stats; +/** + Structure containing the processing buffers + */ +typedef struct nrLDPC_procBuf { + int8_t* cnProcBuf; /**< CN processing buffer */ + int8_t* cnProcBufRes; /**< Buffer for CN processing results */ + int8_t* bnProcBuf; /**< BN processing buffer */ + int8_t* bnProcBufRes; /**< Buffer for BN processing results */ + int8_t* llrRes; /**< Buffer for LLR results */ + int8_t* llrProcBuf; /**< LLR processing buffer */ +} t_nrLDPC_procBuf; + #endif diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 1e8f2bc990..f4cb9cef4b 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -937,6 +937,9 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); + // LDPC processing buffer allocation + ue->p_nrLDPC_procBuf[0] = nrLDPC_init_mem(); + ue->p_nrLDPC_procBuf[1] = nrLDPC_init_mem(); } void phy_init_nr_top(PHY_VARS_NR_UE *ue) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9dfcacb611..e182e3e3a9 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -158,6 +158,7 @@ #include "targets/ARCH/COMMON/common_lib.h" #include "NR_IF_Module.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" /// Context data structure for RX/TX portion of subframe processing typedef struct { @@ -1063,6 +1064,9 @@ typedef struct { #endif t_nrPolar_params *nrPolar_params; + /// LDPC processing buffers for 2 segments in parallel + t_nrLDPC_procBuf* p_nrLDPC_procBuf[2]; + /// PBCH DMRS sequence uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; From f187b0e17c86c9f89ba2ff39782cef7ccdf65196 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 10 Dec 2018 10:34:47 +0100 Subject: [PATCH 2/9] WIP: integrated changes to softmodem, TODO: not sure where to free memory --- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 15 ++++++++++++++- openair1/PHY/defs_nr_UE.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 717501f232..8229862abf 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -494,8 +494,8 @@ int test_ldpc(short No_iteration, //free(channel_output_fixed); //free(estimated_output); - //nrLDPC_free_mem(p_nrLDPC_procBuf); - + nrLDPC_free_mem(p_nrLDPC_procBuf); + print_meas(&time,"ldpc_encoder",NULL,NULL); print_meas(time_optim,"ldpc_encoder_optim",NULL,NULL); print_meas(&tinput,"ldpc_encoder_optim(input)",NULL,NULL); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 448c01c397..10794c0a3e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -219,6 +219,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + // Pointer to LDPC processing buffer of thread 0 + t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[0]; + int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -506,7 +509,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, - p_procTime); + p_nrLDPC_procBuf, + p_procTime); /* if (check_crc(llrProcBuf,Kr,harq_process->F,crc_type)) { @@ -692,6 +696,8 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + // Pointer to LDPC processing buffer of thread 0 + t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[0]; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1091,6 +1097,7 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); nb_total_decod++; @@ -1274,6 +1281,8 @@ void *nr_dlsch_decoding_2thread0(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + // Pointer to LDPC processing buffer of thread 0 + t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[0]; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1607,6 +1616,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); if (no_iteration_ldpc > 10) @@ -1779,6 +1789,8 @@ void *nr_dlsch_decoding_2thread1(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; + // Pointer to LDPC processing buffer of thread 1 + t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[1]; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -2111,6 +2123,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, + p_nrLDPC_procBuf, p_procTime); if (no_iteration_ldpc > 10) diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index e182e3e3a9..a374aba941 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -158,7 +158,7 @@ #include "targets/ARCH/COMMON/common_lib.h" #include "NR_IF_Module.h" -#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h" /// Context data structure for RX/TX portion of subframe processing typedef struct { From 972780141797225dbe4666548b6560b53e7ae9c7 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 12 Dec 2018 09:42:06 +0100 Subject: [PATCH 3/9] WIP: Version to be tested --- .../PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h | 18 +----------------- openair1/PHY/INIT/nr_init_ue.c | 3 --- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 15 +++++++-------- openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 8 ++++---- openair1/PHY/defs_nr_UE.h | 4 ---- 5 files changed, 12 insertions(+), 36 deletions(-) diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h index abab93fb42..940d842550 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h @@ -100,23 +100,7 @@ #define NR_LDPC_MAX_NUM_LLR 26112 // ============================================================================== -// GLOBAL VARIABLES - -// Aligned on 32 bytes = 256 bits for AVX2 -/** CN processing buffer */ -//static int8_t cnProcBuf [NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); -/** Buffer for CN processing results */ -//static int8_t cnProcBufRes[NR_LDPC_SIZE_CN_PROC_BUF] __attribute__ ((aligned(32))); - -/** BN processing buffer */ -//static int8_t bnProcBuf [NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); -/** Buffer for BN processing results */ -//static int8_t bnProcBufRes[NR_LDPC_SIZE_BN_PROC_BUF] __attribute__ ((aligned(32))); - -/** Buffer for LLR results */ -//static int8_t llrRes [NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); -/** LLR processing buffer */ -//static int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); +// GLOBAL CONSTANT VARIABLES /** Start addresses for the cnProcBuf for each CN group in BG1*/ static const uint32_t lut_startAddrCnGroups_BG1[NR_LDPC_NUM_CN_GROUPS_BG1] = {0, 1152, 8832, 43392, 61824, 75264, 81408, 88320, 92160}; diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index f4cb9cef4b..1e8f2bc990 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -937,9 +937,6 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); - // LDPC processing buffer allocation - ue->p_nrLDPC_procBuf[0] = nrLDPC_init_mem(); - ue->p_nrLDPC_procBuf[1] = nrLDPC_init_mem(); } void phy_init_nr_top(PHY_VARS_NR_UE *ue) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 10794c0a3e..295673fdde 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -81,6 +81,8 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch) } } + nrLDPC_free_mem(dlsch->p_nrLDPC_procBuf); + free16(dlsch,sizeof(NR_UE_DLSCH_t)); dlsch = NULL; } @@ -120,6 +122,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint dlsch->Mdlharq = Mdlharq; dlsch->Nsoft = Nsoft; dlsch->max_ldpc_iterations = max_ldpc_iterations; + dlsch->p_nrLDPC_procBuf = nrLDPC_init_mem(); for (i=0; ip_nrLDPC_procBuf[0]; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; @@ -696,8 +698,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - // Pointer to LDPC processing buffer of thread 0 - t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[0]; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1281,8 +1282,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - // Pointer to LDPC processing buffer of thread 0 - t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[0]; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1789,8 +1789,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - // Pointer to LDPC processing buffer of thread 1 - t_nrLDPC_procBuf* p_nrLDPC_procBuf = phy_vars_ue->p_nrLDPC_procBuf[1]; + t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index f89816c782..c8ef70b242 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -34,7 +34,7 @@ #include #include "PHY/impl_defs_top.h" - +#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" //#include "PHY/defs_nr_UE.h" #include "../NR_TRANSPORT/nr_transport_common_proto.h" @@ -352,10 +352,10 @@ typedef struct { uint32_t Nsoft; /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; + /// LDPC processing buffers + t_nrLDPC_procBuf* p_nrLDPC_procBuf; /// number of iterations used in last turbo decoding - uint8_t last_iteration_cnt; - - + uint8_t last_iteration_cnt; } NR_UE_DLSCH_t; typedef enum {format0_0, diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index a374aba941..9dfcacb611 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -158,7 +158,6 @@ #include "targets/ARCH/COMMON/common_lib.h" #include "NR_IF_Module.h" -#include "PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h" /// Context data structure for RX/TX portion of subframe processing typedef struct { @@ -1064,9 +1063,6 @@ typedef struct { #endif t_nrPolar_params *nrPolar_params; - /// LDPC processing buffers for 2 segments in parallel - t_nrLDPC_procBuf* p_nrLDPC_procBuf[2]; - /// PBCH DMRS sequence uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; From 9548ab863d88e8b6cdb89019ea1f653c8a961808 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 8 Jan 2019 11:07:49 +0100 Subject: [PATCH 4/9] Fixed bug in memory allocation --- .../CODING/nrLDPC_decoder/nrLDPC_init_mem.h | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h index 87949f81dd..bdaa118e1f 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h @@ -57,21 +57,16 @@ static inline void* malloc32_clear(size_t size) */ static inline t_nrLDPC_procBuf* nrLDPC_init_mem(void) { - t_nrLDPC_procBuf procBuf; - t_nrLDPC_procBuf* p_procBuf = &procBuf; + t_nrLDPC_procBuf* p_procBuf = (t_nrLDPC_procBuf*) malloc32_clear(sizeof(t_nrLDPC_procBuf)); - p_procBuf->cnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); - p_procBuf->cnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); - p_procBuf->bnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); - p_procBuf->bnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); - p_procBuf->llrRes = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); - p_procBuf->llrProcBuf = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); - - int i; - for (i=0;i<10;i++) + if (p_procBuf) { - printf("p_procBuf->cnProcBuf[%d] = %d\n",i,p_procBuf->cnProcBuf[i]); - printf("p_procBuf->cnProcBuf[%d] = %d\n",NR_LDPC_SIZE_CN_PROC_BUF - i - 1,p_procBuf->cnProcBuf[NR_LDPC_SIZE_CN_PROC_BUF - i - 1]); + p_procBuf->cnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->cnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_CN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBuf = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->bnProcBufRes = (int8_t*) malloc32_clear(NR_LDPC_SIZE_BN_PROC_BUF*sizeof(int8_t)); + p_procBuf->llrRes = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); + p_procBuf->llrProcBuf = (int8_t*) malloc32_clear(NR_LDPC_MAX_NUM_LLR *sizeof(int8_t)); } return(p_procBuf); @@ -85,5 +80,7 @@ static inline void nrLDPC_free_mem(t_nrLDPC_procBuf* p_procBuf) free(p_procBuf->bnProcBufRes); free(p_procBuf->llrRes); free(p_procBuf->llrProcBuf); + + free(p_procBuf); } #endif From 73178c81534012d1b08919dfd7cea13ebcbfdf72 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 9 Jan 2019 20:49:15 +0100 Subject: [PATCH 5/9] Nr cpu affinity2 --- cmake_targets/build_oai | 4 +++ .../SYRTEM_IQ_QuickStart.readme | 12 +++++-- targets/COMMON/threads_t.h | 27 ++++++++-------- targets/RT/USER/lte-softmodem.c | 8 +++-- targets/RT/USER/lte-softmodem.h | 3 +- targets/RT/USER/lte-ue.c | 8 ++--- targets/RT/USER/lte-uesoftmodem.c | 9 ++++-- targets/RT/USER/nr-ru.c | 5 +-- targets/RT/USER/nr-softmodem.c | 11 ++++--- targets/RT/USER/nr-softmodem.h | 6 ---- targets/RT/USER/nr-ue.c | 16 +++++----- targets/RT/USER/nr-uesoftmodem.c | 31 ++++++++++++++++--- targets/RT/USER/nr-uesoftmodem.h | 17 +++++----- targets/RT/USER/rt_wrapper.c | 28 +++++++++++------ 14 files changed, 117 insertions(+), 68 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f4b64026e1..f018e8c422 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -339,6 +339,10 @@ function main() { FORCE_DEADLINE_SCHEDULER_FLAG_USER="True" echo_info "Enabling the usage of deadline scheduler" shift 1;; + --enable-cpu-affinity) + CPU_AFFINITY_FLAG_USER="True" + echo_info "Enabling CPU Affinity (only valid when not using deadline scheduler)" + shift 1;; --disable-cpu-affinity) CPU_AFFINITY_FLAG_USER="False" echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)" diff --git a/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme b/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme index d7f6585a75..cd74fdb397 100755 --- a/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme +++ b/targets/ARCH/ADRV9371_ZC706/SYRTEM_IQ_QuickStart.readme @@ -115,8 +115,16 @@ sudo cset shield --reset cd eur_oai_develop-nr/openairinterface5g/ source oaienv -sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 -I -sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 +sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 -I --enable-cpu-affinity + +/* CPU available shall be mapped on CPU2 to get_nprocs() number with hyperthreading disabled */ +/* because : */ +/* - cset shield leave CPU0 for system */ +/* - CPU1 is reserved for HwRxTx thread for I/Q acquisition ! */ +/* Note: "/usr/local/etc/syriq/cpu-irq.sh" shall be changed if more than 8 cores are used */ +/* ie. "cset shield --force --kthread on -c 1-7" where "-c 1-7" reserves CPU1 to CPU7 for application (CPU0 is for system) */ + +sudo -E ./cmake_targets/build_oai -c --gNB -w ADRV9371_ZC706 --enable-cpu-affinity diff --git a/targets/COMMON/threads_t.h b/targets/COMMON/threads_t.h index 99fb0d8cf4..0671f40988 100644 --- a/targets/COMMON/threads_t.h +++ b/targets/COMMON/threads_t.h @@ -2,19 +2,20 @@ #define _THREADS_T_H_ typedef struct threads_s { - int iq; - int one; - int two; - int three; - int slot1_proc_one; - int slot1_proc_two; - int slot1_proc_three; - int dlsch_td_one; - int dlsch_td_two; - int dlsch_td_three; - int dlsch_td1_one; - int dlsch_td1_two; - int dlsch_td1_three; + int main; + int sync; + int one; + int two; + int three; + int slot1_proc_one; + int slot1_proc_two; + int slot1_proc_three; + //int dlsch_td_one; + //int dlsch_td_two; + //int dlsch_td_three; + //int dlsch_td1_one; + //int dlsch_td1_two; + //int dlsch_td1_three; } threads_t; #endif /* _THREADS_T_H_ */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 03a461454f..8dbd1d51c9 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -253,7 +253,7 @@ extern char uecap_xer[1024]; char uecap_xer_in=0; int oaisim_flag=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; +threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -906,14 +906,16 @@ int main( int argc, char **argv ) char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 96ab799c3d..0870405fac 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -169,7 +169,8 @@ {"clock", CONFIG_HLP_CLK, 0, uptr:&clock_source, defintval:0, TYPE_UINT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:0, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ +{"threadMain", NULL, 0, iptr:&(threads.main), defintval:1, TYPE_INT, 0}, \ +{"threadSync", NULL, 0, iptr:&(threads.sync), defintval:1, TYPE_INT, 0}, \ {"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ {"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ {"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 965203f47e..a9a880dde7 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -456,8 +456,8 @@ static void *UE_thread_synch(void *arg) cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.sync != -1 ) + CPU_SET(threads.sync, &cpuset); // this thread priority must be lower that the main acquisition thread sprintf(threadname, "sync UE %d\n", UE->Mod_id); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); @@ -1435,8 +1435,8 @@ void *UE_thread(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.main != -1 ) + CPU_SET(threads.main, &cpuset); init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads"); diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 3d2995e5d1..617756e722 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -260,7 +260,7 @@ extern char uecap_xer[1024]; char uecap_xer_in=0; int oaisim_flag=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; +threads_t threads = {-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -1014,14 +1014,17 @@ printf("~~~~~~~~~~~~~~~~~~~~successfully get the parallel config[%d], worker con char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-ru.c b/targets/RT/USER/nr-ru.c index 31698232b4..0e91074691 100644 --- a/targets/RT/USER/nr-ru.c +++ b/targets/RT/USER/nr-ru.c @@ -1499,7 +1499,7 @@ static void* ru_thread( void* param ) { int ret; int subframe =9; int frame =1023; - char filename[40]; + char filename[40],threadname[40]; int print_frame = 2; int i = 0; @@ -1508,7 +1508,8 @@ static void* ru_thread( void* param ) { // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); + sprintf(threadname,"ru_thread %d",ru->idx); + thread_top_init(threadname,0,870000,1000000,1000000); LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 67d226327c..f6e61884fe 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -247,8 +247,6 @@ double cpuf; extern char uecap_xer[1024]; char uecap_xer_in=0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; - /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution */ @@ -1036,14 +1034,19 @@ int main( int argc, char **argv ) char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + int j; if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + // CPU_SET(1, &cpuset); + for (j = 2; j < get_nprocs(); j++) + { + CPU_SET(j, &cpuset); + } s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-softmodem.h b/targets/RT/USER/nr-softmodem.h index 9dce5f34bd..5ee2880f3d 100644 --- a/targets/RT/USER/nr-softmodem.h +++ b/targets/RT/USER/nr-softmodem.h @@ -152,12 +152,6 @@ {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:DEFAULT_DLF, TYPE_UINT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 22ada266bf..ed55e15d3c 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -341,8 +341,8 @@ static void *UE_thread_synch(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); + if ( threads.sync != -1 ) + CPU_SET(threads.sync, &cpuset); // this thread priority must be lower that the main acquisition thread sprintf(threadname, "sync UE %d", UE->Mod_id); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); @@ -833,15 +833,15 @@ void *UE_thread(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); - init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, - "UHD Threads"); + if ( threads.main != -1 ) + CPU_SET(threads.main, &cpuset); + sprintf(threadname, "Main UE %d", UE->Mod_id); + init_thread(100000, 500000, FIFO_PRIORITY, &cpuset,threadname); + if ((oaisim_flag == 0) && (UE->mode !=loop_through_memory)) AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); UE->rfdevice.host_type = RAU_HOST; - sprintf(threadname, "Main UE %d", UE->Mod_id); - pthread_setname_np(pthread_self(), threadname); + init_UE_threads(UE); #ifdef NAS_UE diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 68f0254762..beebdfd561 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -268,7 +268,8 @@ char uecap_xer[1024],uecap_xer_in=0; int oaisim_flag=0; int emulate_rf = 0; -threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; +threads_t threads = {-1,-1,-1,-1,-1,-1,-1,-1}; +int threads_offset = 0; char* usrp_args=NULL; char* usrp_clksrc=NULL; @@ -1029,8 +1030,25 @@ int main( int argc, char **argv ) { //dump_frame_parms(frame_parms[0]); init_openair0(); - + // default threads.main = 2 + // if there are enough processors, all others on subsequent CPUs + if (threads_offset>0) { + if (threads_offset+8<=get_nprocs()) { + if (threads.main<0) threads.main=threads_offset+1; + if (threads.sync<0) threads.sync=threads_offset+2; + if (threads.one<0) threads.one=threads_offset+3; + if (threads.two<0) threads.two=threads_offset+4; + if (threads.three<0) threads.three=threads_offset+5; + if (threads.slot1_proc_one<0) threads.slot1_proc_one=threads_offset+6; + if (threads.slot1_proc_two<0) threads.slot1_proc_two=threads_offset+7; + if (threads.slot1_proc_three<0) threads.slot1_proc_three=threads_offset+8; + } + else { + LOG_E(HW,"Not enough CPUs available (nprocs (=%d) >= threadmain (=%d) + 10)\n",get_nprocs(),threads_offset); + exit_fun("Error setting thread affinity\n"); + } + } #ifndef DEADLINE_SCHEDULER @@ -1041,14 +1059,17 @@ int main( int argc, char **argv ) { char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) { - CPU_SET(0, &cpuset); + int j; + if (get_nprocs()>=2) { + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } - LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); + LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); } #endif diff --git a/targets/RT/USER/nr-uesoftmodem.h b/targets/RT/USER/nr-uesoftmodem.h index 99fb64f175..816e753086 100644 --- a/targets/RT/USER/nr-uesoftmodem.h +++ b/targets/RT/USER/nr-uesoftmodem.h @@ -157,13 +157,16 @@ {"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ -{"nr_dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ +{"threadoffset", NULL, 0, iptr:&(threads_offset), defintval:0, TYPE_INT, 0}, \ +{"threadMain", NULL, 0, iptr:&(threads.main), defintval:-1, TYPE_INT, 0}, \ +{"threadSync", NULL, 0, iptr:&(threads.sync), defintval:-1, TYPE_INT, 0}, \ +{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:-1, TYPE_INT, 0}, \ +{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:-1, TYPE_INT, 0}, \ +{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:-1, TYPE_INT, 0}, \ +{"threadSlot1ProcThree", NULL, 0, iptr:&(threads.slot1_proc_three), defintval:-1, TYPE_INT, 0}, \ +{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ {"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index 443d183068..e4dc54f78f 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -294,20 +294,20 @@ void thread_top_init(char *thread_name, char cpu_affinity[1024]; cpu_set_t cpuset; - /* Set affinity mask to include CPUs 1 to MAX_CPUS */ + /* Set affinity mask to include CPUs 2 to MAX_CPUS */ /* CPU 0 is reserved for UHD threads */ /* CPU 1 is reserved for all RX_TX threads */ - /* Enable CPU Affinity only if number of CPUs >2 */ + /* Enable CPU Affinity only if number of CPUs > 2 */ CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() > 2) + if (affinity == 0) { + LOG_W(HW,"thread_top_init() called with affinity==0, but overruled by #ifdef CPU_AFFINITY\n"); + } + else if (get_nprocs() > 2) { - if (affinity == 0) - CPU_SET(0,&cpuset); - else - for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); + for (j = 2; j < get_nprocs(); j++) + CPU_SET(j, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) { @@ -315,21 +315,29 @@ void thread_top_init(char *thread_name, exit_fun("Error setting processor affinity"); } } +#else //CPU_AFFINITY + if (affinity) { + LOG_W(HW,"thread_top_init() called with affinity>0, but overruled by #ifndef CPU_AFFINITY.\n"); + } #endif //CPU_AFFINITY /* Check the actual affinity mask assigned to the thread */ s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) { + if (s != 0) + { perror( "pthread_getaffinity_np"); exit_fun("Error getting processor affinity "); } memset(cpu_affinity,0,sizeof(cpu_affinity)); for (j = 0; j < 1024; j++) - if (CPU_ISSET(j, &cpuset)) { + { + if (CPU_ISSET(j, &cpuset)) + { char temp[1024]; sprintf (temp, " CPU_%d", j); strcat(cpu_affinity, temp); } + } memset(&sparam, 0, sizeof(sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); From 454c552de225f7a1981892825dd49e7a9a0338e4 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Thu, 10 Jan 2019 10:16:36 +0100 Subject: [PATCH 6/9] Test passed for multithreading dlsch_decoding --- openair1/PHY/INIT/nr_init_ue.c | 4 +- .../NR_TRANSPORT/nr_transport_common_proto.h | 3 +- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 87 ++++++++++++++----- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 4 +- 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 1e8f2bc990..51d881b13e 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -942,9 +942,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { void phy_init_nr_top(PHY_VARS_NR_UE *ue) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - NR_UE_DLSCH_t *dlsch0 = ue->dlsch[0][0][0]; - dlsch0 =(NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); - + crcTableInit(); init_dfts(); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 3c318874ac..b075da4e97 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -1,3 +1,4 @@ + /* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with @@ -33,7 +34,7 @@ #ifndef __NR_TRANSPORT_COMMON_PROTO__H__ #define __NR_TRANSPORT_COMMON_PROTO__H__ -#define MAX_NUM_NR_DLSCH_SEGMENTS 32 +#define MAX_NUM_NR_DLSCH_SEGMENTS 16 #define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS #define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 295673fdde..26dd0af0dd 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -45,8 +45,6 @@ #define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX -static int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); - static uint64_t nb_total_decod =0; static uint64_t nb_error_decod =0; @@ -75,14 +73,19 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch) free16(dlsch->harq_processes[i]->d[r],(3*8448)*sizeof(short)); dlsch->harq_processes[i]->d[r] = NULL; } + + for (r=0; r<(MAX_NUM_NR_DLSCH_SEGMENTS); r++) { + if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ + nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]); + dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; + } + } free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t)); dlsch->harq_processes[i] = NULL; } } - - nrLDPC_free_mem(dlsch->p_nrLDPC_procBuf); - + free16(dlsch,sizeof(NR_UE_DLSCH_t)); dlsch = NULL; } @@ -122,8 +125,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint dlsch->Mdlharq = Mdlharq; dlsch->Nsoft = Nsoft; dlsch->max_ldpc_iterations = max_ldpc_iterations; - dlsch->p_nrLDPC_procBuf = nrLDPC_init_mem(); - + for (i=0; iharq_processes[i] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); @@ -139,7 +141,8 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint exit_flag=3; if (abstraction_flag == 0) { - for (r=0; rharq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056); if (dlsch->harq_processes[i]->c[r]) @@ -218,11 +221,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, //short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)]; uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint8_t crc_type; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; + t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; @@ -511,7 +515,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, no_iteration_ldpc = nrLDPC_decoder(p_decParams, (int8_t*)&pl[0], llrProcBuf, - p_nrLDPC_procBuf, + p_nrLDPC_procBuf[r], p_procTime); /* @@ -698,7 +702,9 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + t_nrLDPC_procBuf* p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[0]; + int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -794,7 +800,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, kb = harq_process->K/harq_process->Z; if ( kb==22){ p_decParams->BG = 1; - p_decParams->R = 89; + p_decParams->R = 13; kc = 68; } else{ @@ -833,7 +839,7 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, return((1+dlsch->max_ldpc_iterations)); } #ifdef DEBUG_DLSCH_DECODING - printf("Segmentation: C %d, Cminus %d, Kminus %d, Kplus %d\n",harq_process->C,harq_process->Cminus,harq_process->Kminus,harq_process->Kplus); + printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif opp_enabled=1; @@ -963,7 +969,9 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment Cby2 = 1; } - for (r=0; rK; Kr_bytes = Kr>>3; @@ -1015,8 +1023,13 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; //printf("main thread r_offset %d\n",r_offset); + +#ifdef DEBUG_DLSCH_DECODING + for (int i =0; i<16; i++) + printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); +#endif /* printf("Subblock deinterleaving, d %p w %p\n", @@ -1030,6 +1043,11 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment harq_process->Qm, harq_process->d[r], harq_process->w[r]); +#ifdef DEBUG_DLSCH_DECODING + for (int i =0; i<16; i++) + printf("rx output interleaving d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset); +#endif + #if UE_TIMING_TRACE stop_meas(dlsch_deinterleaving_stats); #endif @@ -1072,6 +1090,10 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment start_meas(dlsch_turbo_decoding_stats); #endif LOG_D(PHY,"mthread AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); + + for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ + inv_d[cnt] = (1)*harq_process->d[r][cnt]; + } memset(pv,0,2*p_decParams->Z*sizeof(int16_t)); //memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); @@ -1109,6 +1131,16 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment else { ret=2; } + + if (check_crc(llrProcBuf,harq_process->B,harq_process->F,crc_type)) { + printf("CRC OK\n"); + ret = 2; + } + else { + printf("CRC NOK\n"); + ret = 1+dlsch->max_ldpc_iterations; + } + //if (!nb_total_decod%10000){ printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout); //} @@ -1139,7 +1171,10 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment //printf("output channel decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); - +#ifdef DEBUG_DLSCH_DECODING + for (int k=0;k<32;k++) + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); +#endif #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); @@ -1151,7 +1186,7 @@ if (harq_process->C>1) { // wakeup worker if more than 1 segment LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); err_flag = 1; } - } + //} //loop r int32_t frame_rx_prev = frame; int32_t tti_rx_prev = nr_tti_rx - 1; @@ -1282,7 +1317,8 @@ void *nr_dlsch_decoding_2thread0(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + t_nrLDPC_procBuf* p_nrLDPC_procBuf; int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1375,6 +1411,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[harq_pid]; short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[1]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -1420,7 +1457,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) kb = harq_process->K/harq_process->Z; if ( kb==22){ p_decParams->BG = 1; - p_decParams->R = 89; + p_decParams->R = 13; kc = 68; } else{ @@ -1533,7 +1570,7 @@ void *nr_dlsch_decoding_2thread0(void *arg) stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; //for (int i =0; i<16; i++) // printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); @@ -1644,6 +1681,10 @@ void *nr_dlsch_decoding_2thread0(void *arg) } printf(" \n");*/ +#ifdef DEBUG_DLSCH_DECODING + for (int k=0;k<2;k++) + printf("segment 1 output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); +#endif #if UE_TIMING_TRACE stop_meas(dlsch_turbo_decoding_stats); @@ -1789,7 +1830,8 @@ void *nr_dlsch_decoding_2thread1(void *arg) t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats* p_procTime =&procTime ; - t_nrLDPC_procBuf* p_nrLDPC_procBuf = dlsch->p_nrLDPC_procBuf; + t_nrLDPC_procBuf* p_nrLDPC_procBuf; + int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); int16_t z [68*384]; int8_t l [68*384]; //__m128i l; @@ -1883,6 +1925,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) short *dlsch_llr = phy_vars_ue->pdsch_vars[phy_vars_ue->current_thread_id[subframe]][eNB_id]->llr[0]; //printf("2thread0 llr flag %d tdp flag %d\n",llr8_flag1, tdp->llr8_flag); //printf("2thread1 nr_tti_tx %d subframe %d SF thread id %d r_offset %d\n", proc->nr_tti_rx, subframe, phy_vars_ue->current_thread_id[subframe], r_offset); + p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf[2]; /* if (nb_rb > frame_parms->N_RB_DL) { @@ -2044,7 +2087,7 @@ void *nr_dlsch_decoding_2thread1(void *arg) stop_meas(dlsch_rate_unmatching_stats); #endif } - r_offset += E; + //r_offset += E; /* printf("Subblock deinterleaving, d %p w %p\n", diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index c8ef70b242..b41b23dd32 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -267,6 +267,8 @@ typedef struct { double w_abs[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) int16_t *d[MAX_NUM_NR_DLSCH_SEGMENTS]; + /// LDPC processing buffers + t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_DLSCH_SEGMENTS]; /// Number of code segments uint32_t C; /// Number of bits in code segments @@ -352,8 +354,6 @@ typedef struct { uint32_t Nsoft; /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; - /// LDPC processing buffers - t_nrLDPC_procBuf* p_nrLDPC_procBuf; /// number of iterations used in last turbo decoding uint8_t last_iteration_cnt; } NR_UE_DLSCH_t; From 8f0fd7387b1acf2e9e3b596d4a007db2ba7c9a31 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 14 Jan 2019 16:18:31 +0100 Subject: [PATCH 7/9] CI: adapt parameters for better FDD performances --- ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf | 6 +++--- ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf | 8 ++++---- ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf index f3cb31f449..2c2ca635a6 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.100PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf index e33daa7a8a..4dd8c1ee22 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.25PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -218,7 +218,7 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 115; + max_rxgain = 125; eNB_instances = [0]; } @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf index 32e8bb9931..cae47b152c 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.50PRB.usrpb210.conf @@ -197,8 +197,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -218,7 +218,7 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 115; + max_rxgain = 120; eNB_instances = [0]; } @@ -227,7 +227,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } From 28e4486c07a516309686bdefdaf3dc92404e6c99 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Tue, 15 Jan 2019 12:12:21 +0100 Subject: [PATCH 8/9] CI: updating the IF4p5 conf files w/ same values as in monolithic also disabling LLL realtime issues as an error until PRACH allocation is fixed Signed-off-by: Raphael Defosseux --- .../conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf | 6 +++--- .../conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf | 6 +++--- .../conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf | 6 +++--- ci-scripts/main.py | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf index fc2f24b8a1..6c80a4f7cf 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.100PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf index 010ef28061..f4be50810c 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf index ddf01096cd..48c8370b4b 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.50PRB.usrpb210.conf @@ -200,8 +200,8 @@ MACRLCs = ( tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; phy_test_mode = 0; - puSch10xSnr = 200; - puCch10xSnr = 200; + puSch10xSnr = 160; + puCch10xSnr = 160; } ); @@ -234,7 +234,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 24475f7eb3..5c371a99ee 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -1504,7 +1504,8 @@ class SSHConnection(): return ENB_PROCESS_ASSERTION if foundRealTimeIssue: logging.debug('\u001B[1;37;41m eNB faced real time issues! \u001B[0m') - return ENB_PROCESS_REALTIME_ISSUE + self.htmleNBFailureMsg += 'eNB faced real time issues!\n' + #return ENB_PROCESS_REALTIME_ISSUE return 0 def TerminateeNB(self): From 4e74773d3c604cf15ceab4edaf2c0343ca10597c Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Tue, 15 Jan 2019 16:36:31 +0100 Subject: [PATCH 9/9] CI: modified also RRU config Signed-off-by: Raphael Defosseux --- ci-scripts/conf_files/rru.fdd.band7.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/conf_files/rru.fdd.band7.conf b/ci-scripts/conf_files/rru.fdd.band7.conf index ff5e13908e..dab69e1f1e 100644 --- a/ci-scripts/conf_files/rru.fdd.band7.conf +++ b/ci-scripts/conf_files/rru.fdd.band7.conf @@ -20,7 +20,7 @@ RUs = ( THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; }