parameterized multi-parallelism threads for pdsch

parent 9c645ed5
...@@ -241,7 +241,7 @@ for(int th=0;th<thread_num_pressure;th++){ ...@@ -241,7 +241,7 @@ for(int th=0;th<thread_num_pressure;th++){
} }
//Get value for multi pdsch //Get value for multi pdsch
//scrambling //scrambling
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_scrambling; th++){
for (int i=0; i<encoded_length>>3; i++) { for (int i=0; i<encoded_length>>3; i++) {
for (int j=0; j<8; j++) for (int j=0; j<8; j++)
gNB->multi_pdsch.f[th][(i<<3)+j] = harq->f[(i<<3)+j]; gNB->multi_pdsch.f[th][(i<<3)+j] = harq->f[(i<<3)+j];
...@@ -253,7 +253,7 @@ for (int th=0; th<2; th++){ ...@@ -253,7 +253,7 @@ for (int th=0; th<2; th++){
gNB->multi_pdsch.n_RNTI[th] = n_RNTI; gNB->multi_pdsch.n_RNTI[th] = n_RNTI;
} }
//modulation //modulation
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_modulation; 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 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)); 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++){ for (int q=0; q<NR_MAX_NB_CODEWORDS; q++){
...@@ -284,7 +284,7 @@ for (int q=0; q<thread_num_pdsch; q++){ ...@@ -284,7 +284,7 @@ for (int q=0; q<thread_num_pdsch; q++){
for (int q=0; q<thread_num_pressure; q++){ for (int q=0; q<thread_num_pressure; q++){
pthread_cond_signal(&(gNB->pressure_test[q].cond_scr_mod)); pthread_cond_signal(&(gNB->pressure_test[q].cond_scr_mod));
} }
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_scrambling; th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_scr[th])); pthread_cond_signal(&(gNB->multi_pdsch.cond_scr[th]));
} }
//Wait scrambling threads(or scr_mod threads) //Wait scrambling threads(or scr_mod threads)
...@@ -294,7 +294,7 @@ for (int q=0; q<thread_num_pdsch; q++){ ...@@ -294,7 +294,7 @@ for (int q=0; q<thread_num_pdsch; q++){
for (int q=0; q<thread_num_pressure; q++){ for (int q=0; q<thread_num_pressure; q++){
while(gNB->pressure_test[q].complete_scr_mod!=1); while(gNB->pressure_test[q].complete_scr_mod!=1);
} }
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_scrambling; th++){
while(gNB->multi_pdsch.complete_scr[th]!=1); while(gNB->multi_pdsch.complete_scr[th]!=1);
} }
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
...@@ -303,11 +303,11 @@ printf("==================[Mod]==================\n"); ...@@ -303,11 +303,11 @@ printf("==================[Mod]==================\n");
printf(" [Movement] [No.] [Round] [Cost time] \n"); printf(" [Movement] [No.] [Round] [Cost time] \n");
clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing
//Awake modulation threads //Awake modulation threads
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_modulation; th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_mod[th])); pthread_cond_signal(&(gNB->multi_pdsch.cond_mod[th]));
} }
//Wait modulation threads //Wait modulation threads
for (int th=0; th<2; th++){ for (int th=0; th<thread_num_modulation; th++){
while(gNB->multi_pdsch.complete_mod[th]!=1); while(gNB->multi_pdsch.complete_mod[th]!=1);
} }
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
......
...@@ -472,7 +472,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -472,7 +472,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
gNB->pressure_test[th].n_segments = dlsch->harq_processes[harq_pid]->C; gNB->pressure_test[th].n_segments = dlsch->harq_processes[harq_pid]->C;
} }
/*cpy original data to multi pdsch*/ /*cpy original data to multi pdsch*/
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_ldpc_encoder;th++){
for(int j=0;j<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;j++){ // ==Why can not just be MAX_NUM_NR_DLSCH_SEGMENTS ==??? 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.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); gNB->multi_pdsch.d[th][j]=(uint8_t*)malloc16(68*384);//(unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
...@@ -508,7 +508,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -508,7 +508,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
for(int th=0;th<thread_num_pressure;th++){ for(int th=0;th<thread_num_pressure;th++){
pthread_cond_signal(&(gNB->pressure_test[th].cond)); pthread_cond_signal(&(gNB->pressure_test[th].cond));
} }
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_ldpc_encoder;th++){
pthread_cond_signal(&(gNB->multi_pdsch.cond_enc[th])); pthread_cond_signal(&(gNB->multi_pdsch.cond_enc[th]));
} }
for(int th = 0;th<thread_num_pdsch;th++){ for(int th = 0;th<thread_num_pdsch;th++){
...@@ -517,7 +517,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -517,7 +517,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
for(int th = 0;th<thread_num_pressure;th++){ for(int th = 0;th<thread_num_pressure;th++){
while(gNB->pressure_test[th].complete!=1); // ==check if multi_ldpc_enc done == while(gNB->pressure_test[th].complete!=1); // ==check if multi_ldpc_enc done ==
} }
for(int th = 0;th<2;th++){ for(int th = 0;th<thread_num_ldpc_encoder;th++){
while(gNB->multi_pdsch.complete_enc[th]!=1); // ==check if multi_ldpc_enc done == while(gNB->multi_pdsch.complete_enc[th]!=1); // ==check if multi_ldpc_enc done ==
} }
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
......
...@@ -46,8 +46,11 @@ ...@@ -46,8 +46,11 @@
#include "common/utils/LOG/vcd_signal_dumper.h" //VCD #include "common/utils/LOG/vcd_signal_dumper.h" //VCD
#define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB #define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB
#define thread_num_pdsch 1 // ==Change thread_num_pdsch here. Don't greater than 2 == #define thread_num_pdsch 0 // ==Change thread_num_pdsch here. Don't greater than 2 ==
#define thread_num_pressure 0 // ==Change thread_num_pressure here == #define thread_num_pressure 0 // ==Change thread_num_pressure here ==
#define thread_num_ldpc_encoder 2
#define thread_num_scrambling 3
#define thread_num_modulation 4
#define check_time 0 // ==Change if you wnat to check time of threads == #define check_time 0 // ==Change if you wnat to check time of threads ==
typedef struct{ typedef struct{
...@@ -89,43 +92,43 @@ typedef struct{ ...@@ -89,43 +92,43 @@ typedef struct{
typedef struct{ typedef struct{
/*params of thread*/ /*params of thread*/
int id_enc[2]; int id_enc[thread_num_ldpc_encoder];
int id_scr[2]; int id_scr[thread_num_scrambling];
int id_mod[2]; int id_mod[thread_num_modulation];
pthread_t pthread_enc[2]; pthread_t pthread_enc[thread_num_ldpc_encoder];
pthread_t pthread_scr[2]; pthread_t pthread_scr[thread_num_scrambling];
pthread_t pthread_mod[2]; pthread_t pthread_mod[thread_num_modulation];
pthread_cond_t cond_enc[2]; pthread_cond_t cond_enc[thread_num_ldpc_encoder];
pthread_cond_t cond_scr[2]; pthread_cond_t cond_scr[thread_num_scrambling];
pthread_cond_t cond_mod[2]; pthread_cond_t cond_mod[thread_num_modulation];
pthread_mutex_t mutex_enc[2]; pthread_mutex_t mutex_enc[thread_num_ldpc_encoder];
pthread_mutex_t mutex_scr[2]; pthread_mutex_t mutex_scr[thread_num_scrambling];
pthread_mutex_t mutex_mod[2]; pthread_mutex_t mutex_mod[thread_num_modulation];
pthread_attr_t attr_enc[2]; pthread_attr_t attr_enc[thread_num_ldpc_encoder];
pthread_attr_t attr_scr[2]; pthread_attr_t attr_scr[thread_num_scrambling];
pthread_attr_t attr_mod[2]; pthread_attr_t attr_mod[thread_num_modulation];
volatile uint8_t complete_enc[2]; volatile uint8_t complete_enc[thread_num_ldpc_encoder];
volatile uint8_t complete_scr[2]; volatile uint8_t complete_scr[thread_num_scrambling];
volatile uint8_t complete_mod[2]; volatile uint8_t complete_mod[thread_num_modulation];
/*encoder*/ /*encoder*/
uint8_t *c[2][MAX_NUM_NR_DLSCH_SEGMENTS]; uint8_t *c[thread_num_ldpc_encoder][MAX_NUM_NR_DLSCH_SEGMENTS];
uint8_t *d[2][MAX_NUM_NR_DLSCH_SEGMENTS]; uint8_t *d[thread_num_ldpc_encoder][MAX_NUM_NR_DLSCH_SEGMENTS];
int Zc[2]; int Zc[thread_num_ldpc_encoder];
int Kb[2]; int Kb[thread_num_ldpc_encoder];
short block_length[2]; short block_length[thread_num_ldpc_encoder];
short BG[2]; short BG[thread_num_ldpc_encoder];
int n_segments[2]; int n_segments[thread_num_ldpc_encoder];
/*scrambling*/ /*scrambling*/
uint8_t f[2][MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32))); uint8_t f[thread_num_scrambling][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 scrambled_output_scr[thread_num_scrambling][NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; // ==use thread_num_scrambling or thread_num_modulation ==???
uint32_t encoded_length_scr[2]; // ==use 2 or 2 ==??? uint32_t encoded_length_scr[thread_num_scrambling]; // ==use thread_num_scrambling or thread_num_modulation ==???
uint16_t Nid[2]; uint16_t Nid[thread_num_scrambling];
uint16_t n_RNTI[2]; uint16_t n_RNTI[thread_num_scrambling];
/*modulation*/ /*modulation*/
uint32_t scrambled_output_mod[2][NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; // ==use 2 or 2 ==??? uint32_t scrambled_output_mod[thread_num_modulation][NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; // ==use thread_num_scrambling or thread_num_modulation ==???
int32_t *mod_symbs[2][NR_MAX_NB_CODEWORDS]; int32_t *mod_symbs[thread_num_modulation][NR_MAX_NB_CODEWORDS];
uint32_t encoded_length_mod[2]; // ==use 2 or 2 ==??? uint32_t encoded_length_mod[thread_num_modulation]; // ==use thread_num_scrambling or thread_num_modulation ==???
uint8_t Qm[2]; uint8_t Qm[thread_num_modulation];
}multi_pdsch_gNB; }multi_pdsch_gNB;
typedef struct { typedef struct {
......
...@@ -141,18 +141,18 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned char **output_buff ...@@ -141,18 +141,18 @@ int32_t nr_segmentation(unsigned char *input_buffer, unsigned char **output_buff
int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput); int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
/*! \file openair1/SIMULATION/NR_PHY/dlsim.c /*! \file openair1/SIMULATION/NR_PHY/dlsim.c
* \brief multi-parallelism threads for pdsch * \brief parameterized multi-parallelism threads for pdsch
* \author Terngyin Hsu, Sendren Xu, Nungyi Kuo, Kuankai Hsiung, Kaimi Yang (OpInConnect_NCTU) * \author Terngyin Hsu, Sendren Xu, Nungyi Kuo, Kuankai Hsiung, Kaimi Yang (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw * \email tyhsu@cs.nctu.edu.tw
* \date 22-05-2020 * \date 28-05-2020
* \version 3.0 * \version 3.1
* \note * \note
* \warning * \warning
*/ */
//[START]multi_genetate_pdsch_proc //[START]multi_genetate_pdsch_proc
struct timespec start_encoder_ts[thread_num_pdsch], end_encoder_ts[thread_num_pdsch], start_perenc_ts[thread_num_pdsch], end_perenc_ts[thread_num_pdsch], start_pressure_ts[thread_num_pressure], end_pressure_ts[thread_num_pressure], start_perpre_ts[thread_num_pressure], end_perpre_ts[thread_num_pressure]; struct timespec start_encoder_ts[thread_num_pdsch], end_encoder_ts[thread_num_pdsch], start_perenc_ts[thread_num_pdsch], end_perenc_ts[thread_num_pdsch], start_pressure_ts[thread_num_pressure], end_pressure_ts[thread_num_pressure], start_perpre_ts[thread_num_pressure], end_perpre_ts[thread_num_pressure];
struct timespec start_multi_enc_ts[2], end_multi_enc_ts[2], start_multi_scr_ts[2], end_multi_scr_ts[2], start_multi_mod_ts[2], end_multi_mod_ts[2]; struct timespec start_multi_enc_ts[thread_num_ldpc_encoder], end_multi_enc_ts[thread_num_ldpc_encoder], start_multi_scr_ts[thread_num_scrambling], end_multi_scr_ts[thread_num_scrambling], start_multi_mod_ts[thread_num_modulation], end_multi_mod_ts[thread_num_modulation];
int vcd = 0; //default : 0 int vcd = 0; //default : 0
/*original genetate_pdsch for multi threads*/ /*original genetate_pdsch for multi threads*/
static void *multi_genetate_pdsch_proc(void *ptr){ static void *multi_genetate_pdsch_proc(void *ptr){
...@@ -960,7 +960,7 @@ int main(int argc, char **argv) ...@@ -960,7 +960,7 @@ int main(int argc, char **argv)
printf("[CREATE] LDPC encoder thread %d(p) \n",gNB->pressure_test[th].id); printf("[CREATE] LDPC encoder thread %d(p) \n",gNB->pressure_test[th].id);
} }
/*multi pdsch*/ /*multi pdsch*/
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_ldpc_encoder;th++){
pthread_attr_init(&(gNB->multi_pdsch.attr_enc[th])); pthread_attr_init(&(gNB->multi_pdsch.attr_enc[th]));
pthread_mutex_init(&(gNB->multi_pdsch.mutex_enc[th]), NULL); pthread_mutex_init(&(gNB->multi_pdsch.mutex_enc[th]), NULL);
pthread_cond_init(&(gNB->multi_pdsch.cond_enc[th]), NULL); pthread_cond_init(&(gNB->multi_pdsch.cond_enc[th]), NULL);
...@@ -969,7 +969,7 @@ int main(int argc, char **argv) ...@@ -969,7 +969,7 @@ int main(int argc, char **argv)
pthread_create(&(gNB->multi_pdsch.pthread_enc[th]), &(gNB->multi_pdsch.attr_enc[th]), multi_ldpc_encoder_proc, gNB->multi_pdsch.id_enc[th]); pthread_create(&(gNB->multi_pdsch.pthread_enc[th]), &(gNB->multi_pdsch.attr_enc[th]), multi_ldpc_encoder_proc, gNB->multi_pdsch.id_enc[th]);
printf("[CREATE] multi_ldpc_encoder_proc %d \n",gNB->multi_pdsch.id_enc[th]); printf("[CREATE] multi_ldpc_encoder_proc %d \n",gNB->multi_pdsch.id_enc[th]);
} }
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_scrambling;th++){
pthread_attr_init(&(gNB->multi_pdsch.attr_scr[th])); pthread_attr_init(&(gNB->multi_pdsch.attr_scr[th]));
pthread_mutex_init(&(gNB->multi_pdsch.mutex_scr[th]), NULL); pthread_mutex_init(&(gNB->multi_pdsch.mutex_scr[th]), NULL);
pthread_cond_init(&(gNB->multi_pdsch.cond_scr[th]), NULL); pthread_cond_init(&(gNB->multi_pdsch.cond_scr[th]), NULL);
...@@ -979,7 +979,7 @@ int main(int argc, char **argv) ...@@ -979,7 +979,7 @@ int main(int argc, char **argv)
printf("[CREATE] multi_scrambling_proc %d \n",gNB->multi_pdsch.id_scr[th]); printf("[CREATE] multi_scrambling_proc %d \n",gNB->multi_pdsch.id_scr[th]);
} }
//for(int th=0;th<0;th++){ //for(int th=0;th<0;th++){
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_modulation;th++){
pthread_attr_init(&(gNB->multi_pdsch.attr_mod[th])); pthread_attr_init(&(gNB->multi_pdsch.attr_mod[th]));
pthread_mutex_init(&(gNB->multi_pdsch.mutex_mod[th]), NULL); pthread_mutex_init(&(gNB->multi_pdsch.mutex_mod[th]), NULL);
pthread_cond_init(&(gNB->multi_pdsch.cond_mod[th]), NULL); pthread_cond_init(&(gNB->multi_pdsch.cond_mod[th]), NULL);
...@@ -1359,13 +1359,13 @@ int main(int argc, char **argv) ...@@ -1359,13 +1359,13 @@ int main(int argc, char **argv)
// } // }
} }
//free multi_pdsch memorys //free multi_pdsch memorys
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_ldpc_encoder;th++){
for(int j=0;j<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;j++){ for(int j=0;j<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;j++){
free(gNB->multi_pdsch.c[th][j]); free(gNB->multi_pdsch.c[th][j]);
free(gNB->multi_pdsch.d[th][j]); free(gNB->multi_pdsch.d[th][j]);
} }
} }
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_modulation;th++){
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++){ for (int q=0; q<NR_MAX_NB_CODEWORDS; q++){
free(gNB->multi_pdsch.mod_symbs[th][q]); free(gNB->multi_pdsch.mod_symbs[th][q]);
} }
......
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