Add changes for avx512/aarch64 ldpc encoder optimizations

newly-generated files for innermost part of the parity bit
generation which, for AVX512, uses the mm512_permutex2var_epi8
instruction and for 128-bit (aarch64) the mm_alignr_epi8 (vextq_s8) in
the computation corresponding to each non-zero bit of the H matrix.

It is generated with ldpctest -n0 -g1. the changes for this are in a
future MR.  I did these changes to compare with the GPU version
(ldpc_encoder_cuda), so that the CPU version is as fast as possible. The
generator will come when we merge the GPU encoder/decoder which also has
a generator for the CUDA version. it was difficult to extract the
changes in ldpctest/ldpc_encoder.c so I just took the generated file.

This allows for removing a very large memcpy and reduces the memory
demand for the parity matrix computation. For the moment this is limited
to largest case in BG1, namely Zc=384. This is the only format used when
the number of segments after codeblock segmentation is large (>8).  This
improves the timing required for ldpc parity bits generation by more
than a factor 2 with AVX512. This significantly reduces the total time
to generate the DLSCH/PDSCH
This commit is contained in:
Raymond Knopp
2025-09-02 08:55:08 +02:00
committed by Robert Schmidt
parent 48d19e8a91
commit 0e09c7c347
4 changed files with 544 additions and 3 deletions
@@ -36,13 +36,27 @@
#include "assertions.h"
#include "common/utils/LOG/log.h"
#define USE_PERMUTEX
#ifdef __aarch64__
#define USE_ALIGNR
#endif
#ifdef __AVX512F__
#if defined(__AVX512VBMI__) && defined(USE_PERMUTEX)
// For AVX512 machines, use an AVX512 version of the encoder for Zc=384 only for now. This is used almost exclusively for
// high-throughput cases. The version with "permutex2var" instruction uses less memory (i.e. 1/64th of the memory to store the
// input), but uses more reads instead of creating 64 shifts of the input with memcpy
#include "ldpc384_simd512_permutex_byte.c"
#else
#include "ldpc384_simd512_byte.c"
#endif
#else
#include "ldpc384_byte.c"
#endif
#ifdef USE_ALIGNR
#include "ldpc384_alignr_byte_128.c"
#else
#include "ldpc384_byte_128.c"
#endif
#include "ldpc352_byte.c"
#include "ldpc352_byte_128.c"
#include "ldpc320_byte.c"
@@ -96,8 +110,13 @@ static void encode_parity_check_part_optim(uint8_t *cc, uint8_t *d, short BG,sho
memcpy(&c[2 * i1 * Zc], &cc[i1 * Zc], Zc * sizeof(unsigned char));
memcpy(&c[(2 * i1 + 1) * Zc], &cc[i1 * Zc], Zc * sizeof(unsigned char));
}
for (int i1 = 1; i1 < simd_size; i1++) {
memcpy(&c[(2 * ncols * Zc * i1)], &c[i1], (2 * ncols * Zc * sizeof(unsigned char)) - i1);
#if (defined(USE_PERMUTEX) && defined(__AVX512VBMI__)) || defined(USE_ALIGNR)
if (Zc < 384 || BG == 2)
#endif
{
for (int i1 = 1; i1 < simd_size; i1++) {
memcpy(&c[(2 * ncols * Zc * i1)], &c[i1], (2 * ncols * Zc * sizeof(unsigned char)) - i1);
}
}
if (BG == 1) {
switch (Zc) {