Commit 3d181d71 authored by lfarizav's avatar lfarizav

using SSE for rf_rx_simple function

parent 30ae8423
......@@ -63,7 +63,15 @@ void rf_rx_simple(double *r_re[2],
unsigned int length,
double s_time,
double rx_gain_dB);
void rf_rx_simple_freq(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
unsigned int length,
double s_time,
double rx_gain_dB,
unsigned int symbols_per_tti,
unsigned int ofdm_symbol_size,
unsigned int n_samples);
void adc(double *r_re[2],
double *r_im[2],
......
......@@ -199,8 +199,8 @@ void rf_rx(double **r_re,
// pn[i] = p_noise;
}
}
#define CHANNEL_SSE
#ifdef CHANNEL_SSE
#define RF_RX_SSE
#ifdef RF_RX_SSE
void rf_rx_simple(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
......@@ -225,7 +225,6 @@ void rf_rx_simple(double *r_re[2],
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));
......@@ -240,9 +239,10 @@ void rf_rx_simple(double *r_re[2],
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);
gauss0_sqrt_NOW=sqrt_NOW*gaussdouble(0.0,1.0);
gauss1_sqrt_NOW=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);
......@@ -257,8 +257,7 @@ clock_t start=clock();*/
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);
}
......@@ -311,6 +310,152 @@ sum=(sum+stop-start);*/
}
}
}
#endif
#ifdef RF_RX_SSE
void rf_rx_simple_freq(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
unsigned int length,
double s_time,
double rx_gain_dB,
unsigned int symbols_per_tti,
unsigned int ofdm_symbol_size,
unsigned int n_samples)
{
/* 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,j,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 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++) {
if (i%(ofdm_symbol_size>>1)>(n_samples>>1) && i%(ofdm_symbol_size>>1)<(ofdm_symbol_size>>1)-(n_samples>>1))
{
//printf("i = %d\n",i);
//_mm_storeu_pd(&r_re[a][2*i],_mm_setzero_pd());
//_mm_storeu_pd(&r_im[a][2*i],_mm_setzero_pd());
break;
}
else
{
//rx128_gain_lin=mm_mul_set1_ps(rx_gain_lin);
gauss0_sqrt_NOW=sqrt_NOW*gaussdouble(0.0,1.0);
gauss1_sqrt_NOW=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);
}
//#define __AVX__
/*else
{
//rx256_gain_lin=mm_mul_set1_ps(rx_gain_lin);
gauss0_sqrt_NOW=sqrt_NOW*gaussdouble(0.0,1.0);
gauss1_sqrt_NOW=sqrt_NOW*gaussdouble(0.0,1.0);
rx256_re = _mm256_load_pd(&r_re[a][2*i]);//r_re[a][i],r_re[a][i+1]
rx256_im = _mm256_load_pd(&r_im[a][2*i]);//r_im[a][i],r_im[a][i+1]
rx256_gain_lin = _mm_set1_pd(rx_gain_lin);
gauss_0_256_sqrt_NOW = _mm_set1_pd(gauss0_sqrt_NOW);
gauss_1_256_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));
rx256_re = _mm256_add_pd(rx256_re,gauss_0_256_sqrt_NOW);
rx256_im = _mm256_add_pd(rx256_im,gauss_1_256_sqrt_NOW);
rx256_re = _mm256_mul_pd(rx256_re,rx256_gain_lin);
rx256_im = _mm256_mul_pd(rx256_im,rx256_gain_lin);
_mm_storeu_pd(&r_re[a][2*i],rx256_re);
_mm_storeu_pd(&r_im[a][2*i],rx256_im);
}*/
//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_freq(double *r_re[2],
double *r_im[2],
unsigned int nb_rx_antennas,
unsigned int length,
double s_time,
double rx_gain_dB,
unsigned int symbols_per_tti,
unsigned int ofdm_symbol_size,
unsigned int n_samples)
{
static int first_run=0;
static double sum;
static int count;
if (!first_run)
{
first_run=1;
sum=0;
count=0;
}
int i,j,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 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
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
......
......@@ -139,7 +139,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "10.188.114.179";
mme_ip_address = ( { ipv4 = "172.24.11.18";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......
......@@ -380,7 +380,7 @@ 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;
time_stats_t dl_chan_stats_f;
static int first_run=0;
static double sum;
static int count;
......@@ -390,7 +390,6 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
sum=0;
count=0;
}
count++;*/
//int32_t att_eNB_id=-1;
int32_t **txdataF,**rxdataF;
......@@ -430,8 +429,8 @@ void do_DL_sig_freq(channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][
r_re0_f[1] = r_re01_f;
r_im0_f[1] = r_im01_f;
//FILE *file1;
//file1 = fopen("chsim_chF.m","w");
FILE *file1;
file1 = fopen("chsim_s_re_im.m","w");
//printf("chsim thread %d. ue->proc->frame_rx %d, ue->subframe_rx %d, ue->proc->frame_tx %d, ue->subframe_tx %d\n",subframe&0x1,PHY_vars_UE_g[0][0]->proc.proc_rxtx[subframe&0x1].frame_rx,PHY_vars_UE_g[0][0]->proc.proc_rxtx[subframe&0x1].subframe_rx,PHY_vars_UE_g[0][0]->proc.proc_rxtx[subframe&0x1].frame_tx,PHY_vars_UE_g[0][0]->proc.proc_rxtx[subframe&0x1].subframe_tx);
......@@ -490,9 +489,12 @@ 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;
//clock_t start=clock();
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);
/*clock_t stop=clock();
printf("multipath_channel DL 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);*/
//for (int x=0;x<frame_parms->N_RB_DL*12;x++){
// fprintf(file1,"%d\t%e\t%e\n",x,eNB2UE[eNB_id][UE_id][CC_id]->chF[0][x].x,eNB2UE[eNB_id][UE_id][CC_id]->chF[0][x].y);
//}
......@@ -543,17 +545,23 @@ 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,
count++;
clock_t start=clock();
rf_rx_simple_freq(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);*/
(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)
frame_parms->symbols_per_tti,
frame_parms->ofdm_symbol_size,
12.0*frame_parms->N_RB_DL);
clock_t stop=clock();
printf("rf_rx DL 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);
for (int x=0;x<frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti;x++){
fprintf(file1,"%d\t%e\t%e\n",x,r_re0_f[0][x],r_im0_f[0][x]);
}
#ifdef DEBUG_SIM
rx_pwr = signal_energy_fp(r_re0_f,r_im0_f,
nb_antennas_rx,
......
......@@ -1051,8 +1051,7 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
first_run=1;
sum=0;
count=0;
}
count++;*/
} */
int ret = nsamps;
......@@ -1122,6 +1121,8 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
for (UE_id=0; UE_id<NB_UE_INST; UE_id++){
if (is_prach_subframe(&PHY_vars_UE_g[UE_id][CC_id]->frame_parms,frame,subframe) && PHY_vars_UE_g[UE_id][CC_id]->generate_prach)
{
//count++;
//clock_t start=clock();
do_UL_prach(UE2eNB,
enb_data,
ue_data,
......@@ -1131,6 +1132,9 @@ int eNB_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
0, // frame is only used for abstraction
eNB_id,
CC_id);
/*clock_t stop=clock();
printf("do_UL_sig_PRACH 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);*/
//write_output("txprachF.m","prach_txF", PHY_vars_UE_g[0][CC_id]->prach_vars[0]->prachF,12*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti,1,16);
break;
}
......@@ -1198,7 +1202,7 @@ 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;
/*time_stats_t dl_chan_stats_f;
static int first_run=0;
static double sum;
static int count;
......@@ -1208,7 +1212,7 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
sum=0;
count=0;
}
count++;
count++;*/
int ret = nsamps;
int UE_id = device->Mod_id;
......@@ -1276,7 +1280,7 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **
if (do_ofdm_mod)
{
//start_meas(&dl_chan_stats_f);
clock_t start=clock();
//clock_t start=clock();
do_DL_sig_freq(eNB2UE,
enb_data,
ue_data,
......@@ -1285,9 +1289,9 @@ 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);
clock_t stop=clock();
/*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);
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);
}
......
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