Commit d459b33e authored by Florian Kaltenberger's avatar Florian Kaltenberger

Merge branch 'RU-RAU-split-parallel-EMUFH' into gNB_mwc18_integration

Conflicts:
	openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
parents 7d144d26 30d5f151
......@@ -1275,6 +1275,7 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms)
generate_64qam_table();
generate_16qam_table();
generate_qpsk_table();
generate_RIV_tables();
init_unscrambling_lut();
......
......@@ -280,6 +280,8 @@ int dlsch_encoding_2threads0(te_params *tep) {
LTE_eNB_DLSCH_t *dlsch = tep->dlsch;
unsigned int G = tep->G;
unsigned char harq_pid = tep->harq_pid;
unsigned int total_worker = tep->total_worker;
unsigned int current_worker = tep->current_worker;
unsigned short iind;
......@@ -292,7 +294,7 @@ int dlsch_encoding_2threads0(te_params *tep) {
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) {
for (r=(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*current_worker; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
......@@ -335,90 +337,8 @@ 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
// outputs for each code segment, see Section 5.1.5 p.20
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],
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_2threads1(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>>2); r<(dlsch->harq_processes[harq_pid]->C>>1); 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>>1); r++) {
if(r<(dlsch->harq_processes[harq_pid]->C>>2)){
for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) {
if(r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker)){
int Nl=dlsch->harq_processes[harq_pid]->Nl;
int Qm=dlsch->harq_processes[harq_pid]->Qm;
int C = dlsch->harq_processes[harq_pid]->C;
......@@ -452,100 +372,6 @@ int dlsch_encoding_2threads1(te_params *tep) {
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 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);
}
extern int oai_exit;
void *te_thread(void *param) {
......@@ -556,25 +382,20 @@ void *te_thread(void *param) {
pthread_setname_np( pthread_self(),"te processing");
LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid));
CPU_SET(4, &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;
te_params *tep = (te_params *)param;
wait_sync("te_thread");
while (!oai_exit) {
if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break;
if (wait_on_condition(&tep->mutex_te,&tep->cond_te,&tep->instance_cnt_te,"te thread")<0) break;
start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0);
dlsch_encoding_2threads0((te_params*)param);
stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0);
dlsch_encoding_2threads0(tep);
if (release_thread(&proc->mutex_te[0],&proc->instance_cnt_te[0],"te thread")<0) break;
if (release_thread(&tep->mutex_te,&tep->instance_cnt_te,"te thread")<0) break;
if (pthread_cond_signal(&proc->cond_te[0]) != 0) {
if (pthread_cond_signal(&tep->cond_te) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return(NULL);
......@@ -588,83 +409,7 @@ void *te_thread(void *param) {
return(NULL);
}
void *te_thread1(void *param) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
thread_top_init("te_thread1",1,200000,250000,500000);
pthread_setname_np( pthread_self(),"te processing 1");
LOG_I(PHY,"thread te 1 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;
wait_sync("te_thread1");
while (!oai_exit) {
if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break;
start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1);
dlsch_encoding_2threads1((te_params*)param);
stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1);
if (release_thread(&proc->mutex_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break;
if (pthread_cond_signal(&proc->cond_te[1]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return(NULL);
}
/*if(opp_enabled == 1 && te_wakeup_stats1->diff_now>50*3000){
print_meas_now(te_wakeup_stats1,"coding_wakeup",stderr);
printf("te_thread1 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx);
}*/
}
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(8, &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;
wait_sync("te_thread2");
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_2threads2((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,
unsigned char *a,
......@@ -678,7 +423,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
time_stats_t *te_main_stats,
time_stats_t *te_wakeup_stats0,
time_stats_t *te_wakeup_stats1,
time_stats_t *i_stats)
time_stats_t *i_stats,
int worker_num)
{
//start_meas(&eNB->dlsch_turbo_encoding_preperation_stats);
......@@ -708,13 +454,14 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
// Add 24-bit crc (polynomial A) to payload
crc = crc24a(a,
A)>>8;
stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats);
a[A>>3] = ((uint8_t*)&crc)[2];
a[1+(A>>3)] = ((uint8_t*)&crc)[1];
a[2+(A>>3)] = ((uint8_t*)&crc)[0];
dlsch->harq_processes[harq_pid]->B = A+24;
memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4);
stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats);
//stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats);
start_meas(&eNB->dlsch_turbo_encoding_segmentation_stats);
if (lte_segmentation(dlsch->harq_processes[harq_pid]->b,
......@@ -730,87 +477,39 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats);
proc->tep[0].eNB = eNB;
proc->tep[0].dlsch = dlsch;
proc->tep[0].G = G;
proc->tep[0].harq_pid = harq_pid;
proc->tep[1].eNB = eNB;
proc->tep[1].dlsch = dlsch;
proc->tep[1].G = G;
proc->tep[1].harq_pid = harq_pid;
proc->tep[2].eNB = eNB;
proc->tep[2].dlsch = dlsch;
proc->tep[2].G = G;
proc->tep[2].harq_pid = harq_pid;
start_meas(&eNB->dlsch_turbo_encoding_signal_stats);
pthread_mutex_lock( &proc->mutex_te[0] );
if (proc->instance_cnt_te[0]==0) {
printf("[eNB] TE thread busy\n");
exit_fun("TE thread busy");
pthread_mutex_unlock( &proc->mutex_te[0] );
return(-1);
}
++proc->instance_cnt_te[0];
// wakeup worker to do second half segments
if (pthread_cond_signal(&proc->cond_te[0]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return (-1);
}
//start_meas(te_wakeup_stats0);
pthread_mutex_unlock( &proc->mutex_te[0] );
////////////////////////////////////////////////////////////////
pthread_mutex_lock( &proc->mutex_te[1] );
if (proc->instance_cnt_te[1]==0) {
for(int i=0;i<worker_num;i++)
{
proc->tep[i].eNB = eNB;
proc->tep[i].dlsch = dlsch;
proc->tep[i].G = G;
proc->tep[i].harq_pid = harq_pid;
proc->tep[i].total_worker = worker_num;
proc->tep[i].current_worker = i;
pthread_mutex_lock( &proc->tep[i].mutex_te );
if (proc->tep[i].instance_cnt_te==0) {
printf("[eNB] TE thread busy\n");
exit_fun("TE thread busy");
pthread_mutex_unlock( &proc->mutex_te[1] );
pthread_mutex_unlock( &proc->tep[i].mutex_te );
return(-1);
}
++proc->instance_cnt_te[1];
++proc->tep[i].instance_cnt_te;
// wakeup worker to do second half segments
if (pthread_cond_signal(&proc->cond_te[1]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
// wakeup worker to do segments
if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread %d exit\n",i);
exit_fun( "ERROR pthread_cond_signal" );
return (-1);
}
//start_meas(te_wakeup_stats1);
pthread_mutex_unlock( &proc->mutex_te[1] );
////////////////////////////////////////////////////////////////
pthread_mutex_lock( &proc->mutex_te[2] );
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];
// 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->tep[i].mutex_te );
}
pthread_mutex_unlock( &proc->mutex_te[2] );
////////////////////////////////////////////////////////////////
stop_meas(&eNB->dlsch_turbo_encoding_signal_stats);
start_meas(te_main_stats);
for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; r<dlsch->harq_processes[harq_pid]->C; r++) {
for (r=(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num; r<dlsch->harq_processes[harq_pid]->C; r++) {
if (r<dlsch->harq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
......@@ -855,33 +554,18 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
}
else {
proc->tep[0].eNB = eNB;
proc->tep[0].dlsch = dlsch;
proc->tep[0].G = G;
proc->tep[1].eNB = eNB;
proc->tep[1].dlsch = dlsch;
proc->tep[1].G = G;
proc->tep[2].eNB = eNB;
proc->tep[2].dlsch = dlsch;
proc->tep[2].G = G;
// wakeup worker to do second half segments
if (pthread_cond_signal(&proc->cond_te[0]) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return (-1);
}
if (pthread_cond_signal(&proc->cond_te[1]) != 0) {
for(int i=0;i<worker_num;i++)
{
proc->tep[i].eNB = eNB;
proc->tep[i].dlsch = dlsch;
proc->tep[i].G = G;
proc->tep[i].total_worker = worker_num;
proc->tep[i].current_worker = i;
if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) {
printf("[eNB] ERROR pthread_cond_signal for te thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return (-1);
}
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);
}
}
......@@ -891,7 +575,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
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
if (r<(dlsch->harq_processes[harq_pid]->C>>2)*3) {
if (r<(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num) {
int Nl=dlsch->harq_processes[harq_pid]->Nl;
int Qm=dlsch->harq_processes[harq_pid]->Qm;
int C = dlsch->harq_processes[harq_pid]->C;
......@@ -925,9 +609,9 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
// wait for worker to finish
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[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");
wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0");
wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1");
wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2");
stop_meas(te_wait_stats);
if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){
print_meas_now(te_wait_stats,"coding_wait",stderr);
......@@ -956,7 +640,6 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
int encoding_return = 0;
unsigned int L,C,B;
B = dlsch->harq_processes[dlsch->harq_ids[subframe]]->B;
//printf("total bit length is %d\n",B);///////////*******
if(B<=6144)
{
L=0;
......@@ -972,7 +655,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
}
}
if(0/*C >= 5*/)
if(0/*C >= 8&&get_nprocs()>=6*/)//one main three worker
{
encoding_return =
dlsch_encoding_2threads(eNB,
......@@ -987,7 +670,44 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
te_main_stats,
te_wakeup_stats0,
te_wakeup_stats1,
i_stats);
i_stats,
3);
}
else if(C >= 6&&get_nprocs()>=4)//one main two worker
{
encoding_return =
dlsch_encoding_2threads(eNB,
a,
num_pdcch_symbols,
dlsch,
frame,
subframe,
rm_stats,
te_stats,
te_wait_stats,
te_main_stats,
te_wakeup_stats0,
te_wakeup_stats1,
i_stats,
2);
}
else if(C >= 4&&get_nprocs()>=2)//one main one worker
{
encoding_return =
dlsch_encoding_2threads(eNB,
a,
num_pdcch_symbols,
dlsch,
frame,
subframe,
rm_stats,
te_stats,
te_wait_stats,
te_main_stats,
te_wakeup_stats0,
te_wakeup_stats1,
i_stats,
1);
}
else
{
......
......@@ -121,6 +121,16 @@ void generate_16qam_table(void)
}
}
void generate_qpsk_table(void)
{
int a,index;
for (a=-1; a<=1; a+=2)
index = (1+a)/2;
qpsk_table[index] = -a*QPSK;
}
......@@ -158,6 +168,158 @@ void layer1prec2A(int32_t *antenna0_sample, int32_t *antenna1_sample, uint8_t pr
uint32_t FOUR[2]={0,4};
uint32_t TWO[2]={0,2};
int allocate_REs_in_RB_no_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB,
int **txdataF,
uint32_t *jj,
uint32_t *jj2,
uint16_t re_offset,
uint32_t symbol_offset,
LTE_DL_eNB_HARQ_t *dlsch0_harq,
LTE_DL_eNB_HARQ_t *dlsch1_harq,
uint8_t pilots,
int16_t amp,
uint8_t precoder_index,
int16_t *qam_table_s0,
int16_t *qam_table_s1,
uint32_t *re_allocated,
uint8_t skip_dc,
uint8_t skip_half,
uint8_t lprime,
uint8_t mprime,
uint8_t Ns,
int *P1_SHIFT,
int *P2_SHIFT)
{
LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms;
uint8_t *x0 = dlsch0_harq->e;
uint32_t qpsk_table_offset_re = 0;
uint32_t qpsk_table_offset_im = 0;
uint32_t tti_offset;
uint8_t re;
uint8_t *x0p;
if (skip_dc == 0) {
for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0;
re<12;
re++,x0p+=2,tti_offset++) {
qpsk_table_offset_re=x0p[0];
qpsk_table_offset_im=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
}
}
else {
// 1st half of PRB
for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0;
re<6;
re++,x0p+=2,tti_offset++) {
qpsk_table_offset_re=x0p[0];
qpsk_table_offset_im=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
}
// 2nd half of PRB
for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+7;
re<12;
re++,x0p+=2,tti_offset++) {
qpsk_table_offset_re=x0p[0];
qpsk_table_offset_im=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
}
}
*re_allocated = *re_allocated + 12;
*jj=*jj + 24;
return(0);
}
int allocate_REs_in_RB_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB,
int **txdataF,
uint32_t *jj,
uint32_t *jj2,
uint16_t re_offset,
uint32_t symbol_offset,
LTE_DL_eNB_HARQ_t *dlsch0_harq,
LTE_DL_eNB_HARQ_t *dlsch1_harq,
uint8_t pilots,
int16_t amp,
uint8_t precoder_index,
int16_t *qam_table_s0,
int16_t *qam_table_s1,
uint32_t *re_allocated,
uint8_t skip_dc,
uint8_t skip_half,
uint8_t lprime,
uint8_t mprime,
uint8_t Ns,
int *P1_SHIFT,
int *P2_SHIFT)
{
LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms;
uint8_t *x0 = dlsch0_harq->e;
uint32_t qpsk_table_offset_re = 0;
uint32_t qpsk_table_offset_im = 0;
uint32_t tti_offset;
uint8_t re;
uint8_t *x0p;
if (skip_dc == 0) {
// printf("pilots: P1_SHIFT[0] %d\n",P1_SHIFT[0]);
for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0];
re<12;
x0p+=2) {
qpsk_table_offset_re=x0p[0];
qpsk_table_offset_im=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
// printf("pilots: re %d, tti_offset %d, P1_SHIFT %d\n",re,tti_offset,P1_SHIFT[re+1]);
tti_offset+=P1_SHIFT[re+1];
re+=P1_SHIFT[re+1];
}
}
else {
for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0];
re<6;
x0p+=2) {
qpsk_table_offset_re+=x0p[0];
qpsk_table_offset_im+=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
tti_offset+=P1_SHIFT[re+1];
re+=P1_SHIFT[re+1];
}
for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+6+P1_SHIFT[6];
re<12;
x0p+=2) {
qpsk_table_offset_re+=x0p[0];
qpsk_table_offset_im+=x0p[1];
((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re];
((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im];
tti_offset+=P1_SHIFT[re+1];
re+=P1_SHIFT[re+1];
}
}
*re_allocated = *re_allocated + 10;
*jj=*jj + 20;
return(0);
}
int allocate_REs_in_RB_no_pilots_16QAM_siso(PHY_VARS_eNB* phy_vars_eNB,
int **txdataF,
uint32_t *jj,
......@@ -2012,8 +2174,8 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
uint8_t mod_order0 = 0;
uint8_t mod_order1 = 0;
int16_t amp_rho_a, amp_rho_b;
int16_t qam16_table_a0[4],qam64_table_a0[8],qam16_table_b0[4],qam64_table_b0[8];
int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8];
int16_t qpsk_table_a0[2],qam16_table_a0[4],qam64_table_a0[8],qpsk_table_b0[2],qam16_table_b0[4],qam64_table_b0[8];
int16_t qpsk_table_a1[2],qam16_table_a1[4],qam64_table_a1[8],qpsk_table_b1[2],qam16_table_b1[4],qam64_table_b1[8];
int16_t *qam_table_s0=NULL,*qam_table_s1=NULL;
#ifdef NEW_ALLOC_RE
......@@ -2126,7 +2288,15 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
amp_rho_b = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_b)>>13);
}
if (mod_order0 == 4)
if(mod_order0 == 2)
{
for(i=0;i<2;i++)
{
qpsk_table_a0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15);
qpsk_table_b0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15);
}
}
else if (mod_order0 == 4)
for (i=0;i<4; i++) {
qam16_table_a0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15);
qam16_table_b0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15);
......@@ -2137,7 +2307,14 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
qam64_table_b0[i] = (int16_t)(((int32_t)qam64_table[i]*amp_rho_b)>>15);
}
if (mod_order1 == 4)
if (mod_order1 == 2)
{
for (i=0; i<2; i++) {
qpsk_table_a1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15);
qpsk_table_b1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15);
}
}
else if (mod_order1 == 4)
for (i=0; i<4; i++) {
qam16_table_a1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15);
qam16_table_b1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15);
......@@ -2265,7 +2442,26 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
switch (mod_order0) {
case 2:
qam_table_s0 = NULL;
//qam_table_s0 = NULL;
if (pilots) {
qam_table_s0 = qpsk_table_b0;
#ifdef NEW_ALLOC_RE
/* TODO: remove this code? */
allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ?
allocate_REs_in_RB_pilots_QPSK_siso :
allocate_REs_in_RB;
#endif
}
else {
qam_table_s0 = qpsk_table_a0;
#ifdef NEW_ALLOC_RE
/* TODO: remove this code? */
allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ?
allocate_REs_in_RB_no_pilots_QPSK_siso :
allocate_REs_in_RB;
#endif
}
break;
case 4:
if (pilots) {
......
......@@ -30,7 +30,7 @@ extern short *ul_ref_sigs_rx[30][2][33];
extern unsigned short dftsizes[33];
extern unsigned short ref_primes[33];
extern int qam64_table[8],qam16_table[4];
extern int qam64_table[8],qam16_table[4],qpsk_table[2];
extern unsigned char cs_ri_normal[4];
extern unsigned char cs_ri_extended[4];
......
......@@ -183,7 +183,8 @@ int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
time_stats_t *te_main_stats,
time_stats_t *te_wakeup_stats0,
time_stats_t *te_wakeup_stats1,
time_stats_t *i_stats);
time_stats_t *i_stats,
int worker_num);
void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB,
uint8_t *DLSCH_pdu,
......
......@@ -62,7 +62,7 @@ unsigned char ue_power_offsets[25] = {14,11,9,8,7,6,6,5,4,4,4,3,3,3,2,2,2,1,1,1,
short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1};
short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
int qam64_table[8],qam16_table[4];
int qam64_table[8],qam16_table[4],qpsk_table[2];
unsigned char cs_ri_normal[4] = {1,4,7,10};
unsigned char cs_ri_extended[4] = {0,3,5,8};
......
......@@ -279,6 +279,20 @@ typedef struct {
LTE_eNB_DLSCH_t *dlsch;
int G;
int harq_pid;
int total_worker;
int current_worker;
/// \internal This variable is protected by \ref mutex_te.
int instance_cnt_te;
/// pthread attributes for parallel turbo-encoder thread
pthread_attr_t attr_te;
/// scheduling parameters for parallel turbo-encoder thread
struct sched_param sched_param_te;
/// pthread structure for parallel turbo-encoder thread
pthread_t pthread_te;
/// condition variable for parallel turbo-encoder thread
pthread_cond_t cond_te;
/// mutex for parallel turbo-encoder thread
pthread_mutex_t mutex_te;
} te_params;
typedef struct RU_proc_t_s {
......
......@@ -207,6 +207,9 @@
// QAM amplitude definitions
/// Amplitude for QPSK (\f$ 2^15 \times 1/\sqrt{2}\f$)
#define QPSK 23170
/// First Amplitude for QAM16 (\f$ 2^{15} \times 2/\sqrt{10}\f$)
#define QAM16_n1 20724
/// Second Amplitude for QAM16 (\f$ 2^{15} \times 1/\sqrt{10}\f$)
......
......@@ -1509,41 +1509,42 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) {
}
extern void *te_thread(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) {
eNB_proc_t *proc = &eNB->proc;
proc->tep[0].eNB = eNB;
proc->instance_cnt_te[0] = -1;
proc->tep[0].instance_cnt_te = -1;
pthread_mutex_init( &proc->mutex_te[0], NULL);
pthread_cond_init( &proc->cond_te[0], NULL);
pthread_mutex_init( &proc->tep[0].mutex_te, NULL);
pthread_cond_init( &proc->tep[0].cond_te, NULL);
pthread_attr_init( &proc->tep[0].attr_te);
printf("Creating te_thread\n");
pthread_create(&proc->pthread_te[0], attr_te, te_thread, (void*)&proc->tep[0]);
printf("Creating te_thread 0\n");
pthread_create(&proc->tep[0].pthread_te, &proc->tep[0].attr_te, te_thread, (void*)&proc->tep[0]);
/////////////////////////////////////////////////////////////////////////
proc->tep[1].eNB = eNB;
proc->instance_cnt_te[1] = -1;
proc->tep[1].instance_cnt_te = -1;
pthread_mutex_init( &proc->mutex_te[1], NULL);
pthread_cond_init( &proc->cond_te[1], NULL);
pthread_mutex_init( &proc->tep[1].mutex_te, NULL);
pthread_cond_init( &proc->tep[1].cond_te, NULL);
pthread_attr_init( &proc->tep[1].attr_te);
printf("Creating te_thread1\n");
pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]);
printf("Creating te_thread 1\n");
pthread_create(&proc->tep[1].pthread_te, &proc->tep[1].attr_te, te_thread, (void*)&proc->tep[1]);
/////////////////////////////////////////////////////////////////////////
proc->tep[2].eNB = eNB;
proc->instance_cnt_te[2] = -1;
proc->tep[2].instance_cnt_te = -1;
pthread_mutex_init( &proc->mutex_te[2], NULL);
pthread_cond_init( &proc->cond_te[2], NULL);
pthread_mutex_init( &proc->tep[2].mutex_te, NULL);
pthread_cond_init( &proc->tep[2].cond_te, NULL);
pthread_attr_init( &proc->tep[2].attr_te);
printf("Creating te_thread2\n");
pthread_create(&proc->pthread_te[2], attr_te1, te_thread2, (void*)&proc->tep[2]);
printf("Creating te_thread 2\n");
pthread_create(&proc->tep[2].pthread_te, &proc->tep[2].attr_te, te_thread, (void*)&proc->tep[2]);
}
......
......@@ -696,7 +696,7 @@ static void* eNB_thread_prach_br( void* param ) {
extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *);
extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *,pthread_attr_t *);
extern void init_te_thread(PHY_VARS_eNB *);
//////////////////////////////////////need to modified////////////////*****
static void* process_stats_thread(void* param) {
......@@ -734,7 +734,7 @@ void init_eNB_proc(int inst) {
PHY_VARS_eNB *eNB;
eNB_proc_t *proc;
eNB_rxtx_proc_t *proc_rxtx;
pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_te1=NULL,*attr_td=NULL;
pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL;//,*attr_te=NULL,*attr_te1=NULL;
#ifdef Rel14
pthread_attr_t *attr_prach_br=NULL;
#endif
......@@ -776,8 +776,8 @@ void init_eNB_proc(int inst) {
pthread_attr_init( &proc->attr_prach);
pthread_attr_init( &proc->attr_asynch_rxtx);
pthread_attr_init( &proc->attr_td);
pthread_attr_init( &proc->attr_te[0]);
pthread_attr_init( &proc->attr_te[1]);
//pthread_attr_init( &proc->attr_te[0]);
//pthread_attr_init( &proc->attr_te[1]);
pthread_attr_init( &proc_rxtx[0].attr_rxtx);
pthread_attr_init( &proc_rxtx[1].attr_rxtx);
#ifdef Rel14
......@@ -800,8 +800,8 @@ void init_eNB_proc(int inst) {
// attr_te = &proc->attr_te;
#endif
attr_td = &proc->attr_td;
attr_te = &proc->attr_te[0];
attr_te1 = &proc->attr_te[1];
//attr_te = &proc->attr_te[0];
//attr_te1 = &proc->attr_te[1];
pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc );
pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc);
if (eNB->single_thread_flag==0) {
......@@ -824,7 +824,7 @@ void init_eNB_proc(int inst) {
//////////////////////////////////////need to modified////////////////*****
init_te_thread(eNB,attr_te,attr_te1);
init_te_thread(eNB);
init_td_thread(eNB,attr_td);
if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB);
......
......@@ -687,7 +687,7 @@ static void* emulatedRF_thread(void* param) {
int microsec = 500; // length of time to sleep, in miliseconds
struct timespec req = {0};
req.tv_sec = 0;
req.tv_nsec = ((microsec * 1000L)/numerology);
req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2;
cpu_set_t cpuset;
CPU_SET(1,&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