Commit 94502c9c authored by Rupanjali's avatar Rupanjali

NR UE PDSCH: Pre-allocate LLR buffers in scratch to eliminate per-slot malloc/free

Add llr[2] and llr_buf_max to pdsch_scratch_t, allocated once at init at
worst-case size (12 * 14 * N_RB_DL * 8 * 4). Remove the per-slot
malloc16_clear + free from nr_ue_pdsch_procedures. The zero-init is also
dropped as nr_dlsch_layer_demapping unconditionally overwrites all G
positions before any function reads the buffer.
Signed-off-by: default avatarRupanjali <rupanjali.srivastava@openairinterface.org>
parent dc593dee
......@@ -368,6 +368,8 @@ void free_nr_ue_pdsch_buffers(pdsch_scratch_t *buffers, int num_actors)
free_and_zero(buffers[i].dl_ch_magr);
free_and_zero(buffers[i].rho_dl);
free_and_zero(buffers[i].pdsch_dl_ch_estimates);
for (int c = 0; c < 2; c++)
free_and_zero(buffers[i].llr[c]);
}
}
......@@ -452,18 +454,22 @@ void nr_init_pdsch_buffers(pdsch_scratch_t *buffers, int num_actors, const NR_DL
{
const uint32_t pdsch_buf_size_max = (fp->N_RB_DL * NR_NB_SC_PER_RB + 15) & ~15;
const uint32_t pdsch_est_size = fp->symbols_per_slot * fp->ofdm_symbol_size;
const uint32_t llr_buf_max = NR_NB_SC_PER_RB * NR_SYMBOLS_PER_SLOT * fp->N_RB_DL * 8 * NR_MAX_NB_LAYERS;
const size_t comp_elems = (size_t)NR_SYMBOLS_PER_SLOT * NR_MAX_NB_LAYERS * pdsch_buf_size_max;
const size_t rho_elems = (size_t)NR_SYMBOLS_PER_SLOT * NR_MAX_NB_LAYERS * NR_MAX_NB_LAYERS * pdsch_buf_size_max;
const size_t ch_est_elems = (size_t)fp->nb_antennas_rx * NR_MAX_NB_LAYERS * pdsch_est_size;
for (int i = 0; i < num_actors; i++) {
buffers[i].pdsch_buf_size_max = pdsch_buf_size_max;
buffers[i].pdsch_est_size = pdsch_est_size;
buffers[i].llr_buf_max = llr_buf_max;
buffers[i].rxdataF_comp = malloc16_clear(comp_elems * sizeof(c16_t));
buffers[i].dl_ch_mag = malloc16_clear(comp_elems * sizeof(c16_t));
buffers[i].dl_ch_magb = malloc16_clear(comp_elems * sizeof(c16_t));
buffers[i].dl_ch_magr = malloc16_clear(comp_elems * sizeof(c16_t));
buffers[i].rho_dl = malloc16_clear(rho_elems * sizeof(c16_t));
buffers[i].pdsch_dl_ch_estimates = malloc16_clear(ch_est_elems * sizeof(int32_t));
for (int c = 0; c < 2; c++)
buffers[i].llr[c] = malloc16(llr_buf_max * sizeof(int16_t));
}
}
......
......@@ -451,8 +451,10 @@ typedef struct PHY_VARS_NR_UE_s {
c16_t *dl_ch_magr; // [NR_SYMBOLS_PER_SLOT][NR_MAX_NB_LAYERS][pdsch_buf_size_max]
c16_t *rho_dl; // [NR_SYMBOLS_PER_SLOT][NR_MAX_NB_LAYERS*NR_MAX_NB_LAYERS][pdsch_buf_size_max]
int32_t *pdsch_dl_ch_estimates; // [nb_antennas_rx*NR_MAX_NB_LAYERS][pdsch_est_size]
int16_t *llr[2]; // [2 codewords][llr_buf_max]
uint32_t pdsch_buf_size_max;
uint32_t pdsch_est_size;
uint32_t llr_buf_max;
} *pdsch_scratch;
int pdsch_num_actors;
} PHY_VARS_NR_UE;
......
......@@ -1199,7 +1199,8 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_
}
}
int16_t *llr[2];
const int actor_idx_llr = proc->nr_slot_rx % ue->pdsch_num_actors;
int16_t **llr = ue->pdsch_scratch[actor_idx_llr].llr;
fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config = &phy_data->dlsch_config;
for (int c = 0; c < phy_data->n_dlsch_codewords; c++) {
NR_UE_DLSCH_t *dlsch = &phy_data->dlsch[c];
......@@ -1248,7 +1249,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_
dlsch->cw_info.qamModOrder,
dlsch->cw_info.Nl);
const uint32_t rx_llr_buf_sz = ALIGNARRAYSIZE(G, 32); // each LLR is 2 bytes hence 64 byte aligned
llr[c] = (int16_t *)malloc16_clear(rx_llr_buf_sz * sizeof(int16_t));
// dlsch_harq contains the previous transmissions data for this harq pid
NR_DL_UE_HARQ_t *harq = &ue->dl_harq_processes[c][dlsch_config->harq_process_nbr];
......@@ -1285,7 +1285,6 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_
if (ue->phy_sim_pdsch_llr)
memcpy(ue->phy_sim_pdsch_llr, llr[c], sizeof(int16_t) * rx_llr_buf_sz);
free(llr[c]);
}
if (nr_slot_rx==9) {
......
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