Commit 0819ff2c authored by root's avatar root

fixing ldpc_encoder to use BG1

also using single segment encoder for now
parent 09f13c21
......@@ -117,14 +117,14 @@ int test_ldpc(short No_iteration,
}
//determine number of bits in codeword
if (block_length>3840)
//if (block_length>3840)
{
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (block_length<=3840)
/*else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
......@@ -138,7 +138,7 @@ int test_ldpc(short No_iteration,
Kb = 8;
else
Kb = 6;
}
}*/
//find minimum value in all sets of lifting size
Zc=0;
......@@ -165,17 +165,19 @@ int test_ldpc(short No_iteration,
//// encoder
start_meas(&time);
for(j=0;j<n_segments;j++) {
//if (BG==1)
//ldpc_encoder(test_input, channel_input,block_length,nom_rate,denom_rate);
//else
ldpc_encoder_orig(test_input[j], channel_input[j],block_length,nom_rate,denom_rate,0);
}
stop_meas(&time);
start_meas(&time_optim);
ldpc_encoder_optim_8seg(test_input,channel_input_optim,block_length,nom_rate,denom_rate,n_segments,&tinput,&tprep,&tparity,&toutput);
//ldpc_encoder_optim_8seg(test_input,channel_input_optim,block_length,nom_rate,denom_rate,n_segments,&tinput,&tprep,&tparity,&toutput);
for(j=0;j<n_segments;j++) {
ldpc_encoder_optim(test_input[j],channel_input_optim[j],block_length,nom_rate,denom_rate,&tinput,&tprep,&tparity,&toutput);
}
stop_meas(&time_optim);
if (ntrials==1)
......
......@@ -17,14 +17,14 @@ int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,sh
int i1,i2,i3,i4,i5,temp_prime;
unsigned char channel_temp,temp;
if (BG==1)
//if (BG==1)
{
no_shift_values=(short *) no_shift_values_BG1;
pointer_shift_values=(short *) pointer_shift_values_BG1;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (BG==2)
/*else if (BG==2)
{
no_shift_values=(short *) no_shift_values_BG2;
pointer_shift_values=(short *) pointer_shift_values_BG2;
......@@ -35,6 +35,7 @@ int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,sh
printf("problem with BG\n");
return(-1);
}
*/
no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*3)/Zc;
......
......@@ -7,6 +7,8 @@
#include "PHY/TOOLS/time_meas.h"
#include "defs.h"
#define DEBUG_LDPC
#include "ldpc384_byte.c"
#include "ldpc352_byte.c"
#include "ldpc320_byte.c"
......@@ -179,14 +181,14 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
char temp;
//determine number of bits in codeword
if (block_length>3840)
//if (block_length>3840)
{
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (block_length<=3840)
/*else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
......@@ -200,7 +202,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
Kb = 8;
else
Kb = 6;
}
}*/
//find minimum value in all sets of lifting size
Zc=0;
......@@ -215,6 +217,11 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
}
AssertFatal(Zc>0,"no valid Zc found for block length %d\n",block_length);
#ifdef DEBUG_LDPC
LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d\n",BG,Zc,Kb,block_length);
LOG_D(PHY,"ldpc_encoder_optim_8seg: PDU %x %x %x %x\n",test_input[0],test_input[1],test_input[2],test_input[3]);
#endif
if ((Zc&31) > 0) simd_size = 16;
else simd_size = 32;
......@@ -240,7 +247,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
stop_meas(tinput);
if ((BG==1) || (BG==2 && Zc>64)) {
if ((BG==1 && Zc>176) || (BG==2 && Zc>64)) {
// extend matrix
start_meas(tprep);
for (i1=0; i1 < ncols; i1++)
......@@ -293,14 +300,14 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
AssertFatal(n_segments>0&&n_segments<=8,"0 < n_segments %d <= 8\n",n_segments);
//determine number of bits in codeword
if (block_length>3840)
//if (block_length>3840)
{
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (block_length<=3840)
/*else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
......@@ -314,7 +321,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
Kb = 8;
else
Kb = 6;
}
}*/
//find minimum value in all sets of lifting size
Zc=0;
......@@ -327,6 +334,12 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
break;
}
}
#ifdef DEBUG_LDPC
LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d, segments %d\n",BG,Zc,Kb,block_length,n_segments);
LOG_D(PHY,"ldpc_encoder_optim_8seg: PDU (seg 0) %x %x %x %x\n",test_input[0][0],test_input[0][1],test_input[0][2],test_input[0][3]);
#endif
AssertFatal(Zc>0,"no valid Zc found for block length %d\n",block_length);
if ((Zc&31) > 0) simd_size = 16;
......@@ -387,7 +400,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
stop_meas(tinput);
if ((BG==1) || (BG==2 && Zc>64)) {
if ((BG==1 && Zc>176) || (BG==2 && Zc>64)) {
// extend matrix
start_meas(tprep);
for (i1=0; i1 < ncols; i1++)
......@@ -422,34 +435,41 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
memcpy(&channel_input[block_length-2*Zc], &d[0], ((nrows-no_punctured_columns) * Zc-removed_bit)*sizeof(unsigned char));
*/
#if 0
for (i=0;i<(block_length-2*Zc);i++)
for (j=0; j<n_segments; j++)
channel_input[j][i] = (c[2*Zc+i]>>j)&1;
for (i=0;i<((nrows-no_punctured_columns) * Zc-removed_bit);i++)
for (j=0; j<n_segments; j++)
channel_input[j][block_length-2*Zc+i] = (d[i]>>j)&1;
#else
#ifdef __AVX2__
uint32_t l1 = (block_length-(2*Zc))>>5;
uint32_t l2 = ((nrows-no_punctured_columns) * Zc-removed_bit)>>5;
AssertFatal(((2*Zc)&31) == 0,"2*Zc needs to be a multiple of 32 for now\n");
AssertFatal(((block_length-(2*Zc))&31) == 0,"block_length-(2*Zc) needs to be a multiple of 32 for now\n");
__m256i *c256p = (__m256i *)&c[2*Zc];
__m256i *d256p = (__m256i *)&d[0];
// if (((block_length-(2*Zc))&31)>0) l1++;
for (i=0;i<l1;i++)
for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j),masks[0]);
// if ((((nrows-no_punctured_columns) * Zc-removed_bit)&31)>0) l2++;
if ((((2*Zc)&31) == 0) && (((block_length-(2*Zc))&31) == 0)) {
//AssertFatal(((2*Zc)&31) == 0,"2*Zc needs to be a multiple of 32 for now\n");
//AssertFatal(((block_length-(2*Zc))&31) == 0,"block_length-(2*Zc) needs to be a multiple of 32 for now\n");
uint32_t l1 = (block_length-(2*Zc))>>5;
uint32_t l2 = ((nrows-no_punctured_columns) * Zc-removed_bit)>>5;
__m256i *c256p = (__m256i *)&c[2*Zc];
__m256i *d256p = (__m256i *)&d[0];
// if (((block_length-(2*Zc))&31)>0) l1++;
for (i=0;i<l1;i++)
for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j),masks[0]);
// if ((((nrows-no_punctured_columns) * Zc-removed_bit)&31)>0) l2++;
for (i1=0;i1<l2;i1++,i++)
for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j),masks[0]);
}
else {
#ifdef DEBUG_LDPC
LOG_W(PHY,"using non-optimized version\n");
#endif
// do non-SIMD version
for (i=0;i<(block_length-2*Zc);i++)
for (j=0; j<n_segments; j++)
channel_input[j][i] = (c[2*Zc+i]>>j)&1;
for (i=0;i<((nrows-no_punctured_columns) * Zc-removed_bit);i++)
for (j=0; j<n_segments; j++)
channel_input[j][block_length-2*Zc+i] = (d[i]>>j)&1;
}
for (i1=0;i1<l2;i1++,i++)
for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j),masks[0]);
#else
AssertFatal(1==0,"Need AVX2 for now\n");
#endif
AssertFatal(1==0,"Need AVX2 for now\n");
#endif
stop_meas(toutput);
return 0;
}
......@@ -347,14 +347,14 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho
int indlist2[1000];
//determine number of bits in codeword
if (block_length>3840)
//if (block_length>3840)
{
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (block_length<=3840)
/*else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
......@@ -368,7 +368,7 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho
Kb = 8;
else
Kb = 6;
}
}*/
//find minimum value in all sets of lifting size
Zc=0;
......
......@@ -916,24 +916,26 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
printf("start ldpc encoder B %d\n",dlsch->harq_processes[harq_pid]->B);
printf("input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]);
#endif
}
start_meas(te_stats);
//ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1.0/3.0);
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3,NULL,NULL,NULL,NULL);
ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,1,3,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL);
ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3,NULL,NULL,NULL,NULL);
stop_meas(te_stats);
}
/*
start_meas(te_stats);
ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,1,3,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL);
stop_meas(te_stats);
*/
#if 0
printf("end ldpc encoder -- output\n");
//printf("output %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->d[r][96], dlsch->harq_processes[harq_pid]->d[r][96+1], dlsch->harq_processes[harq_pid]->d[r][96+2],dlsch->harq_processes[harq_pid]->d[r][96+3], dlsch->harq_processes[harq_pid]->d[r][96+4]);
printf("end ldpc encoder -- output %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->d[0][96], dlsch->harq_processes[harq_pid]->d[0][96+1], dlsch->harq_processes[harq_pid]->d[0][96+2],dlsch->harq_processes[harq_pid]->d[0][96+3], dlsch->harq_processes[harq_pid]->d[0][96+4]);
/*
for (int cnt =0 ; cnt < 66*128; cnt ++){
printf("%d \n", dlsch->harq_processes[harq_pid]->d[r][96+cnt]);
}
printf("\n");
*/
#endif
#ifdef DEBUG_DLSCH_CODING
......
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