Commit 8e3f720b authored by Laurent THOMAS's avatar Laurent THOMAS

fix unaligned mem for SIMD

parent 18a42157
...@@ -346,7 +346,7 @@ typedef struct { ...@@ -346,7 +346,7 @@ typedef struct {
@param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit) @param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit)
@param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1) @param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1)
*/ */
#define MATLAB_RAW (1<<31) #define MATLAB_RAW (1U<<31)
#define MATLAB_SHORT 0 #define MATLAB_SHORT 0
#define MATLAB_CSHORT 1 #define MATLAB_CSHORT 1
#define MATLAB_INT 2 #define MATLAB_INT 2
......
...@@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr, ...@@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr,
unsigned int i, crc = 0, c; unsigned int i, crc = 0, c;
while (octetlen-- > 0) { while (octetlen-- > 0) {
c = (*inputptr++) << 24; c = ((unsigned int)(*inputptr++)) << 24;
for (i = 8; i != 0; i--) { for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc)) if ((1U << 31) & (c ^ crc))
crc = (crc << 1) ^ poly; crc = (crc << 1) ^ poly;
else else
crc <<= 1; crc <<= 1;
......
...@@ -64,7 +64,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, ...@@ -64,7 +64,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
reset = 1; reset = 1;
x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
x2 = (x2tmp0+(nid<<1))%(1<<31); //cinit x2 = (x2tmp0+(nid<<1))%(1U<<31); //cinit
for (n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) { for (n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) {
ue->nr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset); ue->nr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset);
...@@ -95,7 +95,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue, ...@@ -95,7 +95,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,
reset = 1; reset = 1;
x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit x2 = (x2tmp0+(nid<<1)+nscid)%(1U<<31); //cinit
LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid);
for (n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) { for (n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) {
......
...@@ -149,9 +149,9 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini ...@@ -149,9 +149,9 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
// computing channel estimation for selected best ssb // computing channel estimation for selected best ssb
const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size; const int estimateSz=7*2*frame_parms->ofdm_symbol_size;
struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz];
struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz];
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++) for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_channel_estimation(ue,estimateSz, dl_ch_estimates, dl_ch_estimates_time, nr_pbch_channel_estimation(ue,estimateSz, dl_ch_estimates, dl_ch_estimates_time,
proc,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf); proc,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf);
......
...@@ -457,6 +457,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -457,6 +457,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][nb_re]; struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][nb_re];
//was dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); //was dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][20*12*4]; struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][20*12*4];
memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext);
nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF,
estimateSz, estimateSz,
dl_ch_estimates, dl_ch_estimates,
...@@ -540,7 +541,9 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); ...@@ -540,7 +541,9 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt));
nr_pbch_unscrambling(nr_ue_pbch_vars,pbch_e_rx,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0, pbch_a_prime, &pbch_a_interleaved); nr_pbch_unscrambling(nr_ue_pbch_vars,pbch_e_rx,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0, pbch_a_prime, &pbch_a_interleaved);
//polar decoding de-rate matching //polar decoding de-rate matching
const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList); const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&pbch_a_prime,0,currentPtr); uint64_t tmp=pbch_a_prime;
decoderState = polar_decoder_int16(pbch_e_rx,&tmp,0,currentPtr);
pbch_a_prime=tmp;
if(decoderState) return(decoderState); if(decoderState) return(decoderState);
......
...@@ -883,7 +883,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -883,7 +883,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
/* perform correlation of rx data and pss sequence ie it is a dot product */ /* perform correlation of rx data and pss sequence ie it is a dot product */
result = dot_product64((short*)primary_synchro_time_nr[pss_index], result = dot_product64((short*)primary_synchro_time_nr[pss_index],
(short*) &(rxdata[ar][n+is*frame_parms->samples_per_frame]), (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]),
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
shift); shift);
pss_corr_ue[pss_index][n] += abs64(result); pss_corr_ue[pss_index][n] += abs64(result);
......
...@@ -1404,8 +1404,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1404,8 +1404,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN);
LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
const int estimateSz=7*2*sizeof(int)*fp->ofdm_symbol_size; const int estimateSz=7*2*sizeof(int)*fp->ofdm_symbol_size;
struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz];
struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][estimateSz];
for (int i=1; i<4; i++) { for (int i=1; i<4; i++) {
nr_slot_fep(ue, nr_slot_fep(ue,
......
...@@ -430,13 +430,14 @@ int main(int argc, char **argv) ...@@ -430,13 +430,14 @@ int main(int argc, char **argv)
printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL); printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB = (PHY_VARS_gNB**) calloc(sizeof(PHY_VARS_gNB *),1);
RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0]; gNB = RC.gNB[0];
gNB->ofdm_offset_divisor = UINT_MAX; gNB->ofdm_offset_divisor = UINT_MAX;
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx; frame_parms->nb_antennas_rx = n_rx;
frame_parms->nb_antenna_ports_gNB=n_rx;
frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_DL = N_RB_DL;
frame_parms->Nid_cell = Nid_cell; frame_parms->Nid_cell = Nid_cell;
frame_parms->nushift = Nid_cell%4; frame_parms->nushift = Nid_cell%4;
...@@ -522,23 +523,17 @@ int main(int argc, char **argv) ...@@ -522,23 +523,17 @@ int main(int argc, char **argv)
s_im = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*));
r_re = malloc(2*sizeof(double*)); r_re = malloc(2*sizeof(double*));
r_im = malloc(2*sizeof(double*)); r_im = malloc(2*sizeof(double*));
txdata = malloc(2*sizeof(int*)); txdata = calloc(2,sizeof(int*));
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
s_re[i] = malloc(frame_length_complex_samples*sizeof(double)); s_re[i] = calloc(frame_length_complex_samples, sizeof(double));
bzero(s_re[i],frame_length_complex_samples*sizeof(double)); s_im[i] = calloc(frame_length_complex_samples, sizeof(double));
s_im[i] = malloc(frame_length_complex_samples*sizeof(double)); r_re[i] = calloc(frame_length_complex_samples, sizeof(double));
bzero(s_im[i],frame_length_complex_samples*sizeof(double)); r_im[i] = calloc(frame_length_complex_samples, sizeof(double));
r_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_re[i],frame_length_complex_samples*sizeof(double));
r_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_im[i],frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for txdata\n",frame_length_complex_samples); printf("Allocating %d samples for txdata\n",frame_length_complex_samples);
txdata[i] = malloc(frame_length_complex_samples*sizeof(int)); txdata[i] = calloc(frame_length_complex_samples, sizeof(int));
bzero(r_re[i],frame_length_complex_samples*sizeof(int));
} }
if (pbch_file_fd!=NULL) { if (pbch_file_fd!=NULL) {
...@@ -547,8 +542,8 @@ int main(int argc, char **argv) ...@@ -547,8 +542,8 @@ int main(int argc, char **argv)
//configure UE //configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE)); UE = calloc(1,sizeof(*UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); memcpy(&UE->frame_parms,frame_parms,sizeof(*frame_parms));
//phy_init_nr_top(UE); //called from init_nr_ue_signal //phy_init_nr_top(UE); //called from init_nr_ue_signal
if (run_initial_sync==1) UE->is_synchronized = 0; if (run_initial_sync==1) UE->is_synchronized = 0;
else UE->is_synchronized = 1; else UE->is_synchronized = 1;
...@@ -721,8 +716,8 @@ int main(int argc, char **argv) ...@@ -721,8 +716,8 @@ int main(int argc, char **argv)
UE->rx_offset=0; UE->rx_offset=0;
uint8_t ssb_index = 0; uint8_t ssb_index = 0;
const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size; const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size;
struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz];
struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz];
while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb
UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index); UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index);
......
...@@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP) ...@@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP)
{ {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
if (nameP) { if (nameP) {
strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 );
listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string
} }
......
...@@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP) ...@@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP)
{ {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
if (nameP) { if (nameP) {
strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 );
listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string
} }
......
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