parameterized dual thread for pdsch

parent 84de00ed
...@@ -103,6 +103,16 @@ uint16_t NB_UE_INST = 1; ...@@ -103,6 +103,16 @@ uint16_t NB_UE_INST = 1;
short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384};
/*! \file openair1/PHY/CODING/TESTBENCH/ldpctest.c
* \brief NCTU OpInConnect
* \author Terngyin Hsu, Sendren Xu, Nungyi Kuo, Kuankai Hsiung, Kaimi Yang (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 13-05-2020
* \version 2.0
* \note
* \warning
*/
// ==[START]multi_lpdc_encoder // ==[START]multi_lpdc_encoder
struct timespec start_ts, end_ts, start_per_ts, end_per_ts, start_enc_ts[thread_num_max], end_enc_ts[thread_num_max], start_perenc_ts[thread_num_max], end_perenc_ts[thread_num_max]; struct timespec start_ts, end_ts, start_per_ts, end_per_ts, start_enc_ts[thread_num_max], end_enc_ts[thread_num_max], start_perenc_ts[thread_num_max], end_perenc_ts[thread_num_max];
multi_ldpc_encoder ldpc_enc[thread_num_max]; multi_ldpc_encoder ldpc_enc[thread_num_max];
......
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
*/ */
/*!\file PHY/NR_TRANSPORT/dlsch_decoding.c /*!\file PHY/NR_TRANSPORT/dlsch_decoding.c
* \brief Add triggers for dual thread * \brief Add triggers for parameterized dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU) * \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw * \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020 * \date 01-05-2020
* \version 1.1 * \version 1.2
* \note * \note
* \warning * \warning
*/ */
...@@ -220,7 +220,7 @@ uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_ ...@@ -220,7 +220,7 @@ uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_
printf("================[Scr_Mod]================\n"); printf("================[Scr_Mod]================\n");
printf(" [Movement] [No.] [Round] [Cost time] \n"); printf(" [Movement] [No.] [Round] [Cost time] \n");
//Get value //Get value
for (int q=0; q<2; q++){ for (int q=0; q<thread_num_pdsch; q++){
gNB->multi_encoder[q].f = harq->f; gNB->multi_encoder[q].f = harq->f;
gNB->multi_encoder[q].encoded_length = encoded_length; gNB->multi_encoder[q].encoded_length = encoded_length;
gNB->multi_encoder[q].Nid = Nid; gNB->multi_encoder[q].Nid = Nid;
...@@ -231,11 +231,11 @@ for (int q=0; q<2; q++){ ...@@ -231,11 +231,11 @@ for (int q=0; q<2; q++){
} }
//Awake threads //Awake threads
clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing
for (int q=0; q<2; q++){ for (int q=0; q<thread_num_pdsch; q++){
pthread_cond_signal(&(gNB->multi_encoder[q].cond_scr_mod)); pthread_cond_signal(&(gNB->multi_encoder[q].cond_scr_mod));
} }
//Wait threads //Wait threads
for (int q=0; q<2; q++){ for (int q=0; q<thread_num_pdsch; q++){
while(gNB->multi_encoder[q].complete_scr_mod!=1); while(gNB->multi_encoder[q].complete_scr_mod!=1);
} }
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
......
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
*/ */
/*!\file PHY/NR_TRANSPORT/dlsch_coding.c /*!\file PHY/NR_TRANSPORT/dlsch_coding.c
* \brief Add triggers for dual thread * \brief Add triggers for parameterized dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU) * \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw * \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020 * \date 01-05-2020
* \version 1.1 * \version 1.2
* \note * \note
* \warning * \warning
*/ */
...@@ -450,7 +450,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -450,7 +450,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
// printf(" Total Single %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000); // printf(" Total Single %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000);
/*get value*/ /*get value*/
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_pdsch;th++){
gNB->multi_encoder[th].test_input = dlsch->harq_processes[harq_pid]->c; gNB->multi_encoder[th].test_input = dlsch->harq_processes[harq_pid]->c;
gNB->multi_encoder[th].channel_input_optim = dlsch->harq_processes[harq_pid]->d; gNB->multi_encoder[th].channel_input_optim = dlsch->harq_processes[harq_pid]->d;
gNB->multi_encoder[th].Zc = *Zc; gNB->multi_encoder[th].Zc = *Zc;
...@@ -466,7 +466,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -466,7 +466,7 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
// dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448); // dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
// dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output // dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
// } // }
// for(int th=0;th<2;th++){ // for(int th=0;th<thread_num_pdsch;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_encoder[th].c_test[j]=(uint8_t*)malloc16(8448);//(unsigned char *)malloc16(sizeof(unsigned char) * Kr/8); // gNB->multi_encoder[th].c_test[j]=(uint8_t*)malloc16(8448);//(unsigned char *)malloc16(sizeof(unsigned char) * Kr/8);
// gNB->multi_encoder[th].d_test[j]=(uint8_t*)malloc16(68*384);//(unsigned char *)malloc16(sizeof(unsigned char) * 68*384); // gNB->multi_encoder[th].d_test[j]=(uint8_t*)malloc16(68*384);//(unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
...@@ -489,16 +489,16 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har ...@@ -489,16 +489,16 @@ int nr_dlsch_encoding(unsigned char *a, //harq->pdu => dlsch->harq_processes[har
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
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_pdsch;th++){
pthread_cond_signal(&(gNB->multi_encoder[th].cond)); pthread_cond_signal(&(gNB->multi_encoder[th].cond));
} }
for(int th = 0;th<2;th++){ for(int th = 0;th<thread_num_pdsch;th++){
while(gNB->multi_encoder[th].complete!=1); // ==check if multi_ldpc_enc done == while(gNB->multi_encoder[th].complete!=1); // ==check if multi_ldpc_enc done ==
} }
clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
//printf(" Movement No. Round Cost time \n"); //printf(" Movement No. Round Cost time \n");
printf(" Total %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000); printf(" Total %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000);
// for(int th = 0;th<2;th++){ // for(int th = 0;th<thread_num_pdsch;th++){
// pthread_mutex_destroy(&gNB->multi_encoder[th].mutex); // pthread_mutex_destroy(&gNB->multi_encoder[th].mutex);
// pthread_join(gNB->multi_encoder[th].pthread, NULL); // pthread_join(gNB->multi_encoder[th].pthread, NULL);
// } // }
......
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
*/ */
/*! \file PHY/defs_gNB.h /*! \file PHY/defs_gNB.h
* \brief Add defines and structure for dual thread * \brief Add thread_num_pdsch to parameterize dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU) * \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw * \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020 * \date 01-05-2020
* \version 1.1 * \version 1.2
* \note * \note
* \warning * \warning
*/ */
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#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 2 // ==Change thread_num_pdsch here. Don't greater than 2 ==
typedef struct{ typedef struct{
/*params of thread*/ /*params of thread*/
...@@ -917,7 +918,7 @@ typedef struct PHY_VARS_gNB_s { ...@@ -917,7 +918,7 @@ typedef struct PHY_VARS_gNB_s {
//**************************DLSCH ENCODING**************************// //**************************DLSCH ENCODING**************************//
dlsch_encoding_ISIP thread_encode[4]; dlsch_encoding_ISIP thread_encode[4];
ldpc_encoding_ISIP ldpc_encode; ldpc_encoding_ISIP ldpc_encode;
multi_ldpc_encoder_gNB multi_encoder[2]; multi_ldpc_encoder_gNB multi_encoder[thread_num_pdsch];
volatile uint8_t complete_encode[4]; volatile uint8_t complete_encode[4];
......
...@@ -19,6 +19,15 @@ ...@@ -19,6 +19,15 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*!\file SIMULATION/NR_PHY/dlsim.c
* \brief Parameterize dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 01-05-2020
* \version 1.2
* \note
* \warning
*/
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sched.h> #include <sched.h>
...@@ -65,6 +74,7 @@ ...@@ -65,6 +74,7 @@
#include "PHY/CODING/nrLDPC_encoder/defs.h" #include "PHY/CODING/nrLDPC_encoder/defs.h"
struct timespec start_enc_ts[4], end_enc_ts[4]; //timespec struct timespec start_enc_ts[4], end_enc_ts[4]; //timespec
//multi_ldpc_encoder_gNB ldpc_enc[thread_num_pdsch]; //things in ldpc_encoder
PHY_VARS_gNB *gNB; PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE; PHY_VARS_NR_UE *UE;
...@@ -289,17 +299,18 @@ static void *dlsch_encoding_proc(void *ptr){ ...@@ -289,17 +299,18 @@ static void *dlsch_encoding_proc(void *ptr){
} }
/*! \file openair1/SIMULATION/NR_PHY/dlsim.c /*! \file openair1/SIMULATION/NR_PHY/dlsim.c
* \brief dual thread for pdsch * \brief parameterized dual thread 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 13-05-2020 * \date 13-05-2020
* \version 2.1 * \version 2.2
* \note * \note
* \warning * \warning
*/ */
//[START]multi_genetate_pdsch_proc //[START]multi_genetate_pdsch_proc
struct timespec start_encoder_ts[2], end_encoder_ts[2], start_perenc_ts[2], end_perenc_ts[2]; 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];
//int thread_num_pdsch = 2; //Craete 2 threads for temp
// int ifRand = 0; // int ifRand = 0;
int vcd = 0; int vcd = 0;
static void *multi_genetate_pdsch_proc(void *ptr){ static void *multi_genetate_pdsch_proc(void *ptr){
...@@ -323,9 +334,14 @@ static void *multi_genetate_pdsch_proc(void *ptr){ ...@@ -323,9 +334,14 @@ static void *multi_genetate_pdsch_proc(void *ptr){
// ldpc_enc[test->id].block_length, // ldpc_enc[test->id].block_length,
// ldpc_enc[test->id].n_segments); // ldpc_enc[test->id].n_segments);
int j_start, j_end; int j_start, j_end; //Check if our situation((n_segments > 7)&(thread_num_pdsch == 2))
if((gNB->multi_encoder[test->id].n_segments > 7)&&(thread_num_pdsch == 2)){
j_start = test->id;
j_end = j_start + 1;
}else{
j_start = 0; j_start = 0;
j_end = (gNB->multi_encoder[test->id].n_segments/8+1); j_end = (gNB->multi_encoder[test->id].n_segments/8+1);
}
int offset = test->id>7?7:test->id; int offset = test->id>7?7:test->id;
//printf("[OFFSET] : %d %d\n", offset, test->id); //printf("[OFFSET] : %d %d\n", offset, test->id);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MULTI_ENC_0 + offset,1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MULTI_ENC_0 + offset,1);
...@@ -1051,7 +1067,7 @@ int main(int argc, char **argv) ...@@ -1051,7 +1067,7 @@ int main(int argc, char **argv)
// } // }
//[START]multi_genetate_pdsch_proc:create thread //[START]multi_genetate_pdsch_proc:create thread
for(int th=0;th<2;th++){ for(int th=0;th<thread_num_pdsch;th++){
pthread_attr_init(&(gNB->multi_encoder[th].attr)); pthread_attr_init(&(gNB->multi_encoder[th].attr));
pthread_mutex_init(&(gNB->multi_encoder[th].mutex), NULL); pthread_mutex_init(&(gNB->multi_encoder[th].mutex), NULL);
pthread_mutex_init(&(gNB->multi_encoder[th].mutex_scr_mod), NULL); pthread_mutex_init(&(gNB->multi_encoder[th].mutex_scr_mod), NULL);
...@@ -1429,7 +1445,7 @@ int main(int argc, char **argv) ...@@ -1429,7 +1445,7 @@ int main(int argc, char **argv)
//[START]Send Kill massage //[START]Send Kill massage
oai_exit = 1; // ==We should do for threading ==*** oai_exit = 1; // ==We should do for threading ==***
printf("Kill them all!\n"); printf("Kill them all!\n");
for(int th=0; th<2; th++){ for(int th=0; th<thread_num_pdsch; th++){
pthread_cond_signal(&(gNB->multi_encoder[th].cond)); pthread_cond_signal(&(gNB->multi_encoder[th].cond));
} }
//[END]Send Kill massage //[END]Send Kill massage
......
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