multi-parallelism threads for pdsch

parent c45aa6ce
......@@ -206,7 +206,7 @@ for (int q=0; q<rel15->nb_codewords; q++) // ==Look out!NR_MAX_NB_CODEWORDS is 2
memset((void*)scrambled_output[q], 0, (encoded_length>>5)*sizeof(uint32_t));
uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC) ? ((pdcch_params.scrambling_id==0)?pdcch_params.rnti:0) : 0;
uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC) ? pdcch_params.scrambling_id : config->sch_config.physical_cell_id.value;
printf("================[Scr_Mod]================\n");
printf("==================[Scr]==================\n");
printf(" [Movement] [No.] [Round] [Cost time] \n");
//Get value for dual thread
for (int q=0; q<thread_num_pdsch; q++){
......@@ -239,6 +239,29 @@ for(int th=0;th<thread_num_pressure;th++){
for (int q=0; q<rel15->nb_codewords; q++) // ==Look out!NR_MAX_NB_CODEWORDS is 2!So we can't let q>2 until spec change
memset((void*)gNB->pressure_test[th].scrambled_output_test[q], 0, (encoded_length>>5)*sizeof(uint32_t));
}
//Get value for multi pdsch
//scrambling
for (int th=0; th<2; th++){
for (int i=0; i<encoded_length>>3; i++) {
for (int j=0; j<8; j++)
gNB->multi_pdsch.f[th][(i<<3)+j] = harq->f[(i<<3)+j];
}
for (int q=0; q<rel15->nb_codewords; q++) // ==Look out!NR_MAX_NB_CODEWORDS is 2!So we can't let q>2 until spec change
memset((void*)gNB->multi_pdsch.scrambled_output_scr[th][q], 0, (encoded_length>>5)*sizeof(uint32_t));
gNB->multi_pdsch.encoded_length_scr[th] = encoded_length;
gNB->multi_pdsch.Nid[th] = Nid;
gNB->multi_pdsch.n_RNTI[th] = n_RNTI;
}
//modulation
for (int th=0; th<2; th++){
for (int q=0; q<rel15->nb_codewords; q++) // ==Look out!NR_MAX_NB_CODEWORDS is 2!So we can't let q>2 until spec change
memset((void*)gNB->multi_pdsch.scrambled_output_mod[th][q], 0, (encoded_length>>5)*sizeof(uint32_t));
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++){
gNB->multi_pdsch.mod_symbs[th][q] = (int32_t *)malloc16(NR_MAX_PDSCH_ENCODED_LENGTH*sizeof(int32_t));
}
gNB->multi_pdsch.encoded_length_mod[th] = encoded_length;
gNB->multi_pdsch.Qm[th] = Qm;
}
//Show value for pressure
// printf("\nEncoded payload:\n");
// for (int i=0; i<10; i++) {
......@@ -252,7 +275,7 @@ for(int th=0;th<thread_num_pressure;th++){
// printf("%d", gNB->pressure_test[0].f_test[(i<<3)+j]);
// printf("\t");
// }
//Awake threads
//Awake scrambling threads(or scr_mod threads)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MULTI_ENC,1);
clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing
for (int q=0; q<thread_num_pdsch; q++){
......@@ -261,13 +284,32 @@ for (int q=0; q<thread_num_pdsch; q++){
for (int q=0; q<thread_num_pressure; q++){
pthread_cond_signal(&(gNB->pressure_test[q].cond_scr_mod));
}
//Wait threads
for (int th=0; th<2; th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_scr[th]));
}
//Wait scrambling threads(or scr_mod threads)
for (int q=0; q<thread_num_pdsch; q++){
while(gNB->multi_encoder[q].complete_scr_mod!=1);
}
for (int q=0; q<thread_num_pressure; q++){
while(gNB->pressure_test[q].complete_scr_mod!=1);
}
for (int th=0; th<2; th++){
while(gNB->multi_pdsch.complete_scr[th]!=1);
}
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
printf(" Total %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000);
printf("==================[Mod]==================\n");
printf(" [Movement] [No.] [Round] [Cost time] \n");
clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing
//Awake modulation threads
for (int th=0; th<2; th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_mod[th]));
}
//Wait modulation threads
for (int th=0; th<2; th++){
while(gNB->multi_pdsch.complete_mod[th]!=1);
}
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MULTI_ENC,0);
//printf(" Movement No. Round Cost time \n");
......
......@@ -471,6 +471,19 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
gNB->pressure_test[th].BG = BG;
gNB->pressure_test[th].n_segments = dlsch->harq_processes[harq_pid]->C;
}
/*cpy original data to multi pdsch*/
for(int th=0;th<2;th++){
for(int j=0;j<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;j++){ // ==Why can not just be MAX_NUM_NR_DLSCH_SEGMENTS ==???
gNB->multi_pdsch.c[th][j]=(uint8_t*)malloc16(8448);//(unsigned char *)malloc16(sizeof(unsigned char) * Kr/8);
gNB->multi_pdsch.d[th][j]=(uint8_t*)malloc16(68*384);//(unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
memcpy(gNB->multi_pdsch.c[th][j], dlsch->harq_processes[harq_pid]->c[j], 8448); // ==Check 8448 ==***
}
gNB->multi_pdsch.Zc[th] = *Zc;
gNB->multi_pdsch.Kb[th] = Kb;
gNB->multi_pdsch.block_length[th] = Kr;
gNB->multi_pdsch.BG[th] = BG;
gNB->multi_pdsch.n_segments[th] = dlsch->harq_processes[harq_pid]->C;
}
/*Show c_test*/
// printf("c_test :\n");
// for (int i=0; i<3; i++){
......@@ -495,12 +508,18 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
for(int th=0;th<thread_num_pressure;th++){
pthread_cond_signal(&(gNB->pressure_test[th].cond));
}
for(int th=0;th<2;th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_enc[th]));
}
for(int th = 0;th<thread_num_pdsch;th++){
while(gNB->multi_encoder[th].complete!=1); // ==check if multi_ldpc_enc done ==
}
for(int th = 0;th<thread_num_pressure;th++){
while(gNB->pressure_test[th].complete!=1); // ==check if multi_ldpc_enc done ==
}
for(int th = 0;th<2;th++){
while(gNB->multi_pdsch.complete_enc[th]!=1); // ==check if multi_ldpc_enc done ==
}
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MULTI_ENC,0);
//printf(" Movement No. Round Cost time \n");
......
......@@ -46,8 +46,8 @@
#include "common/utils/LOG/vcd_signal_dumper.h" //VCD
#define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB
#define thread_num_pdsch 2 // ==Change thread_num_pdsch here. Don't greater than 2 ==
#define thread_num_pressure 3 // ==Change thread_num_pressure here ==
#define thread_num_pdsch 1 // ==Change thread_num_pdsch here. Don't greater than 2 ==
#define thread_num_pressure 0 // ==Change thread_num_pressure here ==
#define check_time 0 // ==Change if you wnat to check time of threads ==
typedef struct{
......@@ -87,6 +87,47 @@ typedef struct{
uint32_t scrambled_output_test[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
}multi_ldpc_encoder_gNB;
typedef struct{
/*params of thread*/
int id_enc[2];
int id_scr[2];
int id_mod[2];
pthread_t pthread_enc[2];
pthread_t pthread_scr[2];
pthread_t pthread_mod[2];
pthread_cond_t cond_enc[2];
pthread_cond_t cond_scr[2];
pthread_cond_t cond_mod[2];
pthread_mutex_t mutex_enc[2];
pthread_mutex_t mutex_scr[2];
pthread_mutex_t mutex_mod[2];
pthread_attr_t attr_enc[2];
pthread_attr_t attr_scr[2];
pthread_attr_t attr_mod[2];
volatile uint8_t complete_enc[2];
volatile uint8_t complete_scr[2];
volatile uint8_t complete_mod[2];
/*encoder*/
uint8_t *c[2][MAX_NUM_NR_DLSCH_SEGMENTS];
uint8_t *d[2][MAX_NUM_NR_DLSCH_SEGMENTS];
int Zc[2];
int Kb[2];
short block_length[2];
short BG[2];
int n_segments[2];
/*scrambling*/
uint8_t f[2][MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
uint32_t scrambled_output_scr[2][NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; // ==use 2 or 2 ==???
uint32_t encoded_length_scr[2]; // ==use 2 or 2 ==???
uint16_t Nid[2];
uint16_t n_RNTI[2];
/*modulation*/
uint32_t scrambled_output_mod[2][NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; // ==use 2 or 2 ==???
int32_t *mod_symbs[2][NR_MAX_NB_CODEWORDS];
uint32_t encoded_length_mod[2]; // ==use 2 or 2 ==???
uint8_t Qm[2];
}multi_pdsch_gNB;
typedef struct {
uint32_t pbch_a;
uint32_t pbch_a_interleaved;
......@@ -918,6 +959,7 @@ typedef struct PHY_VARS_gNB_s {
ldpc_encoding_ISIP ldpc_encode;
multi_ldpc_encoder_gNB multi_encoder[thread_num_pdsch];
multi_ldpc_encoder_gNB pressure_test[thread_num_pressure];
multi_pdsch_gNB multi_pdsch;
volatile uint8_t complete_encode[4];
......
This diff is collapsed.
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