remove the big LUT for decoder de-interleaver
no performance degradation some reformatting
This commit is contained in:
committed by
Robert Schmidt
parent
d57ea715c0
commit
3e019af4d9
@@ -48,49 +48,49 @@ int main(int argc, char *argv[])
|
||||
printf("handling optarg %c\n",arguments);
|
||||
switch (arguments) {
|
||||
case 's':
|
||||
SNRstart = atof(optarg);
|
||||
SNRstop = SNRstart + 2;
|
||||
break;
|
||||
SNRstart = atof(optarg);
|
||||
SNRstop = SNRstart + 2;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
SNRinc = atof(optarg);
|
||||
break;
|
||||
SNRinc = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
SNRstop = atof(optarg);
|
||||
break;
|
||||
SNRstop = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
polarMessageType = atoi(optarg);
|
||||
if (polarMessageType!=0 && polarMessageType!=1 && polarMessageType!=2)
|
||||
printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType);
|
||||
break;
|
||||
polarMessageType = atoi(optarg);
|
||||
if (polarMessageType!=0 && polarMessageType!=1 && polarMessageType!=2)
|
||||
printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
iterations = atoi(optarg);
|
||||
break;
|
||||
iterations = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
decoderListSize = (uint8_t) atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
iterations = 1;
|
||||
SNRstart = -6.0;
|
||||
SNRstop = -6.0;
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
iterations = 1;
|
||||
SNRstart = -6.0;
|
||||
SNRstop = -6.0;
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
logFlag = 1;
|
||||
break;
|
||||
logFlag = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
aggregation_level=atoi(optarg);
|
||||
aggregation_level=atoi(optarg);
|
||||
if (aggregation_level != 1 && aggregation_level != 2 && aggregation_level != 4 && aggregation_level != 8
|
||||
&& aggregation_level != 16) {
|
||||
printf("Illegal aggregation level %d \n", aggregation_level);
|
||||
@@ -99,18 +99,18 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
testLength=atoi(optarg);
|
||||
if (testLength < 12 || testLength > 127) {
|
||||
printf("Illegal packet bitlength %d \n",testLength);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
testLength=atoi(optarg);
|
||||
if (testLength < 12 || testLength > 127) {
|
||||
printf("Illegal packet bitlength %d \n",testLength);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
printf(
|
||||
"./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n"
|
||||
"-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n"
|
||||
"-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n");
|
||||
"./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n"
|
||||
"-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n"
|
||||
"-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n");
|
||||
exit(-1);
|
||||
break;
|
||||
|
||||
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
strcat(fileName,currentTimeInfo);
|
||||
//Create "~/Desktop/polartestResults" folder if it doesn't already exist.
|
||||
/*struct stat folder = {0};
|
||||
if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/
|
||||
if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/
|
||||
logFile = fopen(fileName, "w");
|
||||
|
||||
if (logFile==NULL) {
|
||||
@@ -203,25 +203,25 @@ int main(int argc, char *argv[])
|
||||
t_nrPolar_params *currentPtrDCI=nr_polar_params(1, size, aggregation_level);
|
||||
|
||||
polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti);
|
||||
for (int i=0; i<54; i++) printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]);
|
||||
for (int i=0; i<54; i++)
|
||||
printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]);
|
||||
|
||||
uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength);
|
||||
double *modulated_input = malloc (sizeof(double) * currentPtrDCI->encoderLength);
|
||||
double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength);
|
||||
uint32_t dci_est[4];
|
||||
memset(dci_est,0,sizeof(uint32_t)*4);
|
||||
printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]);
|
||||
memset(dci_est,0,sizeof(dci_est));
|
||||
nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte);
|
||||
printf("[polartest] encoder_outputByte: ");
|
||||
for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); printf("\n");
|
||||
|
||||
SNR_lin = pow(10, 0/10); //SNR = 0 dB
|
||||
for(int i=0; i<currentPtrDCI->encoderLength; i++) {
|
||||
if (encoder_outputByte[i] == 0)
|
||||
modulated_input[i]=1/sqrt(2);
|
||||
else
|
||||
modulated_input[i]=(-1)/sqrt(2);
|
||||
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
if (encoder_outputByte[i] == 0)
|
||||
modulated_input[i]=1/sqrt(2);
|
||||
else
|
||||
modulated_input[i]=(-1)/sqrt(2);
|
||||
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
}
|
||||
decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti,
|
||||
1, size, aggregation_level);
|
||||
@@ -235,41 +235,41 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) {
|
||||
printf("SNR %f\n",SNR);
|
||||
SNR_lin = pow(10, SNR/10);
|
||||
printf("SNR %f\n",SNR);
|
||||
SNR_lin = pow(10, SNR/10);
|
||||
|
||||
for (itr = 1; itr <= iterations; itr++) {
|
||||
//Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits".
|
||||
for (int i = 0; i < testArrayLength; i++) {
|
||||
for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) {
|
||||
testInput[i] |= ( ((uint32_t) (rand()%2)) &1);
|
||||
testInput[i]<<=1;
|
||||
}
|
||||
testInput[i] |= ( ((uint32_t) (rand()%2)) &1);
|
||||
}
|
||||
for (itr = 1; itr <= iterations; itr++) {
|
||||
//Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits".
|
||||
for (int i = 0; i < testArrayLength; i++) {
|
||||
for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) {
|
||||
testInput[i] |= ( ((uint32_t) (rand()%2)) &1);
|
||||
testInput[i]<<=1;
|
||||
}
|
||||
testInput[i] |= ( ((uint32_t) (rand()%2)) &1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_POLARTEST
|
||||
//testInput[0] = 0x360f8a5c;
|
||||
printf("testInput: [0]->0x%08x\n", testInput[0]);
|
||||
//testInput[0] = 0x360f8a5c;
|
||||
printf("testInput: [0]->0x%08x\n", testInput[0]);
|
||||
#endif
|
||||
int len_mod64=currentPtr->payloadBits&63;
|
||||
((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1);
|
||||
int len_mod64=currentPtr->payloadBits&63;
|
||||
((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1);
|
||||
|
||||
start_meas(&timeEncoder);
|
||||
if (decoder_int16==1) {
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level);
|
||||
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0)
|
||||
polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
|
||||
else if (polarMessageType == 1)
|
||||
polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
stop_meas(&timeEncoder);
|
||||
start_meas(&timeEncoder);
|
||||
if (decoder_int16==1) {
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level);
|
||||
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0)
|
||||
polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
|
||||
else if (polarMessageType == 1)
|
||||
polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
stop_meas(&timeEncoder);
|
||||
|
||||
#ifdef DEBUG_POLARTEST
|
||||
printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
|
||||
//for (int i=1;i<coderArrayLength;i++) printf("encoderOutput: [i]->0x%08x\n", i, encoderOutput[1]);
|
||||
printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
|
||||
//for (int i=1;i<coderArrayLength;i++) printf("encoderOutput: [i]->0x%08x\n", i, encoderOutput[1]);
|
||||
#endif
|
||||
|
||||
//Bit-to-byte:
|
||||
@@ -277,14 +277,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
//BPSK modulation
|
||||
for(int i=0; i<coderLength; i++) {
|
||||
if (encoderOutputByte[i] == 0)
|
||||
modulatedInput[i]=1/sqrt(2);
|
||||
else
|
||||
modulatedInput[i]=(-1)/sqrt(2);
|
||||
if (encoderOutputByte[i] == 0)
|
||||
modulatedInput[i]=1/sqrt(2);
|
||||
else
|
||||
modulatedInput[i]=(-1)/sqrt(2);
|
||||
|
||||
channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
|
||||
if (decoder_int16==1) {
|
||||
if (decoder_int16==1) {
|
||||
if (channelOutput[i] > 15)
|
||||
channelOutput_int16[i] = 127;
|
||||
else if (channelOutput[i] < -16)
|
||||
@@ -296,17 +296,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
start_meas(&timeDecoder);
|
||||
|
||||
if (decoder_int16==1) {
|
||||
if (decoder_int16 == 1) {
|
||||
decoderState = polar_decoder_int16(channelOutput_int16,
|
||||
(uint64_t *)estimatedOutput,
|
||||
0,
|
||||
polarMessageType,
|
||||
testLength,
|
||||
aggregation_level);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0) {
|
||||
} else { // 0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0) {
|
||||
decoderState =
|
||||
polar_decoder(channelOutput, estimatedOutput, decoderListSize, polarMessageType, testLength, aggregation_level);
|
||||
polar_decoder(channelOutput, estimatedOutput, decoderListSize, polarMessageType, testLength, aggregation_level);
|
||||
} else if (polarMessageType == 1) {
|
||||
decoderState = polar_decoder_dci(channelOutput,
|
||||
estimatedOutput,
|
||||
@@ -325,28 +325,28 @@ int main(int argc, char *argv[])
|
||||
|
||||
//calculate errors
|
||||
if (decoderState!=0) {
|
||||
blockErrorState=-1;
|
||||
nBitError=-1;
|
||||
blockErrorState=-1;
|
||||
nBitError=-1;
|
||||
} else {
|
||||
for (int i = 0; i < (testArrayLength-1); i++) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
if ( ((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1) )
|
||||
nBitError++;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < testLength - ((testArrayLength-1) * 32); j++)
|
||||
if ( ((estimatedOutput[(testArrayLength-1)]>>j) & 1) != ((testInput[(testArrayLength-1)]>>j) & 1) )
|
||||
nBitError++;
|
||||
for (int i = 0; i < (testArrayLength-1); i++) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
if ( ((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1) )
|
||||
nBitError++;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < testLength - ((testArrayLength-1) * 32); j++)
|
||||
if ( ((estimatedOutput[(testArrayLength-1)]>>j) & 1) != ((testInput[(testArrayLength-1)]>>j) & 1) )
|
||||
nBitError++;
|
||||
}
|
||||
if (nBitError>0) blockErrorState=1;
|
||||
#ifdef DEBUG_POLARTEST
|
||||
for (int i = 0; i < testArrayLength; i++)
|
||||
printf("[polartest/decoderState=%u] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n",
|
||||
decoderState,
|
||||
i,
|
||||
testInput[i],
|
||||
i,
|
||||
estimatedOutput[i]);
|
||||
for (int i = 0; i < testArrayLength; i++)
|
||||
printf("[polartest/decoderState=%u] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n",
|
||||
decoderState,
|
||||
i,
|
||||
testInput[i],
|
||||
i,
|
||||
estimatedOutput[i]);
|
||||
#endif
|
||||
|
||||
//Iteration times are in microseconds.
|
||||
@@ -363,9 +363,9 @@ int main(int argc, char *argv[])
|
||||
decoderState=0;
|
||||
nBitError=0;
|
||||
blockErrorState=0;
|
||||
memset(testInput,0,sizeof(uint32_t) * realArrayLength);
|
||||
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
|
||||
memset(testInput,0,sizeof(uint32_t) * realArrayLength);
|
||||
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
|
||||
}
|
||||
|
||||
//Calculate error statistics for the SNR.
|
||||
|
||||
@@ -592,29 +592,6 @@ int8_t polar_decoder_dci(double *input,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
|
||||
AssertFatal(polarParams->K > 17, "K = %d < 18, is not allowed\n",polarParams->K);
|
||||
AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
|
||||
int numbytes = (polarParams->K + 7) / 8;
|
||||
for (int byte=0; byte<numbytes; byte++) {
|
||||
int numbits = byte < (polarParams->K >> 3) ? 8 : polarParams->K & 7;
|
||||
|
||||
for (int bit = 0; bit < numbits; bit++) {
|
||||
// flip bit endian for B
|
||||
int ip = polarParams->K - 1 - polarParams->interleaving_pattern[(8 * byte) + bit];
|
||||
int ipmod64 = ip & 63;
|
||||
AssertFatal(ip < 128, "ip = %d\n", ip);
|
||||
for (int val=0; val<256; val++) {
|
||||
int bit_i = (val >> bit) & 1;
|
||||
if (ip < 64)
|
||||
polarParams->B_tab0[byte][val] |= ((uint64_t)bit_i) << ipmod64;
|
||||
else
|
||||
polarParams->B_tab1[byte][val] |= ((uint64_t)bit_i) << ipmod64;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void nr_polar_rate_matching_int16(int16_t *input,
|
||||
int16_t *output,
|
||||
const uint16_t *rmp,
|
||||
@@ -644,28 +621,29 @@ static inline void nr_polar_info_extraction_from_u(uint64_t *Cprime,
|
||||
const uint8_t *u,
|
||||
const uint8_t *information_bit_pattern,
|
||||
const uint8_t *parity_check_bit_pattern,
|
||||
const uint16_t *interleaving_pattern,
|
||||
uint16_t N,
|
||||
uint8_t n_pc)
|
||||
uint8_t n_pc,
|
||||
int K)
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
if (n_pc > 0) {
|
||||
for (int n = 0; n < N; n++) {
|
||||
if (information_bit_pattern[n] == 1) {
|
||||
if (parity_check_bit_pattern[n] == 0) {
|
||||
int k1 = k >> 6;
|
||||
int k2 = k - (k1 << 6);
|
||||
Cprime[k1] |= (uint64_t)u[n] << k2;
|
||||
k++;
|
||||
}
|
||||
if (information_bit_pattern[n] == 1 && parity_check_bit_pattern[n] == 0) {
|
||||
int targetBit = K - 1 - interleaving_pattern[k];
|
||||
int k1 = targetBit >> 6;
|
||||
int k2 = targetBit & 63;
|
||||
Cprime[k1] |= (uint64_t)u[n] << k2;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (int n = 0; n < N; n++) {
|
||||
if (information_bit_pattern[n] == 1) {
|
||||
int k1 = k >> 6;
|
||||
int k2 = k - (k1 << 6);
|
||||
int targetBit = K - 1 - interleaving_pattern[k];
|
||||
int k1 = targetBit >> 6;
|
||||
int k2 = targetBit & 63;
|
||||
Cprime[k1] |= (uint64_t)u[n] << k2;
|
||||
k++;
|
||||
}
|
||||
@@ -725,18 +703,8 @@ uint32_t polar_decoder_int16(int16_t *input,
|
||||
#endif
|
||||
uint8_t nr_polar_U[N];
|
||||
memset(nr_polar_U, 0, sizeof(nr_polar_U));
|
||||
static uint64_t cnt = 0, timeTree = 0, timeDecoder = 0;
|
||||
uint64_t a = rdtsc_oai();
|
||||
decoder_tree_t tree;
|
||||
build_decoder_tree(&tree, polarParams);
|
||||
uint64_t b = rdtsc_oai();
|
||||
memcpy(treeAlpha(tree.root), d_tilde, sizeof(d_tilde));
|
||||
generic_polar_decoder(polarParams, tree.root, nr_polar_U);
|
||||
uint64_t c = rdtsc_oai();
|
||||
timeTree += b - a;
|
||||
timeDecoder += c - b;
|
||||
if (cnt++ % 1000 == 0)
|
||||
printf("tree: %ld, dec %ld\n", timeTree / (cnt), timeDecoder / (cnt));
|
||||
memcpy(treeAlpha(polarParams->decoder.root), d_tilde, sizeof(d_tilde));
|
||||
generic_polar_decoder(polarParams, polarParams->decoder.root, nr_polar_U);
|
||||
#ifdef POLAR_CODING_DEBUG
|
||||
printf("u: ");
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -749,13 +717,15 @@ uint32_t polar_decoder_int16(int16_t *input,
|
||||
#endif
|
||||
|
||||
// Extract the information bits (û to ĉ)
|
||||
uint64_t Cprime[4]= {0};
|
||||
nr_polar_info_extraction_from_u(Cprime,
|
||||
uint64_t B[4] = {0};
|
||||
nr_polar_info_extraction_from_u(B,
|
||||
nr_polar_U,
|
||||
polarParams->information_bit_pattern,
|
||||
polarParams->parity_check_bit_pattern,
|
||||
polarParams->interleaving_pattern,
|
||||
N,
|
||||
polarParams->n_pc);
|
||||
polarParams->n_pc,
|
||||
polarParams->K);
|
||||
|
||||
#ifdef POLAR_CODING_DEBUG
|
||||
printf("c: ");
|
||||
@@ -765,55 +735,7 @@ uint32_t polar_decoder_int16(int16_t *input,
|
||||
}
|
||||
int n1 = n >> 6;
|
||||
int n2 = n - (n1 << 6);
|
||||
printf("%lu", (Cprime[n1] >> n2) & 1);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
//Deinterleaving (ĉ to b)
|
||||
uint8_t *Cprimebyte = (uint8_t *)Cprime;
|
||||
uint64_t B[4] = {0};
|
||||
|
||||
if (polarParams->K<65) {
|
||||
B[0] = polarParams->B_tab0[0][Cprimebyte[0]] | polarParams->B_tab0[1][Cprimebyte[1]] | polarParams->B_tab0[2][Cprimebyte[2]]
|
||||
| polarParams->B_tab0[3][Cprimebyte[3]] | polarParams->B_tab0[4][Cprimebyte[4]] | polarParams->B_tab0[5][Cprimebyte[5]]
|
||||
| polarParams->B_tab0[6][Cprimebyte[6]] | polarParams->B_tab0[7][Cprimebyte[7]];
|
||||
} else if (polarParams->K<129) {
|
||||
for (int k = 0; k < 8; k++) {
|
||||
B[0] |= polarParams->B_tab0[k][Cprimebyte[k]];
|
||||
B[1] |= polarParams->B_tab1[k][Cprimebyte[k]];
|
||||
}
|
||||
}
|
||||
|
||||
uint128_t Cprime128 = *(uint128_t *)Cprime;
|
||||
uint128_t res = 0;
|
||||
uint deinterleaving_pattern[polarParams->K];
|
||||
|
||||
for (int i = 0; i < polarParams->K; i++)
|
||||
deinterleaving_pattern[polarParams->interleaving_pattern[i]] = i;
|
||||
for (int i = 0; i < polarParams->K; i++) {
|
||||
uint128_t bit = (Cprime128 >> i) & 1;
|
||||
res |= bit << (polarParams->K - 1 - deinterleaving_pattern[i]);
|
||||
}
|
||||
uint128_t B128 = *(uint128_t *)B;
|
||||
printf("old:(k=%d)", polarParams->K);
|
||||
for (int i = 0; i < polarParams->K; i++)
|
||||
printf("%lld", (B128 >> i) & 1);
|
||||
printf("\nnew:(k=%d)", polarParams->K);
|
||||
for (int i = 0; i < polarParams->K; i++)
|
||||
printf("%lld", (res >> i) & 1);
|
||||
printf("\n\n");
|
||||
#ifdef POLAR_CODING_DEBUG
|
||||
int B_array = (polarParams->K + 63) >> 6;
|
||||
int n_start = (B_array << 6) - polarParams->K;
|
||||
printf("b: ");
|
||||
for (int n = 0; n < polarParams->K; n++) {
|
||||
if (n % 4 == 0) {
|
||||
printf(" ");
|
||||
}
|
||||
int n1 = (n + n_start) >> 6;
|
||||
int n2 = (n + n_start) - (n1 << 6);
|
||||
printf("%lu", (B[B_array - 1 - n1] >> (63 - n2)) & 1);
|
||||
printf("%lu", (B[n1] >> n2) & 1);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
@@ -161,8 +161,10 @@ static inline decoder_node_t *new_decoder_node(simde__m256i **buffer,
|
||||
if (leaf_sz > 15) // we will use SIMD256
|
||||
leaf_sz = (leaf_sz + 15) & ~15;
|
||||
const int tree_sz = (sizeof(decoder_node_t) + 31) & ~31;
|
||||
decoder_node_t *node = (decoder_node_t *)*buffer;
|
||||
*buffer = *buffer + (tree_sz + leaf_sz * sizeof(int16_t) + leaf_sz + sizeof(**buffer) - 1) / sizeof(**buffer);
|
||||
uintptr_t tmp = (uintptr_t)*buffer;
|
||||
tmp = (tmp + sizeof(**buffer) - 1) & ~(sizeof(**buffer) - 1);
|
||||
decoder_node_t *node = (decoder_node_t *)tmp;
|
||||
*buffer = (simde__m256i *)(tmp + tree_sz + leaf_sz * sizeof(int16_t) + leaf_sz);
|
||||
*node = (decoder_node_t){.first_leaf_index = first_leaf_index,
|
||||
.level = level,
|
||||
.leaf = leaf,
|
||||
@@ -204,17 +206,16 @@ static inline decoder_node_t *add_nodes(decoder_tree_t *tree,
|
||||
return(new_node);
|
||||
}
|
||||
|
||||
void build_decoder_tree(decoder_tree_t *tree, const t_nrPolar_params *pp)
|
||||
void build_decoder_tree(t_nrPolar_params *pp)
|
||||
{
|
||||
simde__m256i *buffer = tree->buffer;
|
||||
tree->root = add_nodes(tree, pp->n, 0, pp->information_bit_pattern, &buffer);
|
||||
AssertFatal(buffer < tree->buffer + sizeofArray(tree->buffer),
|
||||
uintptr_t tmp = (uintptr_t)pp->decoder.buffer;
|
||||
tmp = (tmp + sizeof(*pp->decoder.buffer) - 1) & ~(sizeof(*pp->decoder.buffer) - 1);
|
||||
simde__m256i *buffer = (simde__m256i *)tmp;
|
||||
pp->decoder.root = add_nodes(&pp->decoder, pp->n, 0, pp->information_bit_pattern, &buffer);
|
||||
AssertFatal(buffer < pp->decoder.buffer + sizeofArray(pp->decoder.buffer),
|
||||
"Arbitrary size too small (also check arbitrary max size of the entire polar decoder) %ld instead of max %ld\n",
|
||||
buffer - tree->buffer,
|
||||
sizeofArray(tree->buffer));
|
||||
#ifdef DEBUG_NEW_IMPL
|
||||
printf("root : left %p, right %p\n", tree->root->left, tree->root->right);
|
||||
#endif
|
||||
buffer - pp->decoder.buffer,
|
||||
sizeofArray(pp->decoder.buffer));
|
||||
}
|
||||
|
||||
static inline void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output)
|
||||
|
||||
@@ -113,8 +113,7 @@ typedef struct nrPolar_params {
|
||||
int *rm_tab;
|
||||
uint64_t cprime_tab0[16][256];
|
||||
uint64_t cprime_tab1[16][256];
|
||||
uint64_t B_tab0[16][256];
|
||||
uint64_t B_tab1[16][256];
|
||||
decoder_tree_t decoder;
|
||||
} t_nrPolar_params;
|
||||
|
||||
void polar_encoder(uint32_t *input,
|
||||
@@ -172,9 +171,8 @@ static inline int8_t *treeBeta(decoder_node_t *node)
|
||||
return (int8_t *)node + node->beta;
|
||||
}
|
||||
|
||||
void build_decoder_tree(decoder_tree_t *tree, const t_nrPolar_params *pp);
|
||||
void build_decoder_tree(t_nrPolar_params *pp);
|
||||
void build_polar_tables(t_nrPolar_params *polarParams);
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
|
||||
|
||||
void nr_polar_print_polarParams(void);
|
||||
|
||||
|
||||
@@ -452,6 +452,8 @@ void build_polar_tables(t_nrPolar_params *polarParams) {
|
||||
// rerun again to create groups
|
||||
for (int outpos = 0, tcnt = 0; outpos < polarParams->encoderLength; outpos += mingroupsize, tcnt++)
|
||||
polarParams->rm_tab[tcnt] = polarParams->rate_matching_pattern[outpos] >> shift;
|
||||
|
||||
build_decoder_tree(polarParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -246,8 +246,6 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui
|
||||
qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp);
|
||||
|
||||
build_polar_tables(newPolarInitNode);
|
||||
|
||||
init_polar_deinterleaver_table(newPolarInitNode);
|
||||
return newPolarInitNode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user