Commit 3c56a7ed authored by Florian Kaltenberger's avatar Florian Kaltenberger

a new proposal for the dlsch_channel_level function

parent 804a9a06
...@@ -3377,7 +3377,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3377,7 +3377,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
short rb; short rb;
unsigned char aatx,aarx,nre=12,symbol_mod; unsigned char aatx,aarx,nre=12,symbol_mod;
__m128i *dl_ch128, avg128D, coeff128; __m128i *dl_ch128, avg128D;
symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
...@@ -3388,11 +3388,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3388,11 +3388,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
else else
nre=12; nre=12;
double one_over_nb_re = 0.0; //nb_rb*nre = y * 2^x
one_over_nb_re = 1/((double)(nb_rb*nre)); int16_t x = log2_approx(nb_rb*nre)-1;
int16_t one_over_nb_re_q1_15 = (int16_t)(one_over_nb_re * (double)(1<<15) ); //int16_t one_over_y_q15 = (int16_t)((1<<((int32_t)x+15))/((int32_t)nb_rb*(int32_t)nre));
coeff128 = _mm_set_epi16(one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15, float y = (float)(nb_rb*nre)/(float)(1<<x);
one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15); //printf("1/(nb_rb*nre) = 1/%d = %d*2^(-15) * 2^(-%d)\n",nb_rb*nre,one_over_y_q15,x);
printf("nb_rb*nre = %d = %f * 2^(%d)\n",nb_rb*nre,y,x);
for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
...@@ -3405,14 +3406,18 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3405,14 +3406,18 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
for (rb=0;rb<nb_rb;rb++) { for (rb=0;rb<nb_rb;rb++) {
// printf("rb %d : ",rb); // printf("rb %d : ",rb);
// print_shorts("ch",&dl_ch128[0]); // print_shorts("ch",&dl_ch128[0]);
avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[0], coeff128),15))); avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[0],dl_ch128[0]),x));
avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[1], coeff128),15))); avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[1],dl_ch128[1]),x));
//avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[0], coeff128),15)));
//avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[1], coeff128),15)));
if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) { if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->mode1_flag==0)) {
dl_ch128+=2; dl_ch128+=2;
} }
else { else {
avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15))); avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[2],dl_ch128[2]),x));
//avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15)));
dl_ch128+=3; dl_ch128+=3;
} }
/* /*
...@@ -3424,11 +3429,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, ...@@ -3424,11 +3429,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext,
*/ */
} }
avg[(aatx<<1)+aarx] =(((int32_t*)&avg128D)[0] + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] +
((int32_t*)&avg128D)[1] + ((int32_t*)&avg128D)[1] +
((int32_t*)&avg128D)[2] + ((int32_t*)&avg128D)[2] +
((int32_t*)&avg128D)[3]); ((int32_t*)&avg128D)[3]);
// printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); avg[(aatx<<1)+aarx] = (int32_t) ((float) avg[(aatx<<1)+aarx]/y);
printf("Channel level : %d\n",avg[(aatx<<1)+aarx]);
} }
_mm_empty(); _mm_empty();
......
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