Commit 0f89e9f8 authored by Robert Schmidt's avatar Robert Schmidt

free memory when stopping/restarting lte-softmodem

- add function free_td() -> complements init_td() [seems to not be used, added
  for completeness]
- add function free_td8() -> undoes init_td8() [free memory of 8-bit LLR Turbo
  decoder]
- add function free_td16() -> undoes init_td16() [free memory of 16-bit LLR
  Turbo decoder]
- change function free_tdavx216() -> undoes init_tdavx216() [free memory of
  16-bit LLR Turbo decoder, AVX2 version]
- add free_lte_top() -> frees memory allocated by init_lte_top()
- change free_ul_ref_sigs() to set freed pointers to NULL
- add method free_transport() -> frees memory of ULSCH/DLSCH transport channels
- use the above functions when stopping/restarting the lte-softmodem
parent 745e0247
......@@ -830,10 +830,10 @@ void free_td16avx2(void)
int ind;
for (ind=0; ind<188; ind++) {
free(pi2tab16avx2[ind]);
free(pi5tab16avx2[ind]);
free(pi4tab16avx2[ind]);
free(pi6tab16avx2[ind]);
free_and_zero(pi2tab16avx2[ind]);
free_and_zero(pi5tab16avx2[ind]);
free_and_zero(pi4tab16avx2[ind]);
free_and_zero(pi6tab16avx2[ind]);
}
}
......
......@@ -1907,6 +1907,18 @@ void compute_ext(llr_t* alpha,llr_t* beta,llr_t* m_11,llr_t* m_10,llr_t* ext, ll
//int pi2[n],pi3[n+8],pi5[n+8],pi4[n+8],pi6[n+8],
int *pi2tab[188],*pi5tab[188],*pi4tab[188],*pi6tab[188];
void free_td()
{
int ind;
for (ind = 0; ind < 188; ind++) {
free_and_zero(pi2tab[ind]);
free_and_zero(pi5tab[ind]);
free_and_zero(pi4tab[ind]);
free_and_zero(pi6tab[ind]);
}
}
void init_td()
{
......
......@@ -1117,10 +1117,10 @@ void free_td16(void)
int ind;
for (ind=0; ind<188; ind++) {
free(pi2tab16[ind]);
free(pi5tab16[ind]);
free(pi4tab16[ind]);
free(pi6tab16[ind]);
free_and_zero(pi2tab16[ind]);
free_and_zero(pi5tab16[ind]);
free_and_zero(pi4tab16[ind]);
free_and_zero(pi6tab16[ind]);
}
}
......
......@@ -838,10 +838,10 @@ void free_td8(void)
int ind;
for (ind=0; ind<188; ind++) {
free(pi2tab8[ind]);
free(pi5tab8[ind]);
free(pi4tab8[ind]);
free(pi6tab8[ind]);
free_and_zero(pi2tab8[ind]);
free_and_zero(pi5tab8[ind]);
free_and_zero(pi4tab8[ind]);
free_and_zero(pi6tab8[ind]);
}
}
......
......@@ -356,10 +356,17 @@ void ccodedab_init_inv(void);
\brief This function initializes the different crc tables.*/
void crcTableInit (void);
/*!\fn void free_td8(void)
\brief This function frees the tables for 8-bit LLR Turbo decoder.*/
void free_td8(void);
/*!\fn void init_td8(void)
\brief This function initializes the tables for 8-bit LLR Turbo decoder.*/
void init_td8 (void);
/*!\fn void free_td16(void)
\brief This function frees the tables for 16-bit LLR Turbo decoder.*/
void free_td16(void);
/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder.*/
......@@ -370,6 +377,9 @@ void init_td16 (void);
\brief This function initializes the tables for 8-bit LLR Turbo decoder (AVX2).*/
void init_td8avx2 (void);
/*!\fn void free_td16avx2(void)
\brief This function frees the tables for 16-bit LLR Turbo decoder (AVX2).*/
void free_td16avx2(void);
/*!\fn void init_td16(void)
\brief This function initializes the tables for 16-bit LLR Turbo decoder (AVX2).*/
......
......@@ -324,6 +324,7 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *phy_vars_eNB);
*/
int phy_init_secsys_eNB(PHY_VARS_eNB *phy_vars_eNb);
void free_lte_top(void);
void init_lte_top(LTE_DL_FRAME_PARMS *lte_frame_parms);
......
......@@ -1247,6 +1247,18 @@ void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uin
}
}
void free_lte_top(void)
{
free_td8();
free_td16();
#ifdef __AVX2__
free_td16avx2();
#endif
lte_sync_time_free();
/* free_ul_ref_sigs() is called in phy_free_lte_eNB() */
}
void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms)
{
......
......@@ -188,11 +188,15 @@ void free_ul_ref_sigs(void)
for (Msc_RS=2; Msc_RS<33; Msc_RS++) {
for (u=0; u<30; u++) {
for (v=0; v<2; v++) {
if (ul_ref_sigs[u][v][Msc_RS])
if (ul_ref_sigs[u][v][Msc_RS]) {
free16(ul_ref_sigs[u][v][Msc_RS],2*sizeof(int16_t)*dftsizes[Msc_RS]);
ul_ref_sigs_rx[u][v][Msc_RS] = NULL;
}
if (ul_ref_sigs_rx[u][v][Msc_RS])
if (ul_ref_sigs_rx[u][v][Msc_RS]) {
free16(ul_ref_sigs_rx[u][v][Msc_RS],4*sizeof(int16_t)*dftsizes[Msc_RS]);
ul_ref_sigs_rx[u][v][Msc_RS] = NULL;
}
}
}
}
......
......@@ -83,6 +83,12 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch);
void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch);
/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch)
\brief This function frees memory allocated for a particular ULSCH at eNB
@param ulsch Pointer to ULSCH to be removed
*/
void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch);
LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag);
......
......@@ -794,6 +794,21 @@ void print_opp_meas(void) {
}
}
void free_transport(PHY_VARS_eNB *eNB)
{
int i;
int j;
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
LOG_I(PHY, "Freeing Transport Channel Buffers for DLSCH, UE %d\n",i);
for (j=0; j<2; j++) free_eNB_dlsch(eNB->dlsch[i][j]);
LOG_I(PHY, "Freeing Transport Channel Buffer for ULSCH, UE %d\n",i);
free_eNB_ulsch(eNB->ulsch[1+i]);
}
free_eNB_ulsch(eNB->ulsch[0]);
}
void init_transport(PHY_VARS_eNB *eNB) {
int i;
......@@ -975,6 +990,9 @@ void stop_eNB(int nb_inst) {
LOG_I(PHY,"Killing eNB %d processing threads\n",inst);
kill_eNB_proc(inst);
/* release memory used by these threads (incomplete) */
for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) phy_free_lte_eNB(RC.eNB[inst][cc_id]);
for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) {
free_transport(RC.eNB[inst][cc_id]);
phy_free_lte_eNB(RC.eNB[inst][cc_id]);
}
}
}
......@@ -1557,8 +1557,6 @@ void *ru_thread_synch(void *arg) {
if (release_thread(&ru->proc.mutex_synch,&ru->proc.instance_cnt_synch,"ru_synch_thread") < 0) break;
} // oai_exit
lte_sync_time_free();
ru_thread_synch_status = 0;
return &ru_thread_synch_status;
......
......@@ -884,6 +884,7 @@ void terminate_task(task_id_t task_id, module_id_t mod_id)
itti_send_msg_to_task (task_id, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg);
}
extern void free_transport(PHY_VARS_eNB *);
extern void phy_free_RU(RU_t*);
int stop_L1L2(module_id_t enb_id)
......@@ -923,8 +924,12 @@ int stop_L1L2(module_id_t enb_id)
LOG_I(ENB_APP, "calling kill_RU_proc() for instance %d\n", enb_id);
kill_RU_proc(enb_id);
oai_exit = 0;
for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) phy_free_lte_eNB(RC.eNB[enb_id][cc_id]);
for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) {
free_transport(RC.eNB[enb_id][cc_id]);
phy_free_lte_eNB(RC.eNB[enb_id][cc_id]);
}
phy_free_RU(RC.ru[enb_id]);
free_lte_top();
return 0;
}
......@@ -1491,6 +1496,7 @@ int main( int argc, char **argv )
} else {
stop_eNB(NB_eNB_INST);
stop_RU(NB_RU);
free_lte_top();
}
......
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