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);
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_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_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);
......
......@@ -94,30 +94,28 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
int simd_size;
//determine number of bits in codeword
//if (block_length>3840)
//{
AssertFatal(block_length>3840,"Block length < 3840 not supported yet\n");
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
//}
/* else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
ncols=10; // info bits
if (block_length>640)
Kb = 10;
else if (block_length>560)
Kb = 9;
else if (block_length>192)
if (block_length>3840)
{
BG=1;
Kb = 22;
nrows=46; //parity check bits
ncols=22; //info bits
}
else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
ncols=10; // info bits
if (block_length>640)
Kb = 10;
else if (block_length>560)
Kb = 9;
else if (block_length>192)
Kb = 8;
else
Kb = 6;
} */
}
//find minimum value in all sets of lifting size
Zc=0;
......@@ -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]=(test_input[i/8]&(1<<(i&7)))>>(i&7);
}
stop_meas(tinput);
// extend matrix
start_meas(tprep);
for (i1=0; i1 < ncols; i1++)
{
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));
stop_meas(tinput);
if (BG==1) {
// extend matrix
start_meas(tprep);
for (i1=0; i1 < ncols; i1++)
{
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++) {
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");
*/
else if (BG==2) {
if (encode_parity_check_part_orig(c, d, BG, Zc, Kb, block_length)!=0) {
printf("Problem with encoder\n");
return(-1);
}
}
stop_meas(tprep);
//parity check part
start_meas(tparity);
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb);
stop_meas(tparity);
else {
printf("Problem with encoder\n");
return(-1);
}
start_meas(toutput);
// information part and puncture columns
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,
else
Kr_int = Kr;
start_meas(te_stats);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][96];
#ifdef DEBUG_DLSCH_CODING
......@@ -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]);
#endif
//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);
#endif
/*printf("end ldpc encoder -- output\n");
......
......@@ -43,7 +43,7 @@ double get_cpu_freq_GHz(void) {
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;
......@@ -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)
{
if (opp_enabled) {
if (opp_enabled && ts) {
static int first_time = 0;
static double cpu_freq_GHz = 0.0;
......
......@@ -98,7 +98,7 @@ static inline uint32_t rdtsc_oai(void)
static inline void start_meas(time_stats_t *ts)
{
if (opp_enabled) {
if (opp_enabled && ts) {
if (ts->meas_flag==0) {
ts->trials++;
ts->in = rdtsc_oai();
......@@ -113,7 +113,7 @@ static inline void start_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();
ts->diff_now = (out-ts->in);
......@@ -133,6 +133,8 @@ static inline void stop_meas(time_stats_t *ts)
static inline void reset_meas(time_stats_t *ts) {
if (ts) {
ts->trials=0;
ts->diff=0;
ts->diff_now=0;
......@@ -141,6 +143,7 @@ static inline void reset_meas(time_stats_t *ts) {
ts->max=0;
ts->meas_flag=0;
}
}
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