Merge remote-tracking branch 'origin/replace-INT16_MIN-when-obvious' into integration_2025_w41 (!3472)
Replace int16 min when obvious INT16_MIN doesn't have a opposite value on 16 bits, so SIMD abs (absolute()), or simple C operations doesn't make the expected result. example: (gdb) p (short)-(short)-32768 $4 = -32768 (gdb) This MR replaces constants INT16_MIN by -INT16_MAX (so -32767) in places where it used for mathematical operations. This is not perfect, nevertheless reduces overflow probability. We saw in some places a dirty case: code do first calls to _mm_adds_epi16 (or subs), so because of the saturated operations, the probability to reach 32767 and -32768 is higher than the other numbers but, _mm_abs_epi16(), or negate operations (conjugate) can follow, that is making strong error as abs(-32768)=-32768
This commit is contained in:
@@ -123,9 +123,6 @@ typedef char Binary;
|
||||
typedef short llr_t; // internal decoder data is 16-bit fixed
|
||||
typedef short channel_t;
|
||||
|
||||
#define LLR_MAX 32767
|
||||
#define LLR_MIN -32768
|
||||
#define LLRTOT 16
|
||||
#define MAX 32767//16383
|
||||
#define FRAME_LENGTH_MAX 6144
|
||||
#define STATES 8
|
||||
|
||||
@@ -526,11 +526,7 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms,
|
||||
|
||||
//if ((1<<(sub_frame_number%T_SFC))&transmission_offset_tdd[Ssrs]) {
|
||||
|
||||
if (generate_srs(frame_parms,
|
||||
soundingrs_ul_config_dedicated,
|
||||
&srs_vars->srs[eNB_id],
|
||||
0x7FFF,
|
||||
subframe)==-1) {
|
||||
if (generate_srs(frame_parms, soundingrs_ul_config_dedicated, &srs_vars->srs[eNB_id], INT16_MAX, subframe) == -1) {
|
||||
LOG_E(PHY,"lte_srs_channel_estimation: Error in generate_srs\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB,
|
||||
uint8_t m,l;
|
||||
uint8_t n_cs,alpha_ind;
|
||||
int16_t tmp_re,tmp_im,W_re=0,W_im=0;
|
||||
int16_t W4_nouse[4]={32767,32767,-32768,-32768};
|
||||
int16_t W4_nouse[4] = {32767, 32767, -32767, -32767};
|
||||
int32_t n0_IQ[2];
|
||||
double interference_power;
|
||||
int16_t *rxptr;
|
||||
|
||||
@@ -72,7 +72,7 @@ void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7])
|
||||
}
|
||||
}
|
||||
|
||||
const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32768, 32767, -32768}, {32767, -32768, -32768, 32767}};
|
||||
const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32767, 32767, -32767}, {32767, -32767, -32767, 32767}};
|
||||
const int16_t W3_re[3][6] = {{32767, 32767, 32767}, {32767, -16384, -16384}, {32767, -16384, -16384}};
|
||||
|
||||
const int16_t W3_im[3][6] = {{0, 0, 0}, {0, 28377, -28378}, {0, -28378, 28377}};
|
||||
@@ -334,8 +334,8 @@ const uint8_t chcod_tbl[128][48] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
{0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1}};
|
||||
|
||||
const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384, -1, 16383, 28377};
|
||||
const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384};
|
||||
const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377};
|
||||
const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384};
|
||||
|
||||
// W5_TBL
|
||||
const int16_t W5_fmt3_re[5][5] = {{32767, 32767, 32767, 32767, 32767},
|
||||
|
||||
@@ -2867,16 +2867,16 @@ void float_to_chan_est(int32_t **dl_ch_estimates_ext,
|
||||
for (aarx=0; aarx<n_rx; aarx++) {
|
||||
for (re=0; re<length; re++) {
|
||||
if (cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])<-1)
|
||||
imag = 0x8000;
|
||||
imag = -INT16_MAX;
|
||||
else if (cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])>=1)
|
||||
imag = 0x7FFF;
|
||||
imag = INT16_MAX;
|
||||
else
|
||||
imag = cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768;
|
||||
|
||||
if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])<-1)
|
||||
real = 0x8000;
|
||||
real = -INT16_MAX;
|
||||
else if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])>=1)
|
||||
real = 0x7FFF;
|
||||
real = INT16_MAX;
|
||||
else
|
||||
real = creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768;
|
||||
|
||||
@@ -2910,16 +2910,16 @@ void float_to_rxdataF(int32_t **rxdataF_ext,
|
||||
for (aarx=0; aarx<n_rx; aarx++) {
|
||||
for (re=0; re<length; re++) {
|
||||
if (cimag(rxdataF_f[aarx][re])<-1)
|
||||
imag = 0x8000;
|
||||
imag = -INT16_MAX;
|
||||
else if (cimag(rxdataF_f[aarx][re])>=1)
|
||||
imag = 0x7FFF;
|
||||
imag = INT16_MAX;
|
||||
else
|
||||
imag = cimag(rxdataF_f[aarx][re])*32768;
|
||||
|
||||
if (creal(rxdataF_f[aarx][re])<-1)
|
||||
real = 0x8000;
|
||||
real = -INT16_MAX;
|
||||
else if (creal(rxdataF_f[aarx][re])>=1)
|
||||
real = 0x7FFF;
|
||||
real = INT16_MAX;
|
||||
else
|
||||
real = creal(rxdataF_f[aarx][re])*32768;
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue,
|
||||
//uint32_t phase_shift; // phase shift for cyclic delay in DM RS
|
||||
//uint8_t alpha_ind;
|
||||
|
||||
int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377};
|
||||
int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384};
|
||||
int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377};
|
||||
int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384};
|
||||
|
||||
uint8_t cyclic_shift,cyclic_shift0=0,cyclic_shift1=0;
|
||||
LTE_DL_FRAME_PARMS *fp = (ue==NULL) ? frame_parms : &ue->frame_parms;
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
// length : length of vector in complex samples
|
||||
|
||||
#define shift 4
|
||||
//#define shift_DC 0
|
||||
//#define SHRT_MIN -32768
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Average Power calculation with DC removing
|
||||
|
||||
@@ -27,11 +27,12 @@
|
||||
#include "sched_eNB.h"
|
||||
|
||||
// This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25
|
||||
static const int16_t hundred_times_delta_TF[100] = {-32768, -1268, -956, -768, -631, -523, -431, -352, -282, -219, -161, -107, -57, -9, 36, 79, 120, 159, 197, 234,
|
||||
269, 304, 337, 370, 402, 434, 465, 495, 525, 555, 583, 612, 640, 668, 696, 723, 750, 777, 803, 829,
|
||||
856, 881, 907, 933, 958, 983, 1008, 1033, 1058, 1083, 1108, 1132, 1157, 1181, 1205, 1229, 1254, 1278, 1302, 1325,
|
||||
1349, 1373, 1397, 1421, 1444, 1468, 1491, 1515, 1538, 1562, 1585, 1609, 1632, 1655, 1679, 1702, 1725, 1748, 1772, 1795,
|
||||
1818, 1841, 1864, 1887, 1910, 1933, 1956, 1980, 2003, 2026, 2049, 2072, 2095, 2118, 2141, 2164, 2186, 2209, 2232, 2255};
|
||||
static const int16_t hundred_times_delta_TF[100] = {
|
||||
-32767, -1268, -956, -768, -631, -523, -431, -352, -282, -219, -161, -107, -57, -9, 36, 79, 120, 159, 197, 234,
|
||||
269, 304, 337, 370, 402, 434, 465, 495, 525, 555, 583, 612, 640, 668, 696, 723, 750, 777, 803, 829,
|
||||
856, 881, 907, 933, 958, 983, 1008, 1033, 1058, 1083, 1108, 1132, 1157, 1181, 1205, 1229, 1254, 1278, 1302, 1325,
|
||||
1349, 1373, 1397, 1421, 1444, 1468, 1491, 1515, 1538, 1562, 1585, 1609, 1632, 1655, 1679, 1702, 1725, 1748, 1772, 1795,
|
||||
1818, 1841, 1864, 1887, 1910, 1933, 1956, 1980, 2003, 2026, 2049, 2072, 2095, 2118, 2141, 2164, 2186, 2209, 2232, 2255};
|
||||
static const uint16_t hundred_times_log10_NPRB[100] = {0, 301, 477, 602, 698, 778, 845, 903, 954, 1000, 1041, 1079, 1113, 1146, 1176, 1204, 1230, 1255, 1278, 1301,
|
||||
1322, 1342, 1361, 1380, 1397, 1414, 1431, 1447, 1462, 1477, 1491, 1505, 1518, 1531, 1544, 1556, 1568, 1579, 1591, 1602,
|
||||
1612, 1623, 1633, 1643, 1653, 1662, 1672, 1681, 1690, 1698, 1707, 1716, 1724, 1732, 1740, 1748, 1755, 1763, 1770, 1778,
|
||||
|
||||
Reference in New Issue
Block a user