Commit f3e5ab10 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/remove-most-of-m64-type-usage' into...

Merge remote-tracking branch 'origin/remove-most-of-m64-type-usage' into integration_2025_w04 (!3209)

Remove most of m64 type usage

MMX instructions were first SIMD version, the registers management is complex
(_mm_empty()) so, it is better to remove it now and use more recent instructions

anyway, gcc/clang should replace it automatically as long as we enable sse2,
that should always be the case but for code understanding and for ARM porting
for example, it is better to explicitly remove it
parents 10392b5d b9991778
......@@ -47,14 +47,8 @@
//#define CALLGRIND 1
struct treillis {
union {
simde__m64 systematic_andp1_64[3];
uint8_t systematic_andp1_8[24];
};
union {
simde__m64 parity2_64[3];
uint8_t parity2_8[24];
};
uint8_t systematic_andp1[24] __attribute__((aligned(32)));
uint8_t parity2[24] __attribute__((aligned(32)));
int exit_state;
} __attribute__ ((aligned(64)));
......@@ -91,12 +85,11 @@ static void treillis_table_init(void) {
current_state=i;
for (b=0; b<8 ; b++ ) { // pre-compute the image of the byte j in _m128i vector right place
all_treillis[i][j].systematic_andp1_8[b*3]= (j&(1<<(7-b)))>>(7-b);
v=threegpplte_rsc( all_treillis[i][j].systematic_andp1_8[b*3] ,
&current_state);
all_treillis[i][j].systematic_andp1_8[b*3+1]=v; // for the yparity1
all_treillis[i][j].systematic_andp1[b * 3] = (j & (1 << (7 - b))) >> (7 - b);
v = threegpplte_rsc(all_treillis[i][j].systematic_andp1[b * 3], &current_state);
all_treillis[i][j].systematic_andp1[b * 3 + 1] = v; // for the yparity1
// all_treillis[i][j].parity1_8[b*3+1]=v; // for the yparity1
all_treillis[i][j].parity2_8[b*3+2]=v; // for the yparity2
all_treillis[i][j].parity2[b * 3 + 2] = v; // for the yparity2
}
all_treillis[i][j].exit_state=current_state;
......@@ -275,13 +268,9 @@ char interleave_compact_byte(short *base_interleaver,unsigned char *input, unsig
}
*/
void threegpplte_turbo_encoder_sse(unsigned char *input,
unsigned short input_length_bytes,
unsigned char *output,
unsigned char F) {
int i;
void threegpplte_turbo_encoder_sse(unsigned char *input, unsigned short input_length_bytes, unsigned char *output, unsigned char F)
{
unsigned char *x;
unsigned char state0=0,state1=0;
unsigned short input_length_bits = input_length_bytes<<3;
short *base_interleaver;
......@@ -290,6 +279,7 @@ void threegpplte_turbo_encoder_sse(unsigned char *input,
}
// look for f1 and f2 precomputed interleaver values
int i;
for (i=0; i < 188 && f1f2mat[i].nb_bits != input_length_bits; i++);
if ( i == 188 ) {
......@@ -301,24 +291,19 @@ void threegpplte_turbo_encoder_sse(unsigned char *input,
unsigned char systematic2[768] __attribute__((aligned(32)));
interleave_compact_byte(base_interleaver, input, systematic2, input_length_bytes);
simde__m64 *ptr_output = (simde__m64 *)output;
unsigned char cur_s1, cur_s2;
int code_rate;
for ( state0=state1=i=0 ; i<input_length_bytes; i++ ) {
cur_s1=input[i];
cur_s2=systematic2[i];
for (code_rate = 0; code_rate < 3; code_rate++) {
/*
*ptr_output++ = simde_mm_add_pi8(all_treillis[state0][cur_s1].systematic_64[code_rate],
simde_mm_add_pi8(all_treillis[state0][cur_s1].parity1_64[code_rate],
all_treillis[state1][cur_s2].parity2_64[code_rate]));
*/
*ptr_output++ = simde_mm_add_pi8(all_treillis[state0][cur_s1].systematic_andp1_64[code_rate],
all_treillis[state1][cur_s2].parity2_64[code_rate]);
unsigned char *ptr_output = output;
unsigned char state0 = 0, state1 = 0;
for (int i = 0; i < input_length_bytes; i++) {
int cur_s1 = input[i];
uint8_t *systematic_andp1 = all_treillis[state0][cur_s1].systematic_andp1;
int cur_s2 = systematic2[i];
uint8_t *parity2 = all_treillis[state1][cur_s2].parity2;
simde_mm_storeu_si128((simde__m128i *)ptr_output,
simde_mm_add_epi8(*(simde__m128i *)systematic_andp1, *(simde__m128i *)parity2));
ptr_output += 16;
for (int code_rate = 16; code_rate < 24; code_rate++) {
*ptr_output++ = systematic_andp1[code_rate] + parity2[code_rate];
}
state0=all_treillis[state0][cur_s1].exit_state;
state1=all_treillis[state1][cur_s2].exit_state;
}
......
......@@ -252,6 +252,7 @@ static inline void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node
simde__m128i minabs128 = simde_mm_min_epi16(absa128, absb128);
*((simde__m128i *)alpha_l) = simde_mm_sign_epi16(minabs128, simde_mm_sign_epi16(a128, b128));
} else if (avx2mod == 4) {
// this uses __m64, but only with SSE instructions, so we can disable MMX even with this piece of code
simde__m64 a64 = *((simde__m64 *)alpha_v);
simde__m64 b64 = ((simde__m64 *)alpha_v)[1];
simde__m64 absa64 = simde_mm_abs_pi16(a64);
......
......@@ -128,7 +128,7 @@ void phy_init_nr_gNB(PHY_VARS_gNB *gNB)
load_dftslib();
crcTableInit();
init_scrambling_luts();
init_byte2m128i();
init_pucch2_luts();
nr_init_fde(); // Init array for frequency equalization of transform precoding of PUSCH
......
......@@ -515,7 +515,7 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
init_delay_table(frame_parms->ofdm_symbol_size, MAX_DELAY_COMP, NR_MAX_OFDM_SYMBOL_SIZE, frame_parms->delay_table);
crcTableInit();
init_scrambling_luts();
init_byte2m128i();
load_dftslib();
init_context_synchro_nr(frame_parms);
generate_ul_reference_signal_sequences(SHRT_MAX);
......
This diff is collapsed.
......@@ -44,12 +44,10 @@ void nr_generate_csi_rs(const NR_DL_FRAME_PARMS *frame_parms,
const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csi_params,
const int slot,
const csi_mapping_parms_t *phy_csi_parms);
void init_byte2m128i(void);
void init_scrambling_luts(void);
void nr_generate_modulation_table(void);
extern simde__m64 byte2m64_re[256];
extern simde__m64 byte2m64_im[256];
extern simde__m128i byte2m128i[256];
int nr_pusch_lowpaprtype1_dmrs_rx(PHY_VARS_gNB *gNB,
......
......@@ -22,40 +22,13 @@
/* Lookup tables for 3GPP scrambling/unscrambling */
/* Author R. Knopp / EURECOM / OpenAirInterface.org */
#ifndef __SCRAMBLING_LUTS__C__
#define __SCRAMBLING_LUTS__C__
#include "PHY/impl_defs_nr.h"
#include "PHY/sse_intrin.h"
#include <common/utils/LOG/log.h>
simde__m64 byte2m64_re[256];
simde__m64 byte2m64_im[256];
simde__m128i byte2m128i[256];
void init_byte2m64(void) {
for (int s=0;s<256;s++) {
byte2m64_re[s] = simde_mm_insert_pi16(byte2m64_re[s],(1-2*(s&1)),0);
byte2m64_im[s] = simde_mm_insert_pi16(byte2m64_im[s],(1-2*((s>>1)&1)),0);
byte2m64_re[s] = simde_mm_insert_pi16(byte2m64_re[s],(1-2*((s>>2)&1)),1);
byte2m64_im[s] = simde_mm_insert_pi16(byte2m64_im[s],(1-2*((s>>3)&1)),1);
byte2m64_re[s] = simde_mm_insert_pi16(byte2m64_re[s],(1-2*((s>>4)&1)),2);
byte2m64_im[s] = simde_mm_insert_pi16(byte2m64_im[s],(1-2*((s>>5)&1)),2);
byte2m64_re[s] = simde_mm_insert_pi16(byte2m64_re[s],(1-2*((s>>6)&1)),3);
byte2m64_im[s] = simde_mm_insert_pi16(byte2m64_im[s],(1-2*((s>>7)&1)),3);
LOG_T(PHY,"init_scrambling_luts: s %x (%d) ((%d,%d),(%d,%d),(%d,%d),(%d,%d))\n",
((uint16_t*)&s)[0],
(1-2*(s&1)),
((int16_t*)&byte2m64_re[s])[0],((int16_t*)&byte2m64_im[s])[0],
((int16_t*)&byte2m64_re[s])[1],((int16_t*)&byte2m64_im[s])[1],
((int16_t*)&byte2m64_re[s])[2],((int16_t*)&byte2m64_im[s])[2],
((int16_t*)&byte2m64_re[s])[3],((int16_t*)&byte2m64_im[s])[3]);
}
}
void init_byte2m128i(void) {
for (int s=0;s<256;s++) {
......@@ -70,10 +43,3 @@ void init_byte2m128i(void) {
}
}
void init_scrambling_luts(void) {
init_byte2m64();
init_byte2m128i();
}
#endif
......@@ -44,42 +44,6 @@ int fullread(int fd, void *_buf, int count) {
return ret;
}
#define shift 4
int32_t signal_energy(int32_t *input,uint32_t length) {
int32_t i;
int32_t temp,temp2;
register simde__m64 mm0, mm1, mm2, mm3;
simde__m64 *in = (simde__m64 *)input;
mm0 = simde_mm_setzero_si64(); // pxor(mm0,mm0);
mm3 = simde_mm_setzero_si64(); // pxor(mm3,mm3);
for (i=0; i<length>>1; i++) {
mm1 = in[i];
mm2 = mm1;
mm1 = _m_pmaddwd(mm1,mm1);
mm1 = _m_psradi(mm1,shift);// shift any 32 bits blocs of the word by the value shift
mm0 = _m_paddd(mm0,mm1);// add the two 64 bits words 4 bytes by 4 bytes
// mm2 = _m_psrawi(mm2,shift_DC);
mm3 = _m_paddw(mm3,mm2);// add the two 64 bits words 2 bytes by 2 bytes
}
mm1 = mm0;
mm0 = _m_psrlqi(mm0,32);
mm0 = _m_paddd(mm0,mm1);
temp = _m_to_int(mm0);
temp/=length;
temp<<=shift; // this is the average of x^2
// now remove the DC component
mm2 = _m_psrlqi(mm3,32);
mm2 = _m_paddw(mm2,mm3);
mm2 = _m_pmaddwd(mm2,mm2);
temp2 = _m_to_int(mm2);
temp2/=(length*length);
// temp2<<=(2*shift_DC);
temp -= temp2;
return((temp>0)?temp:1);
}
void fullwrite(int fd, void *_buf, int count) {
char *buf = _buf;
......@@ -238,8 +202,8 @@ int main(int argc, char *argv[]) {
((int16_t *)buff)[i]/=16;
usleep(1000);
printf("sending at ts: %lu, number of samples: %d, energy: %d\n",
header.timestamp, header.size, signal_energy(buff, header.size));
printf("sending at ts: %lu, number of samples: %d\n",
header.timestamp, header.size);
fullwrite(serviceSock, buff, dataSize);
// Purge incoming samples
setblocking(serviceSock, notBlocking);
......
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