Commit 1664d814 authored by Florian Kaltenberger's avatar Florian Kaltenberger

integrating SIMD optimized LDPC encoder

Conflicts:
	openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
parent 9118116a
...@@ -573,6 +573,7 @@ void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t); ...@@ -573,6 +573,7 @@ void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t);
short *ldpc_decoder(short *msgChannel,short block_length,short No_iteration,double rate); short *ldpc_decoder(short *msgChannel,short block_length,short No_iteration,double rate);
int encode_parity_check_part(uint16_t *c,uint16_t *d, short BG,short Zc,short Kb); int encode_parity_check_part(uint16_t *c,uint16_t *d, short BG,short Zc,short Kb);
int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb,short block_length);
int ldpc_encoder(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate); int ldpc_encoder(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate);
int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate,unsigned char gen_code); int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate,unsigned char gen_code);
int ldpc_encoder_multi_segment(unsigned char **test_input,unsigned char **channel_input,short block_length,double rate,uint8_t n_segments); int ldpc_encoder_multi_segment(unsigned char **test_input,unsigned char **channel_input,short block_length,double rate,uint8_t n_segments);
......
...@@ -94,30 +94,28 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh ...@@ -94,30 +94,28 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
int simd_size; int simd_size;
//determine number of bits in codeword //determine number of bits in codeword
//if (block_length>3840) if (block_length>3840)
//{ {
AssertFatal(block_length>3840,"Block length < 3840 not supported yet\n"); BG=1;
BG=1; Kb = 22;
Kb = 22; nrows=46; //parity check bits
nrows=46; //parity check bits ncols=22; //info bits
ncols=22; //info bits }
else if (block_length<=3840)
//} {
/* else if (block_length<=3840) BG=2;
{ nrows=42; //parity check bits
BG=2; ncols=10; // info bits
nrows=42; //parity check bits
ncols=10; // info bits if (block_length>640)
Kb = 10;
if (block_length>640) else if (block_length>560)
Kb = 10; Kb = 9;
else if (block_length>560) else if (block_length>192)
Kb = 9;
else if (block_length>192)
Kb = 8; Kb = 8;
else else
Kb = 6; Kb = 6;
} */ }
//find minimum value in all sets of lifting size //find minimum value in all sets of lifting size
Zc=0; Zc=0;
...@@ -155,28 +153,42 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh ...@@ -155,28 +153,42 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
//c[i]=c[i]>>7&1; //c[i]=c[i]>>7&1;
c[i]=(test_input[i/8]&(1<<(i&7)))>>(i&7); c[i]=(test_input[i/8]&(1<<(i&7)))>>(i&7);
} }
stop_meas(tinput); stop_meas(tinput);
// extend matrix
start_meas(tprep); if (BG==1) {
for (i1=0; i1 < ncols; i1++) // extend matrix
{ start_meas(tprep);
memcpy(&c_extension[2*i1*Zc], &c[i1*Zc], Zc*sizeof(unsigned char)); for (i1=0; i1 < ncols; i1++)
memcpy(&c_extension[(2*i1+1)*Zc], &c[i1*Zc], Zc*sizeof(unsigned char)); {
memcpy(&c_extension[2*i1*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
memcpy(&c_extension[(2*i1+1)*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
}
for (i1=1;i1<simd_size;i1++) {
memcpy(&c_extension[(2*ncols*Zc*i1)], &c_extension[i1], (2*ncols*Zc*sizeof(unsigned char))-i1);
// memset(&c_extension[(2*ncols*Zc*i1)],0,i1);
/*
printf("shift %d: ",i1);
for (int j=0;j<64;j++) printf("%d ",c_extension[(2*ncols*Zc*i1)+j]);
printf("\n");
*/
}
stop_meas(tprep);
//parity check part
start_meas(tparity);
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb);
stop_meas(tparity);
} }
for (i1=1;i1<simd_size;i1++) { else if (BG==2) {
memcpy(&c_extension[(2*ncols*Zc*i1)], &c_extension[i1], (2*ncols*Zc*sizeof(unsigned char))-i1); if (encode_parity_check_part_orig(c, d, BG, Zc, Kb, block_length)!=0) {
// memset(&c_extension[(2*ncols*Zc*i1)],0,i1); printf("Problem with encoder\n");
/* return(-1);
printf("shift %d: ",i1); }
for (int j=0;j<64;j++) printf("%d ",c_extension[(2*ncols*Zc*i1)+j]);
printf("\n");
*/
} }
stop_meas(tprep); else {
//parity check part printf("Problem with encoder\n");
start_meas(tparity); return(-1);
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb); }
stop_meas(tparity);
start_meas(toutput); start_meas(toutput);
// information part and puncture columns // information part and puncture columns
memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char)); memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
......
...@@ -709,6 +709,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, ...@@ -709,6 +709,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
else else
Kr_int = Kr; Kr_int = Kr;
start_meas(te_stats);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][96]; d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][96];
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
...@@ -716,9 +717,9 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, ...@@ -716,9 +717,9 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
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]); 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 #endif
//ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],Kr,rate); //ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],Kr,rate);
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);
} }
start_meas(te_stats); //ldpc_encoder_multi_segment(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,rate,dlsch->harq_processes[harq_pid]->C);
ldpc_encoder_multi_segment(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,rate,dlsch->harq_processes[harq_pid]->C);
stop_meas(te_stats); stop_meas(te_stats);
#endif #endif
/*printf("end ldpc encoder -- output\n"); /*printf("end ldpc encoder -- output\n");
......
...@@ -43,7 +43,7 @@ double get_cpu_freq_GHz(void) { ...@@ -43,7 +43,7 @@ double get_cpu_freq_GHz(void) {
void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){ void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){
if (opp_enabled) { if (opp_enabled && ts) {
//static double cpu_freq_GHz = 3.2; //static double cpu_freq_GHz = 3.2;
...@@ -62,7 +62,7 @@ void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){ ...@@ -62,7 +62,7 @@ void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time) void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time)
{ {
if (opp_enabled) { if (opp_enabled && ts) {
static int first_time = 0; static int first_time = 0;
static double cpu_freq_GHz = 0.0; static double cpu_freq_GHz = 0.0;
......
...@@ -98,7 +98,7 @@ static inline uint32_t rdtsc_oai(void) ...@@ -98,7 +98,7 @@ static inline uint32_t rdtsc_oai(void)
static inline void start_meas(time_stats_t *ts) static inline void start_meas(time_stats_t *ts)
{ {
if (opp_enabled) { if (opp_enabled && ts) {
if (ts->meas_flag==0) { if (ts->meas_flag==0) {
ts->trials++; ts->trials++;
ts->in = rdtsc_oai(); ts->in = rdtsc_oai();
...@@ -113,7 +113,7 @@ static inline void start_meas(time_stats_t *ts) ...@@ -113,7 +113,7 @@ static inline void start_meas(time_stats_t *ts)
static inline void stop_meas(time_stats_t *ts) static inline void stop_meas(time_stats_t *ts)
{ {
if (opp_enabled) { if (opp_enabled && ts) {
long long out = rdtsc_oai(); long long out = rdtsc_oai();
ts->diff_now = (out-ts->in); ts->diff_now = (out-ts->in);
...@@ -133,6 +133,8 @@ static inline void stop_meas(time_stats_t *ts) ...@@ -133,6 +133,8 @@ static inline void stop_meas(time_stats_t *ts)
static inline void reset_meas(time_stats_t *ts) { static inline void reset_meas(time_stats_t *ts) {
if (ts) {
ts->trials=0; ts->trials=0;
ts->diff=0; ts->diff=0;
ts->diff_now=0; ts->diff_now=0;
...@@ -141,6 +143,7 @@ static inline void reset_meas(time_stats_t *ts) { ...@@ -141,6 +143,7 @@ static inline void reset_meas(time_stats_t *ts) {
ts->max=0; ts->max=0;
ts->meas_flag=0; ts->meas_flag=0;
}
} }
static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts)
......
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