Commit 9c254730 authored by Laurent THOMAS's avatar Laurent THOMAS

fix polar race condition

parent f0116bea
......@@ -86,6 +86,7 @@ check_supported_distribution() {
"ubuntu20.04") return 0 ;;
"ubuntu20.10") return 0 ;;
"ubuntu21.04") return 0 ;;
"ubuntu21.10") return 0 ;;
esac
return 1
}
......
......@@ -268,7 +268,7 @@ int8_t polar_decoder(double *input,
if (decoderIterationCheck==0) {
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
return(-1);
polarReturn(-1);
}
nonFrozenBit++;
......@@ -301,7 +301,8 @@ int8_t polar_decoder(double *input,
* Return bits.
*/
nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out);
return(0);
polarReturn 0;
}
int8_t polar_decoder_dci(double *input,
......@@ -532,7 +533,7 @@ int8_t polar_decoder_dci(double *input,
if (decoderIterationCheck==0) {
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
return(-1);
polarReturn -1;
}
nonFrozenBit++;
......@@ -565,7 +566,8 @@ int8_t polar_decoder_dci(double *input,
* Return bits.
*/
nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out);
return(0);
polarReturn 0;
}
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
......@@ -705,5 +707,6 @@ uint32_t polar_decoder_int16(int16_t *input,
rxcrc,polarParams->payloadBits);
#endif
out[0]=Ar;
return(crc^rxcrc);
polarReturn crc^rxcrc;
}
......@@ -81,6 +81,7 @@ struct nrPolar_params {
//messageType: 0=PBCH, 1=DCI, -1=UCI
struct nrPolar_params *nextPtr __attribute__((aligned(16)));
bool busy;
uint32_t idx;
uint8_t n_max;
uint8_t i_il;
......@@ -344,4 +345,11 @@ 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 *);
#define polarReturn \
pthread_mutex_lock(&PolarListMutex); \
currentPtr->busy=false; \
pthread_mutex_unlock(&PolarListMutex); \
return
#endif
......@@ -153,6 +153,9 @@ void polar_encoder(uint32_t *in,
#endif
nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out);
polarReturn;
}
void polar_encoder_dci(uint32_t *in,
......@@ -256,6 +259,7 @@ void polar_encoder_dci(uint32_t *in,
printf("\n[polar_encoder_dci] out: ");
for (int i = 0; i < outputInd; i++) printf("[%d]->0x%08x\t", i, out[i]);
#endif
polarReturn;
}
static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline));
......@@ -698,4 +702,7 @@ void polar_encoder_fast(uint64_t *A,
}
memset((void*)out,0,polarParams->encoderLength>>3);
polar_rate_matching(polarParams,(void *)D, out);
polarReturn;
}
......@@ -100,10 +100,11 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
while (currentPtr != NULL) {
//printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength);
//LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime));
if (currentPtr->idx == PolarKey ) {
if (currentPtr->busy == false && currentPtr->idx == PolarKey ) {
currentPtr->busy=true;
pthread_mutex_unlock(&PolarListMutex);
if (decoder_flag && !currentPtr->tree.root)
build_decoder_tree(currentPtr);
pthread_mutex_unlock(&PolarListMutex);
return currentPtr ;
}
else
......@@ -113,8 +114,11 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
//Else, initialize and add node to the end of the linked list.
t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1);
newPolarInitNode->busy=true;
pthread_mutex_unlock(&PolarListMutex);
AssertFatal(newPolarInitNode != NULL, "[nr_polar_init] New t_nrPolar_params * could not be created");
if (newPolarInitNode != NULL) {
// LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime);
newPolarInitNode->idx = PolarKey;
newPolarInitNode->nextPtr = NULL;
......@@ -243,13 +247,9 @@ t_nrPolar_params * nr_polar_params(int8_t messageType,
build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode);
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
} else {
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
}
newPolarInitNode->nextPtr=PolarList;
PolarList=newPolarInitNode;
pthread_mutex_unlock(&PolarListMutex);
return newPolarInitNode;
}
......
......@@ -147,7 +147,7 @@ void do_OFDM_mod_l(int32_t **txdataF, int32_t **txdata, uint16_t next_slot, LTE_
}
void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, int tx_lev,int hold_channel,int abstx, int num_rounds, int trials, int round, channel_desc_t *eNB2UE[4],
double *s_re[2],double *s_im[2],double *r_re[2],double *r_im[2],FILE *csv_fd) {
double *s_re[NB_ANTENNAS_TX],double *s_im[[NB_ANTENNAS_TX],double *r_re[NB_ANTENNAS_RX],double *r_im[NB_ANTENNAS_RX],FILE *csv_fd) {
int i,u;
int aa,aarx,aatx;
double channelx,channely;
......
......@@ -340,10 +340,10 @@ int main(int argc, char **argv) {
double s_re1[30720],s_im1[30720],r_re1[30720],r_im1[30720];
double r_re2[30720],r_im2[30720];
double r_re3[30720],r_im3[30720];
double *s_re[2]= {s_re0,s_re1};
double *s_im[2]= {s_im0,s_im1};
double *r_re[4]= {r_re0,r_re1,r_re2,r_re3};
double *r_im[4]= {r_im0,r_im1,r_im2,r_im3};
double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1, NULL, NULL};
double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1, NULL, NULL};
double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1,r_re2,r_re3};
double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1,r_im2,r_im3};
double forgetting_factor=0.0; //in [0,1] 0 means a new channel every time, 1 means keep the same channel
double iqim=0.0;
int cqi_error,cqi_errors,ack_errors,cqi_crc_falsepositives,cqi_crc_falsenegatives;
......
......@@ -1096,6 +1096,7 @@ static int _nas_message_decrypt(
"Unknown security header type %u", security_header_type);
LOG_FUNC_RETURN (0);
};
LOG_FUNC_RETURN (0);
}
......
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