Commit 76f399cd authored by Robert Schmidt's avatar Robert Schmidt

Threading/memory improvements at nr-softmodem end

- First stop threads then free memory
- Don't call kill_NR_RU_proc() twice (is called in stop_RU())
- Memory allocation optimizations
parent 604d52a4
......@@ -833,16 +833,14 @@ int main( int argc, char **argv ) {
/* release memory used by the RU/gNB threads (incomplete), after all
* threads have been stopped (they partially use the same memory) */
for (int inst = 0; inst < NB_gNB_INST; inst++) {
//free_transport(RC.gNB[inst]);
phy_free_nr_gNB(RC.gNB[inst]);
}
for (int inst = 0; inst < NB_RU; inst++) {
kill_NR_RU_proc(inst);
nr_phy_free_RU(RC.ru[inst]);
}
for (int inst = 0; inst < NB_gNB_INST; inst++) {
phy_free_nr_gNB(RC.gNB[inst]);
}
pthread_cond_destroy(&sync_cond);
pthread_mutex_destroy(&sync_mutex);
pthread_cond_destroy(&nfapi_sync_cond);
......
......@@ -625,7 +625,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
gNB->first_run_I0_measurements = 1;
common_vars->rxdata = (int32_t **)malloc16(Prx*sizeof(int32_t*));
common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*));
common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*));
common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*));
......@@ -640,7 +639,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
}
for (i=0;i<Prx;i++){
common_vars->rxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t));
common_vars->rxdata[i] = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t));
}
common_vars->debugBuff = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)*100);
common_vars->debugBuff_sample_offset = 0;
......@@ -786,11 +784,9 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
for (int i = 0; i < Prx; ++i) {
free_and_zero(common_vars->rxdataF[i]);
free_and_zero(common_vars->rxdata[i]);
}
free_and_zero(common_vars->txdataF);
free_and_zero(common_vars->rxdata);
free_and_zero(common_vars->rxdataF);
free_and_zero(common_vars->beam_id);
......
......@@ -176,8 +176,11 @@ void nr_phy_free_RU(RU_t *ru)
LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx);
if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals
for (i = 0; i < ru->nb_tx; i++)
free_and_zero(ru->common.txdata[i]);
// Hack: undo what is done at allocation
for (i = 0; i < ru->nb_tx; i++) {
int32_t *p = &ru->common.txdata[i][-ru->sf_extension];
free_and_zero(p);
}
free_and_zero(ru->common.txdata);
for (i = 0; i < ru->nb_rx; i++)
......@@ -198,8 +201,10 @@ void nr_phy_free_RU(RU_t *ru)
free_and_zero(ru->common.txdataF_BF);
// free FFT output buffers (RX)
for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]);
free_and_zero(ru->common.rxdataF);
// HACK: cannot free here, or the gNB code in phy_free_nr_gNB() will
// segfault. The rxdataF memory between RU and gNB is not properly handled!
//for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdataF[i]);
//free_and_zero(ru->common.rxdataF);
for (j=0;j<NUMBER_OF_NR_RU_PRACH_OCCASIONS_MAX;j++) {
for (i = 0; i < ru->nb_rx; 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