Commit 94b7762b authored by Francesco Mani's avatar Francesco Mani

dynamic allocation of e and f vectors

parent e8b69323
......@@ -80,7 +80,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
time_stats_t *dlsch_modulation_stats);
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch,uint16_t N_RB);
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
......
......@@ -48,12 +48,22 @@
//#define DEBUG_DLSCH_CODING
//#define DEBUG_DLSCH_FREE 1
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch,uint16_t N_RB)
{
int i;
int r;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
if (dlsch) {
if (N_RB != 273) {
a_segments = a_segments*N_RB;
a_segments = a_segments/273;
}
uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch %p\n",dlsch);
#endif
......@@ -69,18 +79,34 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
#endif
if (dlsch->harq_processes[i]->b) {
free16(dlsch->harq_processes[i]->b,MAX_NR_DLSCH_PAYLOAD_BYTES);
free16(dlsch->harq_processes[i]->b,dlsch_bytes);
dlsch->harq_processes[i]->b = NULL;
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b);
#endif
}
if (dlsch->harq_processes[i]->e) {
free16(dlsch->harq_processes[i]->e,14*N_RB*12*8);
dlsch->harq_processes[i]->e = NULL;
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d e (%p)\n",i,dlsch->harq_processes[i]->e);
#endif
}
if (dlsch->harq_processes[i]->f) {
free16(dlsch->harq_processes[i]->f,14*N_RB*12*8);
dlsch->harq_processes[i]->f = NULL;
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d f (%p)\n",i,dlsch->harq_processes[i]->f);
#endif
}
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c);
#endif
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++) {
for (r=0; r<a_segments; r++) {
#ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
......@@ -210,6 +236,20 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
exit_flag=2;
}
}
dlsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB*12*8);
if (dlsch->harq_processes[i]->e) {
bzero(dlsch->harq_processes[i]->e,14*N_RB*12*8);
} else {
printf("Can't get e\n");
exit_flag=1;
}
dlsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB*12*8);
if (dlsch->harq_processes[i]->f) {
bzero(dlsch->harq_processes[i]->f,14*N_RB*12*8);
} else {
printf("Can't get f\n");
exit_flag=1;
}
}
} else {
printf("Can't get harq_p %d\n",i);
......@@ -228,7 +268,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
LOG_D(PHY,"new_gNB_dlsch exit flag %d, size of %ld\n",
exit_flag, sizeof(NR_gNB_DLSCH_t));
free_gNB_dlsch(dlsch);
free_gNB_dlsch(dlsch,N_RB);
return(NULL);
......
......@@ -42,7 +42,7 @@
#define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056)
#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056)
#define MAX_NUM_NR_CHANNEL_BITS (14*273*12*6) // 14 symbols, 273 RB
#define MAX_NUM_NR_CHANNEL_BITS (14*273*12*8) // 14 symbols, 273 RB
#define MAX_NUM_NR_RE (14*273*12)
#define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1
......
......@@ -32,7 +32,7 @@
#include "PHY/defs_gNB.h"
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch);
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch,uint8_t N_RB_UL);
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
......
......@@ -57,30 +57,38 @@ static uint64_t nb_error_decod =0;
//extern double cpuf;
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch,uint8_t N_RB_UL)
{
int i,r;
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
if (ulsch) {
if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL;
a_segments = a_segments/273;
}
uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (ulsch->harq_processes[i]) {
if (ulsch->harq_processes[i]->b) {
free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES);
free16(ulsch->harq_processes[i]->b,ulsch_bytes);
ulsch->harq_processes[i]->b = NULL;
}
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
for (r=0; r<a_segments; r++) {
free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t));
ulsch->harq_processes[i]->c[r] = NULL;
}
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->d[r]) {
free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t));
ulsch->harq_processes[i]->d[r] = NULL;
}
}
for (r=0; r<(MAX_NUM_NR_ULSCH_SEGMENTS); r++) {
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
......@@ -164,7 +172,7 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
}
printf("new_gNB_ulsch with size %zu: exit_flag = %u\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag);
free_gNB_ulsch(ulsch);
free_gNB_ulsch(ulsch,N_RB_UL);
return(NULL);
}
......
......@@ -56,31 +56,39 @@ notifiedFIFO_elt_t *msgToPush;
//extern double cpuf;
void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch)
void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch,uint8_t N_RB_DL)
{
int i,r;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
if (dlsch) {
if (N_RB_DL != 273) {
a_segments = a_segments*N_RB_DL;
a_segments = a_segments/273;
}
uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
for (i=0; i<dlsch->Mdlharq; i++) {
if (dlsch->harq_processes[i]) {
if (dlsch->harq_processes[i]->b) {
free16(dlsch->harq_processes[i]->b,MAX_NR_DLSCH_PAYLOAD_BYTES);
free16(dlsch->harq_processes[i]->b,dlsch_bytes);
dlsch->harq_processes[i]->b = NULL;
}
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++) {
for (r=0; r<a_segments; r++) {
free16(dlsch->harq_processes[i]->c[r],1056);
dlsch->harq_processes[i]->c[r] = NULL;
}
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++)
for (r=0; r<a_segments; r++)
if (dlsch->harq_processes[i]->d[r]) {
free16(dlsch->harq_processes[i]->d[r],(3*8448)*sizeof(short));
dlsch->harq_processes[i]->d[r] = NULL;
}
for (r=0; r<(MAX_NUM_NR_DLSCH_SEGMENTS); r++) {
for (r=0; r<a_segments; r++) {
if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
......@@ -164,7 +172,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
}
printf("new_ue_dlsch with size %zu: exit_flag = %u\n",sizeof(NR_DL_UE_HARQ_t), exit_flag);
free_nr_ue_dlsch(dlsch);
free_nr_ue_dlsch(dlsch,N_RB_DL);
return(NULL);
}
......
......@@ -47,7 +47,7 @@
\brief This function frees memory allocated for a particular DLSCH at UE
@param dlsch Pointer to DLSCH to be removed
*/
void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch);
void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch,uint8_t N_RB_DL);
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
\brief This function allocates structures for a particular DLSCH at UE
......@@ -61,7 +61,7 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t *dlsch);
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag);
void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch);
void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch,unsigned char N_RB_UL);
NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag);
......
......@@ -127,9 +127,9 @@ typedef struct {
/// LDPC-code outputs
uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS];
/// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17)
uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
uint8_t *e;
/// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30)
uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
uint8_t *f;
/// Number of code segments
uint32_t C;
/// Number of bits in code segments
......
......@@ -42,7 +42,7 @@
void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch)
void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch,unsigned char N_RB_UL)
{
int i, r;
......@@ -51,18 +51,35 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t *ulsch)
printf("Freeing ulsch %p\n",ulsch);
#endif
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL;
a_segments = a_segments/273;
}
uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (ulsch->harq_processes[i]) {
if (ulsch->harq_processes[i]->a) {
free16(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES);
free16(ulsch->harq_processes[i]->a,ulsch_bytes);
ulsch->harq_processes[i]->a = NULL;
}
if (ulsch->harq_processes[i]->b) {
free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES);
free16(ulsch->harq_processes[i]->b,ulsch_bytes);
ulsch->harq_processes[i]->b = NULL;
}
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
if (ulsch->harq_processes[i]->e) {
free16(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
ulsch->harq_processes[i]->e = NULL;
}
if (ulsch->harq_processes[i]->f) {
free16(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
ulsch->harq_processes[i]->f = NULL;
}
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->c[r]) {
free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
ulsch->harq_processes[i]->c[r] = NULL;
......@@ -155,6 +172,20 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
exit_flag=2;
}
}
ulsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB_UL*12*8);
if (ulsch->harq_processes[i]->e) {
bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
} else {
printf("Can't get e\n");
exit_flag=1;
}
ulsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB_UL*12*8);
if (ulsch->harq_processes[i]->f) {
bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
} else {
printf("Can't get f\n");
exit_flag=1;
}
}
ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
......@@ -175,7 +206,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
}
LOG_E(PHY,"new_ue_ulsch exit flag, size of %d , %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t));
free_nr_ue_ulsch(ulsch);
free_nr_ue_ulsch(ulsch,N_RB_UL);
return(NULL);
......
......@@ -112,11 +112,11 @@ typedef struct {
/// MIMO mode for this DLSCH
MIMO_mode_t mimo_mode;
/// Concatenated sequences
uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
uint8_t *e;
/// LDPC-code outputs
uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
/// Interleaver outputs
uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
uint8_t *f;
/// Number of code segments
uint32_t C;
/// Number of bits in "small" code segments
......
......@@ -621,9 +621,9 @@ int main(int argc, char **argv)
for (i = 0; i < 2; i++) {
printf("gNB %d\n", i);
free_gNB_dlsch(gNB->dlsch[0][i]);
free_gNB_dlsch(gNB->dlsch[0][i],N_RB_DL);
printf("UE %d\n", i);
free_nr_ue_dlsch(UE->dlsch[0][0][i]);
free_nr_ue_dlsch(UE->dlsch[0][0][i],N_RB_DL);
}
for (i = 0; i < 2; i++) {
......
......@@ -573,18 +573,18 @@ int main(int argc, char **argv)
printf("gNB ulsch[0][%d]\n", i); // [hna] ulsch[0] is for RA
free_gNB_ulsch(gNB->ulsch[0][i]);
free_gNB_ulsch(gNB->ulsch[0][i],N_RB_UL);
printf("gNB ulsch[%d][%d]\n",UE_id+1, i);
free_gNB_ulsch(gNB->ulsch[UE_id+1][i]);
free_gNB_ulsch(gNB->ulsch[UE_id+1][i],N_RB_UL);
for (sf = 0; sf < 2; sf++) {
printf("UE ulsch[%d][0][%d]\n", sf, i);
if (UE->ulsch[sf][0][i])
free_nr_ue_ulsch(UE->ulsch[sf][0][i]);
free_nr_ue_ulsch(UE->ulsch[sf][0][i],N_RB_UL);
}
printf("\n");
......
......@@ -605,18 +605,18 @@ int main(int argc, char **argv)
printf("gNB ulsch[0][%d]\n", i); // [hna] ulsch[0] is for RA
free_gNB_ulsch(gNB->ulsch[0][i]);
free_gNB_ulsch(gNB->ulsch[0][i],N_RB_UL);
printf("gNB ulsch[%d][%d]\n",UE_id+1, i);
free_gNB_ulsch(gNB->ulsch[UE_id+1][i]); // "+1" because first element in ulsch is for RA
free_gNB_ulsch(gNB->ulsch[UE_id+1][i],N_RB_UL); // "+1" because first element in ulsch is for RA
for (sf = 0; sf < 2; sf++) {
printf("UE ulsch[%d][0][%d]\n", sf, i);
if (UE->ulsch[sf][0][i])
free_nr_ue_ulsch(UE->ulsch[sf][0][i]);
free_nr_ue_ulsch(UE->ulsch[sf][0][i],N_RB_UL);
}
printf("\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