Commit 61f2bd10 authored by Laurent THOMAS's avatar Laurent THOMAS

more-polar-cleaning

parent 1a07ae2d
......@@ -805,7 +805,6 @@ set(PHY_POLARSRC
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
......
......@@ -2221,7 +2221,6 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h \
......
......@@ -34,14 +34,14 @@
void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) {
const uint arrayInd = ceil(arraySize / 32.0);
for (int i = 0; i < (arrayInd - 1); i++) {
for (int i = 0; i < arrayInd - 1; i++) {
for (int j = 0; j < 32; j++) {
out[j + (i * 32)] = (in[i] >> j) & 1;
out[j + i * 32] = (in[i] >> j) & 1;
}
}
for (int j = 0; j < arraySize - ((arrayInd - 1) * 32); j++)
out[j + ((arrayInd - 1) * 32)] = (in[(arrayInd - 1)] >> j) & 1;
out[j + (arrayInd - 1) * 32] = (in[arrayInd - 1] >> j) & 1;
}
void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) {
......@@ -49,9 +49,9 @@ void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) {
for (int i = 0; i < arrayInd; i++) {
out[i] = 0;
for (int j = 31; j > 0; j--) {
out[i] |= in[(i * 32) + j];
out[i] |= in[i * 32 + j];
out[i] <<= 1;
}
out[i] |= in[(i * 32)];
out[i] |= in[i * 32];
}
}
......@@ -80,7 +80,7 @@ int8_t polar_decoder(double *input,
double pathMetric[2*listSize];
uint8_t crcState[2*listSize]; //0=False, 1=True
for (int i=0; i<(2*listSize); i++) {
for (int i=0; i<2*listSize; i++) {
pathMetric[i] = 0;
crcState[i]=1;
}
......@@ -210,7 +210,7 @@ int8_t polar_decoder(double *input,
for (int k=(listSize-1); k>0; k--) {
for (int i = 0; i < polarParams->crcParityBits; i++) {
crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]];
crcChecksum[i][listIndex[(2*listSize-1) -k]] = crcChecksum[i][listIndex[k]];
}
}
......@@ -220,7 +220,7 @@ int8_t polar_decoder(double *input,
//Copy the best "listSize" number of entries to the first indices.
for (int k = 0; k < listSize; k++) {
if (k > listIndex[k]) {
copyIndex = listIndex[(2*listSize-1)-k];
copyIndex = listIndex[(2*listSize-1) -k];
} else { //Use the backup.
copyIndex = listIndex[k];
}
......@@ -235,7 +235,7 @@ int8_t polar_decoder(double *input,
for (int k = 0; k < listSize; k++) {
if (k > listIndex[k]) {
copyIndex = listIndex[(2*listSize-1)-k];
copyIndex = listIndex[(2*listSize-1) -k];
} else { //Use the backup.
copyIndex = listIndex[k];
}
......@@ -247,7 +247,7 @@ int8_t polar_decoder(double *input,
for (int k = 0; k < listSize; k++) {
if (k > listIndex[k]) {
copyIndex = listIndex[(2*listSize-1)-k];
copyIndex = listIndex[(2*listSize-1) -k];
} else { //Use the backup.
copyIndex = listIndex[k];
}
......@@ -595,7 +595,6 @@ int8_t polar_decoder_dci(double *input,
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 bit_i,ip,ipmod64;
int numbytes = polarParams->K>>3;
int residue = polarParams->K & 7;
......@@ -607,17 +606,17 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
for (int i=0; i<numbits; i++) {
// flip bit endian for B
ip = polarParams->K - 1 - polarParams->interleaving_pattern[(8 * byte) + i];
ipmod64 = ip&63;
int ip = polarParams->K - 1 - polarParams->interleaving_pattern[(8 * byte) + i];
int ipmod64 = ip&63;
AssertFatal(ip<128,"ip = %d\n",ip);
for (int val=0; val<256; val++) {
bit_i=(val>>i)&1;
uint64_t bit_i=(val>>i)&1;
if (ip < 64)
polarParams->B_tab0[byte][val] |= ((uint64_t)bit_i) << ipmod64;
polarParams->B_tab0[byte][val] |= bit_i << ipmod64;
else
polarParams->B_tab1[byte][val] |= ((uint64_t)bit_i) << ipmod64;
polarParams->B_tab1[byte][val] |= bit_i << ipmod64;
}
}
}
......
......@@ -68,7 +68,7 @@ void polar_encoder(uint32_t *in,
// Attach CRC to the Transport Block. (a to b)
memcpy(nr_polar_B, nr_polar_A, polarParams->payloadBits);
for (uint i = polarParams->payloadBits; i < polarParams->K; i++)
nr_polar_B[i] = nr_polar_crc[i - (polarParams->payloadBits)];
nr_polar_B[i] = nr_polar_crc[i - polarParams->payloadBits];
#ifdef DEBUG_POLAR_ENCODER
uint64_t B2 = 0;
......@@ -112,10 +112,8 @@ void polar_encoder(uint32_t *in,
for (uint i = 0; i < polarParams->N; i++)
nr_polar_D[i] %= 2;
uint64_t D[8];
memset(D, 0, sizeof(D));
#ifdef DEBUG_POLAR_ENCODER
uint64_t D[8]={0};
for (int i = 0; i < polarParams->N; i++)
D[i / 64] |= ((uint64_t)nr_polar_D[i]) << (i & 63);
......@@ -290,7 +288,7 @@ void nr_polar_rm_interleaving_cb(void *in, void *out, uint16_t E)
}
}
__attribute__((always_inline)) static inline void polar_rate_matching(const t_nrPolar_params *polarParams, void *in, void *out)
static inline void polar_rate_matching(const t_nrPolar_params *polarParams, void *in, void *out)
{
// handle rate matching with a single 128 bit word using bit shuffling
// can be done with SIMD intrisics if needed
......
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include "PHY/sse_intrin.h"
void nr_polar_kernal_operation(uint8_t *u, uint8_t *d, uint16_t N)
{
// Martino's algorithm to avoid multiplication for the generating matrix of polar codes
uint32_t i,j;
simde__m256i A,B,C,D,E,U,zerosOnly, OUT;
simde__m256i inc;
uint32_t dTest[8];
uint32_t uArray[8];
uint32_t k;
uint32_t incArray[8];
//initialisation
for(k=0; k<8; k++)
incArray[k]=k;
inc=simde_mm256_loadu_si256((simde__m256i const*)incArray); // 0, 1, ..., 7 to increase
zerosOnly=simde_mm256_setzero_si256(); // for comparison
for(i=0; i<N; i+=8)
{
B=simde_mm256_set1_epi32((int)i); // i, ..., i
B=simde_mm256_add_epi32(B, inc); // i, i+1, ..., i+7
OUT=simde_mm256_setzero_si256(); // it will contain the result of all the XORs for the d(i)s
for(j=0; j<N; j++)
{
A=simde_mm256_set1_epi32((int)(j)); //j, j, ..., j
A=simde_mm256_sub_epi32(A, B); //(j-i), (j-(i+1)), ... (j-(i+7))
U=simde_mm256_set1_epi32((int)u[j]);
simde_mm256_storeu_si256((simde__m256i*)uArray, U); //u(j) ... u(j) for the maskload
C=simde_mm256_and_si256(A, B); //(j-i)&i -> If zero, then XOR with the u(j)
D=simde_mm256_cmpeq_epi32(C, zerosOnly); // compare with zero and use the result as mask
E=simde_mm256_maskload_epi32((int const*)uArray, D); // load only some u(j)s for the XOR
OUT=simde_mm256_xor_si256(OUT, E); //32 bit x 8
}
simde_mm256_storeu_si256((simde__m256i*)dTest, OUT);
for(k=0; k<8; k++) // Conversion from 32 bits to 8 bits
{
d[i+k]=(uint8_t)dTest[k]; // With AVX512 there is an intrinsic to do it
}
}
}
......@@ -204,12 +204,12 @@ void nr_polar_bit_insertion(uint8_t *input,
} else {
for (int n=0; n<=N-1; n++) {
output[n] = 0;
for (int m=0; m<=(K+n_PC)-1; m++) {
for (int m=0; m<=K+n_PC-1; m++) {
if ( n == Q_I_N[m]) {
output[n] = input[k];
k++;
break;
}
}
}
}
}
......
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