Commit 136cc93a authored by Robert Schmidt's avatar Robert Schmidt

Fix memory leaks in nr_dlschsim

parent ac0af5a8
...@@ -553,6 +553,16 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) { ...@@ -553,6 +553,16 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) {
} }
} }
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg)
{
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
const nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
const uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
for (int i=0; i<gNB->number_of_nr_dlsch_max; i++)
for (int j=0; j<2; j++)
free_gNB_dlsch(&msg->dlsch[i][j], grid_size);
}
void init_nr_transport(PHY_VARS_gNB *gNB) { void init_nr_transport(PHY_VARS_gNB *gNB) {
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
LOG_I(PHY, "Initialise nr transport\n"); LOG_I(PHY, "Initialise nr transport\n");
......
...@@ -410,6 +410,7 @@ void init_dfts(void); ...@@ -410,6 +410,7 @@ void init_dfts(void);
void fill_subframe_mask(PHY_VARS_eNB *eNB); void fill_subframe_mask(PHY_VARS_eNB *eNB);
void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg); void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
/** @} */ /** @} */
#endif #endif
......
...@@ -55,42 +55,39 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) { ...@@ -55,42 +55,39 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) {
NR_gNB_DLSCH_t *dlsch = *dlschptr; NR_gNB_DLSCH_t *dlsch = *dlschptr;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
if (dlsch) {
if (N_RB != 273) { if (N_RB != 273) {
a_segments = a_segments*N_RB; a_segments = a_segments*N_RB;
a_segments = a_segments/273 +1; a_segments = a_segments/273 +1;
} }
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY,"Freeing dlsch %p\n",dlsch);
#endif
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
if (harq->b) { if (harq->b) {
free16(harq->b, a_segments * 1056); free16(harq->b, a_segments * 1056);
harq->b = NULL; harq->b = NULL;
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY, "Freeing harq->b (%p)\n", harq->b);
#endif
} }
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY, "Freeing dlsch process %d c (%p)\n", i, harq->c);
#endif
for (r = 0; r < a_segments; r++) { for (r = 0; r < a_segments; r++) {
#ifdef DEBUG_DLSCH_FREE free(harq->c[r]);
LOG_D(PHY, "Freeing dlsch process %d c[%d] (%p)\n", i, r, harq->c[r]);
#endif
if (harq->c[r]) {
free16(harq->c[r], 1056);
harq->c[r] = NULL; harq->c[r] = NULL;
} }
free(harq->pdu);
for (int aa = 0; aa < 64; aa++)
free(dlsch->calib_dl_ch_estimates[aa]);
free(dlsch->calib_dl_ch_estimates);
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
free(dlsch->mod_symbs[q]);
for (int layer = 0; layer < NR_MAX_NB_LAYERS; layer++) {
free(dlsch->txdataF_precoding[layer]);
free(dlsch->txdataF[layer]);
for (int aa = 0; aa < 64; aa++)
free(dlsch->ue_spec_bf_weights[layer][aa]);
free(dlsch->ue_spec_bf_weights[layer]);
} }
free16(dlsch, sizeof(NR_gNB_DLSCH_t));
free(dlsch);
*dlschptr = NULL; *dlschptr = NULL;
}
} }
NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
......
...@@ -106,6 +106,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, ...@@ -106,6 +106,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
uint8_t abstraction_flag, uint8_t abstraction_flag,
uint16_t N_RB); uint16_t N_RB);
void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB);
/** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs /** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs
- RB extraction (signal and channel estimates) - RB extraction (signal and channel estimates)
- channel compensation (matched filtering) - channel compensation (matched filtering)
......
...@@ -473,16 +473,13 @@ int main(int argc, char **argv) ...@@ -473,16 +473,13 @@ int main(int argc, char **argv)
rel15->dlDmrsSymbPos = 4; rel15->dlDmrsSymbPos = 4;
rel15->mcsIndex[0] = Imcs; rel15->mcsIndex[0] = Imcs;
rel15->numDmrsCdmGrpsNoData = 1; rel15->numDmrsCdmGrpsNoData = 1;
double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc
short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short channel_output_fixed[16 * 68 * 384];
short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384);
//unsigned char *estimated_output; //unsigned char *estimated_output;
unsigned char *estimated_output_bit;
unsigned char *test_input_bit;
unsigned int errors_bit = 0; unsigned int errors_bit = 0;
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); unsigned char test_input_bit[16 * 68 * 384];
//estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); //estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); unsigned char estimated_output_bit[16 * 68 * 384];
NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0];
NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid];
harq_process->mcs = Imcs; harq_process->mcs = Imcs;
...@@ -496,9 +493,10 @@ int main(int argc, char **argv) ...@@ -496,9 +493,10 @@ int main(int argc, char **argv)
harq_process->dlDmrsSymbPos = 4; harq_process->dlDmrsSymbPos = 4;
harq_process->n_dmrs_cdm_groups = 1; harq_process->n_dmrs_cdm_groups = 1;
printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch);
unsigned char *test_input; unsigned char *test_input;
test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
//unsigned char test_input[TBS / 8] __attribute__ ((aligned(16)));
for (i = 0; i < TBS / 8; i++) for (i = 0; i < TBS / 8; i++)
test_input[i] = (unsigned char) rand(); test_input[i] = (unsigned char) rand();
...@@ -555,12 +553,6 @@ int main(int argc, char **argv) ...@@ -555,12 +553,6 @@ int main(int argc, char **argv)
i,modulated_input[i], i,modulated_input[i],
i,channel_output_fixed[i]); i,channel_output_fixed[i]);
*/ */
//Uncoded BER
if (channel_output_fixed[i] < 0)
channel_output_uncoded[i] = 1; //QPSK demod
else
channel_output_uncoded[i] = 0;
} }
#ifdef DEBUG_CODER #ifdef DEBUG_CODER
...@@ -642,12 +634,11 @@ int main(int argc, char **argv) ...@@ -642,12 +634,11 @@ int main(int argc, char **argv)
} }
}*/ }*/
for (i = 0; i < 2; i++) { free(test_input);
printf("gNB %d\n", i);
free_gNB_dlsch(&(msgDataTx.dlsch[0][i]),N_RB_DL); free_channel_desc_scm(gNB2UE);
printf("UE %d\n", i);
free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL); reset_DLSCH_struct(gNB, &msgDataTx);
}
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
free(s_re[i]); free(s_re[i]);
......
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