Commit a60c4f03 authored by Xiwen JIANG's avatar Xiwen JIANG

using thread pool to parallize the precoding and ifft for each phy antenna in dlsim

parent a2420288
......@@ -1025,6 +1025,7 @@ set(PHY_SRC
${OPENAIR1_DIR}/PHY/TOOLS/sqrt.c
${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c
${OPENAIR1_DIR}/PHY/TOOLS/lut.c
${OPENAIR1_DIR}/PHY/TOOLS/thread_pool.c
)
if (${SMBV})
set(PHY_SRC "${PHY_SRC} ${OPENAIR1_DIR}/PHY/TOOLS/smbv.c")
......@@ -1840,7 +1841,7 @@ target_link_libraries (oaisim_nos1 ${T_LIB})
# Unitary tests for each piece of L1: example, mbmssim is MBMS L1 simulator
#####################################
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
foreach(myExe dlsim ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
add_executable(${myExe}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c
......@@ -1921,7 +1922,6 @@ if (${T_TRACER})
add_dependencies(oaisim generate_T)
add_dependencies(oaisim_nos1 generate_T)
add_dependencies(dlsim generate_T)
add_dependencies(dlsim_tm7 generate_T)
add_dependencies(ulsim generate_T)
add_dependencies(pbchsim generate_T)
add_dependencies(scansim generate_T)
......
......@@ -22,6 +22,8 @@
#include "defs.h"
#include "SCHED/defs.h"
#include "PHY/extern.h"
#include "PHY/TOOLS/thread_pool.h"
#include "PHY/MODULATION/defs.h"
#include "SIMULATION/TOOLS/defs.h"
#include "RadioResourceConfigCommonSIB.h"
#include "RadioResourceConfigDedicated.h"
......@@ -1309,7 +1311,9 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
}
} //eNB_id
/* Create thread pool */
eNB->pool = new_thread_pool(do_OFDM_mod_thread, eNB);
sleep(1);
if (abstraction_flag==0) {
if (eNB->node_function != NGFI_RRU_IF4p5) {
......
......@@ -64,16 +64,16 @@ int beam_precoding(int32_t **txdataF,
memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size));
for (p=0; p<14; p++) {
//if (p==0 || p==1 || p==5 || p>7)
// mult_cpx_conj_vector((int16_t*)txdataF[p], (int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15);
//if (p==0 || p==1 || p==4 || p==5 || p>=7)
//multadd_cpx_vector((int16_t*)txdataF[p],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15);
for (re=0;re<frame_parms->ofdm_symbol_size;re++) {
if ((p==0 || p==1 || p==5 || p>=7) && txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) {
if ((p==0 || p==1 || p==4 || p==5 || p>=7) && txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) {
((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
/*
/*
printf("beamforming.c:txdataF[%d][%d]=%d+j%d, beam_weights[%d][%d][%d]=%d+j%d,txdata_BF[%d][%d]=%d+j%d\n",
p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re,
((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0],
......@@ -83,7 +83,7 @@ int beam_precoding(int32_t **txdataF,
aa,re,
((int16_t*)&txdataF_BF[aa][re])[0],
((int16_t*)&txdataF_BF[aa][re])[1]);
*/
*/
}
}
}
......
......@@ -46,6 +46,14 @@ void PHY_ofdm_mod(int *input,
Extension_t etype
);
/**
\brief This function is a thread performing beamforming precoding and
ifft for each physical antenna
@param eNB The eNB context
*/
void *do_OFDM_mod_thread(PHY_VARS_eNB *eNB);
#ifdef OPENAIR_LTE
/*!
......@@ -82,7 +90,7 @@ void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRA
void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms);
void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms);
void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms, int antenna);
void remove_7_5_kHz(PHY_VARS_eNB *phy_vars_eNB,uint8_t subframe);
......
......@@ -29,9 +29,11 @@ This section deals with basic functions for OFDM Modulation.
*/
#include <sys/syscall.h>
#include "PHY/defs.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "PHY/TOOLS/thread_pool.h"
//static short temp2[2048*4] __attribute__((aligned(16)));
......@@ -285,7 +287,7 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne
}
// OFDM modulation for each symbol
void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms)
void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms, int antenna)
{
int aa, l, slot_offset;
......@@ -293,12 +295,13 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
int32_t **txdataF_BF = eNB_common_vars->txdataF_BF[eNB_id];
int32_t **txdata = eNB_common_vars->txdata[eNB_id];
aa = antenna;
slot_offset = (next_slot)*(frame_parms->samples_per_tti>>1);
//printf("Thread %d starting ... aa %d (%llu)\n",omp_get_thread_num(),aa,rdtsc());
for (l=0; l<frame_parms->symbols_per_tti>>1; l++) {
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
for (l=0; l<frame_parms->symbols_per_tti>>1; l++) {
//printf("do_OFDM_mod_l, slot=%d, l=%d, NUMBER_OF_OFDM_CARRIERS=%d,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES=%d\n",next_slot, l,NUMBER_OF_OFDM_CARRIERS,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,1);
......@@ -322,7 +325,6 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
1, // number of symbols
frame_parms->nb_prefix_samples0, // number of prefix samples
CYCLIC_PREFIX);
} else {
PHY_ofdm_mod(txdataF_BF[aa], // input
&txdata[aa][slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES], // output
......@@ -336,6 +338,69 @@ void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, int eNB_id, uint16_t ne
}
}
}
}
// OFDM modulation thread
void *do_OFDM_mod_thread(PHY_VARS_eNB *eNB)
{
thread_pool *pool = eNB->pool;
int eNB_id = 0;
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
int32_t **txdataF = eNB->common_vars.txdataF[eNB_id];
int32_t **txdataF_BF = eNB->common_vars.txdataF_BF[eNB_id];
int32_t **txdata = eNB->common_vars.txdata[eNB_id];
int aa, l, slot_offset;
//printf("Thread %d starting ... aa %d (%llu)\n",omp_get_thread_num(),aa,rdtsc());
while(1) {
aa = thread_pool_wait(pool);
slot_offset = (pool->next_slot)*(frame_parms->samples_per_tti>>1);
printf("OFDM mod thread %ld starts processing antenna %d slot %d\n", syscall(SYS_gettid), aa, pool->next_slot);
for (l=0; l<frame_parms->symbols_per_tti>>1; l++) {
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,1);
beam_precoding(txdataF,txdataF_BF,frame_parms,eNB->common_vars.beam_weights[eNB_id],pool->next_slot,l,aa);
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_BEAM_PRECODING,0);
//PMCH case not implemented...
if (frame_parms->Ncp == 1)
PHY_ofdm_mod(txdataF_BF[aa], // input
&txdata[aa][slot_offset+l*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES], // output
frame_parms->ofdm_symbol_size,
1, // number of symbols
frame_parms->nb_prefix_samples, // number of prefix samples
CYCLIC_PREFIX);
else {
if (l==0) {
PHY_ofdm_mod(txdataF_BF[aa], // input
&txdata[aa][slot_offset], // output
frame_parms->ofdm_symbol_size,
1, // number of symbols
frame_parms->nb_prefix_samples0, // number of prefix samples
CYCLIC_PREFIX);
} else {
PHY_ofdm_mod(txdataF_BF[aa], // input
&txdata[aa][slot_offset+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(l-1)*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES], // output
frame_parms->ofdm_symbol_size,
1, // number of symbols
frame_parms->nb_prefix_samples, // number of prefix samples
CYCLIC_PREFIX);
}
}
}
printf("OFDM mod thread %ld finished processing antenna %d slot %d\n", syscall(SYS_gettid), aa, pool->next_slot);
/* signal end of computation to thread pool */
thread_pool_done(pool);
}
}
......@@ -122,6 +122,7 @@ static inline void* malloc16_clear( size_t size )
#include "PHY/TOOLS/time_meas.h"
#include "PHY/CODING/defs.h"
#include "PHY/TOOLS/defs.h"
#include "PHY/TOOLS/thread_pool.h"
#include "platform_types.h"
#ifdef OPENAIR_LTE
......@@ -411,6 +412,7 @@ typedef struct PHY_VARS_eNB_s {
eNB_func_t node_function;
eNB_timing_t node_timing;
int single_thread_flag;
thread_pool *pool;
openair0_rf_map rf_map;
int abstraction_flag;
void (*do_prach)(struct PHY_VARS_eNB_s *eNB);
......
......@@ -53,6 +53,7 @@
#include "PHY/TOOLS/lte_phy_scope.h"
#include "PHY/TOOLS/thread_pool.h"
PHY_VARS_eNB *eNB;
PHY_VARS_UE *UE;
......@@ -1331,6 +1332,8 @@ int main(int argc, char **argv)
//int len;
uint8_t num_rounds = 4;//,fix_rounds=0;
int thread_pool_active = 0;
int u;
int n=0;
int abstx=0;
......@@ -1419,7 +1422,7 @@ int main(int argc, char **argv)
// num_layers = 1;
perfect_ce = 0;
while ((c = getopt (argc, argv, "ahdpZDe:Em:n:o:s:f:t:c:g:r:F:x:q:y:z:AM:N:I:i:O:R:S:C:T:b:u:v:w:B:Pl:WXY")) != -1) {
while ((c = getopt (argc, argv, "ahdpZDe:Em:n:o:s:f:t:c:g:r:F:x:q:y:z:AM:N:I:i:O:R:S:C:T:b:u:v:w:B:Pl:WXYU")) != -1) {
switch (c) {
case 'a':
awgn_flag = 1;
......@@ -1486,6 +1489,7 @@ int main(int argc, char **argv)
case 'W':
two_thread_flag = 1;
break;
case 'l':
offset_mumimo_llr_drange_fix=atoi(optarg);
break;
......@@ -1627,6 +1631,10 @@ int main(int argc, char **argv)
break;
case 'U':
thread_pool_active = 1;
break;
case 'v':
i_mod = atoi(optarg);
......@@ -1745,6 +1753,7 @@ int main(int argc, char **argv)
printf("-O Set the percenatge of effective rate to testbench the modem performance (typically 30 and 70, range 1-100) \n");
printf("-I Input filename for TrCH data (binary)\n");
printf("-u Enables the Interference Aware Receiver for TM5 (default is normal receiver)\n");
printf("-U Enable thread pool for beam precoding and OFDM modulation\n");
exit(1);
break;
}
......@@ -2406,15 +2415,37 @@ int main(int argc, char **argv)
&eNB->frame_parms);
*/
if (thread_pool_active == 0) {
for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) {
do_OFDM_mod_symbol(&eNB->common_vars,
eNB_id,
(subframe*2),
&eNB->frame_parms);
&eNB->frame_parms,
aa);
do_OFDM_mod_symbol(&eNB->common_vars,
eNB_id,
(subframe*2)+1,
&eNB->frame_parms);
&eNB->frame_parms,
aa);
}
} else {
eNB->pool->next_slot = 2*subframe;
//printf("dlsim:slot=%d\n", eNB->pool->next_slot);
while (eNB->pool->next_slot < subframe*2+2) {
/* start all threads */
thread_pool_start(eNB->pool);
///* wait all threads finishes */
thread_pool_join(eNB->pool);
//usleep(1000*1000);
/* set next_slot */
eNB->pool->next_slot++;
//pool->next_slot %= 20;
}
}
stop_meas(&eNB->ofdm_mod_stats);
......@@ -2453,8 +2484,9 @@ int main(int argc, char **argv)
write_output("txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB_id][0][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
} else if (transmission_mode == 7) {
write_output("txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB_id][5][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
write_output("txsigF0_BF.m","txsF0_BF", &eNB->common_vars.txdataF_BF[eNB_id][0][0],eNB->frame_parms.ofdm_symbol_size,1,1);
}
write_output("txsigF0_BF.m","txsF0_BF", &eNB->common_vars.txdataF_BF[eNB_id][0][0],eNB->frame_parms.ofdm_symbol_size,1,1);
}
}
......
......@@ -295,17 +295,21 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,1);
for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) {
do_OFDM_mod_symbol(&phy_vars_eNB->common_vars,
0,
subframe<<1,
&phy_vars_eNB->frame_parms);
&phy_vars_eNB->frame_parms,
aa);
// if S-subframe generate first slot only
if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) {
do_OFDM_mod_symbol(&phy_vars_eNB->common_vars,
0,
1+(subframe<<1),
&phy_vars_eNB->frame_parms);
&phy_vars_eNB->frame_parms,
aa);
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_OFDM_MODULATION,0);
......
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