Commit 3e2c9af1 authored by Laurent THOMAS's avatar Laurent THOMAS Committed by Robert Schmidt

with polar structures delete and better cpu performance

parent be314a97
......@@ -20,7 +20,7 @@
int main(int argc, char *argv[])
{
//Default simulation values (Aim for iterations = 1000000.)
//Default simulation values (Aim for iterations = 1000000.)
int decoder_int16=0;
int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, 2=UCI
double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB
......@@ -160,7 +160,7 @@ if (logFlag){
uint8_t testArrayLength = ceil(testLength / 32.0);
uint8_t coderArrayLength = ceil(coderLength / 32.0);
uint32_t testInput[min(2,testArrayLength)]; //generate randomly
uint32_t testInput[max(2,testArrayLength)]; //generate randomly
uint32_t encoderOutput[coderArrayLength];
uint32_t estimatedOutput[testArrayLength]; //decoder output
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
......@@ -357,5 +357,6 @@ if (logFlag){
print_meas(&timeEncoder,"polar_encoder",NULL,NULL);
print_meas(&timeDecoder,"polar_decoder",NULL,NULL);
if (logFlag) fclose(logFile);
nr_polar_delete(currentPtr);
return (0);
}
......@@ -29,12 +29,13 @@ uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){
uint8_t crcPolynomialSize = 24;
uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize];
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
uint8_t **crc_generator_matrix = malloc(payloadSizeBits*sizeof(uint8_t *) + payloadSizeBits*crcPolynomialSize*sizeof(uint8_t));
if (crc_generator_matrix)
for (int i = 0; i < payloadSizeBits; i++)
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t));
crc_generator_matrix[i] = ((uint8_t*)&crc_generator_matrix[payloadSizeBits])+i*crcPolynomialSize;
for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
for (int i = 0; i < crcPolynomialSize; i++)
crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
for (int i = payloadSizeBits-2; i >= 0; i--){
for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1];
......
......@@ -141,18 +141,18 @@ int8_t polar_decoder(double *input,
updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n+1, 2*listSize, llr);
for (int i = 0; i < currentListSize; i++) {
for (int j = 0; j < polarParams->N; j++) {
for (int k = 0; k < (polarParams->n+1); k++) {
for (int j = 0; j < polarParams->N; j++) {
for (int k = 0; k < (polarParams->n+1); k++) {
bit[j][k][i+currentListSize]=bit[j][k][i];
llr[j][k][i+currentListSize]=llr[j][k][i];
}
}
}
}
for (int i = 0; i < currentListSize; i++) {
bit[currentBit][0][i]=0;
crcState[i+currentListSize]=crcState[i];
}
for (int i = 0; i < currentListSize; i++) {
bit[currentBit][0][i]=0;
crcState[i+currentListSize]=crcState[i];
}
for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1;
......@@ -264,13 +264,6 @@ int8_t polar_decoder(double *input,
if (decoderIterationCheck==0) {
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
//free(d_tilde);
//free(pathMetric);
//free(crcState);
//nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
//nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
//nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
free(tempECGM);
return(-1);
}
......@@ -531,13 +524,6 @@ int8_t polar_decoder_dci(double *input,
if (decoderIterationCheck==0) {
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
//free(d_tilde);
//free(pathMetric);
//free(crcState);
//nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
//nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
//nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
free(tempECGM);
return(-1);
}
......
......@@ -208,6 +208,23 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol
return(new_node);
}
void delete_nodes(decoder_node_t * n) {
if (n) {
if(n->left)
delete_nodes(n->left);
if(n->right)
delete_nodes(n->right);
free(n->alpha);
free(n->beta);
free(n);
}
}
void delete_decoder_tree(t_nrPolar_params *polarParams) {
if (polarParams->tree.root)
delete_nodes(polarParams->tree.root);
}
void build_decoder_tree(t_nrPolar_params *polarParams)
{
polarParams->tree.num_nodes=0;
......
......@@ -332,5 +332,6 @@ static inline void nr_polar_deinterleaver(uint8_t *input,
{
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
}
void delete_decoder_tree(t_nrPolar_params *);
void nr_polar_delete(t_nrPolar_params *);
#endif
......@@ -334,7 +334,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) {
AssertFatal(polarParams->N==512 || polarParams->N==256 || polarParams->N==128,"N = %d, not done yet\n",polarParams->N);
// build G bit vectors for information bit positions and convert the bit as bytes tables in nr_polar_kronecker_power_matrices.c to 64 bit packed vectors.
// keep only rows of G which correspond to information/crc bits
polarParams->G_N_tab = (uint64_t **)malloc((polarParams->K + polarParams->n_pc) * sizeof(int64_t *));
polarParams->G_N_tab = (uint64_t **)calloc((polarParams->K + polarParams->n_pc),sizeof(int64_t *));
int k=0;
for (int i=0; i<polarParams->N; i++) {
......
......@@ -36,6 +36,37 @@
static int intcmp(const void *p1,const void *p2) {
return(*(int16_t *)p1 > *(int16_t *)p2);
}
void nr_polar_delete(t_nrPolar_params * polarParams) {
delete_decoder_tree(polarParams);
//From build_polar_tables()
for (int k=0; k < polarParams->K + polarParams->n_pc; k++)
if (polarParams->G_N_tab[k])
free(polarParams->G_N_tab[k]);
free(polarParams->G_N_tab);
free(polarParams->rm_tab);
if (polarParams->crc_generator_matrix)
free(polarParams->crc_generator_matrix);
//polar_encoder vectors:
free(polarParams->nr_polar_crc);
free(polarParams->nr_polar_aPrime);
free(polarParams->nr_polar_APrime);
free(polarParams->nr_polar_D);
free(polarParams->nr_polar_E);
//Polar Coding vectors
free(polarParams->nr_polar_U);
free(polarParams->nr_polar_CPrime);
free(polarParams->nr_polar_B);
free(polarParams->nr_polar_A);
free(polarParams->interleaving_pattern);
free(polarParams->deinterleaving_pattern);
free(polarParams->rate_matching_pattern);
free(polarParams->information_bit_pattern);
free(polarParams->Q_I_N);
free(polarParams->Q_F_N);
free(polarParams->Q_PC_N);
free(polarParams->channel_interleaver_pattern);
free(polarParams);
}
static void nr_polar_init(t_nrPolar_params * *polarParams,
int8_t messageType,
......@@ -151,7 +182,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i;
newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
uint16_t *J = malloc(sizeof(uint16_t) * newPolarInitNode->N);
uint16_t J[newPolarInitNode->N];
nr_polar_rate_matching_pattern(newPolarInitNode->rate_matching_pattern,
J,
nr_polar_subblock_interleaver_pattern,
......@@ -181,7 +212,6 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
newPolarInitNode->i_bil,
newPolarInitNode->encoderLength);
free(J);
if (decoder_flag == 1) build_decoder_tree(newPolarInitNode);
build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode);
......
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