Files
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

98 lines
3.5 KiB
C

/*
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
*/
#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
#include "assertions.h"
#include "PHY/sse_intrin.h"
#if defined(__AVX512F__)
#include <simde/x86/avx512.h>
// simde current version missed this instruction
#define simde_mm512_reduce_add_epi32 _mm512_reduce_add_epi32
#define simde_mm512_cvtepi8_epi32 _mm512_cvtepi8_epi32
#endif
//#define DEBUG_DECODESMALLBLOCK
//input = [d̂_0] [d̂_1] [d̂_2] ... [d̂_31]
//output = [? ... ? ĉ_K-1 ... ĉ_2 ĉ_1 ĉ_0]
uint16_t decodeSmallBlock(int8_t *in, uint8_t len){
uint16_t out = 0;
AssertFatal(len >= 3 && len <= 11, "[decodeSmallBlock] Message Length = %d (Small Block Coding is only defined for input lengths 3 to 11)", len);
if(len<7) {
int16_t Rhat[NR_SMALL_BLOCK_CODED_BITS] = {0}, Rhatabs[NR_SMALL_BLOCK_CODED_BITS] = {0};
uint16_t maxVal;
uint8_t maxInd = 0;
uint8_t jmax = (1<<(len-1));
for (int j = 0; j < jmax; ++j)
for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k)
Rhat[j] += in[k] * hadamard32InterleavedTransposed[j][k];
for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; i += 16) {
simde__m256i a15_a0 = simde_mm256_loadu_si256((simde__m256i*)&Rhat[i]);
a15_a0 = simde_mm256_abs_epi16(a15_a0);
simde_mm256_storeu_si256((simde__m256i*)(&Rhatabs[i]), a15_a0);
}
maxVal = Rhatabs[0];
for (int k = 1; k < jmax; ++k){
if (Rhatabs[k] > maxVal){
maxVal = Rhatabs[k];
maxInd = k;
}
}
out = properOrderedBasis[maxInd] | ( (Rhat[maxInd] > 0) ? (uint16_t)0 : (uint16_t)1 );
#ifdef DEBUG_DECODESMALLBLOCK
for (int k = 0; k < jmax; ++k)
printf("[decodeSmallBlock]Rhat[%d]=%d %d %d %d\n",k, Rhat[k], maxVal, maxInd, ((uint32_t)out>>k)&1);
printf("[decodeSmallBlock]0x%x 0x%x\n", out, properOrderedBasis[maxInd]);
#endif
} else {
uint8_t maxRow = 0, maxCol = 0;
int16_t maxVal = 0;
int DmatrixElementVal = 0;
#if !defined(__AVX512F__)
int8_t DmatrixElement[NR_SMALL_BLOCK_CODED_BITS] = {0};
#endif
simde__m256i _in_256 = simde_mm256_loadu_si256 ((simde__m256i*)&in[0]);
simde__m256i _maskD_256, _Dmatrixj_256, _maskH_256, _DmatrixElement_256;
for (int j = 0; j < ( 1<<(len-6) ); ++j) {
_maskD_256 = simde_mm256_loadu_si256 ((simde__m256i*)(&maskD[j][0]));
_Dmatrixj_256 = simde_mm256_sign_epi8 (_in_256, _maskD_256);
for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) {
_maskH_256 = simde_mm256_loadu_si256 ((simde__m256i*)(&hadamard32InterleavedTransposed[k][0]));
_DmatrixElement_256 = simde_mm256_sign_epi8 (_Dmatrixj_256, _maskH_256);
#if defined(__AVX512F__)
DmatrixElementVal = simde_mm512_reduce_add_epi32(
simde_mm512_add_epi32(simde_mm512_cvtepi8_epi32(simde_mm256_extracti128_si256(_DmatrixElement_256, 1)),
simde_mm512_cvtepi8_epi32(simde_mm256_castsi256_si128(_DmatrixElement_256))));
#else
simde_mm256_storeu_si256((simde__m256i*)(&DmatrixElement[0]), _DmatrixElement_256);
for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i)
DmatrixElementVal += DmatrixElement[i];
#endif
if (abs(DmatrixElementVal) > abs(maxVal)){
maxVal = DmatrixElementVal;
maxRow = j;
maxCol = k;
}
DmatrixElementVal=0;
}
}
out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (maxVal > 0) ? (uint16_t)0 : (uint16_t)1 );
#ifdef DEBUG_DECODESMALLBLOCK
for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k)
printf("[decodeSmallBlock]maxRow = %d maxCol = %d out[%d]=%d\n", maxRow, maxCol, k, ((uint32_t)out>>k)&1);
#endif
}
return out;
}