From 12085219598c104fa1f4653d87f716fc3f26c90e Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 25 Apr 2025 14:11:11 +0200 Subject: [PATCH] remove dead code and a wrong comment --- .../CODING/nrPolar_tools/nr_polar_decoder.c | 2 +- .../nrPolar_tools/nr_polar_decoding_tools.c | 27 +++++-- .../nrPolar_tools/nr_polar_rate_match.c | 78 ------------------- 3 files changed, 20 insertions(+), 87 deletions(-) delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 14013681b0..8056d5f63d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -627,7 +627,7 @@ static inline void nr_polar_rate_matching_int16(int16_t *input, memset(output, 0, N * sizeof(*output)); // puncturing else { // shortening for (int i = 0; i <= N - 1; i++) - output[i] = 32767; // instead of INFINITY, to prevent [-Woverflow] + output[i] = INT16_MAX; } for (int i = 0; i <= E - 1; i++) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 80d82c3f8c..d1680e7206 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -306,14 +306,25 @@ static inline void applyGtoright(const t_nrPolar_params *pp, decoder_node_t *nod const int sz = 1 << (node->level - 1); if (node->right->all_frozen == 0) { if (!node->left->betaInit) { - for (int i = 0; i < sz; i++) { - int temp_alpha_r = alpha_v[i + sz] + alpha_v[i]; - if (temp_alpha_r > SHRT_MAX) { - alpha_r[i] = SHRT_MAX; - } else if (temp_alpha_r < -SHRT_MAX) { - alpha_r[i] = -SHRT_MAX; - } else { - alpha_r[i] = temp_alpha_r; + int avx2mod = sz & 15; + if (avx2mod == 0) { + int avx2len = sz / 16; + for (int i = 0; i < avx2len; i++) { + ((simde__m256i *)alpha_r)[i] = + simde_mm256_adds_epi16(((simde__m256i *)alpha_v)[i + avx2len], ((simde__m256i *)alpha_v)[i]); + } + } else if (avx2mod == 8) { + ((simde__m128i *)alpha_r)[0] = simde_mm_adds_epi16(((simde__m128i *)alpha_v)[1], ((simde__m128i *)alpha_v)[0]); + } else { + for (int i = 0; i < sz; i++) { + int temp_alpha_r = alpha_v[i + sz] + alpha_v[i]; + if (temp_alpha_r > SHRT_MAX) { + alpha_r[i] = SHRT_MAX; + } else if (temp_alpha_r < -SHRT_MAX) { + alpha_r[i] = -SHRT_MAX; + } else { + alpha_r[i] = temp_alpha_r; + } } } } else { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c deleted file mode 100644 index f5bca4a9b7..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E) -{ - int d[N]; - int y[N]; - - for (int m = 0; m <= N - 1; m++) - d[m] = m; - - for (int m = 0; m <= N - 1; m++) { - i = floor((32 * m) / N); - J[m] = P_i_[i] * (N / 32)) + (m % (N / 32); - y[m] = d[J[m]]; - } - - if (E >= N) { // repetition - for (int k = 0; k <= E - 1; k++) { - ind = k % N; - rmp[k] = y[ind]; - } - } else { - if ((K / (double)E) <= (7.0 / 16)) { // puncturing - for (int k = 0; k <= E - 1; k++) { - rmp[k] = y[k + N - E]; - } - } else { // shortening - for (int k = 0; k <= E - 1; k++) { - rmp[k] = y[k]; - } - } - } -} - -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E) -{ - if (E >= N) { // repetition - for (int i = 0; i <= N - 1; i++) - output[i] = 0; - for (int i = 0; i <= E - 1; i++) { - output[rmp[i]] += input[i]; - } - } else { - if ((K / (double)E) <= (7.0 / 16)) { // puncturing - for (int i = 0; i <= N - 1; i++) - output[i] = 0; - } else { // shortening - for (int i = 0; i <= N - 1; i++) - output[i] = INFINITY; - } - - for (int i = 0; i <= E - 1; i++) { - output[rmp[i]] = input[i]; - } - } -}