Agora  1.2.0
Agora project
ue_worker.h
Go to the documentation of this file.
1 
6 #ifndef UE_WORKER_H_
7 #define UE_WORKER_H_
8 
9 #include <complex>
10 #include <thread>
11 #include <vector>
12 
13 #include "concurrentqueue.h"
14 #include "config.h"
15 #include "csv_logger.h"
16 #include "dodecode_client.h"
17 #include "doencode.h"
18 #include "doifft_client.h"
19 #include "message.h"
20 #include "mkl_dfti.h"
21 #include "simd_types.h"
22 #include "stats.h"
23 
24 class UeWorker {
25  public:
26  explicit UeWorker(
27  size_t tid, Config& config, Stats& shared_stats,
28  PhyStats& shared_phy_stats,
31  moodycamel::ProducerToken& work_producer, Table<int8_t>& ul_bits_buffer,
32  Table<int8_t>& encoded_buffer, Table<complex_float>& modul_buffer,
33  Table<complex_float>& ifft_buffer, char* const tx_buffer,
34  Table<char>& rx_buffer, Table<complex_float>& csi_buffer,
35  std::vector<SimdAlignCxFltVector>& equal_buffer,
36  std::vector<size_t>& non_null_sc_ind, Table<complex_float>& fft_buffer,
39  std::vector<std::vector<std::complex<float>>>& ue_pilot_vec);
40  ~UeWorker();
41 
42  void Start(size_t core_offset);
43  void Stop();
44 
45  private:
46  void TaskThread(size_t core_offset);
47 
52  void DoEncodeUe(DoEncode* encoder, size_t tag);
53  void DoModul(size_t tag);
54  void DoIfftUe(DoIFFTClient* iffter, size_t tag);
55  void DoIfft(size_t tag);
56 
89  void DoFftPilot(size_t tag);
90  void DoFftData(size_t tag);
91 
116  void DoDemul(size_t tag);
117  void DoDecodeUe(DoDecodeClient* decoder, size_t tag);
118 
119  size_t tid_;
120 
121  DFTI_DESCRIPTOR_HANDLE mkl_handle_;
122  std::unique_ptr<moodycamel::ProducerToken> ptok_;
123  std::thread thread_;
124  std::complex<float>* rx_samps_tmp_; // Temp buffer for received samples
125 
126  // Shared Queues
130 
131  // Shared Objects
135 
136  // Shared Buffers
137  // Uplink
142  char* const tx_buffer_;
143 
144  // Downlink
147  std::vector<SimdAlignCxFltVector>& equal_buffer_;
148  std::vector<size_t>& non_null_sc_ind_;
152 
153  std::vector<std::vector<std::complex<float>>>& ue_pilot_vec_;
154 };
155 #endif // UE_WORKER_H_
PhyStats
Definition: phy_stats.h:15
UeWorker::TaskThread
void TaskThread(size_t core_offset)
Definition: ue_worker.cc:95
CommsLib::IFFT
static MKL_LONG IFFT(std::vector< std::complex< float >> &in_out, int fft_size, bool normalize=true)
Definition: comms-lib.cc:410
kPrintEqualizedSymbols
static constexpr bool kPrintEqualizedSymbols
Definition: ue_worker.cc:29
DemodQpskHardLoop
void DemodQpskHardLoop(const float *vec_in, uint8_t *vec_out, int num)
Definition: modulation.cc:264
FrameStats::GetDLSymbolIdx
size_t GetDLSymbolIdx(size_t symbol_number) const
Definition: framestats.cc:152
UeWorker::phy_stats_
PhyStats & phy_stats_
Definition: ue_worker.h:134
DoDecodeClient::Launch
EventData Launch(size_t tag) override
Definition: dodecode_client.cc:35
DoIFFTClient
Definition: doifft_client.h:16
moodycamel::ProducerToken
Definition: concurrentqueue.h:630
UeWorker::tid_
size_t tid_
Definition: ue_worker.h:119
Config::Running
void Running(bool value)
Definition: config.h:33
Packet::frame_id_
uint32_t frame_id_
Definition: message.h:168
Config::UeAntNum
size_t UeAntNum() const
Definition: config.h:41
complex_float
Definition: test_transpose.cc:22
PinToCoreWithOffset
void PinToCoreWithOffset(ThreadType thread_type, size_t core_offset, size_t thread_id, bool allow_reuse, bool verbose)
Definition: utils.cc:157
Config::Scale
float Scale() const
Definition: config.h:240
UeWorker::DoIfft
void DoIfft(size_t tag)
Definition: ue_worker.cc:631
DoIFFTClient::Launch
EventData Launch(size_t tag) override
Definition: doifft_client.cc:52
PhyStats::IncrementDecodedBlocks
void IncrementDecodedBlocks(size_t ue_id, size_t offset, size_t frame_slot)
Definition: phy_stats.cc:570
Config::SampsPerSymbol
size_t SampsPerSymbol() const
Definition: config.h:234
UeWorker::thread_
std::thread thread_
Definition: ue_worker.h:123
Utils::PrintVec
static void PrintVec(const arma::cx_fvec &c, const std::string &ss)
Definition: utils.cc:488
datatype_conversion.h
kDownlinkHardDemod
static constexpr bool kDownlinkHardDemod
Definition: symbols.h:187
FreeBuffer1d
static void FreeBuffer1d(T **buffer)
Definition: memory_manage.h:116
EventType::kDecode
@ kDecode
Config::UlBits
Table< int8_t > & UlBits()
Definition: config.h:385
Config::OfdmTxZeroPrefix
size_t OfdmTxZeroPrefix() const
Definition: config.h:211
PhyStats::UpdateBlockErrors
void UpdateBlockErrors(size_t ue_id, size_t offset, size_t frame_slot, size_t block_error_count)
Definition: phy_stats.cc:563
CommsLib::Abs2Avx
static std::vector< float > Abs2Avx(std::vector< std::complex< float >> const &f)
Definition: comms-lib-avx.cc:364
Config::GetTotalDataSymbolIdxUl
size_t GetTotalDataSymbolIdxUl(size_t frame_id, size_t symbol_idx_ul) const
Definition: config.h:421
Demod64qamHardAvx2
void Demod64qamHardAvx2(float *vec_in, uint8_t *vec_out, int num)
Definition: modulation.cc:921
UeWorker::config_
Config & config_
Definition: ue_worker.h:132
DoDecodeClient
Definition: dodecode_client.h:18
Stats
Definition: stats.h:63
gen_tag_t::symbol_id_
uint16_t symbol_id_
Definition: message.h:33
UeWorker::non_null_sc_ind_
std::vector< size_t > & non_null_sc_ind_
Definition: ue_worker.h:148
Config::CpLen
size_t CpLen() const
Definition: config.h:46
kFrameWnd
static constexpr size_t kFrameWnd
Definition: symbols.h:18
PhyStats::UpdateDlPilotSnr
void UpdateDlPilotSnr(size_t frame_id, size_t symbol_id, size_t ant_id, complex_float *fft_data)
Definition: phy_stats.cc:477
modulation.h
UeWorker::rx_samps_tmp_
std::complex< float > * rx_samps_tmp_
Definition: ue_worker.h:124
DoEncode
Definition: doencode.h:20
Config::GetOFDMDataNum
size_t GetOFDMDataNum() const
Definition: config.h:554
CommsLib::kQpsk
@ kQpsk
Definition: comms-lib.h:42
Packet::data_
short data_[]
Definition: message.h:173
UeWorker::rx_buffer_
Table< char > & rx_buffer_
Definition: ue_worker.h:145
p
for p
Definition: process_rx_frame.m:36
FrameStats::GetULSymbolIdx
size_t GetULSymbolIdx(size_t symbol_number) const
Definition: framestats.cc:156
fft_req_tag_t
rx_tag_t fft_req_tag_t
Definition: message.h:241
UeWorker::equal_buffer_
std::vector< SimdAlignCxFltVector > & equal_buffer_
Definition: ue_worker.h:147
csv_logger.h
Declaration file for the CsvLogger class which records runtime physical-layer performance into csv fi...
UeWorker::ptok_
std::unique_ptr< moodycamel::ProducerToken > ptok_
Definition: ue_worker.h:122
Packet::ant_id_
uint32_t ant_id_
Definition: message.h:171
y
y
Definition: simulate_performance.m:74
EventData::tags_
std::array< size_t, kMaxTags > tags_
Definition: message.h:146
Config::GetOFDMPilotNum
size_t GetOFDMPilotNum() const
Definition: config.h:550
UeWorker::DoFftPilot
void DoFftPilot(size_t tag)
Definition: ue_worker.cc:150
Direction::kUplink
@ kUplink
Config::Frame
const FrameStats & Frame() const
Definition: config.h:340
ThreadType::kWorker
@ kWorker
Config::DlModBits
Table< int8_t > & DlModBits()
Definition: config.h:386
gen_tag_t::ue_id_
uint16_t ue_id_
Definition: message.h:37
PhyStats::UpdateBitErrors
void UpdateBitErrors(size_t ue_id, size_t offset, size_t frame_slot, uint8_t tx_byte, uint8_t rx_byte)
Definition: phy_stats.cc:542
EventData::event_type_
EventType event_type_
Definition: message.h:144
AllocBuffer1d
static void AllocBuffer1d(T **buffer, U dim, Agora_memory::Alignment_t alignment, int init_zero)
Definition: memory_manage.h:105
gen_tag_t::FrmSymUe
static gen_tag_t FrmSymUe(size_t frame_id, size_t symbol_id, size_t ue_id)
Definition: message.h:84
EventType::kModul
@ kModul
Table< int8_t >
EventType::kFFTPilot
@ kFFTPilot
CommsLib::kQaM64
@ kQaM64
Definition: comms-lib.h:44
gen_tag_t
Definition: message.h:22
UeWorker::ul_bits_buffer_
Table< int8_t > & ul_bits_buffer_
Definition: ue_worker.h:138
UeWorker::DoModul
void DoModul(size_t tag)
Definition: ue_worker.cc:547
Config::OfdmDataNum
size_t OfdmDataNum() const
Definition: config.h:47
kDebugPrintInTask
static constexpr bool kDebugPrintInTask
Definition: symbols.h:201
Demod64qamSoftAvx2
void Demod64qamSoftAvx2(float *vec_in, int8_t *llr, int num)
Definition: modulation.cc:1103
UeWorker::DoIfftUe
void DoIfftUe(DoIFFTClient *iffter, size_t tag)
Definition: ue_worker.cc:598
SimdConvertShortToFloat
static void SimdConvertShortToFloat(const short *in_buf, float *out_buf, size_t n_elems)
Definition: datatype_conversion.h:126
stats.h
Declaration file for the Stats class. Includes definations for DurationStat and FrameSummery types.
kDebugDownlink
static constexpr bool kDebugDownlink
Definition: symbols.h:180
Demod256qamHardAvx2
void Demod256qamHardAvx2(float *vec_in, uint8_t *vec_out, int num)
Definition: modulation.cc:1569
PhyStats::UpdateDecodedBits
void UpdateDecodedBits(size_t ue_id, size_t offset, size_t frame_slot, size_t new_bits_num)
Definition: phy_stats.cc:557
EventData
Definition: message.h:142
CommsLib::kQaM16
@ kQaM16
Definition: comms-lib.h:43
kPrintPhyStats
static constexpr bool kPrintPhyStats
Definition: symbols.h:191
kEnableMac
static constexpr bool kEnableMac
Definition: symbols.h:150
simd_types.h
Aligned types for SIMD compatibility.
gen_tag_t::ant_id_
uint16_t ant_id_
Definition: message.h:38
EventType::kFFT
@ kFFT
message.h
Self defined functions for message storage and passing.
kDebugPrintFft
static constexpr bool kDebugPrintFft
Definition: ue_worker.cc:22
gen_tag_t::FrmSymAnt
static gen_tag_t FrmSymAnt(size_t frame_id, size_t symbol_id, size_t ant_id)
Definition: message.h:106
kEnableCsvLog
static constexpr bool kEnableCsvLog
Definition: symbols.h:168
CommsLib::FFTShift
static std::vector< std::complex< float > > FFTShift(const std::vector< std::complex< float >> &in)
Definition: comms-lib.cc:581
FrameStats::ClientUlPilotSymbols
size_t ClientUlPilotSymbols() const
Definition: framestats.h:73
moodycamel::ConcurrentQueue::try_dequeue_from_producer
bool try_dequeue_from_producer(producer_token_t const &producer, U &item)
Definition: concurrentqueue.h:1279
doencode.h
Declaration file for the Docoding class. Includes the DoEncode and DoDecode classes.
scrambler.h
Scramble Class and helper functions.
i
for i
Definition: generate_data.m:107
UeWorker::csi_buffer_
Table< complex_float > & csi_buffer_
Definition: ue_worker.h:146
Config::OfdmCaNum
size_t OfdmCaNum() const
Definition: config.h:45
UeWorker::demod_buffer_
PtrCube< kFrameWnd, kMaxSymbols, kMaxUEs, int8_t > & demod_buffer_
Definition: ue_worker.h:150
FrameStats::NumDlDataSyms
size_t NumDlDataSyms() const
Definition: framestats.h:83
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail::void
j template void())
Definition: json.hpp:4744
moodycamel::ConcurrentQueue::enqueue
bool enqueue(T const &item)
Definition: concurrentqueue.h:974
Demod16qamHardAvx2
void Demod16qamHardAvx2(float *vec_in, uint8_t *vec_out, int num)
Definition: modulation.cc:472
u
Plot Rx waveform for u
Definition: inspect_single_frame.m:108
GetTime::Rdtsc
static size_t Rdtsc()
Return the TSC.
Definition: gettime.h:25
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
UeWorker::fft_buffer_
Table< complex_float > & fft_buffer_
Definition: ue_worker.h:149
Config::ModTable
Table< complex_float > & ModTable(Direction dir)
Definition: config.h:284
Agora_memory::Alignment_t::kAlign64
@ kAlign64
UeWorker::tx_buffer_
char *const tx_buffer_
Definition: ue_worker.h:142
Packet
Definition: message.h:164
Direction::kDownlink
@ kDownlink
Demod16qamSoftAvx2
void Demod16qamSoftAvx2(float *vec_in, int8_t *llr, int num)
Definition: modulation.cc:601
CommsLib::Ifft2tx
static void Ifft2tx(const complex_float *in, std::complex< short > *out, size_t N, size_t prefix, size_t cp, float scale)
Definition: comms-lib.cc:656
EventType::kDemul
@ kDemul
Packet::symbol_id_
uint32_t symbol_id_
Definition: message.h:169
gen_tag_t::tag_
size_t tag_
Definition: message.h:43
evm
evm
Definition: inspect_agora_results.m:117
fmt::v8::arg
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition: core.h:1887
Config::DlIqF
Table< complex_float > & DlIqF()
Definition: config.h:389
ModSingleUint8
complex_float ModSingleUint8(uint8_t x, Table< complex_float > &mod_table)
Definition: modulation.cc:213
Config::IsDataSubcarrier
bool IsDataSubcarrier(size_t sc_id) const
Definition: config.h:562
LDPCconfig
Definition: ldpc_config.h:14
Config::OfdmRxZeroPrefixClient
size_t OfdmRxZeroPrefixClient() const
Definition: config.h:231
Config::OfdmDataStart
size_t OfdmDataStart() const
Definition: config.h:48
Config::LdpcConfig
const LDPCconfig & LdpcConfig(Direction dir) const
Definition: config.h:280
FrameStats::ClientDlPilotSymbols
size_t ClientDlPilotSymbols() const
Definition: framestats.h:76
RxPacket::RawPacket
Packet * RawPacket()
Definition: message.h:213
FrameStats::NumDLSyms
size_t NumDLSyms() const
Definition: framestats.cc:83
moodycamel::ConcurrentQueue< EventData >
kDebugTxData
static constexpr bool kDebugTxData
Definition: symbols.h:365
UeWorker::notify_queue_
moodycamel::ConcurrentQueue< EventData > & notify_queue_
Definition: ue_worker.h:127
GetTime::MeasureRdtscFreq
static double MeasureRdtscFreq()
Definition: gettime.h:51
CommsLib::kQaM256
@ kQaM256
Definition: comms-lib.h:45
DemodQpskSoftSse
void DemodQpskSoftSse(float *x, int8_t *z, int len)
Definition: modulation_srslte.cc:245
PhyStats::UpdateEvm
void UpdateEvm(size_t frame_id, size_t data_symbol_id, size_t sc_id, const arma::cx_fvec &eq_vec)
Definition: phy_stats.cc:526
Config::UeSpecificPilot
Table< complex_float > & UeSpecificPilot()
Definition: config.h:371
FrameStats::NumULSyms
size_t NumULSyms() const
Definition: framestats.cc:85
GetTime::CyclesToMs
static double CyclesToMs(size_t cycles, double freq_ghz)
Definition: gettime.h:91
gen_tag_t::FrmSymCb
static gen_tag_t FrmSymCb(size_t frame_id, size_t symbol_id, size_t cb_id)
Definition: message.h:73
EventType::kEncode
@ kEncode
Config
Definition: config.h:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
UeWorker::encoded_buffer_
Table< int8_t > & encoded_buffer_
Definition: ue_worker.h:139
kDebugTxMemory
static constexpr bool kDebugTxMemory
Definition: ue_worker.cc:30
UeWorker::UeWorker
UeWorker(size_t tid, Config &config, Stats &shared_stats, PhyStats &shared_phy_stats, moodycamel::ConcurrentQueue< EventData > &notify_queue, moodycamel::ConcurrentQueue< EventData > &work_queue, moodycamel::ProducerToken &work_producer, Table< int8_t > &ul_bits_buffer, Table< int8_t > &encoded_buffer, Table< complex_float > &modul_buffer, Table< complex_float > &ifft_buffer, char *const tx_buffer, Table< char > &rx_buffer, Table< complex_float > &csi_buffer, std::vector< SimdAlignCxFltVector > &equal_buffer, std::vector< size_t > &non_null_sc_ind, Table< complex_float > &fft_buffer, PtrCube< kFrameWnd, kMaxSymbols, kMaxUEs, int8_t > &demod_buffer, PtrCube< kFrameWnd, kMaxSymbols, kMaxUEs, int8_t > &decoded_buffer, std::vector< std::vector< std::complex< float >>> &ue_pilot_vec)
Definition: ue_worker.cc:32
kDebugPrintDecode
static constexpr bool kDebugPrintDecode
Definition: ue_worker.cc:25
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
dodecode_client.h
Declaration file for the DoDecode class.
Demod256qamSoftAvx2
void Demod256qamSoftAvx2(const float *vec_in, int8_t *llr, int num)
Definition: modulation.cc:2365
ue_worker.h
Declaration file for the phy ue class.
kCollectPhyStats
static constexpr bool kCollectPhyStats
Definition: symbols.h:192
to_string
std::string to_string() const
Definition: eth_common.h:64
Config::UlIqF
Table< complex_float > & UlIqF()
Definition: config.h:388
Config::Modulation
std::string Modulation(Direction dir) const
Definition: config.h:243
config.h
Declaration file for the configuration class which importants json configuration values into class va...
EventType::kIFFT
@ kIFFT
doifft_client.h
Declaration file for the DoIFFTClient class.
kDebugPrintDemul
static constexpr bool kDebugPrintDemul
Definition: ue_worker.cc:23
Config::GetModBitsBuf
int8_t * GetModBitsBuf(Table< int8_t > &mod_bits_buffer, Direction dir, size_t frame_id, size_t symbol_id, size_t ue_id, size_t sc_id) const
Get encoded_buffer for this frame, symbol, user and code block ID.
Definition: config.h:531
PtrCube< kFrameWnd, kMaxSymbols, kMaxUEs, int8_t >
UeWorker::work_producer_token_
moodycamel::ProducerToken & work_producer_token_
Definition: ue_worker.h:129
UeWorker::DoEncodeUe
void DoEncodeUe(DoEncode *encoder, size_t tag)
Definition: ue_worker.cc:524
UeWorker::DoDemul
void DoDemul(size_t tag)
Definition: ue_worker.cc:387
phy_stats.h
Declaration file for the PhyStats class.
Config::PacketLength
size_t PacketLength() const
Definition: config.h:238
UeWorker::modul_buffer_
Table< complex_float > & modul_buffer_
Definition: ue_worker.h:140
UeWorker::stats_
Stats & stats_
Definition: ue_worker.h:133
UeWorker::decoded_buffer_
PtrCube< kFrameWnd, kMaxSymbols, kMaxUEs, int8_t > & decoded_buffer_
Definition: ue_worker.h:151
kDebugPrintModul
static constexpr bool kDebugPrintModul
Definition: ue_worker.cc:24
gen_tag_t::frame_id_
uint32_t frame_id_
Definition: message.h:32
UeWorker::~UeWorker
~UeWorker()
Definition: ue_worker.cc:75
UeWorker::Stop
void Stop()
Definition: ue_worker.cc:90
UeWorker::DoFftData
void DoFftData(size_t tag)
Definition: ue_worker.cc:253
UeWorker
Definition: ue_worker.h:24
Config::ModOrderBits
size_t ModOrderBits(Direction dir) const
Definition: config.h:247
UeWorker::ue_pilot_vec_
std::vector< std::vector< std::complex< float > > > & ue_pilot_vec_
Definition: ue_worker.h:153
LDPCconfig::NumBlocksInSymbol
void NumBlocksInSymbol(size_t num_blocks)
Definition: ldpc_config.h:41
DoEncode::Launch
EventData Launch(size_t tag) override
Definition: doencode.cc:54
UeWorker::mkl_handle_
DFTI_DESCRIPTOR_HANDLE mkl_handle_
Definition: ue_worker.h:121
UeWorker::ifft_buffer_
Table< complex_float > & ifft_buffer_
Definition: ue_worker.h:141
RxPacket::Free
void Free()
Definition: message.h:216
CommsLib::CorrelateAvx
static std::vector< std::complex< float > > CorrelateAvx(std::vector< std::complex< float >> const &f, std::vector< std::complex< float >> const &g)
Definition: comms-lib-avx.cc:463
concurrentqueue.h
Config::GetOFDMDataIndex
size_t GetOFDMDataIndex(size_t sc_id) const
Definition: config.h:558
Config::OfdmDataStop
size_t OfdmDataStop() const
Definition: config.h:50
UeWorker::work_queue_
moodycamel::ConcurrentQueue< EventData > & work_queue_
Definition: ue_worker.h:128
kPrintDownlinkPilotStats
static constexpr bool kPrintDownlinkPilotStats
Definition: ue_worker.cc:28
UeWorker::Start
void Start(size_t core_offset)
Definition: ue_worker.cc:81
UeWorker::DoDecodeUe
void DoDecodeUe(DoDecodeClient *decoder, size_t tag)
Definition: ue_worker.cc:493
utils_ldpc.h
rx_tag_t::rx_packet_
RxPacket * rx_packet_
Definition: message.h:228
kPrintLLRData
static constexpr bool kPrintLLRData
Definition: ue_worker.cc:27
kDebugPrintPerTaskDone
static constexpr bool kDebugPrintPerTaskDone
Definition: symbols.h:199