Commit 30ae8423 authored by lfarizav's avatar lfarizav

implementing SSE for rf_rx_simple

parent 2ab90d98
......@@ -42,6 +42,7 @@ extern int write_output(const char *,const char *,void *,int,int,char);
//#define DEBUG_RF 1
//free(input_data);
void rf_rx(double **r_re,
double **r_im,
double **r_re_i1,
......@@ -198,7 +199,8 @@ void rf_rx(double **r_re,
// pn[i] = p_noise;
}
}
#define CHANNEL_SSE
#ifdef CHANNEL_SSE
void rf_rx_simple(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
......@@ -206,7 +208,82 @@ void rf_rx_simple(double *r_re[2],
double s_time,
double rx_gain_dB)
{
/* static int first_run=0;
static double sum;
static int count;
if (!first_run)
{
first_run=1;
sum=0;
count=0;
}
count++;*/
__m128d rx128_re,rx128_im,rx128_gain_lin,gauss_0_128_sqrt_NOW,gauss_1_128_sqrt_NOW;//double
int i,a;
double rx_gain_lin = pow(10.0,.05*rx_gain_dB);
//double rx_gain_lin = 1.0;
double N0W = pow(10.0,.1*(-174.0 - 10*log10(s_time*1e-9)));
double sqrt_NOW = sqrt(.5*N0W);
double gauss0_sqrt_NOW,gauss1_sqrt_NOW;
double div = rx_gain_lin/(1-rx_gain_lin)*sqrt_NOW;
//double N0W = 0.0;
// printf("s_time=%f, N0W=%g\n",s_time,10*log10(N0W));
//Loop over input
#ifdef DEBUG_RF
printf("N0W = %f dBm\n",10*log10(N0W));
printf("rx_gain = %f dB(%f)\n",rx_gain_dB,rx_gain_lin);
#endif
//rx128_gain_lin=mm_loadu_pd(rx_gain_lin);
/*count++;
clock_t start=clock();*/
for (i=0; i<(length>>1); i++) {
for (a=0; a<nb_rx_antennas; a++) {
//rx128_gain_lin=mm_mul_set1_ps(rx_gain_lin);
gauss0_sqrt_NOW=gauss0_sqrt_NOW*gaussdouble(0.0,1.0);
gauss1_sqrt_NOW=gauss1_sqrt_NOW*gaussdouble(0.0,1.0);
rx128_re = _mm_loadu_pd(&r_re[a][2*i]);//r_re[a][i],r_re[a][i+1]
rx128_im = _mm_loadu_pd(&r_im[a][2*i]);//r_im[a][i],r_im[a][i+1]
rx128_gain_lin = _mm_set1_pd(rx_gain_lin);
gauss_0_128_sqrt_NOW = _mm_set1_pd(gauss0_sqrt_NOW);
gauss_1_128_sqrt_NOW = _mm_set1_pd(gauss1_sqrt_NOW);
// Amplify by receiver gain and apply 3rd order non-linearity
//r_re[a][i] = rx_gain_lin*(r_re[a][i] + sqrt(.5*N0W)*gaussdouble(0.0,1.0));
//r_im[a][i] = rx_gain_lin*(r_im[a][i] + sqrt(.5*N0W)*gaussdouble(0.0,1.0));
rx128_re = _mm_add_pd(rx128_re,gauss_0_128_sqrt_NOW);
rx128_im = _mm_add_pd(rx128_im,gauss_1_128_sqrt_NOW);
rx128_re = _mm_mul_pd(rx128_re,rx128_gain_lin);
rx128_im = _mm_mul_pd(rx128_im,rx128_gain_lin);
_mm_storeu_pd(&r_re[a][2*i],rx128_re);
_mm_storeu_pd(&r_im[a][2*i],rx128_im);
gauss0_sqrt_NOW=0;
gauss1_sqrt_NOW=0;
//printf("gaussdouble %e, rx_gain_lin %e\n",gaussdouble(0.0,1.0), rx_gain_lin);
}
}
/*clock_t stop=clock();
printf("do_DL_sig time is %f s, AVERAGE time is %f s, count %d, sum %e\n",(float) (stop-start)/CLOCKS_PER_SEC,(float) (sum+stop-start)/(count*CLOCKS_PER_SEC),count,sum+stop-start);
sum=(sum+stop-start);*/
}
#else
void rf_rx_simple(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
unsigned int length,
double s_time,
double rx_gain_dB)
{
static int first_run=0;
static double sum;
static int count;
if (!first_run)
{
first_run=1;
sum=0;
count=0;
}
int i,a;
double rx_gain_lin = pow(10.0,.05*rx_gain_dB);
//double rx_gain_lin = 1.0;
......@@ -224,12 +301,18 @@ void rf_rx_simple(double *r_re[2],
for (i=0; i<length; i++) {
for (a=0; a<nb_rx_antennas; a++) {
// Amplify by receiver gain and apply 3rd order non-linearity
/*count++;
clock_t start=clock();*/
r_re[a][i] = rx_gain_lin*(r_re[a][i] + sqrt(.5*N0W)*gaussdouble(0.0,1.0));
r_im[a][i] = rx_gain_lin*(r_im[a][i] + sqrt(.5*N0W)*gaussdouble(0.0,1.0));
/*clock_t stop=clock();
printf("do_DL_sig time is %f s, AVERAGE time is %f s, count %d, sum %e\n",(float) (stop-start)/CLOCKS_PER_SEC,(float) (sum+stop-start)/(count*CLOCKS_PER_SEC),count,sum+stop-start);
sum=(sum+stop-start);*/
}
}
}
}
#endif
#ifdef RF_MAIN
#define INPUT_dBm -70.0
......
......@@ -221,7 +221,6 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
\param desc Pointer to the channel descriptor
*/
int random_channel(channel_desc_t *desc, uint8_t abstraction_flag);
/**\fn void multipath_channel(channel_desc_t *desc,
double tx_sig_re[2],
double tx_sig_im[2],
......
......@@ -139,7 +139,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "172.24.11.18";
mme_ip_address = ( { ipv4 = "10.188.114.179";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......
......@@ -380,6 +380,17 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
uint8_t UE_id,
int CC_id)
{
/*time_stats_t dl_chan_stats_f;
static int first_run=0;
static double sum;
static int count;
if (!first_run)
{
first_run=1;
sum=0;
count=0;
}
count++;*/
//int32_t att_eNB_id=-1;
int32_t **txdataF,**rxdataF;
......@@ -479,6 +490,7 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
subframe);
#endif
//eNB2UE[eNB_id][UE_id]->path_loss_dB = 0;
multipath_channel_freq(eNB2UE[eNB_id][UE_id][CC_id],s_re_f,s_im_f,r_re0_f,r_im0_f,
frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,hold_channel,eNB_id,UE_id,CC_id,subframe&0x1);
//for (int x=0;x<frame_parms->N_RB_DL*12;x++){
......@@ -531,12 +543,16 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
LOG_D(OCM,"[SIM][DL] UE %d (CCid %d): rx_gain %d dB (-ADC %f) for subframe %d\n",UE_id,CC_id,PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB,
PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB-66.227,subframe);
#endif
//clock_t start=clock();
rf_rx_simple(r_re0_f,
r_im0_f,
nb_antennas_rx,
frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,
1e3/eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate, // sampling time (ns)
(double)PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
/*clock_t stop=clock();
printf("do_DL_sig time is %f s, AVERAGE time is %f s, count %d, sum %e\n",(float) (stop-start)/CLOCKS_PER_SEC,(float) (sum+stop-start)/(count*CLOCKS_PER_SEC),count,sum+stop-start);
sum=(sum+stop-start);*/
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0_f,r_im0_f,
......@@ -586,8 +602,8 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
12);
//for (int idx=0;idx<10;idx++) printf("dumping DL raw rx subframe %d: rxdataF[%d] = (%d,%d)=====>%s\n", subframe, idx, ((short*)&rxdataF[0][sf_offset+idx])[0], ((short*)&rxdataF[0][sf_offset+idx])[1],(((((r_re_p_f[0][idx]<0)&&(((short*)&rxdataF[0][sf_offset+idx])[0]<0))||((r_re_p_f[0][idx]>=0)&&(((short*)&rxdataF[0][sf_offset+idx])[0]>=0))))&&(((r_im_p_f[0][idx]<0)&&(((short*)&rxdataF[0][sf_offset+idx])[1]<0))||((r_im_p_f[0][idx]>=0)&&(((short*)&rxdataF[0][sf_offset+idx])[1]>=0))))?"OK":"ERROR");
//write_output("chsim_rxsigF_frame0.m","chsm_rxsF0", PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[0].rxdataF[0],10*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
//write_output("chsim_rxsigF_frame1.m","chsm_rxsF1", PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[1].rxdataF[0],10*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
//write_output("chsim_rxsigF_subframe0.m","chsm_rxsF0", PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[0].rxdataF[0],10*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
//write_output("chsim_rxsigF_subframe1.m","chsm_rxsF1", PHY_vars_UE_g[UE_id][CC_id]->common_vars.common_vars_rx_data_per_thread[1].rxdataF[0],10*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
#ifdef DEBUG_SIM
rx_pwr2 = signal_energy((rxdataF[0])+sf_offset,frame_parms->ofdm_symbol_size)/(12.0*frame_parms->N_RB_DL);
......@@ -1233,7 +1249,7 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
double *r_im_p_f_prach[2] = {r_im_UL_f_prach[eNB_id][0],r_im_UL_f_prach[eNB_id][1]};
/*for (int idx=0;idx<10;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_re_im_p_f_prach[%d] = (%d,%d)\n", subframe, idx, (short)(r_re_p_f_prach[0][idx]),(short)(r_im_p_f_prach[0][idx]));
for (int idx=829;idx<839;idx++) printf("dumping raw PRACH UL tx subframe (output) %d: r_re_im_p_f_prach[%d] = (%d,%d)\n", subframe, idx, (short)(r_re_p_f_prach[0][idx]),(short)(r_im_p_f_prach[0][idx]));*/
clock_t start=clock();
//clock_t start=clock();
rf_rx_simple(r_re_p_f_prach,
r_im_p_f_prach,
nb_antennas_rx,
......@@ -1241,9 +1257,9 @@ void do_UL_prach(channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX][MAX
1e3/UE2eNB[0][eNB_id][CC_id]->sampling_rate, // sampling time (ns)
(double)PHY_vars_eNB_g[eNB_id][CC_id]->rx_total_gain_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later)
clock_t stop=clock();
/*clock_t stop=clock();
printf("UE_PRACH_channel time is %f s, AVERAGE time is %f s, count %d, sum %e, subframe %d\n",(float) (stop-start)/CLOCKS_PER_SEC,(float) (sum+stop-start)/(count*CLOCKS_PER_SEC),count,sum+stop-start,subframe);
sum=(sum+stop-start);
sum=(sum+stop-start);*/
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re_p_f_prach,r_im_p_f_prach,nb_antennas_rx,frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*12,0)*(double)frame_parms->ofdm_symbol_size/(12.0*frame_parms->N_RB_DL);
......
......@@ -1042,7 +1042,7 @@ extern int subframe_eNB_mask,subframe_UE_mask;
int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc)
{
/*time_stats_t ul_chan_stats_f;
static int first_meas=0;*/
static int first_meas=0;
static int first_run=0;
static double sum;
static int count;
......@@ -1052,7 +1052,7 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
sum=0;
count=0;
}
count++;
count++;*/
int ret = nsamps;
......@@ -1199,6 +1199,17 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc)
{
time_stats_t dl_chan_stats_f;
static int first_run=0;
static double sum;
static int count;
if (!first_run)
{
first_run=1;
sum=0;
count=0;
}
count++;
int ret = nsamps;
int UE_id = device->Mod_id;
int CC_id = device->CC_id;
......@@ -1264,7 +1275,8 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
(unsigned long long)current_UE_rx_timestamp[UE_id][CC_id]);
if (do_ofdm_mod)
{
start_meas(&dl_chan_stats_f);
//start_meas(&dl_chan_stats_f);
clock_t start=clock();
do_DL_sig_freq(eNB2UE,
enb_data,
ue_data,
......@@ -1273,8 +1285,11 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
&PHY_vars_UE_g[UE_id][CC_id]->frame_parms,
UE_id,
CC_id);
stop_meas(&dl_chan_stats_f);
print_meas(&dl_chan_stats_f,"DL_Channel Stats Frequency Domain",&dl_chan_stats_f,&dl_chan_stats_f);
clock_t stop=clock();
printf("do_DL_sig time is %f s, AVERAGE time is %f s, count %d, sum %e\n",(float) (stop-start)/CLOCKS_PER_SEC,(float) (sum+stop-start)/(count*CLOCKS_PER_SEC),count,sum+stop-start);
sum=(sum+stop-start);
//stop_meas(&dl_chan_stats_f);
//print_meas(&dl_chan_stats_f,"DL_Channel Stats Frequency Domain",&dl_chan_stats_f,&dl_chan_stats_f);
}
else
{
......
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