Agora
1.2.0
Agora project
|
Go to the documentation of this file.
8 #include "phy_ldpc_encoder_5gnr.h"
21 return reinterpret_cast<T*
>(rte_malloc(NULL,
sizeof(
T) *
size, alignment));
24 return reinterpret_cast<T*
>(std::aligned_alloc(alignment,
sizeof(
T) *
size));
26 return reinterpret_cast<T*
>(_aligned_malloc(
sizeof(
T) *
size, alignment));
32 #define __has_builtin(x) 0
36 #if __has_builtin(__builtin_bireverse8)
37 return (__builtin_bitreverse8(
x));
39 x = (
x << 4) | (
x >> 4);
40 x = ((
x & 0x33) << 2) | ((
x >> 2) & 0x33);
41 x = ((
x & 0x55) << 1) | ((
x >> 1) & 0x55);
61 uint8_t* bytes_out,
size_t len,
64 size_t bits_avail = 0;
65 for (
size_t i = 0;
i <
len;
i++) {
66 bits |=
static_cast<uint32_t
>(
Bitreverse8(bit_seq_in[
i]))
69 while (bits_avail >= mod_type) {
70 *bytes_out++ = bits >> (16 - mod_type);
72 bits_avail -= mod_type;
77 *bytes_out++ = bits >> (16 - mod_type);
87 int len,
int mod_type) {
90 for (
int i = 0;
i <
len;
i++) {
91 bits |= (
Bitreverse8(vec_in[
i]) >> (8 - mod_type)) << bits_avail;
92 bits_avail += mod_type;
93 while (bits_avail >= 8) {
94 *vec_out++ = bits & 0xff;
103 if ((Zc % 15) == 0) {
105 }
else if ((Zc % 13) == 0) {
107 }
else if ((Zc % 11) == 0) {
109 }
else if ((Zc % 9) == 0) {
111 }
else if ((Zc % 7) == 0) {
113 }
else if ((Zc % 5) == 0) {
115 }
else if ((Zc % 3) == 0) {
124 static inline size_t BitsToBytes(
size_t n_bits) {
return (n_bits + 7) / 8; }
152 static size_t num_punctured_cols = 2;
153 return zc * (base_graph == 1 ? (
BG1_COL_TOTAL - num_punctured_cols)
161 static size_t num_punctured_cols = 2;
196 int8_t* encoded_buffer,
197 int8_t* parity_buffer,
198 const int8_t* input_buffer) {
200 const size_t num_parity_bits = nRows * zc;
202 bblib_ldpc_encoder_5gnr_request req;
203 bblib_ldpc_encoder_5gnr_response resp;
204 req.baseGraph = base_graph;
208 req.numberCodeblocks = 1;
209 req.input[0] =
const_cast<int8_t*
>(input_buffer);
210 resp.output[0] = parity_buffer;
213 : bblib_ldpc_encoder_5gnr(&req, &resp);
217 static size_t k_num_punctured_cols = 2;
221 const size_t num_punctured_bytes =
BitsToBytes(zc * k_num_punctured_cols);
222 const size_t num_input_bytes_to_copy =
225 std::memcpy(encoded_buffer, input_buffer + num_punctured_bytes,
226 num_input_bytes_to_copy);
227 std::memcpy(encoded_buffer + num_input_bytes_to_copy, parity_buffer,
236 "Zc values >= %zu that are not multiples of four are not "
239 throw std::runtime_error(
240 "Zc values >= values that are not multiples of four");
253 adapter_func((int8_t*)input_buffer, internal_buffer0, zc, num_input_bits,
255 adapter_func(parity_buffer, internal_buffer1, zc, num_parity_bits, 1);
258 std::memcpy(internal_buffer2,
262 std::memcpy(internal_buffer2 +
269 adapter_func(encoded_buffer, internal_buffer2, zc,
274 #endif // UTILS_LDPC_H_
class RadioSocket __attribute__
Definitions for Agora's AVX2-based LDPC encoder.
static size_t LdpcEncodingInputBufSize(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:167
LDPC_ADAPTER_P LdpcSelectAdapterFunc(uint16_t zc_size)
Definition: iobuffer.cc:228
Declaration for for the avx2enc iobuffer functions.
static void AdaptBitsFromMod(const uint8_t *vec_in, uint8_t *vec_out, int len, int mod_type)
Definition: utils_ldpc.h:86
end IFFT Reshape the symbol vector into two different spatial streams size
Definition: generate_data.m:73
static constexpr size_t kMaxProcBytes
Definition: encoder.h:30
static void LdpcEncodeHelper(size_t base_graph, size_t zc, size_t nRows, int8_t *encoded_buffer, int8_t *parity_buffer, const int8_t *input_buffer)
Definition: utils_ldpc.h:195
static size_t LdpcNumEncodedBits(size_t base_graph, size_t zc, size_t nRows)
Definition: utils_ldpc.h:159
#define BG1_COL_TOTAL
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:90
#define BG1_COL_INF_NUM
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:92
static size_t BitsToBytes(size_t n_bits)
Definition: utils_ldpc.h:124
#define BG2_COL_INF_NUM
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:97
void(*)(int8_t **, int8_t *, uint16_t, uint32_t, int8_t) LDPC_ADAPTER_P
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:83
static size_t LdpcEncodingEncodedBufSize(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:181
static constexpr size_t kProcBytes
Definition: encoder.h:22
static size_t LdpcNumInputCols(size_t base_graph)
Definition: utils_ldpc.h:128
static size_t LdpcMaxNumEncodedBits(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:151
T * AlignedMalloc(const int size, const unsigned alignment)
Definition: utils_ldpc.h:19
#define ZC_MAX
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:88
int32_t BblibLdpcEncoder5gnr(struct bblib_ldpc_encoder_5gnr_request *request, struct bblib_ldpc_encoder_5gnr_response *response)
Definition: encoder.cc:239
static size_t LdpcMaxNumRows(size_t base_graph)
Definition: utils_ldpc.h:133
LDPC_ADAPTER_P LdpcSelectAdapterFunc(uint16_t zcSize, uint8_t num_ways)
static size_t LdpcGetMinZc()
Definition: utils_ldpc.h:187
uint16_t len
Definition: eth_common.h:62
for i
Definition: generate_data.m:107
static uint8_t SelectBaseMatrixEntry(uint16_t Zc)
Definition: utils_ldpc.h:101
#define BG2_ROW_TOTAL
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:96
static size_t LdpcMaxNumParityBits(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:145
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
Definition: printf.h:607
static constexpr bool kUseAVX2Encoder
Definition: symbols.h:350
static constexpr size_t kZcMax
Definition: encoder.h:20
#define BG1_ROW_TOTAL
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:91
#define BG2_COL_TOTAL
Definition: gcc_phy_ldpc_encoder_5gnr_internal.h:95
static size_t LdpcGetMaxZc()
Definition: utils_ldpc.h:190
static uint8_t Bitreverse8(uint8_t x)
Definition: utils_ldpc.h:35
static size_t LdpcNumInputBits(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:139
Utility functions for file and text processing.
static size_t LdpcEncodingParityBufSize(size_t base_graph, size_t zc)
Definition: utils_ldpc.h:174
static void AdaptBitsForMod(const uint8_t *bit_seq_in, uint8_t *bytes_out, size_t len, size_t mod_type)
Fill-in the bytes of bytes_out with mod_type bits per byte, taken from the bit sequence bit_seq_in.
Definition: utils_ldpc.h:60