Commit 22e7b1e6 authored by Wang Tsu-Han's avatar Wang Tsu-Han

extending dlsch_coding into four thread

parent 79b11d6b
...@@ -291,7 +291,7 @@ int dlsch_encoding_2threads0(te_params *tep) { ...@@ -291,7 +291,7 @@ int dlsch_encoding_2threads0(te_params *tep) {
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
for (r=0; r<dlsch->harq_processes[harq_pid]->C/3; r++) { for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus) if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus; Kr = dlsch->harq_processes[harq_pid]->Kminus;
...@@ -334,7 +334,7 @@ int dlsch_encoding_2threads0(te_params *tep) { ...@@ -334,7 +334,7 @@ int dlsch_encoding_2threads0(te_params *tep) {
// Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the
// outputs for each code segment, see Section 5.1.5 p.20 // outputs for each code segment, see Section 5.1.5 p.20
for (r=0; r<dlsch->harq_processes[harq_pid]->C/3; r++) { for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) {
r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r],
G, //G G, //G
dlsch->harq_processes[harq_pid]->w[r], dlsch->harq_processes[harq_pid]->w[r],
...@@ -373,7 +373,7 @@ int dlsch_encoding_2threads1(te_params *tep) { ...@@ -373,7 +373,7 @@ int dlsch_encoding_2threads1(te_params *tep) {
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
for (r=dlsch->harq_processes[harq_pid]->C/3; r<dlsch->harq_processes[harq_pid]->C/3*2; r++) { for (r=(dlsch->harq_processes[harq_pid]->C>>2); r<(dlsch->harq_processes[harq_pid]->C>>1); r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus) if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus; Kr = dlsch->harq_processes[harq_pid]->Kminus;
...@@ -416,8 +416,103 @@ int dlsch_encoding_2threads1(te_params *tep) { ...@@ -416,8 +416,103 @@ int dlsch_encoding_2threads1(te_params *tep) {
// Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the
// outputs for each code segment, see Section 5.1.5 p.20 // outputs for each code segment, see Section 5.1.5 p.20
for (r=0,r_offset=0; r<dlsch->harq_processes[harq_pid]->C/3*2; r++) { for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>1); r++) {
if(r<(dlsch->harq_processes[harq_pid]->C/3)){ if(r<(dlsch->harq_processes[harq_pid]->C>>2)){
int Nl=dlsch->harq_processes[harq_pid]->Nl;
int Qm=dlsch->harq_processes[harq_pid]->Qm;
int C = dlsch->harq_processes[harq_pid]->C;
int Gp = G/Nl/Qm;
int GpmodC = Gp%C;
if (r < (C-(GpmodC)))
r_offset += Nl*Qm * (Gp/C);
else
r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C));
}
else{
r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r],
G, //G
dlsch->harq_processes[harq_pid]->w[r],
dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->C, // C
dlsch->Nsoft, // Nsoft,
dlsch->Mdlharq,
dlsch->Kmimo,
dlsch->harq_processes[harq_pid]->rvidx,
dlsch->harq_processes[harq_pid]->Qm,
dlsch->harq_processes[harq_pid]->Nl,
r,
nb_rb);
// m); // r
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT);
return(0);
}
int dlsch_encoding_2threads2(te_params *tep) {
LTE_eNB_DLSCH_t *dlsch = tep->dlsch;
unsigned int G = tep->G;
unsigned char harq_pid = tep->harq_pid;
unsigned short iind;
unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb;
unsigned int Kr=0,Kr_bytes,r,r_offset=0;
// unsigned short m=dlsch->harq_processes[harq_pid]->mcs;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN);
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
for (r=(dlsch->harq_processes[harq_pid]->C>>1); r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
else
Kr = dlsch->harq_processes[harq_pid]->Kplus;
Kr_bytes = Kr>>3;
// get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14)
if (Kr_bytes<=64)
iind = (Kr_bytes-5);
else if (Kr_bytes <=128)
iind = 59 + ((Kr_bytes-64)>>1);
else if (Kr_bytes <= 256)
iind = 91 + ((Kr_bytes-128)>>2);
else if (Kr_bytes <= 768)
iind = 123 + ((Kr_bytes-256)>>3);
else {
printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes);
return(-1);
}
threegpplte_turbo_encoder(dlsch->harq_processes[harq_pid]->c[r],
Kr>>3,
&dlsch->harq_processes[harq_pid]->d[r][96],
(r==0) ? dlsch->harq_processes[harq_pid]->F : 0,
f1f2mat_old[iind*2], // f1 (see 36121-820, page 14)
f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14)
);
dlsch->harq_processes[harq_pid]->RTC[r] =
sub_block_interleaving_turbo(4+(Kr_bytes*8),
&dlsch->harq_processes[harq_pid]->d[r][96],
dlsch->harq_processes[harq_pid]->w[r]);
}
}
// Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the
// outputs for each code segment, see Section 5.1.5 p.20
for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) {
if(r<(dlsch->harq_processes[harq_pid]->C>>1)){
int Nl=dlsch->harq_processes[harq_pid]->Nl; int Nl=dlsch->harq_processes[harq_pid]->Nl;
int Qm=dlsch->harq_processes[harq_pid]->Qm; int Qm=dlsch->harq_processes[harq_pid]->Qm;
int C = dlsch->harq_processes[harq_pid]->C; int C = dlsch->harq_processes[harq_pid]->C;
...@@ -529,6 +624,41 @@ void *te_thread1(void *param) { ...@@ -529,6 +624,41 @@ void *te_thread1(void *param) {
return(NULL); return(NULL);
} }
void *te_thread2(void *param) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
thread_top_init("te_thread2",1,200000,250000,500000);
pthread_setname_np( pthread_self(),"te processing 2");
LOG_I(PHY,"thread te 2 created id=%ld\n", syscall(__NR_gettid));
//CPU_SET(7, &cpuset);
//pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
PHY_VARS_eNB *eNB = ((te_params *)param)->eNB;
eNB_proc_t *proc = &eNB->proc;
time_stats_t *te_wakeup_stats1 = &eNB->dlsch_turbo_encoding_wakeup_stats1;
while (!oai_exit) {
if (wait_on_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break;
//stop_meas(te_wakeup_stats1);
dlsch_encoding_2threads1((te_params*)param);
if (release_thread(&proc->mutex_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break;
if (pthread_cond_signal(&proc->cond_te[2]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return(NULL);
}
}
return(NULL);
}
int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
unsigned char *a, unsigned char *a,
uint8_t num_pdcch_symbols, uint8_t num_pdcch_symbols,
...@@ -611,7 +741,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ...@@ -611,7 +741,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
pthread_mutex_unlock( &proc->mutex_te[0] ); pthread_mutex_unlock( &proc->mutex_te[0] );
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
if (proc->instance_cnt_te[1]==0) { if (proc->instance_cnt_te[1]==0) {
printf("[eNB] TE thread busy\n"); printf("[eNB] TE thread busy\n");
exit_fun("TE thread busy"); exit_fun("TE thread busy");
pthread_mutex_unlock( &proc->mutex_te[1] ); pthread_mutex_unlock( &proc->mutex_te[1] );
...@@ -635,7 +765,32 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ...@@ -635,7 +765,32 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
pthread_mutex_unlock( &proc->mutex_te[1] ); pthread_mutex_unlock( &proc->mutex_te[1] );
for (r=dlsch->harq_processes[harq_pid]->C/3*2; r<dlsch->harq_processes[harq_pid]->C; r++) { ////////////////////////////////////////////////////////////////
if (proc->instance_cnt_te[2]==0) {
printf("[eNB] TE thread busy\n");
exit_fun("TE thread busy");
pthread_mutex_unlock( &proc->mutex_te[2] );
return(-1);
}
++proc->instance_cnt_te[2];
proc->tep[2].eNB = eNB;
proc->tep[2].dlsch = dlsch;
proc->tep[2].G = G;
proc->tep[2].harq_pid = harq_pid;
// wakeup worker to do second half segments
if (pthread_cond_signal(&proc->cond_te[2]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return (-1);
}
pthread_mutex_unlock( &proc->mutex_te[2] );
////////////////////////////////////////////////////////////////
for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; r<dlsch->harq_processes[harq_pid]->C; r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus) if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus; Kr = dlsch->harq_processes[harq_pid]->Kminus;
...@@ -707,7 +862,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ...@@ -707,7 +862,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
for (r=0,r_offset=0; r<dlsch->harq_processes[harq_pid]->C; r++) { for (r=0,r_offset=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
// get information for E for the segments that are handled by the worker thread // get information for E for the segments that are handled by the worker thread
if (r<(dlsch->harq_processes[harq_pid]->C/3*2)) { if (r<(dlsch->harq_processes[harq_pid]->C>>2)*3) {
int Nl=dlsch->harq_processes[harq_pid]->Nl; int Nl=dlsch->harq_processes[harq_pid]->Nl;
int Qm=dlsch->harq_processes[harq_pid]->Qm; int Qm=dlsch->harq_processes[harq_pid]->Qm;
int C = dlsch->harq_processes[harq_pid]->C; int C = dlsch->harq_processes[harq_pid]->C;
...@@ -742,6 +897,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ...@@ -742,6 +897,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
start_meas(te_wait_stats); start_meas(te_wait_stats);
wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread");
wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1");
wait_on_busy_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread2");
stop_meas(te_wait_stats); stop_meas(te_wait_stats);
if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){
print_meas_now(te_wait_stats,"coding_wait",stderr); print_meas_now(te_wait_stats,"coding_wait",stderr);
......
...@@ -471,7 +471,7 @@ typedef struct eNB_proc_t_s { ...@@ -471,7 +471,7 @@ typedef struct eNB_proc_t_s {
/// \internal This variable is protected by \ref mutex_td. /// \internal This variable is protected by \ref mutex_td.
int instance_cnt_td; int instance_cnt_td;
/// \internal This variable is protected by \ref mutex_te. /// \internal This variable is protected by \ref mutex_te.
int instance_cnt_te[2]; int instance_cnt_te[3];
/// \internal This variable is protected by \ref mutex_prach. /// \internal This variable is protected by \ref mutex_prach.
int instance_cnt_prach; int instance_cnt_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -493,7 +493,7 @@ typedef struct eNB_proc_t_s { ...@@ -493,7 +493,7 @@ typedef struct eNB_proc_t_s {
/// pthread attributes for parallel turbo-decoder thread /// pthread attributes for parallel turbo-decoder thread
pthread_attr_t attr_td; pthread_attr_t attr_td;
/// pthread attributes for parallel turbo-encoder thread /// pthread attributes for parallel turbo-encoder thread
pthread_attr_t attr_te[2]; pthread_attr_t attr_te[3];
/// pthread attributes for single eNB processing thread /// pthread attributes for single eNB processing thread
pthread_attr_t attr_single; pthread_attr_t attr_single;
/// pthread attributes for prach processing thread /// pthread attributes for prach processing thread
...@@ -507,7 +507,7 @@ typedef struct eNB_proc_t_s { ...@@ -507,7 +507,7 @@ typedef struct eNB_proc_t_s {
/// scheduling parameters for parallel turbo-decoder thread /// scheduling parameters for parallel turbo-decoder thread
struct sched_param sched_param_td; struct sched_param sched_param_td;
/// scheduling parameters for parallel turbo-encoder thread /// scheduling parameters for parallel turbo-encoder thread
struct sched_param sched_param_te[2]; struct sched_param sched_param_te[3];
/// scheduling parameters for single eNB thread /// scheduling parameters for single eNB thread
struct sched_param sched_param_single; struct sched_param sched_param_single;
/// scheduling parameters for prach thread /// scheduling parameters for prach thread
...@@ -521,7 +521,7 @@ typedef struct eNB_proc_t_s { ...@@ -521,7 +521,7 @@ typedef struct eNB_proc_t_s {
/// pthread structure for parallel turbo-decoder thread /// pthread structure for parallel turbo-decoder thread
pthread_t pthread_td; pthread_t pthread_td;
/// pthread structure for parallel turbo-encoder thread /// pthread structure for parallel turbo-encoder thread
pthread_t pthread_te[2]; pthread_t pthread_te[3];
/// pthread structure for PRACH thread /// pthread structure for PRACH thread
pthread_t pthread_prach; pthread_t pthread_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -531,7 +531,7 @@ typedef struct eNB_proc_t_s { ...@@ -531,7 +531,7 @@ typedef struct eNB_proc_t_s {
/// condition variable for parallel turbo-decoder thread /// condition variable for parallel turbo-decoder thread
pthread_cond_t cond_td; pthread_cond_t cond_td;
/// condition variable for parallel turbo-encoder thread /// condition variable for parallel turbo-encoder thread
pthread_cond_t cond_te[2]; pthread_cond_t cond_te[3];
/// condition variable for PRACH processing thread; /// condition variable for PRACH processing thread;
pthread_cond_t cond_prach; pthread_cond_t cond_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -543,7 +543,7 @@ typedef struct eNB_proc_t_s { ...@@ -543,7 +543,7 @@ typedef struct eNB_proc_t_s {
/// mutex for parallel turbo-decoder thread /// mutex for parallel turbo-decoder thread
pthread_mutex_t mutex_td; pthread_mutex_t mutex_td;
/// mutex for parallel turbo-encoder thread /// mutex for parallel turbo-encoder thread
pthread_mutex_t mutex_te[2]; pthread_mutex_t mutex_te[3];
/// mutex for PRACH thread /// mutex for PRACH thread
pthread_mutex_t mutex_prach; pthread_mutex_t mutex_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -569,7 +569,7 @@ typedef struct eNB_proc_t_s { ...@@ -569,7 +569,7 @@ typedef struct eNB_proc_t_s {
/// parameters for turbo-decoding worker thread /// parameters for turbo-decoding worker thread
td_params tdp; td_params tdp;
/// parameters for turbo-encoding worker thread /// parameters for turbo-encoding worker thread
te_params tep[2]; te_params tep[3];
/// set of scheduling variables RXn-TXnp4 threads /// set of scheduling variables RXn-TXnp4 threads
eNB_rxtx_proc_t proc_rxtx[2]; eNB_rxtx_proc_t proc_rxtx[2];
/// stats thread pthread descriptor /// stats thread pthread descriptor
......
...@@ -1507,6 +1507,7 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { ...@@ -1507,6 +1507,7 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) {
extern void *te_thread(void*); extern void *te_thread(void*);
extern void *te_thread1(void*); extern void *te_thread1(void*);
extern void *te_thread2(void*);
void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *attr_te1) { void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *attr_te1) {
...@@ -1530,7 +1531,16 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *at ...@@ -1530,7 +1531,16 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *at
printf("Creating te_thread1\n"); printf("Creating te_thread1\n");
pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]); pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]);
/////////////////////////////////////////////////////////////////////////
proc->tep[2].eNB = eNB;
proc->instance_cnt_te[2] = -1;
pthread_mutex_init( &proc->mutex_te[2], NULL);
pthread_cond_init( &proc->cond_te[2], NULL);
printf("Creating te_thread2\n");
pthread_create(&proc->pthread_te[2], attr_te1, te_thread2, (void*)&proc->tep[2]);
} }
......
...@@ -1472,7 +1472,7 @@ static void* ru_thread( void* param ) { ...@@ -1472,7 +1472,7 @@ static void* ru_thread( void* param ) {
// set default return value // set default return value
thread_top_init("ru_thread",0,400000,500000,500000); thread_top_init("ru_thread",1,400000,500000,500000);
//CPU_SET(1, &cpuset); //CPU_SET(1, &cpuset);
//pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
......
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