Commit c04699c4 authored by Sakthivel Velumani's avatar Sakthivel Velumani

dlsim encoding speed improved

parent 3ec56603
...@@ -2981,6 +2981,7 @@ target_link_libraries(nr_pucchsim ...@@ -2981,6 +2981,7 @@ target_link_libraries(nr_pucchsim
add_executable(nr_dlsim add_executable(nr_dlsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/system.c
${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c
......
...@@ -531,7 +531,6 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { ...@@ -531,7 +531,6 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
for (j=0; j<2; j++) { for (j=0; j<2; j++) {
gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size);
gNB->dlsch[i][j]->threadPool = gNB->threadPool;
AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i); AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i);
} }
} }
......
...@@ -109,7 +109,8 @@ void nr_pdsch_codeword_scrambling_optim(uint8_t *in, ...@@ -109,7 +109,8 @@ void nr_pdsch_codeword_scrambling_optim(uint8_t *in,
} }
uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
NR_gNB_DLSCH_t *dlsch,
uint32_t ***pdsch_dmrs, uint32_t ***pdsch_dmrs,
int32_t** txdataF, int32_t** txdataF,
int16_t amp, int16_t amp,
...@@ -155,14 +156,14 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, ...@@ -155,14 +156,14 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
/// CRC, coding, interleaving and rate matching /// CRC, coding, interleaving and rate matching
AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n"); AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
start_meas(dlsch_encoding_stats); start_meas(dlsch_encoding_stats);
nr_dlsch_encoding(harq->pdu, frame, slot, dlsch, frame_parms,tinput,tprep,tparity,toutput, nr_dlsch_encoding(gNB, harq->pdu, frame, slot, dlsch, frame_parms,tinput,tprep,tparity,toutput,
dlsch_rate_matching_stats, dlsch_rate_matching_stats,
dlsch_interleaving_stats, dlsch_interleaving_stats,
dlsch_segmentation_stats); dlsch_segmentation_stats);
stop_meas(dlsch_encoding_stats); stop_meas(dlsch_encoding_stats);
while (dlsch->nbEncode > 0) { while (gNB->nbEncode > 0) {
notifiedFIFO_elt_t *req=pullTpool(&dlsch->respEncode, dlsch->threadPool); notifiedFIFO_elt_t *req=pullTpool(gNB->respEncode, gNB->threadPool);
dlsch->nbEncode--; gNB->nbEncode--;
delNotifiedFIFO_elt(req); delNotifiedFIFO_elt(req);
} }
#ifdef DEBUG_DLSCH #ifdef DEBUG_DLSCH
......
...@@ -69,7 +69,8 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB, ...@@ -69,7 +69,8 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB,
nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
unsigned char *sdu); unsigned char *sdu);
uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB,
NR_gNB_DLSCH_t *dlsch,
uint32_t ***pdsch_dmrs, uint32_t ***pdsch_dmrs,
int32_t** txdataF, int32_t** txdataF,
int16_t amp, int16_t amp,
...@@ -98,7 +99,7 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); ...@@ -98,7 +99,7 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch);
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
int nr_dlsch_encoding(unsigned char *a,int frame, int nr_dlsch_encoding(PHY_VARS_gNB *gNB, unsigned char *a,int frame,
uint8_t slot, uint8_t slot,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
NR_DL_FRAME_PARMS* frame_parms, NR_DL_FRAME_PARMS* frame_parms,
......
...@@ -330,7 +330,6 @@ int nr_processDLSegment(void* args) { ...@@ -330,7 +330,6 @@ int nr_processDLSegment(void* args) {
int j = impp.macro_num; int j = impp.macro_num;
int E; int E;
int r; int r;
int Nl = 4;
nrLDPC_encoder(dlsch_harq->c,dlsch_harq->d,Z,Kb,Kr,BG,&impp); nrLDPC_encoder(dlsch_harq->c,dlsch_harq->d,Z,Kb,Kr,BG,&impp);
...@@ -360,10 +359,6 @@ int nr_processDLSegment(void* args) { ...@@ -360,10 +359,6 @@ int nr_processDLSegment(void* args) {
Kr-F-2*(Z), Kr-F-2*(Z),
mod_order); mod_order);
// for tbslbrm calculation according to 5.4.2.1 of 38.212
if (nrOfLayers < Nl)
Nl = nrOfLayers;
nr_rate_matching_ldpc(Ilbrm, nr_rate_matching_ldpc(Ilbrm,
Tbslbrm, Tbslbrm,
BG, BG,
...@@ -393,14 +388,15 @@ int nr_processDLSegment(void* args) { ...@@ -393,14 +388,15 @@ int nr_processDLSegment(void* args) {
write_output("enc_output.m","enc",dlsch_harq->f,G,1,4); write_output("enc_output.m","enc",dlsch_harq->f,G,1,4);
#endif #endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
r_offset += E; r_offset += E;
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
} }
int nr_dlsch_encoding(unsigned char *a, int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
unsigned char *a,
int frame, int frame,
uint8_t slot, uint8_t slot,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
...@@ -516,15 +512,20 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -516,15 +512,20 @@ int nr_dlsch_encoding(unsigned char *a,
F = dlsch->harq_processes[harq_pid]->F; F = dlsch->harq_processes[harq_pid]->F;
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
if (rel15->nrOfLayers < Nl)
Nl = rel15->nrOfLayers;
Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
uint16_t Kr_bytes; uint16_t Kr_bytes;
Kr_bytes = Kr>>3; Kr_bytes = Kr>>3;
#endif #endif
dlsch->nbEncode = 0; gNB->nbEncode = 0;
//printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,dlsch->harq_processes[harq_pid]->K,Kr,BG,dlsch->harq_processes[harq_pid]->C); //printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,dlsch->harq_processes[harq_pid]->K,Kr,BG,dlsch->harq_processes[harq_pid]->C);
for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) { for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) {
notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), 0, &dlsch->respEncode, nr_processDLSegment); notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcEncode_t), 0, gNB->respEncode, nr_processDLSegment);
ldpcEncode_t *rdata = (ldpcEncode_t *) NotifiedFifoData(req); ldpcEncode_t *rdata = (ldpcEncode_t *) NotifiedFifoData(req);
rdata->impp.n_segments=dlsch->harq_processes[harq_pid]->C; rdata->impp.n_segments=dlsch->harq_processes[harq_pid]->C;
...@@ -544,17 +545,16 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -544,17 +545,16 @@ int nr_dlsch_encoding(unsigned char *a,
rdata->mod_order = mod_order; rdata->mod_order = mod_order;
rdata->nrOfLayers = rel15->nrOfLayers; rdata->nrOfLayers = rel15->nrOfLayers;
rdata->Kb = Kb; rdata->Kb = Kb;
rdata->G = G;
for (int cj=0; cj<j*8; cj++) { for (int cj=0; cj<j*8; cj++) {
r_offset += nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nrOfLayers, r); r_offset += nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nrOfLayers, r);
} }
rdata->r_offset = r_offset; rdata->r_offset = r_offset;
pushTpool(dlsch->threadPool,req); pushTpool(gNB->threadPool,req);
dlsch->nbEncode++; gNB->nbEncode++;
LOG_D(PHY,"Added a block to encode, in pipe: %d\n",dlsch->nbEncode); LOG_D(PHY,"Added a block to encode, in pipe: %d\n",gNB->nbEncode);
} }
return;
} else { } else {
F = dlsch->harq_processes[harq_pid]->F; F = dlsch->harq_processes[harq_pid]->F;
...@@ -625,6 +625,7 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -625,6 +625,7 @@ int nr_dlsch_encoding(unsigned char *a,
r_offset += E; r_offset += E;
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
} }
return 0; return 0;
......
...@@ -167,12 +167,6 @@ typedef struct { ...@@ -167,12 +167,6 @@ typedef struct {
int16_t sqrt_rho_a; int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots /// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b; int16_t sqrt_rho_b;
/// for maintaining multi threads for encoding
tpool_t *threadPool;
/// number of encoding threads
int nbEncode;
/// fifo to store the thread result
notifiedFIFO_t respEncode;
} NR_gNB_DLSCH_t; } NR_gNB_DLSCH_t;
typedef struct { typedef struct {
...@@ -810,8 +804,10 @@ typedef struct PHY_VARS_gNB_s { ...@@ -810,8 +804,10 @@ typedef struct PHY_VARS_gNB_s {
time_stats_t ulsch_freq_offset_estimation_stats; time_stats_t ulsch_freq_offset_estimation_stats;
*/ */
notifiedFIFO_t *respDecode; notifiedFIFO_t *respDecode;
notifiedFIFO_t *respEncode;
tpool_t *threadPool; tpool_t *threadPool;
int nbDecode; int nbDecode;
int nbEncode;
} PHY_VARS_gNB; } PHY_VARS_gNB;
......
...@@ -194,7 +194,8 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, ...@@ -194,7 +194,8 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
for (int i=0; i<gNB->num_pdsch_rnti[slot]; i++) { for (int i=0; i<gNB->num_pdsch_rnti[slot]; i++) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1);
LOG_D(PHY, "PDSCH generation started (%d) in frame %d.%d\n", gNB->num_pdsch_rnti[slot],frame,slot); LOG_D(PHY, "PDSCH generation started (%d) in frame %d.%d\n", gNB->num_pdsch_rnti[slot],frame,slot);
nr_generate_pdsch(gNB->dlsch[i][0], nr_generate_pdsch(gNB,
gNB->dlsch[i][0],
gNB->nr_gold_pdsch_dmrs[slot], gNB->nr_gold_pdsch_dmrs[slot],
gNB->common_vars.txdataF, gNB->common_vars.txdataF,
AMP, frame, slot, fp, 0, AMP, frame, slot, fp, 0,
......
...@@ -502,7 +502,7 @@ int main(int argc, char **argv) ...@@ -502,7 +502,7 @@ int main(int argc, char **argv)
//printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); //printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32));
// generate signal // generate signal
if (input_fd == NULL) { if (input_fd == NULL) {
nr_dlsch_encoding(test_input, frame, slot, dlsch, frame_parms,NULL,NULL,NULL,NULL,NULL,NULL,NULL); nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
} }
for (SNR = snr0; SNR < snr1; SNR += snr_step) { for (SNR = snr0; SNR < snr1; SNR += snr_step) {
......
...@@ -467,6 +467,11 @@ int main(int argc, char **argv) ...@@ -467,6 +467,11 @@ int main(int argc, char **argv)
gNB_RRC_INST rrc; gNB_RRC_INST rrc;
memset((void*)&rrc,0,sizeof(rrc)); memset((void*)&rrc,0,sizeof(rrc));
gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
gNB->respEncode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
char tp_param[] = "-1,-1,-1";
initTpool(tp_param, gNB->threadPool, true);
initNotifiedFIFO(gNB->respEncode);
/* /*
// read in SCGroupConfig // read in SCGroupConfig
AssertFatal(scg_fd != NULL,"no reconfig.raw file\n"); AssertFatal(scg_fd != NULL,"no reconfig.raw file\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment