From 21d7210cc0ca69612ff2426ad4e0a89606ed3f95 Mon Sep 17 00:00:00 2001 From: rdoost Date: Thu, 18 Nov 2021 08:26:53 -0600 Subject: [PATCH 01/55] sw/hw framer mode for base station --- src/agora/radio_lib.cc | 116 +++++++------ src/agora/txrx/txrx.cc | 2 +- src/agora/txrx/txrx.h | 6 +- src/agora/txrx/txrx_argos.cc | 306 +++++++++++++++++++++++++++-------- src/common/config.cc | 2 +- 5 files changed, 312 insertions(+), 120 deletions(-) diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 44c140c97..cc37de692 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -395,64 +395,68 @@ bool RadioConfig::RadioStart() { size_t ndx = 0; for (size_t i = 0; i < this->radio_num_; i++) { bool is_ref_radio = (i == cfg_->RefRadio()); - ba_stn_[i]->writeSetting( - "TX_SW_DELAY", "30"); // experimentally good value for dev front-end - ba_stn_[i]->writeSetting("TDD_MODE", "true"); - std::vector tdd_sched; - - std::string sched = cfg_->Frame().FrameIdentifier(); - size_t sched_size = sched.length(); - for (size_t s = 0; s < sched_size; s++) { - char c = cfg_->Frame().FrameIdentifier().at(s); - if (c == 'C') { - sched.replace(s, 1, is_ref_radio ? "R" : "T"); - } else if (c == 'L') { - sched.replace(s, 1, is_ref_radio ? "T" : "R"); - } else if (c == 'P') { - sched.replace(s, 1, "R"); - } else if (c == 'U') { - sched.replace(s, 1, "R"); - } else if (c == 'D') { - sched.replace(s, 1, "T"); - } else if (c != 'B') { - sched.replace(s, 1, "G"); + if (cfg_->HwFramer() == true) { + ba_stn_[i]->writeSetting( + "TX_SW_DELAY", "30"); // experimentally good value for dev front-end + ba_stn_[i]->writeSetting("TDD_MODE", "true"); + std::vector tdd_sched; + + std::string sched = cfg_->Frame().FrameIdentifier(); + size_t sched_size = sched.length(); + for (size_t s = 0; s < sched_size; s++) { + char c = cfg_->Frame().FrameIdentifier().at(s); + if (c == 'C') { + sched.replace(s, 1, is_ref_radio ? "R" : "T"); + } else if (c == 'L') { + sched.replace(s, 1, is_ref_radio ? "T" : "R"); + } else if (c == 'P') { + sched.replace(s, 1, "R"); + } else if (c == 'U') { + sched.replace(s, 1, "R"); + } else if (c == 'D') { + sched.replace(s, 1, "T"); + } else if (c != 'B') { + sched.replace(s, 1, "G"); + } } - } - std::cout << "Radio " << i << " Frame 1: " << sched << std::endl; - tdd_sched.push_back(sched); - - conf["frames"] = tdd_sched; - std::string conf_string = conf.dump(); - ba_stn_[i]->writeSetting("TDD_CONFIG", conf_string); - - ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); - for (char const& c : cfg_->Channel()) { - bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); - std::vector beacon_weights(cfg_->NumAntennas(), - is_beacon_antenna ? 1 : 0); - std::string tx_ram_wgt = "BEACON_RAM_WGT_"; - if (cfg_->Beamsweep()) { - for (size_t j = 0; j < cfg_->NumAntennas(); j++) { - beacon_weights[j] = CommsLib::Hadamard2(ndx, j); + std::cout << "Radio " << i << " Frame 1: " << sched << std::endl; + tdd_sched.push_back(sched); + + conf["frames"] = tdd_sched; + std::string conf_string = conf.dump(); + ba_stn_[i]->writeSetting("TDD_CONFIG", conf_string); + + ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); + for (char const& c : cfg_->Channel()) { + bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); + std::vector beacon_weights(cfg_->NumAntennas(), + is_beacon_antenna ? 1 : 0); + std::string tx_ram_wgt = "BEACON_RAM_WGT_"; + if (cfg_->Beamsweep()) { + for (size_t j = 0; j < cfg_->NumAntennas(); j++) { + beacon_weights[j] = CommsLib::Hadamard2(ndx, j); + } } + ba_stn_[i]->writeRegisters(tx_ram_wgt + c, 0, beacon_weights); + ++ndx; } - ba_stn_[i]->writeRegisters(tx_ram_wgt + c, 0, beacon_weights); - ++ndx; - } - ba_stn_[i]->writeSetting("BEACON_START", std::to_string(radio_num_)); - if (cfg_->Frame().IsRecCalEnabled()) { - if (is_ref_radio) { - // Write to the first channel TX_RAM on the calibration node for - // ref-to-array transmission - ba_stn_[i]->writeRegisters( - std::string("TX_RAM_") + cfg_->Channel().at(0), 0, pilot); + ba_stn_[i]->writeSetting("BEACON_START", std::to_string(radio_num_)); + if (cfg_->Frame().IsRecCalEnabled()) { + if (is_ref_radio) { + // Write to the first channel TX_RAM on the calibration node for + // ref-to-array transmission + ba_stn_[i]->writeRegisters( + std::string("TX_RAM_") + cfg_->Channel().at(0), 0, pilot); + } } } if (!kUseUHD) { ba_stn_[i]->setHardwareTime(0, "TRIGGER"); - ba_stn_[i]->activateStream(this->rx_streams_[i]); - ba_stn_[i]->activateStream(this->tx_streams_[i]); + if (cfg_->HwFramer() == true) { + ba_stn_[i]->activateStream(this->rx_streams_[i]); + ba_stn_[i]->activateStream(this->tx_streams_[i]); + } } else { ba_stn_[i]->setHardwareTime(0, "UNKNOWN_PPS"); ba_stn_[i]->activateStream(this->rx_streams_[i], SOAPY_SDR_HAS_TIME, 1e9, @@ -462,6 +466,14 @@ bool RadioConfig::RadioStart() { } } + if (!kUseUHD && cfg_->HwFramer() == false) { + this->Go(); // to set all radio timestamps to zero + int flags = SOAPY_SDR_HAS_TIME; + for (size_t i = 0; i < this->radio_num_; i++) { + ba_stn_[i]->activateStream(this->rx_streams_[i], flags, 1e9, 0); + ba_stn_[i]->activateStream(this->tx_streams_[i], flags, 1e9, 0); + } + } std::cout << "radio start done!" << std::endl; return true; } @@ -498,7 +510,7 @@ int RadioConfig::RadioTx(size_t r /*radio id*/, void** buffs, int flags, // long long frameTime(0); int w; - if (!kUseUHD) { + if (cfg_->HwFramer() == true) { w = ba_stn_[r]->writeStream(this->tx_streams_[r], buffs, cfg_->SampsPerSymbol(), tx_flags, frameTime, 1000000); @@ -540,7 +552,7 @@ int RadioConfig::RadioRx(size_t r /*radio id*/, void** buffs, cfg_->SampsPerSymbol(), flags, frame_time_ns, 1000000); - if (!kUseUHD) { + if (cfg_->HwFramer() == true) { // SoapySDR::timeNsToTicks(frameTimeNs, _rate); frameTime = frame_time_ns; } else { diff --git a/src/agora/txrx/txrx.cc b/src/agora/txrx/txrx.cc index c74e248e8..73f4e1496 100644 --- a/src/agora/txrx/txrx.cc +++ b/src/agora/txrx/txrx.cc @@ -112,7 +112,7 @@ bool PacketTXRX::StartTxRx(Table& buffer, size_t packet_num_in_buffer, } MLPD_INFO("LoopTXRX: socket threads are waiting for events\n"); - if ((kUseArgos == true) || (kUseUHD == true)) { + if ((kUseArgos == true && cfg_->HwFramer() == true) || (kUseUHD == true)) { radioconfig_->Go(); } return true; diff --git a/src/agora/txrx/txrx.h b/src/agora/txrx/txrx.h index bea73151d..e89c69ad8 100644 --- a/src/agora/txrx/txrx.h +++ b/src/agora/txrx/txrx.h @@ -100,6 +100,7 @@ class PacketTXRX { Table& calib_ul_buffer_); void SendBeacon(int tid, size_t frame_id); + void SendBeaconHW(size_t frame_id, size_t radio_id, long long time0); private: void LoopTxRx(size_t tid); // The thread function for thread [tid] @@ -107,9 +108,10 @@ class PacketTXRX { Packet* RecvEnqueue(size_t tid, size_t radio_id, size_t rx_offset); void LoopTxRxArgos(size_t tid); - size_t DequeueSendArgos(int tid); + size_t DequeueSendArgos(int tid, long long time0); std::vector RecvEnqueueArgos(size_t tid, size_t radio_id, - size_t rx_slot); + size_t rx_slot, size_t frame_id, + size_t symbol_id); long long rx_time_bs_; long long tx_time_bs_; diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 4d19dcdbf..f43cfbe76 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -22,6 +22,83 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { std::min((radio_lo + radios_per_thread), cfg_->NumRadios()) - 1; threads_started_.fetch_add(1); + + long long time0; + if (cfg_->HwFramer() == false) { + // prepare BS beacon in host buffer + std::vector beaconbuff(2); + std::vector zeros(2); + zeros[0] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); + zeros[1] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); + beaconbuff[0] = cfg_->BeaconCi16().data(); + beaconbuff[1] = zeros[0]; + + std::vector> samp_buffer0(cfg_->SampsPerSymbol(), 0); + std::vector> samp_buffer1(cfg_->SampsPerSymbol(), 0); + std::vector samp_buffer(2); + samp_buffer[0] = samp_buffer0.data(); + if (cfg_->NumChannels() > 1) { + samp_buffer[1] = samp_buffer1.data(); + } + + long long rx_time_bs = 0; + long long tx_time_bs = 0; + size_t frame_time = cfg_->SampsPerSymbol() * cfg_->Frame().NumTotalSyms(); + + std::cout << "Sync BS host and FGPA timestamp..." << std::endl; + int rx_ret = 0; + int tx_ret = 0; + while ((rx_ret = radioconfig_->RadioRx(radio_lo, samp_buffer.data(), + rx_time_bs)) < 0) + ; + tx_time_bs = rx_time_bs + frame_time * TX_FRAME_DELTA; + time0 = tx_time_bs; + std::cout << "Received first data at time " << rx_time_bs << " on thread " + << tid << std::endl; + std::cout << "Transmit first beacon at time " << tx_time_bs << " on thread " + << tid << std::endl; + for (auto radio = radio_lo + 1; radio < radio_hi; radio++) + radioconfig_->RadioRx(radio_lo, samp_buffer.data(), rx_time_bs); + // Schedule the first beacon in the future + size_t beacon_radio = cfg_->BeaconAnt() / cfg_->NumChannels(); + for (auto radio = radio_lo; radio < radio_hi; radio++) { + if (radio == beacon_radio) + tx_ret = radioconfig_->RadioTx(radio, beaconbuff.data(), 2, tx_time_bs); + else + tx_ret = radioconfig_->RadioTx(radio, zeros.data(), 2, tx_time_bs); + if (tx_ret != (int)cfg_->SampsPerSymbol()) { + std::cerr << "BAD Transmit(" << tx_ret << "/" << cfg_->SampsPerSymbol() + << ") at Time " << tx_time_bs << std::endl; + } + } + for (size_t sym = 1; sym < cfg_->Frame().NumTotalSyms(); sym++) { + for (auto radio = radio_lo; radio < radio_hi; radio++) + radioconfig_->RadioRx(radio, samp_buffer.data(), rx_time_bs); + } + for (size_t frm = 1; frm < TX_FRAME_DELTA; frm++) { + tx_time_bs += frame_time; + for (auto radio = radio_lo; radio < radio_hi; radio++) { + if (radio == beacon_radio) + tx_ret = + radioconfig_->RadioTx(radio, beaconbuff.data(), 2, tx_time_bs); + else + tx_ret = radioconfig_->RadioTx(radio, zeros.data(), 2, tx_time_bs); + if (tx_ret != (int)cfg_->SampsPerSymbol()) { + std::cerr << "BAD Transmit(" << tx_ret << "/" + << cfg_->SampsPerSymbol() << ") at Time " << tx_time_bs + << std::endl; + } + } + for (size_t sym = 0; sym < cfg_->Frame().NumTotalSyms(); sym++) { + for (auto radio = radio_lo; radio < radio_hi; radio++) { + radioconfig_->RadioRx(radio, samp_buffer.data(), rx_time_bs); + } + } + } + + std::cout << "Start BS main recv loop..." << std::endl; + } + if (radio_lo > radio_hi) { MLPD_INFO("LoopTxRxArgos[%zu] has no radios, exiting\n", tid); return; @@ -31,10 +108,13 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { ssize_t prev_frame_id = -1; size_t radio_id = radio_lo; + size_t global_frame_id = 0; + size_t global_symbol_id = 0; while (cfg_->Running() == true) { - if (0 == DequeueSendArgos(tid)) { + if (0 == DequeueSendArgos(tid, time0)) { // receive data - auto pkts = RecvEnqueueArgos(tid, radio_id, rx_slot); + auto pkts = RecvEnqueueArgos(tid, radio_id, rx_slot, global_frame_id, + global_symbol_id); if (pkts.size() > 0) { rx_slot = (rx_slot + pkts.size()) % buffers_per_socket_; RtAssert(pkts.size() == cfg_->NumChannels(), @@ -47,23 +127,38 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { prev_frame_id = frame_id; } } - if (radio_id == radio_hi) { - radio_id = radio_lo; - } else { - radio_id++; - } } // if (pkt.size() > 0) - } // DequeueSendArgos(tid) == 0 - } // cfg_->Running() == true + if (radio_id == radio_hi) { + if (cfg_->HwFramer() == false) { + // Update global frame_id and symbol_id + global_symbol_id++; + if (global_symbol_id == cfg_->Frame().NumTotalSyms()) { + global_symbol_id = 0; + global_frame_id++; + if (cfg_->Frame().NumDLSyms() == 0) { + for (size_t radio = radio_lo; radio <= radio_hi; radio++) + this->SendBeaconHW(global_frame_id, radio, time0); + } + } + } + radio_id = radio_lo; + } else { + radio_id++; + } + } // DequeueSendArgos(tid) == 0 + } // cfg_->Running() == true } std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, - size_t rx_slot) { + size_t rx_slot, + size_t global_frame_id, + size_t global_symbol_id) { moodycamel::ProducerToken* local_ptok = rx_ptoks_[tid]; size_t packet_length = cfg_->PacketLength(); size_t ant_id = radio_id * cfg_->NumChannels(); std::vector ant_ids(cfg_->NumChannels()); + std::vector symbol_ids(cfg_->NumChannels(), global_symbol_id); std::vector samp(cfg_->NumChannels()); for (size_t ch = 0; ch < cfg_->NumChannels(); ++ch) { @@ -81,61 +176,118 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, } long long frame_time; - if ((cfg_->Running() == false) || - radioconfig_->RadioRx(radio_id, samp.data(), frame_time) <= 0) { + bool cal_rx = (radio_id != cfg_->RefRadio() && + cfg_->IsCalUlPilot(global_frame_id, global_symbol_id)) || + (radio_id == cfg_->RefRadio() && + cfg_->IsCalDlPilot(global_frame_id, global_symbol_id)); + bool dummy_read = + (cfg_->HwFramer() == false) && + (!cfg_->IsPilot(global_frame_id, global_symbol_id) && + !cfg_->IsUplink(global_frame_id, global_symbol_id) && !cal_rx); + if (dummy_read) { + // init samp_buffer for dummy read + std::vector> samp_buffer0(cfg_->SampsPerSymbol(), 0); + std::vector> samp_buffer1(cfg_->SampsPerSymbol(), 0); + std::vector samp_buffer(2); + samp_buffer[0] = samp_buffer0.data(); + if (cfg_->NumChannels() == 2) { + samp_buffer[1] = samp_buffer1.data(); + } + if (cfg_->Running() == true) + radioconfig_->RadioRx(radio_id, samp_buffer.data(), frame_time); std::vector empty_pkt; return empty_pkt; - } - - size_t frame_id = (size_t)(frame_time >> 32); - size_t symbol_id = (size_t)((frame_time >> 16) & 0xFFFF); - std::vector symbol_ids(cfg_->NumChannels(), symbol_id); - - /// \TODO: What if ref_ant is set to the second channel? - if ((cfg_->Frame().IsRecCalEnabled() == true) && - (cfg_->IsCalDlPilot(frame_id, symbol_id) == true) && - (radio_id == cfg_->RefRadio()) && (cfg_->AntPerGroup() > 1)) { - if (cfg_->AntPerGroup() > cfg_->NumChannels()) { - symbol_ids.resize(cfg_->AntPerGroup()); - ant_ids.resize(cfg_->AntPerGroup()); + } else { + if ((cfg_->Running() == false) || + radioconfig_->RadioRx(radio_id, samp.data(), frame_time) <= 0) { + std::vector empty_pkt; + return empty_pkt; } - for (size_t s = 1; s < cfg_->AntPerGroup(); s++) { - RxPacket& rx = rx_packets_.at(tid).at(rx_slot + s); - - std::vector tmp_samp(cfg_->NumChannels()); - std::vector dummy_buff(packet_length); - tmp_samp.at(0) = rx.RawPacket()->data_; - tmp_samp.at(1) = dummy_buff.data(); - if ((cfg_->Running() == false) || - radioconfig_->RadioRx(radio_id, tmp_samp.data(), frame_time) <= 0) { - std::vector empty_pkt; - return empty_pkt; + size_t frame_id = global_frame_id; + size_t symbol_id = global_symbol_id; + if (cfg_->HwFramer() == true) { + frame_id = (size_t)(frame_time >> 32); + symbol_id = (size_t)((frame_time >> 16) & 0xFFFF); + symbol_ids.clear(); + symbol_ids.resize(cfg_->NumChannels(), symbol_id); + + // additional read for DL Calibration in two-chan case + /// \TODO: What if ref_ant is set to the second channel? + if ((cfg_->Frame().IsRecCalEnabled() == true) && + (cfg_->IsCalDlPilot(frame_id, symbol_id) == true) && + (radio_id == cfg_->RefRadio()) && (cfg_->AntPerGroup() > 1)) { + if (cfg_->AntPerGroup() > cfg_->NumChannels()) { + symbol_ids.resize(cfg_->AntPerGroup()); + ant_ids.resize(cfg_->AntPerGroup()); + } + for (size_t s = 1; s < cfg_->AntPerGroup(); s++) { + RxPacket& rx = rx_packets_.at(tid).at(rx_slot + s); + + std::vector tmp_samp(cfg_->NumChannels()); + std::vector dummy_buff(packet_length); + tmp_samp.at(0) = rx.RawPacket()->data_; + tmp_samp.at(1) = dummy_buff.data(); + if ((cfg_->Running() == false) || + radioconfig_->RadioRx(radio_id, tmp_samp.data(), frame_time) <= + 0) { + std::vector empty_pkt; + return empty_pkt; + } + symbol_ids.at(s) = cfg_->Frame().GetDLCalSymbol(s); + ant_ids.at(s) = ant_id; + } } - symbol_ids.at(s) = cfg_->Frame().GetDLCalSymbol(s); - ant_ids.at(s) = ant_id; } - } - - std::vector pkt; - for (size_t ch = 0; ch < symbol_ids.size(); ++ch) { - RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); - pkt.push_back(rx.RawPacket()); - new (rx.RawPacket()) - Packet(frame_id, symbol_ids.at(ch), 0 /* cell_id */, ant_ids.at(ch)); + std::vector pkt; + for (size_t ch = 0; ch < symbol_ids.size(); ++ch) { + RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); + pkt.push_back(rx.RawPacket()); + new (rx.RawPacket()) + Packet(frame_id, symbol_ids.at(ch), 0 /* cell_id */, ant_ids.at(ch)); - rx.Use(); - // Push kPacketRX event into the queue. - EventData rx_message(EventType::kPacketRX, rx_tag_t(rx).tag_); + rx.Use(); + // Push kPacketRX event into the queue. + EventData rx_message(EventType::kPacketRX, rx_tag_t(rx).tag_); - if (message_queue_->enqueue(*local_ptok, rx_message) == false) { - std::printf("socket message enqueue failed\n"); - throw std::runtime_error("PacketTXRX: socket message enqueue failed"); + if (message_queue_->enqueue(*local_ptok, rx_message) == false) { + std::printf("socket message enqueue failed\n"); + throw std::runtime_error("PacketTXRX: socket message enqueue failed"); + } } + return pkt; + } +} + +void PacketTXRX::SendBeaconHW(size_t frame_id, size_t radio_id, + long long time0) { + std::vector beaconbuff(2); + std::vector zeros(2); + zeros[0] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); + zeros[1] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); + size_t beacon_radio = cfg_->BeaconAnt() / cfg_->NumChannels(); + size_t beacon_ch = cfg_->BeaconAnt() % cfg_->NumChannels(); + if (radio_id == beacon_radio) { + beaconbuff[beacon_ch] = cfg_->BeaconCi16().data(); + beaconbuff[1 - beacon_ch] = zeros[0]; + } else { + beaconbuff[0] = zeros[0]; + beaconbuff[1] = zeros[1]; + } + if (cfg_->NumChannels() > 1) beaconbuff[1] = zeros[0]; + // assuming beacon is first symbol + long long frame_time = time0 + (frame_id + TX_FRAME_DELTA) * + cfg_->SampsPerSymbol() * + cfg_->Frame().NumTotalSyms(); + int tx_ret = + radioconfig_->RadioTx(radio_id, beaconbuff.data(), 2, frame_time); + if (tx_ret != (int)cfg_->SampsPerSymbol()) { + std::cerr << "BAD BEACON Transmit(" << tx_ret << "/" + << cfg_->SampsPerSymbol() << ") at Time " << tx_time_bs_ + << ", frame count " << frame_id << std::endl; } - return pkt; } -size_t PacketTXRX::DequeueSendArgos(int tid) { +size_t PacketTXRX::DequeueSendArgos(int tid, long long time0) { const size_t max_dequeue_items = (cfg_->BsAntNum() / cfg_->SocketThreadNum()) + 1; @@ -172,7 +324,12 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { ant_id; if (last_antenna) { - // Transmit downlink/uplink calibration pilot + // Schedule beacon in the future + if (cfg_->HwFramer() == false && symbol_id == 0) { + this->SendBeaconHW(frame_id, radio_id, time0); + } + + // Transmit downlink calibration (array to ref) pilot std::vector caltxbuf(cfg_->NumChannels()); if ((cfg_->Frame().IsRecCalEnabled() == true) && (symbol_id == cfg_->Frame().GetDLSymbol(0))) { @@ -187,18 +344,32 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { caltxbuf.at(ch) = calib_turn ? cfg_->PilotCi16().data() : zeros.data(); if (cfg_->NumChannels() > 1) caltxbuf.at(1 - ch) = zeros.data(); - long long frame_time = - ((long long)(frame_id + TX_FRAME_DELTA) << 32) | - (cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch) - << 16); + long long frame_time = 0; + if (cfg_->HwFramer() == false) + frame_time = time0 + cfg_->SampsPerSymbol() * + ((frame_id + TX_FRAME_DELTA) * + cfg_->Frame().NumTotalSyms() + + cfg_->Frame().GetDLCalSymbol( + s * cfg_->NumChannels() + ch)); + else + frame_time = + ((long long)(frame_id + TX_FRAME_DELTA) << 32) | + (cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch) + << 16); radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); } } else { caltxbuf.at(0) = cfg_->PilotCi16().data(); if (cfg_->NumChannels() > 1) caltxbuf.at(1) = zeros.data(); - long long frame_time = - ((long long)(frame_id + TX_FRAME_DELTA) << 32) | - (cfg_->Frame().GetULCalSymbol(0) << 16); + long long frame_time = 0; + if (cfg_->HwFramer() == false) + frame_time = time0 + cfg_->SampsPerSymbol() * + ((frame_id + TX_FRAME_DELTA) * + cfg_->Frame().NumTotalSyms() + + cfg_->Frame().GetULCalSymbol(0)); + else + frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | + (cfg_->Frame().GetULCalSymbol(0) << 16); radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); } } @@ -232,8 +403,15 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { const size_t last = cfg_->Frame().GetDLSymbolLast(); const int flags = (symbol_id != last) ? 1 // HAS_TIME : 2; // HAS_TIME & END_BURST, fixme - frame_id += TX_FRAME_DELTA; - long long frame_time = ((long long)frame_id << 32) | (symbol_id << 16); + long long frame_time = 0; + if (cfg_->HwFramer() == false) + frame_time = + time0 + cfg_->SampsPerSymbol() * ((frame_id + TX_FRAME_DELTA) * + cfg_->Frame().NumTotalSyms() + + symbol_id); + else + frame_time = + ((long long)(frame_id + TX_FRAME_DELTA) << 32) | (symbol_id << 16); radioconfig_->RadioTx(radio_id, txbuf.data(), flags, frame_time); } diff --git a/src/common/config.cc b/src/common/config.cc index 1828d5a68..532ece974 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -188,7 +188,7 @@ Config::Config(const std::string& jsonfile) "tx_advance size must be same as the number of clients!"); cl_tx_advance_.assign(tx_advance.begin(), tx_advance.end()); } - hw_framer_ = tdd_conf.value("hw_framer", true); + hw_framer_ = tdd_conf.value("hw_framer", !kUseUHD); // If frames not specified explicitly, construct default based on frame_type / // symbol_num_perframe / pilot_num / ul_symbol_num_perframe / From 83b0cc6aa47e73824f07e11c2638b15a313303f0 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Sun, 12 Dec 2021 18:34:18 -0600 Subject: [PATCH 02/55] Load iris serials from json. Unify bs and ue configs. --- data/bs-dl-hw-cal.json | 35 ---- data/bs-dl-hw.json | 34 --- data/bs-one-ul-hw.json | 34 --- data/bs-ul-hw.json | 29 --- data/bs-ul-usrp.json | 30 --- data/{bs-sim.json => chsim.json} | 14 +- data/dl-hw.json | 37 ++++ data/{bs-dl-sim.json => dl-sim.json} | 14 +- data/{bs-mac-dl-sim.json => mac-dl-sim.json} | 16 +- data/{bs-mac-sim.json => mac-sim.json} | 16 +- data/{bs-mac-ul-sim.json => mac-ul-sim.json} | 18 +- data/tddconfig-correctness-test-both.json | 10 +- data/tddconfig-correctness-test-dl.json | 10 +- data/tddconfig-correctness-test-ul.json | 10 +- data/tddconfig-sim-both.json | 10 +- data/tddconfig-sim-dl.json | 10 +- data/tddconfig-sim-ul.json | 10 +- data/ue-dl-hw.json | 30 --- data/ue-dl-sim.json | 18 -- data/ue-mac-dl-sim.json | 34 --- data/ue-mac-sim.json | 21 -- data/ue-mac-ul-sim.json | 33 --- data/ue-one-dl-hw.json | 28 --- data/ue-one-ul-hw.json | 32 --- data/ue-sim.json | 21 -- data/ue-ul-hw.json | 33 --- data/ue-ul-sim.json | 18 -- data/ue-ul-usrp.json | 30 --- data/ul-hw.json | 40 ++++ data/{bs-ul-sim.json => ul-sim.json} | 13 +- data/ul-usrp.json | 35 ++++ src/agora/agora.cc | 14 +- src/agora/doencode.cc | 17 +- src/agora/doencode.h | 8 +- src/agora/dofft.cc | 7 +- src/agora/dozf.cc | 25 ++- src/agora/dozf.h | 1 + src/agora/phy_stats.cc | 18 +- src/agora/phy_stats.h | 3 +- src/agora/radio_calibrate.cc | 16 +- src/agora/radio_lib.cc | 58 +++--- src/agora/txrx/txrx_argos.cc | 8 +- src/agora/txrx/txrx_usrp.cc | 14 +- src/client/client_radio.cc | 58 +++--- src/client/phy-ue.cc | 35 ++-- src/client/txrx_client.cc | 35 ++-- src/client/ue_worker.cc | 22 +- src/common/config.cc | 205 ++++++++++++------- src/common/config.h | 87 +++++--- src/common/symbols.h | 2 + test/unit_tests/test_demul_threaded.cc | 2 +- test/unit_tests/test_recipcal.cc | 6 +- test/unit_tests/test_zf.cc | 2 +- test/unit_tests/test_zf_threaded.cc | 2 +- 54 files changed, 578 insertions(+), 790 deletions(-) delete mode 100644 data/bs-dl-hw-cal.json delete mode 100644 data/bs-dl-hw.json delete mode 100644 data/bs-one-ul-hw.json delete mode 100644 data/bs-ul-hw.json delete mode 100644 data/bs-ul-usrp.json rename data/{bs-sim.json => chsim.json} (69%) create mode 100644 data/dl-hw.json rename data/{bs-dl-sim.json => dl-sim.json} (63%) rename data/{bs-mac-dl-sim.json => mac-dl-sim.json} (74%) rename data/{bs-mac-sim.json => mac-sim.json} (65%) rename data/{bs-mac-ul-sim.json => mac-ul-sim.json} (70%) delete mode 100644 data/ue-dl-hw.json delete mode 100644 data/ue-dl-sim.json delete mode 100644 data/ue-mac-dl-sim.json delete mode 100644 data/ue-mac-sim.json delete mode 100644 data/ue-mac-ul-sim.json delete mode 100644 data/ue-one-dl-hw.json delete mode 100644 data/ue-one-ul-hw.json delete mode 100644 data/ue-sim.json delete mode 100644 data/ue-ul-hw.json delete mode 100644 data/ue-ul-sim.json delete mode 100644 data/ue-ul-usrp.json create mode 100644 data/ul-hw.json rename data/{bs-ul-sim.json => ul-sim.json} (64%) create mode 100644 data/ul-usrp.json diff --git a/data/bs-dl-hw-cal.json b/data/bs-dl-hw-cal.json deleted file mode 100644 index fc783aebb..000000000 --- a/data/bs-dl-hw-cal.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "hubs" : "data/bs-hub-serial.txt", - "irises" : "data/bs-iris-serials.txt", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "single_gain" : false, - "rx_gain_a" : 25, - "tx_gain_a" : 40, - "rx_gain_b" : 25, - "tx_gain_b" : 40, - "rate" : 5e6, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_bs" : 160, - "ofdm_rx_zero_prefix_cal_dl" : 288, - "ofdm_rx_zero_prefix_cal_ul" : 168, - "cp_len" : 32, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 336, - "modulation" : "16QAM", - "Zc" : 20, - "beamsweep" : false, - "beacon_antenna" : 4, - "frames" : [ - "BGCLGGPPGGDDDGG" - ], - "client_dl_pilot_syms" : 2, - "external_ref_node" : true, - "ref_ant" : 8, - "socket_thread_num" : 1, - "worker_thread_num" : 16, - "core_offset" : 10, - "demul_block_size" : 48 -} diff --git a/data/bs-dl-hw.json b/data/bs-dl-hw.json deleted file mode 100644 index 0974ecc96..000000000 --- a/data/bs-dl-hw.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "hubs" : "data/bs-hub-serial.txt", - "irises" : "data/bs-iris-serials.txt", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "single_gain" : false, - "rx_gain_a" : 21, - "tx_gain_a" : 35, - "rx_gain_b" : 21, - "tx_gain_b" : 35, - "rate" : 5e6, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_bs" : 160, - "cp_len" : 32, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 336, - "modulation" : "16QAM", - "Zc" : 20, - "beamsweep" : false, - "beacon_antenna" : 0, - "frames" : [ - "BGGGGGPPGGDDDGGGGGGG" - ], - "ref_ant" : 8, - "external_ref_node" : true, - "sample_calibrate" : false, - "imbalance_calibrate" : false, - "init_calib_repeat" : 64, - "client_dl_pilot_syms" : 2, - "worker_thread_num" : 10, - "demul_block_size" : 48 -} diff --git a/data/bs-one-ul-hw.json b/data/bs-one-ul-hw.json deleted file mode 100644 index 787f13be8..000000000 --- a/data/bs-one-ul-hw.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "hubs": "data/bs-hub-serial.txt", - "irises": "data/bs-iris-serials.txt", - "cells": 1, - "ue_num": 1, - "channel": "A", - "frequency": 3.6e9, - "rx_gain_a": 65, - "tx_gain_a": 75, - "rx_gain_b": 65, - "tx_gain_b": 75, - "rate": 7.68e6, - "cp_len": 32, - "ofdm_ca_num": 512, - "ofdm_data_num": 400, - "modulation": "16QAM", - "Zc": 24, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "ofdm_rx_zero_prefix_bs": 160, - "frames": [ - "BPGUUUUG" - ], - "frames_to_test": 100000, - "beamsweep": false, - "beacon_antenna": 0, - "client_ul_pilot_syms": 2, - "worker_thread_num": 16, - "demul_block_size": 48, - "core_offset": 20, - "bs_mac_rx_port": 8070, - "bs_mac_tx_port": 8080, - "ue_server_addr": "10.42.0.1" -} \ No newline at end of file diff --git a/data/bs-ul-hw.json b/data/bs-ul-hw.json deleted file mode 100644 index 84f94876f..000000000 --- a/data/bs-ul-hw.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "hubs" : "data/bs-hub-serial.txt", - "irises" : "data/bs-iris-serials.txt", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "rx_gain_a" : 65, - "tx_gain_a" : 75, - "rx_gain_b" : 65, - "tx_gain_b" : 75, - "rate" : 5e6, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_bs" : 160, - "cp_len" : 32, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 304, - "modulation" : "16QAM", - "Zc" : 18, - "beamsweep" : true, - "beacon_antenna" : 0, - "frames" : [ - "BGGGGGPPGGUUUG" - ], - "downlink_mode": false, - "client_ul_pilot_syms" : 2, - "worker_thread_num" : 20, - "demul_block_size" : 48 -} diff --git a/data/bs-ul-usrp.json b/data/bs-ul-usrp.json deleted file mode 100644 index 94aa39356..000000000 --- a/data/bs-ul-usrp.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "irises" : "data/bs-usrp-addr.txt", - "cells" : 1, - "channel" : "AB", - "frequency" : 3.6e9, - "rx_gain_a" : 20, - "tx_gain_a" : 20, - "rx_gain_b" : 20, - "tx_gain_b" : 20, - "rate" : 5e6, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 304, - "cp_len" : 32, - "ofdm_rx_zero_prefix_bs" : 220, - "Zc" : 18, - "beamsweep" : true, - "beacon_antenna" : 0, - "sample_calibrate" : false, - "frames" : [ - "BGGGGGPGGGUUUG" - ], - "downlink_mode": false, - "client_ul_pilot_syms" : 2, - "core_offset" : 10, - "worker_thread_num" : 2, - "socket_thread_num" : 1, - "demul_block_size" : 48 -} diff --git a/data/bs-sim.json b/data/chsim.json similarity index 69% rename from data/bs-sim.json rename to data/chsim.json index e8d002a38..46fc73c0d 100644 --- a/data/bs-sim.json +++ b/data/chsim.json @@ -1,11 +1,10 @@ { - "ofdm_ca_num": 512, + "fft_size": 512, "ofdm_data_num": 336, "demul_block_size": 48, "Zc": 20, - "UE": false, - "ue_num": 2, - "antenna_num": 8, + "ue_radio_num": 2, + "bs_radio_num": 8, "symbol_num_perframe": 16, "client_ul_pilot_syms": 2, "ul_data_symbol_start": 3, @@ -18,5 +17,8 @@ "bs_rru_port": 8200, "core_offset": 11, "worker_thread_num": 16, - "socket_thread_num": 1 -} \ No newline at end of file + "socket_thread_num": 1, + "ue_core_offset": 1, + "ue_worker_thread_num": 8, + "ue_socket_thread_num": 1 +} diff --git a/data/dl-hw.json b/data/dl-hw.json new file mode 100644 index 000000000..bbb74e169 --- /dev/null +++ b/data/dl-hw.json @@ -0,0 +1,37 @@ +{ + "serial_file" : "data/topology.json", + "cells" : 1, + "channel" : "A", + "frequency" : 3.6e9, + "single_gain" : false, + "rx_gain_a" : 21, + "tx_gain_a" : 35, + "rx_gain_b" : 21, + "tx_gain_b" : 35, + "sample_rate" : 5e6, + "ofdm_tx_zero_prefix" : 160, + "ofdm_tx_zero_postfix" : 160, + "ofdm_rx_zero_prefix_bs" : 160, + "ofdm_rx_zero_prefix_cal_dl" : 288, + "ofdm_rx_zero_prefix_cal_ul" : 168, + "cp_size" : 32, + "fft_size" : 512, + "ofdm_data_num" : 336, + "modulation" : "16QAM", + "Zc" : 20, + "beamsweep" : false, + "beacon_antenna" : 0, + "frame_schedule": [ + "BGCLGGPPGGDDDGG" + ], + "client_dl_pilot_syms" : 2, + "socket_thread_num" : 1, + "worker_thread_num" : 16, + "core_offset" : 10, + "demul_block_size" : 48, + "ue_channel" : "AB", + "hw_framer": false, + "tx_advance" : [144], + "ue_core_offset" : 28, + "ue_worker_thread_num" : 2 +} diff --git a/data/bs-dl-sim.json b/data/dl-sim.json similarity index 63% rename from data/bs-dl-sim.json rename to data/dl-sim.json index 407883627..a0b5465cd 100644 --- a/data/bs-dl-sim.json +++ b/data/dl-sim.json @@ -1,10 +1,9 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 48, - "UE": false, - "ue_num": 2, - "antenna_num": 8, + "ue_radio_num": 2, + "bs_radio_num": 8, "symbol_num_perframe": 70, "client_dl_pilot_syms": 2, "dl_data_symbol_start": 3, @@ -14,5 +13,8 @@ "beacon_position": 0, "core_offset": 1, "worker_thread_num": 8, - "socket_thread_num": 1 -} \ No newline at end of file + "socket_thread_num": 1, + "ue_core_offset": 12, + "ue_worker_thread_num": 2, + "ue_socket_thread_num": 1 +} diff --git a/data/bs-mac-dl-sim.json b/data/mac-dl-sim.json similarity index 74% rename from data/bs-mac-dl-sim.json rename to data/mac-dl-sim.json index 9e7a9e439..f89f0dc27 100644 --- a/data/bs-mac-dl-sim.json +++ b/data/mac-dl-sim.json @@ -1,13 +1,12 @@ { /* General Settings */ - "UE": false, "cells": 1, - "antenna_num": 8, - "ue_num": 1, + "bs_radio_num": 8, + "ue_radio_num": 1, "beamsweep": true, "beacon_antenna": 0, /* Waveform Parameters */ - "ofdm_ca_num": 512, + "fft_size": 512, "ofdm_data_num": 400, "demul_block_size": 48, "cp_len": 32, @@ -30,5 +29,10 @@ "core_offset": 0, "worker_thread_num": 8, "socket_thread_num": 1, - "frames_to_test": 1 -} \ No newline at end of file + "ue_mac_rx_port": 9070, + "ue_mac_tx_port": 9080, + "ue_core_offset": 11, + "ue_worker_thread_num": 2, + "ue_socket_thread_num": 1, + "max_frame": 1 +} diff --git a/data/bs-mac-sim.json b/data/mac-sim.json similarity index 65% rename from data/bs-mac-sim.json rename to data/mac-sim.json index 526f9e472..2f3c05ab6 100644 --- a/data/bs-mac-sim.json +++ b/data/mac-sim.json @@ -1,10 +1,9 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 48, - "UE": false, - "ue_num": 1, - "antenna_num": 8, + "ue_radio_num": 1, + "bs_radio_num": 8, "symbol_num_perframe": 70, "client_ul_pilot_syms": 2, "ul_data_symbol_start": 3, @@ -18,5 +17,10 @@ "core_offset": 16, "worker_thread_num": 8, "socket_thread_num": 1, - "frames_to_test": 5 -} \ No newline at end of file + "ue_mac_rx_port": 9070, + "ue_mac_tx_port": 9080, + "ue_core_offset": 12, + "ue_worker_thread_num": 1, + "ue_socket_thread_num": 1, + "max_frame": 5 +} diff --git a/data/bs-mac-ul-sim.json b/data/mac-ul-sim.json similarity index 70% rename from data/bs-mac-ul-sim.json rename to data/mac-ul-sim.json index a55f560e6..7f0c80b30 100644 --- a/data/bs-mac-ul-sim.json +++ b/data/mac-ul-sim.json @@ -1,13 +1,12 @@ { /* General Settings */ - "UE": false, "cells": 1, - "antenna_num": 8, - "ue_num": 1, + "bs_radio_num": 8, + "ue_radio_num": 1, "beamsweep": true, "beacon_antenna": 0, /* Waveform Parameters */ - "ofdm_ca_num": 512, + "fft_size": 512, "ofdm_data_num": 400, "demul_block_size": 48, "cp_len": 32, @@ -19,7 +18,7 @@ "frequency": 3.6e9, "rate": 7.68e6, /* Frame definition */ - "frames": [ + "frame_schedule": [ "BPGUUUUG" ], "client_ul_pilot_syms": 2, @@ -29,5 +28,10 @@ "core_offset": 0, "worker_thread_num": 8, "socket_thread_num": 1, - "frames_to_test": 9600 -} \ No newline at end of file + "ue_mac_rx_port": 9070, + "ue_mac_tx_port": 9080, + "ue_core_offset": 11, + "ue_worker_thread_num": 2, + "ue_socket_thread_num": 1, + "max_frame": 9600 +} diff --git a/data/tddconfig-correctness-test-both.json b/data/tddconfig-correctness-test-both.json index 11c236dee..dbc82ff4c 100644 --- a/data/tddconfig-correctness-test-both.json +++ b/data/tddconfig-correctness-test-both.json @@ -1,9 +1,9 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 40, - "antenna_num": 8, - "ue_num": 8, + "bs_radio_num": 8, + "ue_radio_num": 8, "modulation": "64QAM", "Zc": 104, "client_ul_pilot_syms": 0, @@ -12,6 +12,6 @@ "core_offset": 1, "worker_thread_num": 1, "socket_thread_num": 1, - "frames_to_test": 1, + "max_frame": 1, "noise_level": 0.01 -} \ No newline at end of file +} diff --git a/data/tddconfig-correctness-test-dl.json b/data/tddconfig-correctness-test-dl.json index c9a23e4c2..e513005a7 100644 --- a/data/tddconfig-correctness-test-dl.json +++ b/data/tddconfig-correctness-test-dl.json @@ -1,9 +1,9 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 40, - "antenna_num": 8, - "ue_num": 8, + "bs_radio_num": 8, + "ue_radio_num": 8, "modulation": "64QAM", "Zc": 104, "symbol_num_perframe": 70, @@ -16,6 +16,6 @@ "core_offset": 1, "worker_thread_num": 1, "socket_thread_num": 1, - "frames_to_test": 1, + "max_frame": 1, "noise_level": 0.01 -} \ No newline at end of file +} diff --git a/data/tddconfig-correctness-test-ul.json b/data/tddconfig-correctness-test-ul.json index ceccafceb..7e50eaccc 100644 --- a/data/tddconfig-correctness-test-ul.json +++ b/data/tddconfig-correctness-test-ul.json @@ -1,9 +1,9 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 40, - "antenna_num": 8, - "ue_num": 8, + "bs_radio_num": 8, + "ue_radio_num": 8, "modulation": "64QAM", "Zc": 104, "symbol_num_perframe": 70, @@ -16,6 +16,6 @@ "core_offset": 1, "worker_thread_num": 1, "socket_thread_num": 1, - "frames_to_test": 1, + "max_frame": 1, "noise_level": 0.01 -} \ No newline at end of file +} diff --git a/data/tddconfig-sim-both.json b/data/tddconfig-sim-both.json index 61528ea80..97d39cc0b 100644 --- a/data/tddconfig-sim-both.json +++ b/data/tddconfig-sim-both.json @@ -1,14 +1,14 @@ { - "antenna_num": 8, - "ue_num": 8, - "frames": [ + "bs_radio_num": 8, + "ue_radio_num": 8, + "frame_schedule": [ "BPUUUUUGGDDDDD" ], "modulation": "64QAM", "Zc": 104, "bs_server_addr": "127.0.0.1", "bs_rru_addr": "127.0.0.1", - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 64, "freq_orthogonal_pilot": true, @@ -18,4 +18,4 @@ "exclude_cores": [0], "worker_thread_num": 22, "socket_thread_num": 2 -} \ No newline at end of file +} diff --git a/data/tddconfig-sim-dl.json b/data/tddconfig-sim-dl.json index cd3b87814..f391521fa 100644 --- a/data/tddconfig-sim-dl.json +++ b/data/tddconfig-sim-dl.json @@ -1,14 +1,14 @@ { - "antenna_num": 8, - "ue_num": 8, - "frames": [ + "bs_radio_num": 8, + "ue_radio_num": 8, + "frame_schedule": [ "PDDDDDDDDDDDDD" ], "modulation": "64QAM", "Zc": 104, "bs_server_addr": "127.0.0.1", "bs_rru_addr": "127.0.0.1", - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 64, "freq_orthogonal_pilot": true, @@ -20,4 +20,4 @@ ], "worker_thread_num": 22, "socket_thread_num": 1 -} \ No newline at end of file +} diff --git a/data/tddconfig-sim-ul.json b/data/tddconfig-sim-ul.json index 5cc015490..4c6dcdd97 100644 --- a/data/tddconfig-sim-ul.json +++ b/data/tddconfig-sim-ul.json @@ -1,14 +1,14 @@ { - "antenna_num": 8, - "ue_num": 8, - "frames": [ + "bs_radio_num": 8, + "ue_radio_num": 8, + "frame_schedule": [ "PUUUUUUUUUUUUU" ], "modulation": "64QAM", "Zc": 104, "bs_server_addr": "127.0.0.1", "bs_rru_addr": "127.0.0.1", - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 64, "freq_orthogonal_pilot": true, @@ -19,4 +19,4 @@ ], "worker_thread_num": 22, "socket_thread_num": 1 -} \ No newline at end of file +} diff --git a/data/ue-dl-hw.json b/data/ue-dl-hw.json deleted file mode 100644 index 592904d58..000000000 --- a/data/ue-dl-hw.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "irises" : "data/user-iris-serials.txt", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "rx_gain_a" : 70, - "tx_gain_a" : 80, - "rx_gain_b" : 65, - "tx_gain_b" : 80, - "client_gain_adjust_a" : [0, 0], - "client_gain_adjust_b" : [-2, -2], - "rate" : 5e6, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 336, - "cp_len" : 32, - "modulation" : "16QAM", - "Zc" : 20, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_client" : 160, - "frames" : [ - "BGGGGGPPGGDDDGG" - ], - "UE" : true, - "hw_framer": false, - "tx_advance" : [144, 144], - "client_dl_pilot_syms": 2, - "core_offset" : 10, - "worker_thread_num" : 2 -} diff --git a/data/ue-dl-sim.json b/data/ue-dl-sim.json deleted file mode 100644 index 2ba3bdb85..000000000 --- a/data/ue-dl-sim.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "ofdm_ca_num": 2048, - "ofdm_data_num": 1200, - "demul_block_size": 48, - "UE": true, - "ue_num": 2, - "antenna_num": 8, - "symbol_num_perframe": 70, - "client_dl_pilot_syms": 2, - "dl_data_symbol_start": 3, - "dl_symbol_num_perframe": 67, - "ul_data_symbol_start": 0, - "ul_symbol_num_perframe": 0, - "beacon_position": 0, - "core_offset": 12, - "worker_thread_num": 2, - "socket_thread_num": 1 -} \ No newline at end of file diff --git a/data/ue-mac-dl-sim.json b/data/ue-mac-dl-sim.json deleted file mode 100644 index 926890111..000000000 --- a/data/ue-mac-dl-sim.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - /* General Settings */ - "UE": true, - "cells": 1, - "antenna_num": 8, - "ue_num": 1, - "beamsweep": true, - "beacon_antenna": 0, - /* Waveform Parameters */ - "ofdm_ca_num": 512, - "ofdm_data_num": 400, - "demul_block_size": 48, - "cp_len": 32, - "modulation": "16QAM", - "Zc": 24, - "frequency": 3.6e9, - "rate": 7.68e6, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "ofdm_rx_zero_prefix_bs": 160, - "ofdm_rx_zero_prefix_client": 160, - /* Frame definition */ - "frames": [ - "BPGDDDDG" - ], - "client_dl_pilot_syms": 2, - /* compute configuration */ - "ue_mac_rx_port": 9070, - "ue_mac_tx_port": 9080, - "core_offset": 11, - "worker_thread_num": 2, - "socket_thread_num": 1, - "frames_to_test": 1 -} \ No newline at end of file diff --git a/data/ue-mac-sim.json b/data/ue-mac-sim.json deleted file mode 100644 index f36a01984..000000000 --- a/data/ue-mac-sim.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "ofdm_ca_num": 2048, - "ofdm_data_num": 1200, - "demul_block_size": 48, - "UE": true, - "ue_num": 1, - "symbol_num_perframe": 70, - "client_ul_pilot_syms": 2, - "ul_data_symbol_start": 3, - "ul_symbol_num_perframe": 3, - "client_dl_pilot_syms": 2, - "dl_data_symbol_start": 8, - "dl_symbol_num_perframe": 3, - "beacon_position": 0, - "mac_rx_port": 9070, - "mac_tx_port": 9080, - "core_offset": 12, - "worker_thread_num": 1, - "socket_thread_num": 1, - "frames_to_test": 5 -} \ No newline at end of file diff --git a/data/ue-mac-ul-sim.json b/data/ue-mac-ul-sim.json deleted file mode 100644 index ca9c318a6..000000000 --- a/data/ue-mac-ul-sim.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - /* General Settings */ - "UE": true, - "cells": 1, - "antenna_num": 8, - "ue_num": 1, - "beamsweep": true, - "beacon_antenna": 0, - /* Waveform Parameters */ - "ofdm_ca_num": 512, - "ofdm_data_num": 400, - "demul_block_size": 48, - "cp_len": 32, - "modulation": "16QAM", - "Zc": 24, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "ofdm_rx_zero_prefix_bs": 160, - "frequency": 3.6e9, - "rate": 7.68e6, - /* Frame definition */ - "frames": [ - "BPGUUUUG" - ], - "client_ul_pilot_syms": 2, - /* compute configuration */ - "ue_mac_rx_port": 9070, - "ue_mac_tx_port": 9080, - "core_offset": 11, - "worker_thread_num": 2, - "socket_thread_num": 1, - "frames_to_test": 9600 -} \ No newline at end of file diff --git a/data/ue-one-dl-hw.json b/data/ue-one-dl-hw.json deleted file mode 100644 index afcd93364..000000000 --- a/data/ue-one-dl-hw.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "irises" : "data/user-iris-serials.txt", - "channel" : "A", - "frequency" : 3.6e9, - "single_gain" : false, - "rx_gain_a" : 21, - "tx_gain_a" : 30, - "rx_gain_b" : 21, - "tx_gain_b" : 30, - "rate" : 5e6, - "cp_len" : 32, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 336, - "modulation" : "16QAM", - "Zc" : 20, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_client" : 160, - "frames" : [ - "GGGGGGPGGGDDDGGGGGGG" - ], - "UE" : true, - "core_offset" : 20, - "hw_framer": false, - "tx_advance" : [144], - "client_dl_pilot_syms": 2, - "worker_thread_num" : 2 -} diff --git a/data/ue-one-ul-hw.json b/data/ue-one-ul-hw.json deleted file mode 100644 index 4c2327b8e..000000000 --- a/data/ue-one-ul-hw.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "irises": "data/user-iris-serials-ul-falcon.txt", - "channel": "A", - "frequency": 3.6e9, - "rx_gain_a": 65, - "tx_gain_a": 75, - "rx_gain_b": 65, - "tx_gain_b": 75, - "rate": 7.68e6, - "cp_len": 32, - "ofdm_ca_num": 512, - "ofdm_data_num": 400, - "modulation": "16QAM", - "Zc": 24, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "frames": [ - "BPGUUUUG" - ], - "hw_framer": false, - "frames_to_test": 100000, - "tx_advance": [ - 140 - ], - "UE": true, - "client_ul_pilot_syms": 2, - "worker_thread_num": 4, - "demul_block_size": 48, - "core_offset": 26, - "ue_mac_rx_port": 9070, - "ue_mac_tx_port": 9080 -} diff --git a/data/ue-sim.json b/data/ue-sim.json deleted file mode 100644 index 1e5778ad9..000000000 --- a/data/ue-sim.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "ofdm_ca_num": 512, - "ofdm_data_num": 336, - "demul_block_size": 48, - "Zc": 20, - "UE": true, - "ue_num": 2, - "symbol_num_perframe": 16, - "client_ul_pilot_syms": 2, - "ul_data_symbol_start": 3, - "ul_symbol_num_perframe": 3, - "client_dl_pilot_syms": 2, - "dl_data_symbol_start": 7, - "dl_symbol_num_perframe": 3, - "beacon_position": 0, - "bs_server_port": 8100, - "bs_rru_port": 8200, - "core_offset": 1, - "worker_thread_num": 8, - "socket_thread_num": 1 -} \ No newline at end of file diff --git a/data/ue-ul-hw.json b/data/ue-ul-hw.json deleted file mode 100644 index 7c0af07c4..000000000 --- a/data/ue-ul-hw.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "irises": "data/user-iris-serials.txt", - "channel": "A", - "frequency": 3.6e9, - "rx_gain_a": 65, - "tx_gain_a": 75, - "rx_gain_b": 65, - "tx_gain_b": 75, - "rate": 7.68e6, - "cp_len": 32, - "ofdm_ca_num": 512, - "ofdm_data_num": 400, - "modulation": "16QAM", - "Zc": 24, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "frames": [ - "BPPGUUUUG" - ], - "hw_framer": false, - "frames_to_test": 100000, - "tx_advance": [ - 140, - 140 - ], - "UE": true, - "client_ul_pilot_syms": 2, - "worker_thread_num": 2, - "demul_block_size": 48, - "core_offset": 26, - "ue_mac_rx_port": 9070, - "ue_mac_tx_port": 9080 -} \ No newline at end of file diff --git a/data/ue-ul-sim.json b/data/ue-ul-sim.json deleted file mode 100644 index cb341aab0..000000000 --- a/data/ue-ul-sim.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "ofdm_ca_num": 2048, - "ofdm_data_num": 1200, - "demul_block_size": 48, - "UE": true, - "ue_num": 2, - "antenna_num": 8, - "symbol_num_perframe": 70, - "client_ul_pilot_syms": 1, - "ul_data_symbol_start": 3, - "ul_symbol_num_perframe": 67, - "dl_data_symbol_start": 0, - "dl_symbol_num_perframe": 0, - "beacon_position": 0, - "core_offset": 12, - "worker_thread_num": 2, - "socket_thread_num": 1 -} \ No newline at end of file diff --git a/data/ue-ul-usrp.json b/data/ue-ul-usrp.json deleted file mode 100644 index 4aec2886d..000000000 --- a/data/ue-ul-usrp.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "irises" : "data/user-usrp-addr.txt", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "rx_gain_a" : 20, - "tx_gain_a" : 20, - "rx_gain_b" : 20, - "tx_gain_b" : 20, - "rate" : 5e6, - "ofdm_ca_num" : 512, - "ofdm_data_num" : 304, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_client" : 240, - "cp_len" : 32, - "Zc" : 18, - "frames" : [ - "GGDDGGPGGGUUUG" - ], - "hw_framer": false, - "tx_advance" : [78], - "UE" : true, - "client_ul_pilot_syms" : 2, - "client_dl_pilot_syms" : 2, - "modulation" : "16QAM", - "worker_thread_num" : 2, - "socket_thread_num" : 1, - "demul_block_size" : 48 -} diff --git a/data/ul-hw.json b/data/ul-hw.json new file mode 100644 index 000000000..8a614e18c --- /dev/null +++ b/data/ul-hw.json @@ -0,0 +1,40 @@ +{ + "serial_file" : "data/topology.json", + "cells" : 1, + "channel" : "A", + "frequency" : 3.6e9, + "rx_gain_a" : 65, + "tx_gain_a" : 75, + "rx_gain_b" : 65, + "tx_gain_b" : 75, + "sample_rate": 7.68e6, + "ofdm_tx_zero_prefix" : 160, + "ofdm_tx_zero_postfix" : 160, + "ofdm_rx_zero_prefix_bs" : 160, + "cp_size" : 32, + "fft_size" : 512, + "ofdm_data_num" : 304, + "modulation" : "16QAM", + "Zc" : 18, + "beamsweep" : true, + "beacon_antenna" : 0, + "frame_schedule": [ + "BPPGUUUUG" + ], + "hw_framer": false, + "max_frame": 100000, + "tx_advance": [ + 140, + 140 + ], + "ue_channel" : "A", + "downlink_mode": false, + "client_ul_pilot_syms" : 2, + "worker_thread_num" : 20, + "demul_block_size" : 48, + "ue_worker_thread_num": 2, + "ue_demul_block_size": 48, + "ue_core_offset": 26, + "ue_mac_rx_port": 9070, + "ue_mac_tx_port": 9080 +} diff --git a/data/bs-ul-sim.json b/data/ul-sim.json similarity index 64% rename from data/bs-ul-sim.json rename to data/ul-sim.json index 0242229f0..9167adea3 100644 --- a/data/bs-ul-sim.json +++ b/data/ul-sim.json @@ -1,10 +1,10 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "demul_block_size": 48, "UE": false, - "ue_num": 2, - "antenna_num": 8, + "ue_radio_num": 2, + "bs_radio_num": 8, "symbol_num_perframe": 70, "client_ul_pilot_syms": 1, "ul_data_symbol_start": 3, @@ -14,5 +14,8 @@ "beacon_position": 0, "core_offset": 1, "worker_thread_num": 8, - "socket_thread_num": 1 -} \ No newline at end of file + "socket_thread_num": 1, + "ue_core_offset": 12, + "ue_worker_thread_num": 2, + "ue_socket_thread_num": 1 +} diff --git a/data/ul-usrp.json b/data/ul-usrp.json new file mode 100644 index 000000000..0b454956a --- /dev/null +++ b/data/ul-usrp.json @@ -0,0 +1,35 @@ +{ + "serial_file" : "data/bs-usrp-addr.txt", + "cells" : 1, + "channel" : "AB", + "frequency" : 3.6e9, + "rx_gain_a" : 20, + "tx_gain_a" : 20, + "rx_gain_b" : 20, + "tx_gain_b" : 20, + "sample_rate" : 5e6, + "ofdm_tx_zero_prefix" : 160, + "ofdm_tx_zero_postfix" : 160, + "ofdm_rx_zero_prefix_bs" : 220, + "ofdm_rx_zero_prefix_client" : 240, + "cp_size" : 32, + "fft_size" : 512, + "ofdm_data_num" : 304, + "Zc" : 18, + "beamsweep" : true, + "beacon_antenna" : 0, + "modulation" : "16QAM", + "frame_schedule" : [ + "BGGGGGPGGGUUUG" + ], + "client_ul_pilot_syms" : 2, + "demul_block_size" : 48, + "core_offset" : 10, + "worker_thread_num" : 2, + "socket_thread_num" : 1, + "hw_framer": false, + "tx_advance" : [78], + "ue_core_offset": 0, + "ue_worker_thread_num" : 2, + "ue_socket_thread_num" : 1 +} diff --git a/src/agora/agora.cc b/src/agora/agora.cc index fcf6c2bfb..96451fcab 100644 --- a/src/agora/agora.cc +++ b/src/agora/agora.cc @@ -16,7 +16,7 @@ Agora::Agora(Config* const cfg) : base_worker_core_offset_(cfg->CoreOffset() + 1 + cfg->SocketThreadNum()), config_(cfg), stats_(std::make_unique(cfg)), - phy_stats_(std::make_unique(cfg)), + phy_stats_(std::make_unique(cfg, Direction::Uplink)), csi_buffers_(kFrameWnd, cfg->UeNum(), cfg->BsAntNum() * cfg->OfdmDataNum()), ul_zf_matrices_(kFrameWnd, cfg->OfdmDataNum(), @@ -809,7 +809,8 @@ void Agora::Worker(int tid) { this->dl_encoded_buffer_, this->stats_.get()); auto compute_encoding = std::make_unique( - config_, tid, (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), + config_, tid, Direction::Downlink, + (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), (kEnableMac == true) ? kFrameWnd : 1, dl_encoded_buffer_, this->stats_.get()); @@ -949,10 +950,11 @@ void Agora::WorkerDemul(int tid) { void Agora::WorkerDecode(int tid) { PinToCoreWithOffset(ThreadType::kWorkerDecode, base_worker_core_offset_, tid); - std::unique_ptr compute_encoding(new DoEncode( - config_, tid, (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), - (kEnableMac == true) ? kFrameWnd : 1, dl_encoded_buffer_, - this->stats_.get())); + std::unique_ptr compute_encoding( + new DoEncode(config_, tid, Direction::Downlink, + (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), + (kEnableMac == true) ? kFrameWnd : 1, dl_encoded_buffer_, + this->stats_.get())); std::unique_ptr compute_decoding( new DoDecode(config_, tid, demod_buffers_, decoded_buffer_, diff --git a/src/agora/doencode.cc b/src/agora/doencode.cc index 4ffd8af99..da5d9ccd1 100644 --- a/src/agora/doencode.cc +++ b/src/agora/doencode.cc @@ -13,10 +13,11 @@ static constexpr bool kPrintEncodedData = false; static constexpr bool kPrintRawMacData = false; -DoEncode::DoEncode(Config* in_config, int in_tid, +DoEncode::DoEncode(Config* in_config, int in_tid, Direction dir, Table& in_raw_data_buffer, size_t in_buffer_rollover, Table& in_encoded_buffer, Stats* in_stats_manager) : Doer(in_config, in_tid), + dir_(dir), raw_data_buffer_(in_raw_data_buffer), raw_buffer_rollover_(in_buffer_rollover), encoded_buffer_(in_encoded_buffer), @@ -57,7 +58,7 @@ EventData DoEncode::Launch(size_t tag) { size_t start_tsc = GetTime::WorkerRdtsc(); size_t symbol_idx, symbol_idx_data; - if (cfg_->IsUe() == false) { + if (dir_ == Direction::Downlink) { symbol_idx = cfg_->Frame().GetDLSymbolIdx(symbol_id); assert(symbol_idx >= cfg_->Frame().ClientDlPilotSymbols()); symbol_idx_data = symbol_idx - cfg_->Frame().ClientDlPilotSymbols(); @@ -80,9 +81,9 @@ EventData DoEncode::Launch(size_t tag) { /// universal with raw_buffer_rollover_ the parameter. if (kEnableMac) { // All cb's per symbol are included in 1 mac packet - tx_data_ptr = - cfg_->GetMacBits(raw_data_buffer_, (frame_id % raw_buffer_rollover_), - symbol_idx_data, ue_id, cur_cb_id); + tx_data_ptr = cfg_->GetMacBits(raw_data_buffer_, dir_, + (frame_id % raw_buffer_rollover_), + symbol_idx_data, ue_id, cur_cb_id); if (kPrintRawMacData) { auto* pkt = reinterpret_cast(tx_data_ptr); @@ -116,10 +117,10 @@ EventData DoEncode::Launch(size_t tag) { LdpcEncodeHelper(ldpc_config.BaseGraph(), ldpc_config.ExpansionFactor(), ldpc_config.NumRows(), encoded_buffer_temp_, parity_buffer_, ldpc_input); - int8_t* final_output_ptr = cfg_->GetEncodedBuf(encoded_buffer_, frame_id, - symbol_idx, ue_id, cur_cb_id); + int8_t* final_output_ptr = cfg_->GetEncodedBuf( + encoded_buffer_, dir_, frame_id, symbol_idx, ue_id, cur_cb_id); - if (kPrintRawMacData && cfg_->IsUe()) { + if (kPrintRawMacData && dir_ == Direction::Uplink) { std::printf("Encoded data - placed at location (%zu %zu %zu) %zu\n", frame_id, symbol_idx, ue_id, (size_t)final_output_ptr); } diff --git a/src/agora/doencode.h b/src/agora/doencode.h index f3e9c8480..6721a95d3 100644 --- a/src/agora/doencode.h +++ b/src/agora/doencode.h @@ -18,14 +18,16 @@ class DoEncode : public Doer { public: - DoEncode(Config* in_config, int in_tid, Table& in_raw_data_buffer, - size_t in_buffer_rollover, Table& in_encoded_buffer, - Stats* in_stats_manager); + DoEncode(Config* in_config, int in_tid, Direction dir, + Table& in_raw_data_buffer, size_t in_buffer_rollover, + Table& in_encoded_buffer, Stats* in_stats_manager); ~DoEncode() override; EventData Launch(size_t tag) override; private: + Direction dir_; + // References to buffers allocated pre-construction Table& raw_data_buffer_; size_t raw_buffer_rollover_; diff --git a/src/agora/dofft.cc b/src/agora/dofft.cc index 71bc6ac6c..10aec9202 100644 --- a/src/agora/dofft.cc +++ b/src/agora/dofft.cc @@ -87,6 +87,7 @@ EventData DoFFT::Launch(size_t tag) { size_t frame_slot = frame_id % kFrameWnd; size_t symbol_id = pkt->symbol_id_; size_t ant_id = pkt->ant_id_; + size_t cell_id = pkt->cell_id_; SymbolType sym_type = cfg_->GetSymbolType(symbol_id); if (cfg_->FftInRru() == true) { @@ -191,7 +192,8 @@ EventData DoFFT::Launch(size_t tag) { } else if (sym_type == SymbolType::kUL) { PartialTranspose(cfg_->GetDataBuf(data_buffer_, frame_id, symbol_id), ant_id, SymbolType::kUL); - } else if (sym_type == SymbolType::kCalUL and ant_id != cfg_->RefAnt()) { + } else if (sym_type == SymbolType::kCalUL and + ant_id != cfg_->RefAnt().at(cell_id)) { // Only process uplink for antennas that also do downlink in this frame // for consistency with calib downlink processing. if (frame_id >= TX_FRAME_DELTA && @@ -204,7 +206,8 @@ EventData DoFFT::Launch(size_t tag) { ant_id, sym_type); phy_stats_->UpdateCalibPilotSnr(frame_grp_id, 1, ant_id, fft_inout_); } - } else if (sym_type == SymbolType::kCalDL && ant_id == cfg_->RefAnt()) { + } else if (sym_type == SymbolType::kCalDL && + ant_id == cfg_->RefAnt().at(cell_id)) { if (frame_id >= TX_FRAME_DELTA) { size_t frame_grp_id = (frame_id - TX_FRAME_DELTA) / cfg_->AntGroupNum(); size_t frame_grp_slot = frame_grp_id % kFrameWnd; diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index 769739f3b..3173a56fd 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -44,6 +44,13 @@ DoZF::DoZF(Config* config, int tid, calib_gather_buffer_ = static_cast( Agora_memory::PaddedAlignedAlloc(Agora_memory::Alignment_t::kAlign64, kMaxAntennas * sizeof(complex_float))); + + if (cfg_->RefAnt().size() > 0) { + ref_ids.zeros(cfg_->NumCells() * cfg_->NumChannels()); + for (size_t i = 0; i < cfg_->NumCells(); i++) + for (size_t j = 0; j < cfg_->NumChannels(); j++) + ref_ids.at(i * cfg_->NumChannels() + j) = cfg_->RefAnt().at(i) + j; + } } DoZF::~DoZF() { @@ -106,18 +113,21 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, mat_dl_zf_tmp *= scale; if (cfg_->ExternalRefNode()) { - mat_dl_zf_tmp.insert_cols( - cfg_->RefAnt(), - arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), arma::fill::zeros)); + for (size_t i = 0; i < cfg_->NumCells(); i++) + mat_dl_zf_tmp.insert_cols( + cfg_->RefRadio().at(i) * cfg_->NumChannels(), + arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), + arma::fill::zeros)); } arma::cx_fmat mat_dl_zf(reinterpret_cast(_mat_dl_zf), cfg_->BsAntNum(), cfg_->UeNum(), false); mat_dl_zf = mat_dl_zf_tmp.st(); } if (cfg_->ExternalRefNode() == true) { - mat_ul_zf_tmp.insert_cols( - cfg_->RefAnt(), - arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), arma::fill::zeros)); + for (size_t i = 0; i < cfg_->NumCells(); i++) + mat_ul_zf_tmp.insert_cols( + cfg_->RefAnt().at(i) * cfg_->NumChannels(), + arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), arma::fill::zeros)); } mat_ul_zf = mat_ul_zf_tmp; float rcond = -1; @@ -309,8 +319,7 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { if (cfg_->Frame().NumDLSyms() > 0) { ComputeCalib(frame_id, cur_sc_id); if (cfg_->ExternalRefNode()) { - mat_csi.shed_rows(cfg_->RefAnt(), - cfg_->RefAnt() + cfg_->NumChannels() - 1); + mat_csi.shed_rows(ref_ids); } } diff --git a/src/agora/dozf.h b/src/agora/dozf.h index 3e7f1bb3c..936a5b369 100644 --- a/src/agora/dozf.h +++ b/src/agora/dozf.h @@ -97,6 +97,7 @@ class DoZF : public Doer { // Intermediate buffer to gather reciprical calibration data vector complex_float* calib_gather_buffer_; PhyStats* phy_stats_; + arma::uvec ref_ids; }; #endif // DOZF_H_ diff --git a/src/agora/phy_stats.cc b/src/agora/phy_stats.cc index fdafa4e4f..74bdd56ec 100644 --- a/src/agora/phy_stats.cc +++ b/src/agora/phy_stats.cc @@ -7,8 +7,8 @@ #include #include -PhyStats::PhyStats(Config* const cfg) : config_(cfg) { - if (config_->IsUe() == true) { +PhyStats::PhyStats(Config* const cfg, Direction dir) : config_(cfg), dir_(dir) { + if (dir_ == Direction::Downlink) { num_rx_symbols_ = cfg->Frame().NumDLSyms(); } else { num_rx_symbols_ = cfg->Frame().NumULSyms(); @@ -34,7 +34,7 @@ PhyStats::PhyStats(Config* const cfg) : config_(cfg) { Agora_memory::Alignment_t::kAlign64); if (num_rx_symbols_ > 0) { - if (config_->IsUe() == true) { + if (dir_ == Direction::Downlink) { auto* dl_iq_f_ptr = reinterpret_cast( cfg->DlIqF()[cfg->Frame().ClientDlPilotSymbols()]); arma::cx_fmat dl_iq_f_mat(dl_iq_f_ptr, cfg->OfdmCaNum(), cfg->UeAntNum(), @@ -74,7 +74,7 @@ PhyStats::~PhyStats() { void PhyStats::PrintPhyStats() { const size_t task_buffer_symbol_num = num_rx_symbols_ * kFrameWnd; std::string tx_type; - if (config_->IsUe()) { + if (dir_ == Direction::Downlink) { tx_type = "Downlink"; } else { tx_type = "Uplink"; @@ -131,9 +131,10 @@ void PhyStats::PrintSnrStats(size_t frame_id) { float* frame_snr = &pilot_snr_[frame_id % kFrameWnd][i * config_->BsAntNum()]; for (size_t j = 0; j < config_->BsAntNum(); j++) { + size_t radio_id = j / config_->NumChannels(); + size_t cell_id = config_->CellId().at(radio_id); if (config_->ExternalRefNode() == true && - j / config_->NumChannels() == - config_->RefAnt() / config_->NumChannels()) + radio_id == config_->RefRadio().at(cell_id)) continue; if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; @@ -158,9 +159,10 @@ void PhyStats::PrintCalibSnrStats(size_t frame_id) { float* frame_snr = &calib_pilot_snr_[frame_id % kFrameWnd][i * config_->BsAntNum()]; for (size_t j = 0; j < config_->BsAntNum(); j++) { + size_t radio_id = j / config_->NumChannels(); + size_t cell_id = config_->CellId().at(radio_id); if (config_->ExternalRefNode() == true && - j / config_->NumChannels() == - config_->RefAnt() / config_->NumChannels()) + radio_id == config_->RefRadio().at(cell_id)) continue; if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; diff --git a/src/agora/phy_stats.h b/src/agora/phy_stats.h index 6a9a42bb7..39680e4e9 100644 --- a/src/agora/phy_stats.h +++ b/src/agora/phy_stats.h @@ -13,7 +13,7 @@ class PhyStats { public: - explicit PhyStats(Config* const cfg); + explicit PhyStats(Config* const cfg, Direction dir); ~PhyStats(); void PrintPhyStats(); void UpdateBitErrors(size_t /*ue_id*/, size_t /*offset*/, uint8_t /*tx_byte*/, @@ -44,6 +44,7 @@ class PhyStats { private: Config const* const config_; + Direction dir_; Table decoded_bits_count_; Table bit_error_count_; Table decoded_blocks_count_; diff --git a/src/agora/radio_calibrate.cc b/src/agora/radio_calibrate.cc index 914b1c7a6..26a8ef6af 100644 --- a/src/agora/radio_calibrate.cc +++ b/src/agora/radio_calibrate.cc @@ -383,7 +383,7 @@ void RadioConfig::DciqCalibrationProc(size_t channel) { double tone_bb_freq = sample_rate / 7; size_t radio_size = cfg_->NumRadios(); - size_t reference_radio = cfg_->RefAnt() / cfg_->NumChannels(); + size_t reference_radio = cfg_->RefRadio().at(0); SoapySDR::Device* ref_dev = ba_stn_[reference_radio]; /* @@ -537,9 +537,9 @@ void RadioConfig::DciqCalibrationProc(size_t channel) { void RadioConfig::AdjustDelays(std::vector offset) { // adjust all trigger delay for all radios // with respect to the first non-ref radio - size_t ref_offset = cfg_->RefAnt() == 0 ? 1 : 0; + size_t ref_offset = cfg_->RefAnt().at(0) == 0 ? 1 : 0; for (size_t i = 0; i < offset.size(); i++) { - if (i == cfg_->RefAnt()) { + if (i == cfg_->RefAnt().at(0)) { continue; } int delta = offset[ref_offset] - offset[i]; @@ -578,8 +578,9 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { std::vector>> buff; // int ant = cfg_->num_channels(); size_t m = cfg_->BsAntNum(); + // TODO: Fix for multi-cell size_t r = cfg_->NumRadios(); - size_t ref = cfg_->RefAnt() / cfg_->NumChannels(); + size_t ref = cfg_->RefRadio().at(0); // allocate for uplink and downlink directions buff.resize(2 * m); for (size_t i = 0; i < 2 * m; i++) { @@ -861,7 +862,8 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { for (size_t q = 0; q < cfg_->OfdmCaNum(); q++) { sig_dn += std::pow(std::abs(dn.at(i).at(q + start_dn.at(i))), 2); noise_dn += std::pow( - std::abs(noise.at(cfg_->RefAnt()).at(q + start_dn.at(i))), 2); + std::abs(noise.at(cfg_->RefAnt().at(0)).at(q + start_dn.at(i))), + 2); } ss0 << 10 * std::log10(sig_dn / noise_dn) << " "; if (kReciprocalCalibPlot) { @@ -877,7 +879,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { plt::plot(up_i); // plt::xlim(0, read_len); plt::ylim(-1, 1); - plt::title("ant " + std::to_string(cfg_->RefAnt()) + + plt::title("ant " + std::to_string(cfg_->RefAnt().at(0)) + " (ref) to ant " + std::to_string(i)); plt::legend(); plt::save("up_" + std::to_string(i) + ".png"); @@ -887,7 +889,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { // plt::xlim(0, read_len); plt::ylim(-1, 1); plt::title("ant " + std::to_string(i) + " to ant (ref)" + - std::to_string(cfg_->RefAnt())); + std::to_string(cfg_->RefAnt().at(0))); plt::legend(); plt::save("dn_" + std::to_string(i) + ".png"); } diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 44c140c97..71be3fa83 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -17,17 +17,20 @@ RadioConfig::RadioConfig(Config* cfg) auto channels = Utils::StrToChannels(cfg_->Channel()); this->radio_num_ = cfg_->NumRadios(); - this->antenna_num_ = radio_num_ * cfg_->NumChannels(); + this->antenna_num_ = cfg_->BsAntNum(); std::cout << "Radio num is " << this->radio_num_ << " Antenna num: " << antenna_num_ << std::endl; - if (cfg_->IsUe() == true) { - throw std::invalid_argument("Bad config! Not a UE!"); - } - if ((kUseUHD == false) && (cfg_->HubIds().empty() == false)) { - args["driver"] = "remote"; - args["timeout"] = "1000000"; - args["serial"] = cfg_->HubIds().at(0); - hubs_.push_back(SoapySDR::Device::make(args)); + if (kUseUHD == false) { + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->HubId().at(i) != "") { + args["driver"] = "remote"; + args["timeout"] = "1000000"; + args["serial"] = cfg_->HubId().at(i); + hubs_.push_back(SoapySDR::Device::make(args)); + } else { + hubs_.push_back(nullptr); + } + } } ba_stn_.resize(radio_num_); @@ -102,7 +105,7 @@ RadioConfig::RadioConfig(Config* cfg) } for (size_t i = 0; i < this->radio_num_; i++) { - std::cout << cfg_->RadioIds().at(i) << ": Front end " + std::cout << cfg_->RadioId().at(i) << ": Front end " << ba_stn_[i]->getHardwareInfo()["frontend"] << std::endl; for (auto c : channels) { if (c < ba_stn_[i]->getNumChannels(SOAPY_SDR_RX)) { @@ -168,11 +171,14 @@ RadioConfig::RadioConfig(Config* cfg) std::cout << std::endl; } - if (!kUseUHD) { - if (hubs_.empty()) { - ba_stn_[0]->writeSetting("SYNC_DELAYS", ""); - } else { - hubs_[0]->writeSetting("SYNC_DELAYS", ""); + // TODO: For multi-cell, this procedure needs modification + if (kUseUHD == false) { + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (hubs_.at(i) == nullptr) { + ba_stn_[i]->writeSetting("SYNC_DELAYS", ""); + } else { + hubs_[i]->writeSetting("SYNC_DELAYS", ""); + } } } @@ -187,10 +193,10 @@ void RadioConfig::InitBsRadio(size_t tid) { args["timeout"] = "1000000"; if (!kUseUHD) { args["driver"] = "iris"; - args["serial"] = cfg_->RadioIds().at(i); + args["serial"] = cfg_->RadioId().at(i); } else { args["driver"] = "uhd"; - args["addr"] = cfg_->RadioIds().at(i); + args["addr"] = cfg_->RadioId().at(i); } ba_stn_[i] = SoapySDR::Device::make(args); for (auto ch : {0, 1}) { @@ -394,7 +400,8 @@ bool RadioConfig::RadioStart() { size_t ndx = 0; for (size_t i = 0; i < this->radio_num_; i++) { - bool is_ref_radio = (i == cfg_->RefRadio()); + size_t cell_id = cfg_->CellId().at(i); + bool is_ref_radio = (i == cfg_->RefRadio().at(cell_id)); ba_stn_[i]->writeSetting( "TX_SW_DELAY", "30"); // experimentally good value for dev front-end ba_stn_[i]->writeSetting("TDD_MODE", "true"); @@ -467,13 +474,14 @@ bool RadioConfig::RadioStart() { } void RadioConfig::Go() { - if (!kUseUHD) { - if (hubs_.empty()) { - // std::cout << "triggering first Iris ..." << std::endl; - ba_stn_[0]->writeSetting("TRIGGER_GEN", ""); - } else { - // std::cout << "triggering Hub ..." << std::endl; - hubs_[0]->writeSetting("TRIGGER_GEN", ""); + // TODO: For multi-cell trigger process needs modification + if (kUseUHD == false) { + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (hubs_.at(i) == nullptr) { + ba_stn_[i]->writeSetting("TRIGGER_GEN", ""); + } else { + hubs_[i]->writeSetting("TRIGGER_GEN", ""); + } } } } diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 4d19dcdbf..1c0c1910a 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -63,6 +63,7 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, size_t packet_length = cfg_->PacketLength(); size_t ant_id = radio_id * cfg_->NumChannels(); + size_t cell_id = cfg_->CellId().at(radio_id); std::vector ant_ids(cfg_->NumChannels()); std::vector samp(cfg_->NumChannels()); @@ -94,7 +95,7 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, /// \TODO: What if ref_ant is set to the second channel? if ((cfg_->Frame().IsRecCalEnabled() == true) && (cfg_->IsCalDlPilot(frame_id, symbol_id) == true) && - (radio_id == cfg_->RefRadio()) && (cfg_->AntPerGroup() > 1)) { + (radio_id == cfg_->RefRadio().at(cell_id)) && (cfg_->AntPerGroup() > 1)) { if (cfg_->AntPerGroup() > cfg_->NumChannels()) { symbol_ids.resize(cfg_->AntPerGroup()); ant_ids.resize(cfg_->AntPerGroup()); @@ -121,7 +122,7 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); pkt.push_back(rx.RawPacket()); new (rx.RawPacket()) - Packet(frame_id, symbol_ids.at(ch), 0 /* cell_id */, ant_ids.at(ch)); + Packet(frame_id, symbol_ids.at(ch), cell_id, ant_ids.at(ch)); rx.Use(); // Push kPacketRX event into the queue. @@ -155,6 +156,7 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { const size_t symbol_id = gen_tag_t(current_event.tags_[0u]).symbol_id_; const size_t ant_id = gen_tag_t(current_event.tags_[0u]).ant_id_; const size_t radio_id = ant_id / cfg_->NumChannels(); + size_t cell_id = cfg_->CellId().at(radio_id); // See if this is the last antenna on the radio. Assume that we receive the // last one @@ -179,7 +181,7 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { std::vector> zeros(cfg_->SampsPerSymbol(), std::complex(0, 0)); for (size_t s = 0; s < cfg_->RadioPerGroup(); s++) { - if (radio_id != cfg_->RefRadio()) { + if (radio_id != cfg_->RefRadio().at(cell_id)) { bool calib_turn = (frame_id % cfg_->RadioGroupNum() == radio_id / cfg_->RadioPerGroup() && s == radio_id % cfg_->RadioPerGroup()); diff --git a/src/agora/txrx/txrx_usrp.cc b/src/agora/txrx/txrx_usrp.cc index 8b1f4eb33..9924b20f2 100644 --- a/src/agora/txrx/txrx_usrp.cc +++ b/src/agora/txrx/txrx_usrp.cc @@ -182,9 +182,11 @@ int PacketTXRX::DequeueSendUsrp(int tid) { std::printf("tx queue length: %zu\n", task_queue_->size_approx()); assert(event.event_type_ == EventType::kPacketTX); - size_t ant_id = gen_tag_t(event.tags_[0]).ant_id_; size_t frame_id = gen_tag_t(event.tags_[0]).frame_id_; size_t symbol_id = gen_tag_t(event.tags_[0]).symbol_id_; + size_t ant_id = gen_tag_t(event.tags_[0]).ant_id_; + size_t radio_id = ant_id / c->NumChannels(); + size_t cell_id = c->CellId().at(radio_id); size_t offset = (c->GetTotalDataSymbolIdx(frame_id, symbol_id) * c->BsAntNum()) + ant_id; @@ -199,7 +201,7 @@ int PacketTXRX::DequeueSendUsrp(int tid) { if (kDebugDownlink == true) { std::vector> zeros(c->SampsPerSymbol()); size_t dl_symbol_idx = c->Frame().GetDLSymbolIdx(symbol_id); - if (ant_id != c->RefAnt()) { + if (ant_id != c->RefAnt().at(cell_id)) { txbuf[ch] = zeros.data(); } else if (dl_symbol_idx < c->Frame().ClientDlPilotSymbols()) { txbuf[ch] = reinterpret_cast(c->UeSpecificPilotT()[0]); @@ -217,7 +219,7 @@ int PacketTXRX::DequeueSendUsrp(int tid) { int flags = (symbol_id != last) ? 1 // HAS_TIME : 2; // HAS_TIME & END_BURST, fixme long long frame_time = ((long long)frame_id << 32) | (symbol_id << 16); - radioconfig_->RadioTx(ant_id / n_channels, txbuf, flags, frame_time); + radioconfig_->RadioTx(radio_id, txbuf, flags, frame_time); if (kDebugPrintInTask == true) { std::printf( @@ -246,6 +248,8 @@ int PacketTXRX::DequeueSendUsrp(int tid, int frame_id, int symbol_id) { assert(event.event_type_ == EventType::kPacketTX); size_t ant_id = gen_tag_t(event.tags_[0]).ant_id_; + size_t radio_id = ant_id / c->NumChannels(); + size_t cell_id = c->CellId().at(radio_id); // size_t frame_id = gen_tag_t(event.tags[0]).frame_id; // size_t symbol_id = gen_tag_t(event.tags[0]).symbol_id; @@ -266,7 +270,7 @@ int PacketTXRX::DequeueSendUsrp(int tid, int frame_id, int symbol_id) { if (kDebugDownlink) { std::vector> zeros(c->SampsPerSymbol()); size_t dl_symbol_idx = c->Frame().GetDLSymbolIdx(symbol_id); - if (ant_id != c->RefAnt()) { + if (ant_id != c->RefAnt().at(cell_id)) { txbuf[ch] = zeros.data(); } else if (dl_symbol_idx < c->Frame().ClientDlPilotSymbols()) { txbuf[ch] = reinterpret_cast(c->UeSpecificPilotT()[0]); @@ -285,7 +289,7 @@ int PacketTXRX::DequeueSendUsrp(int tid, int frame_id, int symbol_id) { ? 1 // HAS_TIME : 2; // HAS_TIME & END_BURST, fixme long long frame_time = ((long long)frame_id << 32) | (symbol_id << 16); - radioconfig_->RadioTx(ant_id / n_channels, txbuf, flags, frame_time); + radioconfig_->RadioTx(radio_id, txbuf, flags, frame_time); if (kDebugPrintInTask) { std::printf( diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 0609a0af1..7a7a63b3f 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -14,8 +14,8 @@ ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { // load channels auto channels = Utils::StrToChannels(cfg_->Channel()); - this->radio_num_ = cfg_->NumRadios(); - this->antenna_num_ = radio_num_ * cfg_->NumChannels(); + this->radio_num_ = cfg_->UeNum(); + this->antenna_num_ = cfg_->UeAntNum(); std::cout << "radio num is " << this->radio_num_ << std::endl; cl_stn_.resize(radio_num_); @@ -54,7 +54,7 @@ ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { #endif for (size_t i = 0; i < this->radio_num_; i++) { - std::cout << cfg_->RadioIds().at(i) << ": Front end " + std::cout << cfg_->UeRadioId().at(i) << ": Front end " << cl_stn_[i]->getHardwareInfo()["frontend"] << std::endl; for (auto c : channels) { if (c < cl_stn_[i]->getNumChannels(SOAPY_SDR_RX)) { @@ -131,10 +131,10 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { args["timeout"] = "1000000"; if (!kUseUHD) { args["driver"] = "iris"; - args["serial"] = cfg_->RadioIds().at(tid); + args["serial"] = cfg_->UeRadioId().at(tid); } else { args["driver"] = "uhd"; - args["addr"] = cfg_->RadioIds().at(tid); + args["addr"] = cfg_->UeRadioId().at(tid); } cl_stn_[tid] = SoapySDR::Device::make(args); for (auto ch : channels) { @@ -181,12 +181,12 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { if (cfg_->SingleGain()) { // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:108] cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); + ch != 0u ? cfg_->ClientRxGainB().at(tid) + : cfg_->ClientRxGainA().at(tid)); // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:105] - cl_stn_[tid]->setGain( - SOAPY_SDR_TX, ch, - ch != 0u ? cfg_->TxGainB() + cfg_->ClientGainAdjB().at(tid) - : cfg_->TxGainA() + cfg_->ClientGainAdjA().at(tid)); + cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, + ch != 0u ? cfg_->ClientTxGainB().at(tid) + : cfg_->ClientTxGainA().at(tid)); } else { if (info["frontend"].find("CBRS") != std::string::npos) { if (cfg_->Freq() > 3e9) { @@ -199,30 +199,30 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA2", 17); //[0,17] } - cl_stn_[tid]->setGain( - SOAPY_SDR_RX, ch, "LNA", - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); //[0,30] - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] + cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA", + ch != 0u + ? cfg_->RxGainB() + : cfg_->ClientRxGainA().at(tid)); //[0,30] + cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] + cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] if (info["frontend"].find("CBRS") != std::string::npos) { cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "ATTN", -6); //[-18,0] by 3 cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PA2", 0); //[0|15] } cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[0,12] - cl_stn_[tid]->setGain( - SOAPY_SDR_TX, ch, "PAD", - ch != 0u - ? cfg_->TxGainB() + cfg_->ClientGainAdjB().at(tid) - : cfg_->TxGainA() + cfg_->ClientGainAdjA().at(tid)); //[0,30] + cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PAD", + ch != 0u + ? cfg_->ClientTxGainB().at(tid) + : cfg_->ClientTxGainA().at(tid)); //[0,30] } } else { cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA0", - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); - cl_stn_[tid]->setGain( - SOAPY_SDR_TX, ch, "PGA0", - ch != 0u ? cfg_->TxGainB() + cfg_->ClientGainAdjB().at(tid) - : cfg_->TxGainA() + cfg_->ClientGainAdjA().at(tid)); + ch != 0u ? cfg_->ClientRxGainB().at(tid) + : cfg_->ClientRxGainA().at(tid)); + cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PGA0", + ch != 0u ? cfg_->ClientTxGainB().at(tid) + : cfg_->ClientTxGainA().at(tid)); } } @@ -260,15 +260,15 @@ bool ClientRadioConfig::RadioStart() { (int)(2.0 / ((cfg_->SampsPerSymbol() * cfg_->Frame().NumTotalSyms()) / cfg_->Rate())); conf["max_frame"] = max_frame; - conf["dual_pilot"] = (cfg_->NumChannels() == 2); + conf["dual_pilot"] = (cfg_->NumUeChannels() == 2); auto tdd_sched = cfg_->Frame().FrameIdentifier(); for (size_t s = 0; s < cfg_->Frame().FrameIdentifier().length(); s++) { char c = cfg_->Frame().FrameIdentifier().at(s); if (c == 'B') { tdd_sched.replace(s, 1, "R"); // Dummy RX used in PHY scheduler - } else if (c == 'P' and ((cfg_->NumChannels() == 1 and + } else if (c == 'P' and ((cfg_->NumUeChannels() == 1 and cfg_->Frame().GetPilotSymbol(i) != s) or - (cfg_->NumChannels() == 2 and + (cfg_->NumUeChannels() == 2 and (cfg_->Frame().GetPilotSymbol(2 * i) != s and cfg_->Frame().GetPilotSymbol(i * 2 + 1) != s)))) { // TODO: change this for @@ -406,7 +406,7 @@ void ClientRadioConfig::DrainBuffers() { std::vector dummybuffs(2); dummybuffs[0] = dummy_buff0.data(); dummybuffs[1] = dummy_buff1.data(); - for (size_t i = 0; i < cfg_->NumRadios(); i++) { + for (size_t i = 0; i < cfg_->UeNum(); i++) { ClientRadioConfig::DrainRxBuffer(cl_stn_[i], rx_streams_[i], dummybuffs, cfg_->SampsPerSymbol()); } diff --git a/src/client/phy-ue.cc b/src/client/phy-ue.cc index 872672fff..6cda63138 100644 --- a/src/client/phy-ue.cc +++ b/src/client/phy-ue.cc @@ -20,7 +20,7 @@ static const size_t kDefaultQueueSize = 36; PhyUe::PhyUe(Config* config) : stats_(std::make_unique(config)), - phy_stats_(std::make_unique(config)), + phy_stats_(std::make_unique(config, Direction::Downlink)), demod_buffer_(kFrameWnd, config->Frame().NumDLSyms(), config->UeAntNum(), kMaxModType * config->OfdmDataNum()), decoded_buffer_(kFrameWnd, config->Frame().NumDLSyms(), @@ -75,16 +75,16 @@ PhyUe::PhyUe(Config* config) work_producer_token_ = std::make_unique(work_queue_); - ru_ = std::make_unique(config_, rx_thread_num_, - config_->CoreOffset() + 1, &complete_queue_, - &tx_queue_, rx_ptoks_ptr_, tx_ptoks_ptr_); + ru_ = std::make_unique( + config_, rx_thread_num_, config_->UeCoreOffset() + 1, &complete_queue_, + &tx_queue_, rx_ptoks_ptr_, tx_ptoks_ptr_); // uplink buffers init (tx) InitializeUplinkBuffers(); // downlink buffers init (rx) InitializeDownlinkBuffers(); - size_t core_offset_worker = config_->CoreOffset() + 1 + rx_thread_num_; + size_t core_offset_worker = config_->UeCoreOffset() + 1 + rx_thread_num_; if (kEnableMac == true) { mac_thread_ = std::make_unique( config_, core_offset_worker, decoded_buffer_, &ul_bits_buffer_, @@ -95,7 +95,7 @@ PhyUe::PhyUe(Config* config) std::thread(&MacThreadClient::RunEventLoop, mac_thread_.get()); } - for (size_t i = 0; i < config_->WorkerThreadNum(); i++) { + for (size_t i = 0; i < config_->UeWorkerThreadNum(); i++) { auto new_worker = std::make_unique( i, *config_, *stats_, *phy_stats_, complete_queue_, work_queue_, *work_producer_token_.get(), ul_bits_buffer_, ul_syms_buffer_, @@ -126,7 +126,7 @@ PhyUe::PhyUe(Config* config) ue_tracker_.reserve(num_ue); ue_tracker_.resize(num_ue); for (auto& ue : ue_tracker_) { - // Might want to change the 1 to NumChannels or channels per ue + // Might want to change the 1 to NumUeChannels or channels per ue ue.ifft_counters_.Init(ul_symbol_perframe_, 1); ue.tx_pending_frame_ = 0; ue.tx_ready_frames_.clear(); @@ -146,9 +146,9 @@ PhyUe::PhyUe(Config* config) } PhyUe::~PhyUe() { - for (size_t i = 0; i < config_->WorkerThreadNum(); i++) { + for (size_t i = 0; i < config_->UeWorkerThreadNum(); i++) { std::printf("Joining Phy worker: %zu : %zu\n", i, - config_->WorkerThreadNum()); + config_->UeWorkerThreadNum()); workers_.at(i)->Stop(); } workers_.clear(); @@ -262,7 +262,7 @@ void PhyUe::Stop() { } void PhyUe::Start() { - PinToCoreWithOffset(ThreadType::kMaster, config_->CoreOffset(), 0); + PinToCoreWithOffset(ThreadType::kMaster, config_->UeCoreOffset(), 0); if (ru_->StartTxRx(rx_buffer_, rx_buffer_size_ / config_->PacketLength(), tx_buffer_, tx_buffer_status_, tx_buffer_status_size_, @@ -314,7 +314,7 @@ void PhyUe::Start() { size_t frame_id = pkt->frame_id_; size_t symbol_id = pkt->symbol_id_; size_t ant_id = pkt->ant_id_; - size_t ue_id = ant_id / config_->NumChannels(); + size_t ue_id = ant_id / config_->NumUeChannels(); size_t frame_slot = frame_id % kFrameWnd; RtAssert(pkt->frame_id_ < (cur_frame_id + kFrameWnd), "Error: Received packet for future frame beyond frame " @@ -338,7 +338,7 @@ void PhyUe::Start() { } } - if (config_->IsPilot(frame_id, symbol_id)) { + if (config_->IsDlPilot(frame_id, symbol_id)) { rx_counters_.num_pilot_pkts_.at(frame_slot)++; if (rx_counters_.num_pilot_pkts_.at(frame_slot) == rx_counters_.num_pilot_pkts_per_frame_) { @@ -361,7 +361,7 @@ void PhyUe::Start() { // Schedule Pilot after receiving last beacon // (Only when in Downlink Only mode, otherwise the pilots // will be transmitted with the uplink data) - if (ant_id % config_->NumChannels() == 0) { + if (ant_id % config_->NumUeChannels() == 0) { EventData do_tx_pilot_task( EventType::kPacketPilotTX, gen_tag_t::FrmSymUe( @@ -371,7 +371,7 @@ void PhyUe::Start() { *tx_ptoks_ptr_[ue_id % rx_thread_num_]); } } else { - if ((ant_id % config_->NumChannels()) == 0) { + if ((ant_id % config_->NumUeChannels()) == 0) { // Schedule the Uplink tasks for (size_t symbol_idx = 0; symbol_idx < config_->Frame().NumULSyms(); symbol_idx++) { @@ -792,9 +792,10 @@ void PhyUe::InitializeVarsFromCfg() { assert(dl_pilot_symbol_perframe_ <= dl_symbol_perframe_); assert(ul_pilot_symbol_perframe <= ul_symbol_perframe_); - rx_thread_num_ = ((kUseArgos == true) && (config_->HwFramer() == false)) - ? config_->UeNum() - : std::min(config_->UeNum(), config_->SocketThreadNum()); + rx_thread_num_ = + ((kUseArgos == true) && (config_->HwFramer() == false)) + ? config_->UeNum() + : std::min(config_->UeNum(), config_->UeSocketThreadNum()); tx_buffer_status_size_ = (ul_symbol_perframe_ * config_->UeAntNum() * kFrameWnd); diff --git a/src/client/txrx_client.cc b/src/client/txrx_client.cc index 0f31e0abd..985834d37 100644 --- a/src/client/txrx_client.cc +++ b/src/client/txrx_client.cc @@ -62,7 +62,7 @@ bool RadioTxRx::StartTxRx(Table& in_buffer, size_t in_buffer_length, txrx_threads_.resize(thread_num_); buffers_per_thread_ = in_buffer_length / thread_num_; /// Make sure we can fit each channel in the tread buffer without rollover - assert(buffers_per_thread_ % config_->NumChannels() == 0); + assert(buffers_per_thread_ % config_->NumUeChannels() == 0); rx_packets_.resize(thread_num_); for (size_t i = 0; i < thread_num_; i++) { rx_packets_.at(i).reserve(buffers_per_thread_); @@ -156,8 +156,8 @@ int RadioTxRx::DequeueSend(int tid) { c->PacketLength() - Packet::kOffsetOfData); // Transmit pilot symbols on each UE channel - for (size_t channel = 0; channel < c->NumChannels(); channel++) { - const size_t ant_id = (ue_id * c->NumChannels()) + channel; + for (size_t channel = 0; channel < c->NumUeChannels(); channel++) { + const size_t ant_id = (ue_id * c->NumUeChannels()) + channel; for (size_t symbol_idx = 0; symbol_idx < c->Frame().NumPilotSyms(); symbol_idx++) { if (kDebugPrintInTask) { @@ -268,7 +268,7 @@ int RadioTxRx::DequeueSendArgos(int tid, long long time0) { // For UHD devices, first pilot should not be with the END_BURST flag // 1: HAS_TIME, 2: HAS_TIME | END_BURST - int flags_tx_pilot = (kUseUHD && c->NumChannels() == 2) ? 1 : 2; + int flags_tx_pilot = (kUseUHD && c->NumUeChannels() == 2) ? 1 : 2; EventData event; if (task_queue_->try_dequeue_from_producer(*tx_ptoks_[tid], event) == false) { @@ -282,7 +282,7 @@ int RadioTxRx::DequeueSendArgos(int tid, long long time0) { size_t frame_id = gen_tag_t(event.tags_[0]).frame_id_; size_t ue_id = gen_tag_t(event.tags_[0]).ue_id_; size_t tx_frame_id = frame_id + TX_FRAME_DELTA; - size_t ant_id = ue_id * c->NumChannels(); + size_t ant_id = ue_id * c->NumUeChannels(); long long tx_time(0); int r; @@ -297,7 +297,7 @@ int RadioTxRx::DequeueSendArgos(int tid, long long time0) { if (r < static_cast(num_samps)) { std::cout << "BAD Write: (PILOT)" << r << "/" << num_samps << std::endl; } - if (c->NumChannels() == 2) { + if (c->NumUeChannels() == 2) { pilot_symbol_id = c->Frame().GetPilotSymbol(ant_id + 1); tx_time = time0 + tx_frame_id * frm_num_samps + pilot_symbol_id * num_samps - c->ClTxAdvance().at(ue_id); @@ -333,7 +333,7 @@ int RadioTxRx::DequeueSendArgos(int tid, long long time0) { ant_id; void* txbuf[2]; - for (size_t ch = 0; ch < c->NumChannels(); ++ch) { + for (size_t ch = 0; ch < c->NumUeChannels(); ++ch) { auto* pkt = reinterpret_cast( tx_buffer_ + (offset + ch) * packet_length); txbuf[ch] = (void*)pkt->data_; @@ -377,8 +377,8 @@ struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, size_t num_samps = c->SampsPerSymbol(); long long rx_time(0); - std::vector samp(c->NumChannels()); - for (size_t ch = 0; ch < c->NumChannels(); ++ch) { + std::vector samp(c->NumUeChannels()); + for (size_t ch = 0; ch < c->NumUeChannels(); ++ch) { RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); if (rx.Empty() == false) { std::printf("RX [%zu] at rx_offset %zu buffer full\n", tid, rx_slot); @@ -415,8 +415,8 @@ struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, "RX [%zu]: frame_id %zu, symbol_id %zu, radio_id %zu rxtime %llx\n", tid, frame_id, symbol_id, radio_id, rx_time); } - size_t ant_id = radio_id * c->NumChannels(); - for (size_t ch = 0; ch < c->NumChannels(); ++ch) { + size_t ant_id = radio_id * c->NumUeChannels(); + for (size_t ch = 0; ch < c->NumUeChannels(); ++ch) { RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); new (rx.RawPacket()) Packet(frame_id, symbol_id, 0 /* cell_id */, ant_id + ch); @@ -433,7 +433,7 @@ struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, void* RadioTxRx::LoopTxRxArgos(size_t tid) { PinToCoreWithOffset(ThreadType::kWorkerTXRX, core_id_, tid); auto& c = config_; - size_t num_radios = c->NumRadios(); + size_t num_radios = c->UeNum(); size_t radio_lo = tid * num_radios / thread_num_; size_t radio_hi = (tid + 1) * num_radios / thread_num_; std::printf("RadioTxRx thread %zu has radios %zu to %zu (%zu)\n", tid, @@ -483,7 +483,7 @@ void* RadioTxRx::LoopTxRxArgos(size_t tid) { continue; } - rx_slot = (rx_slot + c->NumChannels()) % buffers_per_thread_; + rx_slot = (rx_slot + c->NumUeChannels()) % buffers_per_thread_; if (++radio_id == radio_hi) { radio_id = radio_lo; } @@ -518,7 +518,7 @@ void* RadioTxRx::LoopTxRxArgosSync(size_t tid) { pilot_buff0_.resize(2); pilot_buff1_.resize(2); pilot_buff0_.at(0) = c->PilotCi16().data(); - if (c->NumChannels() == 2) { + if (c->NumUeChannels() == 2) { pilot_buff0_.at(1) = zeros0.data(); pilot_buff1_.at(0) = zeros1.data(); pilot_buff1_.at(1) = c->PilotCi16().data(); @@ -605,7 +605,7 @@ void* RadioTxRx::LoopTxRxArgosSync(size_t tid) { break; } symbol_id++; - rx_slot = (rx_slot + c->NumChannels()) % buffers_per_thread_; + rx_slot = (rx_slot + c->NumUeChannels()) % buffers_per_thread_; static const size_t kFrameSync = 1000; // resync every kFrameSync frames: @@ -653,14 +653,13 @@ void* RadioTxRx::LoopTxRxArgosSync(size_t tid) { // receive the remaining of the frame for (; symbol_id < c->Frame().NumTotalSyms(); symbol_id++) { - if ((config_->IsPilot(frame_id, symbol_id) == true) || - (config_->IsDownlink(frame_id, symbol_id) == true)) { + if (config_->IsDownlink(frame_id, symbol_id) == true) { struct Packet* rx_pkt = RecvEnqueueArgos(tid, radio_id, frame_id, symbol_id, rx_slot, false); if (rx_pkt == nullptr) { break; } - rx_slot = (rx_slot + c->NumChannels()) % buffers_per_thread_; + rx_slot = (rx_slot + c->NumUeChannels()) % buffers_per_thread_; } else { // Otherwise throw away the data. radio->RadioRx(radio_id, frm_rx_buff.data(), num_samps, rx_time); diff --git a/src/client/ue_worker.cc b/src/client/ue_worker.cc index 2f09b7e16..861ca9424 100644 --- a/src/client/ue_worker.cc +++ b/src/client/ue_worker.cc @@ -94,7 +94,7 @@ void UeWorker::TaskThread(size_t core_offset) { PinToCoreWithOffset(ThreadType::kWorker, core_offset, tid_); auto encoder = std::make_unique( - &config_, (int)tid_, + &config_, (int)tid_, Direction::Downlink, (kEnableMac == true) ? ul_bits_buffer_ : config_.UlBits(), (kEnableMac == true) ? kFrameWnd : 1, encoded_buffer_, &stats_); @@ -495,8 +495,8 @@ void UeWorker::DoEncodeUe(DoEncode* encoder, size_t tag) { const size_t frame_id = gen_tag_t(tag).frame_id_; const size_t symbol_id = gen_tag_t(tag).symbol_id_; const size_t ue_id = gen_tag_t(tag).ue_id_; - for (size_t ch = 0; ch < config_.NumChannels(); ch++) { - const size_t ant_id = (ue_id * config_.NumChannels()) + ch; + for (size_t ch = 0; ch < config_.NumUeChannels(); ch++) { + const size_t ant_id = (ue_id * config_.NumUeChannels()) + ch; // For now, call for each cb for (size_t cb_id = 0; cb_id < config_.LdpcConfig().NumBlocksInSymbol(); cb_id++) { @@ -527,8 +527,8 @@ void UeWorker::DoModul(size_t tag) { } size_t start_tsc = GetTime::Rdtsc(); - for (size_t ch = 0; ch < config_.NumChannels(); ch++) { - const size_t ant_id = (ue_id * config_.NumChannels()) + ch; + for (size_t ch = 0; ch < config_.NumUeChannels(); ch++) { + const size_t ant_id = (ue_id * config_.NumUeChannels()) + ch; const size_t ul_symbol_idx = config_.Frame().GetULSymbolIdx(symbol_id); const size_t total_ul_data_symbol_id = @@ -537,8 +537,8 @@ void UeWorker::DoModul(size_t tag) { complex_float* modul_buf = &modul_buffer_[total_ul_data_symbol_id][ant_id * config_.OfdmDataNum()]; - auto* ul_bits = config_.GetEncodedBuf(encoded_buffer_, frame_id, - ul_symbol_idx, ant_id, 0); + auto* ul_bits = config_.GetEncodedBuf(encoded_buffer_, Direction::Uplink, + frame_id, ul_symbol_idx, ant_id, 0); if (kDebugPrintModul) { std::printf( @@ -578,8 +578,8 @@ void UeWorker::DoIfftUe(DoIFFTClient* iffter, size_t tag) { const size_t user_id = gen_tag_t(tag).ue_id_; // For now, call for each channel - for (size_t ch = 0; ch < config_.NumChannels(); ch++) { - size_t ant_id = (user_id * config_.NumChannels()) + ch; + for (size_t ch = 0; ch < config_.NumUeChannels(); ch++) { + size_t ant_id = (user_id * config_.NumUeChannels()) + ch; // TODO Remove this copy { @@ -624,11 +624,11 @@ void UeWorker::DoIfft(size_t tag) { } size_t start_tsc = GetTime::Rdtsc(); - for (size_t ch = 0; ch < config_.NumChannels(); ch++) { + for (size_t ch = 0; ch < config_.NumUeChannels(); ch++) { const size_t ul_symbol_perframe = config_.Frame().NumULSyms(); size_t ul_symbol_id = config_.Frame().GetULSymbolIdx(symbol_id); - size_t ant_id = user_id * config_.NumChannels() + ch; + size_t ant_id = user_id * config_.NumUeChannels() + ch; size_t total_ul_symbol_id = frame_slot * ul_symbol_perframe + ul_symbol_id; size_t buff_offset = total_ul_symbol_id * config_.UeAntNum() + ant_id; complex_float* ifft_buff = ifft_buffer_[buff_offset]; diff --git a/src/common/config.cc b/src/common/config.cc index 477418717..7df9fa0a6 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -26,6 +26,7 @@ Config::Config(const std::string& jsonfile) frame_("") { pilots_ = nullptr; pilots_sgn_ = nullptr; + std::string conf; Utils::LoadTddConfig(jsonfile, conf); // Allow json comments @@ -47,48 +48,77 @@ Config::Config(const std::string& jsonfile) if (kUseUHD == false) { std::string hub_file = tdd_conf.value("hubs", ""); if (!hub_file.empty()) { - Utils::LoadDevices(hub_file, hub_ids_); + Utils::LoadDevices(hub_file, hub_id_); } } - std::string serial_file = tdd_conf.value("irises", ""); - ref_ant_ = tdd_conf.value("ref_ant", 0); - external_ref_node_ = tdd_conf.value("external_ref_node", false); + num_cells_ = tdd_conf.value("cells", 1); - channel_ = tdd_conf.value("channel", "A"); - num_channels_ = std::min(channel_.size(), (size_t)2); - bs_ant_num_ = tdd_conf.value("antenna_num", 8); - is_ue_ = tdd_conf.value("UE", false); - ue_num_ = tdd_conf.value("ue_num", 8); - ue_ant_num_ = ue_num_; - if (serial_file.empty() == false) { - Utils::LoadDevices(serial_file, radio_ids_); - } - if (radio_ids_.empty() == false) { - num_radios_ = radio_ids_.size(); - num_antennas_ = num_channels_ * num_radios_; - if (is_ue_) { - ue_ant_num_ = num_antennas_; - ue_num_ = num_radios_; - } else { - if (ref_ant_ >= num_antennas_) { - ref_ant_ = 0; - } - if (bs_ant_num_ != num_antennas_) { - bs_ant_num_ = num_antennas_; + std::string serials_str; + std::string serial_file = tdd_conf.value("serial_file", ""); + Utils::LoadTddConfig(serial_file, serials_str); + external_ref_node_ = false; + if (serials_str.empty() == false) { + const auto j_serials = json::parse(serials_str, nullptr, true, true); + RtAssert(j_serials.size() == num_cells_, "Incorrect cells number!"); + for (size_t i = 0; i < num_cells_; i++) { + json serials_conf; + std::string cell_str = "Cell" + std::to_string(i); + std::stringstream ss; + ss << j_serials[i].value(cell_str, serials_conf); + serials_conf = json::parse(ss); + ss.str(std::string()); + ss.clear(); + + auto hub_serial = serials_conf.value("hub", ""); + hub_id_.push_back(hub_serial); + auto sdr_serials = serials_conf.value("sdr", json::array()); + RtAssert(sdr_serials.size() == 0, "BS has zero sdrs!"); + radio_id_.insert(radio_id_.end(), sdr_serials.begin(), sdr_serials.end()); + num_radios_ += sdr_serials.size(); + cell_id_.resize(num_radios_, i); + + auto refnode_serial = serials_conf.value("reference node", ""); + if (refnode_serial.empty()) { + MLPD_INFO("No calibration node ID found in topology file!\n"); + } else { + radio_id_.push_back(refnode_serial); + ref_radio_.push_back(radio_id_.size()); + num_radios_++; + cell_id_.resize(num_radios_, i); } + bool external_ref_node = true; + for (size_t j = 0; j < sdr_serials.size(); j++) + if (sdr_serials.at(j) == refnode_serial) external_ref_node = false; + external_ref_node_ = external_ref_node; } + auto cl_serials = j_serials.value("Standalone Clients", json::array()); + ue_radio_id_.assign(cl_serials.begin(), cl_serials.end()); + } + if (radio_id_.empty() == true) { + num_radios_ = tdd_conf.value("bs_radio_num", 8); + cell_id_.resize(num_radios_, 0); + } + + if (ue_radio_id_.empty() == false) { + ue_num_ = ue_radio_id_.size(); } else { - if (is_ue_) { - size_t ue_radios = ue_num_ / num_channels_; - num_radios_ = tdd_conf.value("radio_num", ue_radios); - ue_num_ = num_radios_; - ue_ant_num_ = ue_num_ * num_channels_; - } else { - num_radios_ = tdd_conf.value("radio_num", bs_ant_num_); - ue_ant_num_ = ue_num_; + ue_num_ = tdd_conf.value("ue_radio_num", 8); + } + + channel_ = tdd_conf.value("channel", "A"); + ue_channel_ = tdd_conf.value("ue_channel", "A"); + num_channels_ = std::min(channel_.size(), (size_t)2); + num_ue_channels_ = std::min(ue_channel_.size(), (size_t)2); + bs_ant_num_ = num_channels_ * num_radios_; + ue_ant_num_ = ue_num_ * num_ue_channels_; + + if (serials_str.empty() == false) { + for (size_t i = 0; i < num_cells_; i++) { + ref_ant_.push_back(ref_radio_.at(i) * num_channels_); } } + bf_ant_num_ = bs_ant_num_; if (external_ref_node_ == true) { bf_ant_num_ = bs_ant_num_ - num_channels_; @@ -107,25 +137,41 @@ Config::Config(const std::string& jsonfile) rx_gain_b_ = tdd_conf.value("rx_gain_b", 20); calib_tx_gain_a_ = tdd_conf.value("calib_tx_gain_a", tx_gain_a_); calib_tx_gain_b_ = tdd_conf.value("calib_tx_gain_b", tx_gain_b_); - auto gain_adj_json_a = tdd_conf.value("client_gain_adjust_a", json::array()); - if (gain_adj_json_a.empty()) { - client_gain_adj_a_.resize(num_radios_, 0); + + auto gain_tx_json_a = tdd_conf.value("ue_tx_gain_a", json::array()); + if (gain_tx_json_a.empty()) { + client_tx_gain_a_.resize(ue_num_, 20); } else { - RtAssert( - gain_adj_json_a.size() == num_radios_, - "client_gain_adjust_a size must be same as the number of clients!"); - client_gain_adj_a_.assign(gain_adj_json_a.begin(), gain_adj_json_a.end()); + RtAssert(gain_tx_json_a.size() == ue_num_, + "ue_tx_gain_a size must be same as the number of clients!"); + client_tx_gain_a_.assign(gain_tx_json_a.begin(), gain_tx_json_a.end()); } - auto gain_adj_json_b = tdd_conf.value("client_gain_adjust_b", json::array()); - if (gain_adj_json_b.empty()) { - client_gain_adj_b_.resize(num_radios_, 0); + auto gain_tx_json_b = tdd_conf.value("ue_tx_gain_b", json::array()); + if (gain_tx_json_b.empty()) { + client_tx_gain_b_.resize(ue_num_, 0); } else { - RtAssert( - gain_adj_json_a.size() == num_radios_, - "client_gain_adjust_a size must be same as the number of clients!"); - client_gain_adj_b_.assign(gain_adj_json_b.begin(), gain_adj_json_b.end()); + RtAssert(gain_tx_json_b.size() == ue_num_, + "ue_tx_gain_b size must be same as the number of clients!"); + client_tx_gain_b_.assign(gain_tx_json_b.begin(), gain_tx_json_b.end()); + } + auto gain_rx_json_a = tdd_conf.value("ue_rx_gain_a", json::array()); + if (gain_rx_json_a.empty()) { + client_rx_gain_a_.resize(ue_num_, 20); + } else { + RtAssert(gain_rx_json_a.size() == ue_num_, + "ue_rx_gain_a size must be same as the number of clients!"); + client_rx_gain_a_.assign(gain_rx_json_a.begin(), gain_rx_json_a.end()); + } + auto gain_rx_json_b = tdd_conf.value("ue_rx_gain_b", json::array()); + if (gain_rx_json_b.empty()) { + client_rx_gain_b_.resize(ue_num_, 0); + } else { + RtAssert(gain_rx_json_b.size() == ue_num_, + "ue_rx_gain_b size must be same as the number of clients!"); + client_rx_gain_b_.assign(gain_rx_json_b.begin(), gain_rx_json_b.end()); } - rate_ = tdd_conf.value("rate", 5e6); + + rate_ = tdd_conf.value("sample_rate", 5e6); nco_ = tdd_conf.value("nco_frequency", 0.75 * rate_); bw_filter_ = rate_ + 2 * nco_; radio_rf_freq_ = freq_ - nco_; @@ -155,8 +201,8 @@ Config::Config(const std::string& jsonfile) bs_mac_rx_port_ = tdd_conf.value("bs_mac_rx_port", kMacBaseLocalPort); /* frame configurations */ - cp_len_ = tdd_conf.value("cp_len", 0); - ofdm_ca_num_ = tdd_conf.value("ofdm_ca_num", 2048); + cp_len_ = tdd_conf.value("cp_size", 0); + ofdm_ca_num_ = tdd_conf.value("fft_size", 2048); ofdm_data_num_ = tdd_conf.value("ofdm_data_num", 1200); ofdm_tx_zero_prefix_ = tdd_conf.value("ofdm_tx_zero_prefix", 0); ofdm_tx_zero_postfix_ = tdd_conf.value("ofdm_tx_zero_postfix", 0); @@ -182,9 +228,9 @@ Config::Config(const std::string& jsonfile) auto tx_advance = tdd_conf.value("tx_advance", json::array()); if (tx_advance.empty()) { - cl_tx_advance_.resize(num_radios_, 0); + cl_tx_advance_.resize(ue_num_, 0); } else { - RtAssert(tx_advance.size() == num_radios_, + RtAssert(tx_advance.size() == ue_num_, "tx_advance size must be same as the number of clients!"); cl_tx_advance_.assign(tx_advance.begin(), tx_advance.end()); } @@ -193,7 +239,7 @@ Config::Config(const std::string& jsonfile) // If frames not specified explicitly, construct default based on frame_type / // symbol_num_perframe / pilot_num / ul_symbol_num_perframe / // dl_symbol_num_perframe / dl_data_symbol_start - if (tdd_conf.find("frames") == tdd_conf.end()) { + if (tdd_conf.find("frame_schedule") == tdd_conf.end()) { size_t ul_data_symbol_num_perframe = kDefaultULSymPerFrame; size_t ul_data_symbol_start = kDefaultULSymStart; size_t dl_data_symbol_num_perframe = kDefaultDLSymPerFrame; @@ -317,7 +363,7 @@ Config::Config(const std::string& jsonfile) frame_ = FrameStats(sched); } else { - json jframes = tdd_conf.value("frames", json::array()); + json jframes = tdd_conf.value("frame_schedule", json::array()); // Only allow 1 unique frame type assert(jframes.size() == 1); @@ -351,15 +397,15 @@ Config::Config(const std::string& jsonfile) ant_group_num_ = frame_.IsRecCalEnabled() ? (bf_ant_num_ / ant_per_group_) : 0; - if ((is_ue_ == true) && (freq_orthogonal_pilot_ == false) && + if ((freq_orthogonal_pilot_ == false) && (ue_ant_num_ != frame_.NumPilotSyms())) { RtAssert( false, "Number of pilot symbols: " + std::to_string(frame_.NumPilotSyms()) + " does not match number of UEs: " + std::to_string(ue_ant_num_)); } - if ((is_ue_ == false) && (freq_orthogonal_pilot_ == false) && - (tdd_conf.find("ue_num") == tdd_conf.end())) { + if ((freq_orthogonal_pilot_ == false) && + (tdd_conf.find("ue_radio_num") == tdd_conf.end())) { ue_num_ = frame_.NumPilotSyms(); ue_ant_num_ = ue_num_; } @@ -367,7 +413,7 @@ Config::Config(const std::string& jsonfile) ue_ant_total_ = tdd_conf.value("ue_ant_total", ue_ant_num_); // Agora configurations - frames_to_test_ = tdd_conf.value("frames_to_test", 9600); + frames_to_test_ = tdd_conf.value("max_frame", 9600); core_offset_ = tdd_conf.value("core_offset", 0); worker_thread_num_ = tdd_conf.value("worker_thread_num", 25); socket_thread_num_ = tdd_conf.value("socket_thread_num", 4); @@ -986,8 +1032,8 @@ size_t Config::GetSymbolId(size_t input_id) const { return symbol_id; } -/* Returns True if symbol is valid index and is of symbol type 'P' or - if user equiptment and is a client dl pilot_. False otherwise */ +/* Returns True if symbol is valid index and is of symbol type 'P' + False otherwise */ bool Config::IsPilot(size_t /*frame_id*/, size_t symbol_id) const { bool is_pilot = false; assert(symbol_id < this->frame_.NumTotalSyms()); @@ -995,14 +1041,23 @@ bool Config::IsPilot(size_t /*frame_id*/, size_t symbol_id) const { #ifdef DEBUG3 std::printf("IsPilot(%zu, %zu) = %c\n", frame_id, symbol_id, s); #endif - if (this->is_ue_ == true) { - if ((s == 'D') && (this->frame_.ClientDlPilotSymbols() > 0)) { - size_t dl_index = this->frame_.GetDLSymbolIdx(symbol_id); - is_pilot = (this->frame_.ClientDlPilotSymbols() > dl_index); - } - // else { is_pilot = false; } Not needed due to default init - } else { /* TODO should use the symbol type here */ - is_pilot = (s == 'P'); + /* TODO should use the symbol type here */ + is_pilot = (s == 'P'); + return is_pilot; +} + +/* Returns True if user equiptment and is a client dl pilot_ + * False otherwise */ +bool Config::IsDlPilot(size_t /*frame_id*/, size_t symbol_id) const { + bool is_pilot = false; + assert(symbol_id < this->frame_.NumTotalSyms()); + char s = frame_.FrameIdentifier().at(symbol_id); +#ifdef DEBUG3 + std::printf("IsDlPilot(%zu, %zu) = %c\n", frame_id, symbol_id, s); +#endif + if ((s == 'D') && (this->frame_.ClientDlPilotSymbols() > 0)) { + size_t dl_index = this->frame_.GetDLSymbolIdx(symbol_id); + is_pilot = (this->frame_.ClientDlPilotSymbols() > dl_index); } return is_pilot; } @@ -1010,18 +1065,14 @@ bool Config::IsPilot(size_t /*frame_id*/, size_t symbol_id) const { bool Config::IsCalDlPilot(size_t /*frame_id*/, size_t symbol_id) const { bool is_cal_dl_pilot = false; assert(symbol_id < this->frame_.NumTotalSyms()); - if (this->is_ue_ == false) { - is_cal_dl_pilot = (this->frame_.FrameIdentifier().at(symbol_id) == 'C'); - } + is_cal_dl_pilot = (this->frame_.FrameIdentifier().at(symbol_id) == 'C'); return is_cal_dl_pilot; } bool Config::IsCalUlPilot(size_t /*frame_id*/, size_t symbol_id) const { bool is_cal_ul_pilot = false; assert(symbol_id < this->frame_.NumTotalSyms()); - if (this->is_ue_ == false) { - is_cal_ul_pilot = (this->frame_.FrameIdentifier().at(symbol_id) == 'L'); - } + is_cal_ul_pilot = (this->frame_.FrameIdentifier().at(symbol_id) == 'L'); return is_cal_ul_pilot; } @@ -1040,11 +1091,7 @@ bool Config::IsDownlink(size_t frame_id, size_t symbol_id) const { #ifdef DEBUG3 std::printf("IsDownlink(%zu, %zu) = %c\n", frame_id, symbol_id, s); #endif - if (this->is_ue_ == true) { - return ((s == 'D') && (this->IsPilot(frame_id, symbol_id) == false)); - } else { - return (s == 'D'); - } + return (s == 'D'); } SymbolType Config::GetSymbolType(size_t symbol_id) const { diff --git a/src/common/config.h b/src/common/config.h index 3f2b4d295..e6ce4462c 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -42,7 +42,6 @@ class Config { inline void BsAntNum(size_t n_bs_ant) { this->bs_ant_num_ = n_bs_ant; } // Inline accessors (basic types) - inline bool IsUe() const { return this->is_ue_; } inline size_t BfAntNum() const { return this->bf_ant_num_; } inline size_t UeNum() const { return this->ue_num_; } inline size_t UeAntNum() const { return this->ue_ant_num_; } @@ -72,21 +71,31 @@ class Config { inline bool SingleGain() const { return this->single_gain_; } inline double TxGainA() const { return this->tx_gain_a_; } inline double RxGainA() const { return this->rx_gain_a_; } - inline double TxGainB() const { return this->tx_gain_b_; } inline double RxGainB() const { return this->rx_gain_b_; } inline double CalibTxGainA() const { return this->calib_tx_gain_a_; } inline double CalibTxGainB() const { return this->calib_tx_gain_b_; } + inline std::vector ClientTxGainA() const { + return this->client_tx_gain_a_; + } + inline std::vector ClientRxGainA() const { + return this->client_rx_gain_a_; + } + inline std::vector ClientTxGainB() const { + return this->client_tx_gain_b_; + } + inline std::vector ClientRxGainB() const { + return this->client_rx_gain_b_; + } inline size_t NumCells() const { return this->num_cells_; } inline size_t NumRadios() const { return this->num_radios_; } inline size_t InitCalibRepeat() const { return this->init_calib_repeat_; } inline size_t NumAntennas() const { return this->num_antennas_; } inline size_t NumChannels() const { return this->num_channels_; } - inline size_t RefAnt() const { return this->ref_ant_; } - inline size_t RefRadio() const { - return this->ref_ant_ / this->num_channels_; - } + inline size_t NumUeChannels() const { return this->num_ue_channels_; } + inline std::vector RefAnt() const { return this->ref_ant_; } + inline std::vector RefRadio() const { return this->ref_radio_; } inline size_t BeaconAnt() const { return this->beacon_ant_; } inline size_t BeaconLen() const { return this->beacon_len_; } @@ -107,6 +116,13 @@ class Config { inline size_t CoreOffset() const { return this->core_offset_; } inline size_t WorkerThreadNum() const { return this->worker_thread_num_; } inline size_t SocketThreadNum() const { return this->socket_thread_num_; } + inline size_t UeCoreOffset() const { return this->ue_core_offset_; } + inline size_t UeWorkerThreadNum() const { + return this->ue_worker_thread_num_; + } + inline size_t UeSocketThreadNum() const { + return this->ue_socket_thread_num_; + } inline size_t FftThreadNum() const { return this->fft_thread_num_; } inline size_t DemulThreadNum() const { return this->demul_thread_num_; } @@ -218,19 +234,16 @@ class Config { inline const std::vector>& CommonPilot() const { return this->common_pilot_; }; - inline const std::vector& ClientGainAdjA() const { - return this->client_gain_adj_a_; - }; - - inline const std::vector& ClientGainAdjB() const { - return this->client_gain_adj_b_; + inline const std::vector& RadioId() const { + return this->radio_id_; }; - inline const std::vector& RadioIds() const { - return this->radio_ids_; + inline const std::vector& HubId() const { + return this->hub_id_; }; - inline const std::vector& HubIds() const { - return this->hub_ids_; + inline const std::vector& UeRadioId() const { + return this->ue_radio_id_; }; + inline const std::vector& CellId() const { return this->cell_id_; } // non-const (can modify) inline Table& UeSpecificPilot() { @@ -260,6 +273,7 @@ class Config { size_t GetSymbolId(size_t input_id) const; bool IsPilot(size_t /*unused*/, size_t /*symbol_id*/) const; + bool IsDlPilot(size_t /*unused*/, size_t /*symbol_id*/) const; bool IsCalDlPilot(size_t /*unused*/, size_t /*symbol_id*/) const; bool IsCalUlPilot(size_t /*unused*/, size_t /*symbol_id*/) const; bool IsDownlink(size_t /*frame_id*/, size_t /*symbol_id*/) const; @@ -273,6 +287,9 @@ class Config { inline size_t GetNumAntennas() const { return (this->num_radios_ * this->num_channels_); } + inline size_t GetNumClientAntennas() const { + return (this->ue_num_ * this->num_ue_channels_); + } inline void UpdateModCfgs(size_t new_mod_order_bits) { this->mod_order_bits_ = new_mod_order_bits; @@ -333,11 +350,11 @@ class Config { } /// Get mac bits for this frame, symbol, user and code block ID - inline int8_t* GetMacBits(Table& info_bits, size_t frame_id, - size_t symbol_id, size_t ue_id, + inline int8_t* GetMacBits(Table& info_bits, Direction dir, + size_t frame_id, size_t symbol_id, size_t ue_id, size_t cb_id) const { size_t mac_bytes_perframe; - if (is_ue_ == false) { + if (dir == Direction::Downlink) { mac_bytes_perframe = dl_mac_bytes_num_perframe_; } else { mac_bytes_perframe = ul_mac_bytes_num_perframe_; @@ -356,12 +373,12 @@ class Config { } /// Get encoded_buffer for this frame, symbol, user and code block ID - inline int8_t* GetEncodedBuf(Table& encoded_buffer, size_t frame_id, - size_t symbol_id, size_t ue_id, + inline int8_t* GetEncodedBuf(Table& encoded_buffer, Direction dir, + size_t frame_id, size_t symbol_id, size_t ue_id, size_t cb_id) const { size_t total_data_symbol_id; - if (is_ue_ == false) { + if (dir == Direction::Downlink) { total_data_symbol_id = GetTotalDataSymbolIdxDl(frame_id, symbol_id); } else { total_data_symbol_id = GetTotalDataSymbolIdxUl(frame_id, symbol_id); @@ -392,7 +409,6 @@ class Config { /* Private class variables */ const double freq_ghz_; // RDTSC frequency in GHz - bool is_ue_; size_t bs_ant_num_; // Total number of BS antennas size_t bf_ant_num_; // Number of antennas used in beamforming @@ -463,8 +479,10 @@ class Config { Table> ue_specific_pilot_t_; std::vector> common_pilot_; - std::vector client_gain_adj_a_; - std::vector client_gain_adj_b_; + std::vector client_gain_tx_a_; + std::vector client_gain_tx_b_; + std::vector client_gain_rx_a_; + std::vector client_gain_rx_b_; std::string modulation_; // Modulation order as a string, e.g., "16QAM" size_t mod_order_; // Modulation order (e.g., 4: QPSK, 16: 16QAM, 64: 64QAM) @@ -473,8 +491,12 @@ class Config { // Modulation lookup table for mapping binary bits to constellation points Table mod_table_; - std::vector radio_ids_; - std::vector hub_ids_; + std::vector radio_id_; + std::vector hub_id_; + std::vector ue_radio_id_; + std::vector ref_radio_; + std::vector ref_ant_; + std::vector cell_id_; // Controls whether the synchronization and frame time keeping is done // in hardware or software @@ -494,12 +516,16 @@ class Config { double rx_gain_b_; double calib_tx_gain_a_; double calib_tx_gain_b_; + std::vector client_tx_gain_a_; + std::vector client_rx_gain_a_; + std::vector client_tx_gain_b_; + std::vector client_rx_gain_b_; size_t num_cells_; size_t num_radios_; size_t num_antennas_; size_t num_channels_; - size_t ref_ant_; + size_t num_ue_channels_; size_t beacon_ant_; size_t beacon_len_; size_t init_calib_repeat_; @@ -508,6 +534,7 @@ class Config { bool imbalance_cal_en_; bool external_ref_node_; std::string channel_; + std::string ue_channel_; size_t ant_group_num_; size_t ant_per_group_; @@ -519,6 +546,10 @@ class Config { size_t decode_thread_num_; size_t zf_thread_num_; + size_t ue_core_offset_; + size_t ue_worker_thread_num_; + size_t ue_socket_thread_num_; + // Number of OFDM data subcarriers handled in one demodulation event size_t demul_block_size_; size_t demul_events_per_symbol_; // Derived from demul_block_size diff --git a/src/common/symbols.h b/src/common/symbols.h index 4bc272267..d9f7c91ea 100644 --- a/src/common/symbols.h +++ b/src/common/symbols.h @@ -36,6 +36,8 @@ static constexpr inline bool IsPowerOfTwo(T x) { return x && ((x & T(x - 1)) == 0); } +enum class Direction : int { Downlink, Uplink }; + // TODO: Merge EventType and DoerType into WorkType enum class EventType : int { kPacketRX, diff --git a/test/unit_tests/test_demul_threaded.cc b/test/unit_tests/test_demul_threaded.cc index 0d340d485..1912a1f9d 100644 --- a/test/unit_tests/test_demul_threaded.cc +++ b/test/unit_tests/test_demul_threaded.cc @@ -153,7 +153,7 @@ TEST(TestDemul, VaryingConfig) { kMaxUEs * 1.0f / 1024 / 1024); auto stats = std::make_unique(cfg.get()); - auto phy_stats = std::make_unique(cfg.get()); + auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); std::vector threads; threads.emplace_back(MasterToWorkerDynamicMaster, cfg.get(), diff --git a/test/unit_tests/test_recipcal.cc b/test/unit_tests/test_recipcal.cc index e04d5eb14..c314d6f69 100644 --- a/test/unit_tests/test_recipcal.cc +++ b/test/unit_tests/test_recipcal.cc @@ -25,7 +25,7 @@ TEST(TestRecip, Correctness) { calib_buffer.RandAllocCxFloat(kFrameWnd, cfg->OfdmDataNum() * cfg->BsAntNum(), Agora_memory::Alignment_t::kAlign64); - std::printf("Reference antenna: %zu\n", cfg->RefAnt()); + std::printf("Reference antenna: %zu\n", cfg->RefAnt().at(0)); size_t start_tsc = GetTime::Rdtsc(); @@ -34,7 +34,7 @@ TEST(TestRecip, Correctness) { auto* ptr_in = reinterpret_cast(calib_buffer[i % kFrameWnd]); arma::cx_fmat mat_input(ptr_in, cfg->OfdmDataNum(), cfg->BsAntNum(), false); - arma::cx_fvec vec_calib_ref = mat_input.col(cfg->RefAnt()); + arma::cx_fvec vec_calib_ref = mat_input.col(cfg->RefAnt().at(0)); auto* recip_buff = reinterpret_cast(recip_buffer_0[i % kFrameWnd]); arma::cx_fmat calib_mat = mat_input.each_col() / vec_calib_ref; @@ -86,7 +86,7 @@ TEST(TestRecip, Correctness) { auto* ptr_in = reinterpret_cast( recip_buffer_1[i % kFrameWnd] + sc_id * cfg->BsAntNum()); arma::cx_fvec recip_vec(ptr_in, cfg->BsAntNum(), false); - recip_vec = recip_vec / recip_vec(cfg->RefAnt()); + recip_vec = recip_vec / recip_vec(cfg->RefAnt().at(0)); } } diff --git a/test/unit_tests/test_zf.cc b/test/unit_tests/test_zf.cc index 2344658fa..84475b5f1 100644 --- a/test/unit_tests/test_zf.cc +++ b/test/unit_tests/test_zf.cc @@ -42,7 +42,7 @@ TEST(TestZF, Perf) { cfg->OfdmDataNum() * cfg->BsAntNum(), Agora_memory::Alignment_t::kAlign64); - auto phy_stats = std::make_unique(cfg.get()); + auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); auto stats = std::make_unique(cfg.get()); auto compute_zf = std::make_unique( diff --git a/test/unit_tests/test_zf_threaded.cc b/test/unit_tests/test_zf_threaded.cc index 9bc9f5eb1..6b5ec7bc5 100644 --- a/test/unit_tests/test_zf_threaded.cc +++ b/test/unit_tests/test_zf_threaded.cc @@ -136,7 +136,7 @@ TEST(TestZF, VaryingConfig) { calib_ul_buffer.RandAllocCxFloat(kFrameWnd, kMaxDataSCs * kMaxAntennas, Agora_memory::Alignment_t::kAlign64); - auto phy_stats = std::make_unique(cfg.get()); + auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); auto stats = std::make_unique(cfg.get()); std::vector threads; From 017efbf68ac32c0c9d3fe7ab082f5e9951b4b5f1 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Sun, 12 Dec 2021 19:03:31 -0600 Subject: [PATCH 03/55] Remove deprecated recipcal test --- CMakeLists.txt | 2 +- test/unit_tests/test_recipcal.cc | 116 ------------------------------- 2 files changed, 1 insertion(+), 117 deletions(-) delete mode 100644 test/unit_tests/test_recipcal.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0846d6df3..547d62fd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,7 +381,7 @@ endforeach() # Unit tests set(UNIT_TESTS test_datatype_conversion test_udp_client_server test_concurrent_queue test_zf test_zf_threaded test_demul_threaded - test_ptr_grid test_recipcal test_avx512_complex_mul test_scrambler + test_ptr_grid test_avx512_complex_mul test_scrambler test_256qam_demod) foreach(test_name IN LISTS UNIT_TESTS) diff --git a/test/unit_tests/test_recipcal.cc b/test/unit_tests/test_recipcal.cc deleted file mode 100644 index c314d6f69..000000000 --- a/test/unit_tests/test_recipcal.cc +++ /dev/null @@ -1,116 +0,0 @@ -#include -// For some reason, gtest include order matters -#include - -#include "config.h" -#include "gettime.h" -#include "utils.h" - -static constexpr size_t kMaxFrameNum = 10; - -/// Test correctness of two-step recriprocal calibration -TEST(TestRecip, Correctness) { - auto cfg = std::make_unique("data/tddconfig-sim-ul.json"); - cfg->GenData(); - - double freq_ghz = GetTime::MeasureRdtscFreq(); - - Table calib_buffer; - Table recip_buffer_0; - Table recip_buffer_1; - recip_buffer_0.Calloc(kFrameWnd, cfg->OfdmDataNum() * cfg->BsAntNum(), - Agora_memory::Alignment_t::kAlign64); - recip_buffer_1.Calloc(kFrameWnd, cfg->OfdmDataNum() * cfg->BsAntNum(), - Agora_memory::Alignment_t::kAlign64); - calib_buffer.RandAllocCxFloat(kFrameWnd, cfg->OfdmDataNum() * cfg->BsAntNum(), - Agora_memory::Alignment_t::kAlign64); - - std::printf("Reference antenna: %zu\n", cfg->RefAnt().at(0)); - - size_t start_tsc = GetTime::Rdtsc(); - - // Algorithm in reciprocity.cpp (use as ground truth) - for (size_t i = 0; i < kMaxFrameNum; i++) { - auto* ptr_in = - reinterpret_cast(calib_buffer[i % kFrameWnd]); - arma::cx_fmat mat_input(ptr_in, cfg->OfdmDataNum(), cfg->BsAntNum(), false); - arma::cx_fvec vec_calib_ref = mat_input.col(cfg->RefAnt().at(0)); - auto* recip_buff = - reinterpret_cast(recip_buffer_0[i % kFrameWnd]); - arma::cx_fmat calib_mat = mat_input.each_col() / vec_calib_ref; - - arma::cx_fmat recip_mat(recip_buff, cfg->BsAntNum(), cfg->OfdmDataNum(), - false); - recip_mat = calib_mat.st(); - - for (size_t sc_id = 0; sc_id < cfg->OfdmDataNum(); - sc_id += cfg->BsAntNum()) { - // TODO: interpolate instead of steps - recip_mat - .cols(sc_id, - std::min(sc_id + cfg->BsAntNum() - 1, cfg->OfdmDataNum() - 1)) - .each_col() = recip_mat.col(sc_id); - } - } - - double ms0 = GetTime::CyclesToMs(GetTime::Rdtsc() - start_tsc, freq_ghz); - - start_tsc = GetTime::Rdtsc(); - - // 2-step algorithm used in dofft and dozf - // Partially tranpose is not tested here - for (size_t i = 0; i < kMaxFrameNum; i++) { - // In dofft - for (size_t ant_id = 0; ant_id < cfg->BsAntNum(); ant_id++) { - auto* ptr_in = calib_buffer[i % kFrameWnd] + ant_id * cfg->OfdmDataNum(); - for (size_t sc_id = 0; sc_id < cfg->OfdmDataNum(); - sc_id += cfg->BsAntNum()) { - for (size_t j = 0; j < cfg->BsAntNum(); j++) { - ptr_in[std::min(sc_id + j, cfg->OfdmDataNum() - 1)] = ptr_in[sc_id]; - } - } - } - // Transpose - auto* ptr_calib = - reinterpret_cast(calib_buffer[i % kFrameWnd]); - arma::cx_fmat calib_mat(ptr_calib, cfg->OfdmDataNum(), cfg->BsAntNum(), - false); - auto* recip_buff = - reinterpret_cast(recip_buffer_1[i % kFrameWnd]); - arma::cx_fmat recip_mat(recip_buff, cfg->BsAntNum(), cfg->OfdmDataNum(), - false); - recip_mat = calib_mat.st(); - - // In dozf - for (size_t sc_id = 0; sc_id < cfg->OfdmDataNum(); sc_id++) { - auto* ptr_in = reinterpret_cast( - recip_buffer_1[i % kFrameWnd] + sc_id * cfg->BsAntNum()); - arma::cx_fvec recip_vec(ptr_in, cfg->BsAntNum(), false); - recip_vec = recip_vec / recip_vec(cfg->RefAnt().at(0)); - } - } - - double ms1 = GetTime::CyclesToMs(GetTime::Rdtsc() - start_tsc, freq_ghz); - - std::printf("Time per frame (algorithm1, algorithm2) = (%.4f, %.4f) ms\n", - ms0 / kMaxFrameNum, ms1 / kMaxFrameNum); - - // Check correctness - constexpr float kAllowedError = 1e-3; - for (size_t i = 0; i < kMaxFrameNum; i++) { - auto* buf0 = reinterpret_cast(recip_buffer_0[i % kFrameWnd]); - auto* buf1 = reinterpret_cast(recip_buffer_1[i % kFrameWnd]); - for (size_t j = 0; j < cfg->OfdmDataNum() * cfg->BsAntNum(); j++) { - ASSERT_LE(abs(buf0[j] - buf1[j]), kAllowedError); - } - } - - calib_buffer.Free(); - recip_buffer_0.Free(); - recip_buffer_1.Free(); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} From b4c9045a560b3dd8a5909c06391db76f5b61536b Mon Sep 17 00:00:00 2001 From: rdoosty Date: Sun, 12 Dec 2021 22:07:57 -0600 Subject: [PATCH 04/55] Fix reading serial json file --- data/topology.json | 30 ++++++++++++++++++++++++++++++ src/common/config.cc | 38 +++++++++++++++++++++++--------------- 2 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 data/topology.json diff --git a/data/topology.json b/data/topology.json new file mode 100644 index 000000000..2041d7af7 --- /dev/null +++ b/data/topology.json @@ -0,0 +1,30 @@ +{ + "BaseStations": { + "BS0": { + "hub": "FH4B000019", + "rrh": [ + "RH3B000001", + "RH3B000020", + "RH3B000010", + "RH3B000004" + ], + "sdr": [ + "RF3E000087", + "RF3E000084", + "RF3E000107", + "RF3E000086", + "RF3E000110", + "RF3E000162", + "RF3E000127", + "RF3E000597" + ], + "reference node": "RF3E000089" + } + }, + "Clients" : { + "sdr": [ + "RF3E000164", + "RF3E000392" + ] + } +} diff --git a/src/common/config.cc b/src/common/config.cc index 7df9fa0a6..9deed0dbb 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -44,28 +44,28 @@ Config::Config(const std::string& jsonfile) } SetCpuLayoutOnNumaNodes(true, excluded); - /* antenna configurations */ - if (kUseUHD == false) { - std::string hub_file = tdd_conf.value("hubs", ""); - if (!hub_file.empty()) { - Utils::LoadDevices(hub_file, hub_id_); - } - } - num_cells_ = tdd_conf.value("cells", 1); std::string serials_str; std::string serial_file = tdd_conf.value("serial_file", ""); Utils::LoadTddConfig(serial_file, serials_str); + std::cout << serials_str << std::endl; external_ref_node_ = false; if (serials_str.empty() == false) { const auto j_serials = json::parse(serials_str, nullptr, true, true); - RtAssert(j_serials.size() == num_cells_, "Incorrect cells number!"); + + std::stringstream ss; + json j_bs_serials; + ss << j_serials.value("BaseStations", j_bs_serials); + j_bs_serials = json::parse(ss); + ss.str(std::string()); + ss.clear(); + + RtAssert(j_bs_serials.size() == num_cells_, "Incorrect cells number!"); for (size_t i = 0; i < num_cells_; i++) { json serials_conf; - std::string cell_str = "Cell" + std::to_string(i); - std::stringstream ss; - ss << j_serials[i].value(cell_str, serials_conf); + std::string cell_str = "BS" + std::to_string(i); + ss << j_bs_serials.value(cell_str, serials_conf); serials_conf = json::parse(ss); ss.str(std::string()); ss.clear(); @@ -73,7 +73,7 @@ Config::Config(const std::string& jsonfile) auto hub_serial = serials_conf.value("hub", ""); hub_id_.push_back(hub_serial); auto sdr_serials = serials_conf.value("sdr", json::array()); - RtAssert(sdr_serials.size() == 0, "BS has zero sdrs!"); + RtAssert(sdr_serials.size() != 0, "BS has zero sdrs!"); radio_id_.insert(radio_id_.end(), sdr_serials.begin(), sdr_serials.end()); num_radios_ += sdr_serials.size(); cell_id_.resize(num_radios_, i); @@ -92,9 +92,17 @@ Config::Config(const std::string& jsonfile) if (sdr_serials.at(j) == refnode_serial) external_ref_node = false; external_ref_node_ = external_ref_node; } - auto cl_serials = j_serials.value("Standalone Clients", json::array()); - ue_radio_id_.assign(cl_serials.begin(), cl_serials.end()); + + json j_ue_serials; + ss << j_serials.value("Clients", j_ue_serials); + j_ue_serials = json::parse(ss); + ss.str(std::string()); + ss.clear(); + + auto ue_serials = j_ue_serials.value("sdr", json::array()); + ue_radio_id_.assign(ue_serials.begin(), ue_serials.end()); } + if (radio_id_.empty() == true) { num_radios_ = tdd_conf.value("bs_radio_num", 8); cell_id_.resize(num_radios_, 0); From 8f0329f7ea55ea0606f72b7494dcc568484bbf97 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Sun, 12 Dec 2021 22:52:11 -0600 Subject: [PATCH 05/55] Fix end-to-end test --- data/chsim.json | 2 +- src/common/config.cc | 3 +++ test/sim_tests/test_e2e_sim.sh | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/data/chsim.json b/data/chsim.json index 46fc73c0d..d34c8e6db 100644 --- a/data/chsim.json +++ b/data/chsim.json @@ -16,7 +16,7 @@ "bs_server_port": 8100, "bs_rru_port": 8200, "core_offset": 11, - "worker_thread_num": 16, + "worker_thread_num": 10, "socket_thread_num": 1, "ue_core_offset": 1, "ue_worker_thread_num": 8, diff --git a/src/common/config.cc b/src/common/config.cc index 9deed0dbb..cc53cdfb1 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -425,6 +425,9 @@ Config::Config(const std::string& jsonfile) core_offset_ = tdd_conf.value("core_offset", 0); worker_thread_num_ = tdd_conf.value("worker_thread_num", 25); socket_thread_num_ = tdd_conf.value("socket_thread_num", 4); + ue_core_offset_ = tdd_conf.value("ue_core_offset", 0); + ue_worker_thread_num_ = tdd_conf.value("ue_worker_thread_num", 25); + ue_socket_thread_num_ = tdd_conf.value("ue_socket_thread_num", 4); fft_thread_num_ = tdd_conf.value("fft_thread_num", 5); demul_thread_num_ = tdd_conf.value("demul_thread_num", 5); decode_thread_num_ = tdd_conf.value("decode_thread_num", 10); diff --git a/test/sim_tests/test_e2e_sim.sh b/test/sim_tests/test_e2e_sim.sh index 58a014234..089a77f35 100755 --- a/test/sim_tests/test_e2e_sim.sh +++ b/test/sim_tests/test_e2e_sim.sh @@ -7,7 +7,7 @@ ############################################################################### # Check that all required executables are present -exe_list="build/user build/data_generator build/chsim build/agora data/bs-sim.json" +exe_list="build/user build/data_generator build/chsim build/agora data/chsim.json" for exe in ${exe_list}; do if [ ! -f ${exe} ]; then echo "${exe} not found. Exiting." @@ -17,8 +17,8 @@ done # Setup the config with the number of frames to test -cp data/bs-sim.json data/bs-sim-tmp.json -cp data/ue-sim.json data/ue-sim-tmp.json +cp data/chsim.json data/bs-sim-tmp.json +cp data/chsim.json data/ue-sim-tmp.json sed -i '2i\ \ "frames_to_test": 1000,' data/bs-sim-tmp.json sed -i '2i\ \ "frames_to_test": 1000,' data/ue-sim-tmp.json @@ -94,4 +94,4 @@ rm test_agora_output.txt rm test_user_output.txt rm test_output.txt rm test_chsim_output.txt -exit \ No newline at end of file +exit From 456259cd680a70c7aaaddb397cbb59d84d84b896 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Mon, 13 Dec 2021 11:10:56 -0600 Subject: [PATCH 06/55] Fix uplink breaking due to incorrect Direction setting --- data/chsim.json | 2 +- src/client/ue_worker.cc | 2 +- src/common/config.cc | 2 +- src/common/config.h | 8 -------- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/data/chsim.json b/data/chsim.json index d34c8e6db..f7dd7a3c7 100644 --- a/data/chsim.json +++ b/data/chsim.json @@ -19,6 +19,6 @@ "worker_thread_num": 10, "socket_thread_num": 1, "ue_core_offset": 1, - "ue_worker_thread_num": 8, + "ue_worker_thread_num": 2, "ue_socket_thread_num": 1 } diff --git a/src/client/ue_worker.cc b/src/client/ue_worker.cc index 861ca9424..6785f18db 100644 --- a/src/client/ue_worker.cc +++ b/src/client/ue_worker.cc @@ -94,7 +94,7 @@ void UeWorker::TaskThread(size_t core_offset) { PinToCoreWithOffset(ThreadType::kWorker, core_offset, tid_); auto encoder = std::make_unique( - &config_, (int)tid_, Direction::Downlink, + &config_, (int)tid_, Direction::Uplink, (kEnableMac == true) ? ul_bits_buffer_ : config_.UlBits(), (kEnableMac == true) ? kFrameWnd : 1, encoded_buffer_, &stats_); diff --git a/src/common/config.cc b/src/common/config.cc index cc53cdfb1..778a0acac 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -415,7 +415,7 @@ Config::Config(const std::string& jsonfile) if ((freq_orthogonal_pilot_ == false) && (tdd_conf.find("ue_radio_num") == tdd_conf.end())) { ue_num_ = frame_.NumPilotSyms(); - ue_ant_num_ = ue_num_; + ue_ant_num_ = ue_num_ * num_ue_channels_; } ue_ant_offset_ = tdd_conf.value("ue_ant_offset", 0); ue_ant_total_ = tdd_conf.value("ue_ant_total", ue_ant_num_); diff --git a/src/common/config.h b/src/common/config.h index e6ce4462c..e820848c6 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -283,14 +283,6 @@ class Config { /// Return the symbol type of this symbol in this frame SymbolType GetSymbolType(size_t symbol_id) const; - /* Inline functions */ - inline size_t GetNumAntennas() const { - return (this->num_radios_ * this->num_channels_); - } - inline size_t GetNumClientAntennas() const { - return (this->ue_num_ * this->num_ue_channels_); - } - inline void UpdateModCfgs(size_t new_mod_order_bits) { this->mod_order_bits_ = new_mod_order_bits; this->mod_order_ = static_cast(pow(2, this->mod_order_bits_)); From 36d99db0faa3f7cae4abb34df15938e8b1531bfe Mon Sep 17 00:00:00 2001 From: rdoosty Date: Wed, 15 Dec 2021 10:48:48 -0600 Subject: [PATCH 07/55] Small change in json topology format --- data/topology.json | 2 +- src/common/config.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/data/topology.json b/data/topology.json index 2041d7af7..951bd1657 100644 --- a/data/topology.json +++ b/data/topology.json @@ -18,7 +18,7 @@ "RF3E000127", "RF3E000597" ], - "reference node": "RF3E000089" + "reference": "RF3E000089" } }, "Clients" : { diff --git a/src/common/config.cc b/src/common/config.cc index 778a0acac..1b54a65be 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -49,7 +49,6 @@ Config::Config(const std::string& jsonfile) std::string serials_str; std::string serial_file = tdd_conf.value("serial_file", ""); Utils::LoadTddConfig(serial_file, serials_str); - std::cout << serials_str << std::endl; external_ref_node_ = false; if (serials_str.empty() == false) { const auto j_serials = json::parse(serials_str, nullptr, true, true); @@ -78,7 +77,7 @@ Config::Config(const std::string& jsonfile) num_radios_ += sdr_serials.size(); cell_id_.resize(num_radios_, i); - auto refnode_serial = serials_conf.value("reference node", ""); + auto refnode_serial = serials_conf.value("reference", ""); if (refnode_serial.empty()) { MLPD_INFO("No calibration node ID found in topology file!\n"); } else { From 90bae10c386d59f88fcd22edc0a1c496e13207d2 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Wed, 15 Dec 2021 13:57:19 -0600 Subject: [PATCH 08/55] Fix bad indexing for ref radio --- data/dl-hw.json | 17 ++++++++++------- data/ul-hw.json | 14 ++++++++------ src/common/config.cc | 4 ++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index bbb74e169..eae2c76b2 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -3,11 +3,10 @@ "cells" : 1, "channel" : "A", "frequency" : 3.6e9, - "single_gain" : false, - "rx_gain_a" : 21, - "tx_gain_a" : 35, - "rx_gain_b" : 21, - "tx_gain_b" : 35, + "rx_gain_a" : 65, + "tx_gain_a" : 75, + "rx_gain_b" : 65, + "tx_gain_b" : 75, "sample_rate" : 5e6, "ofdm_tx_zero_prefix" : 160, "ofdm_tx_zero_postfix" : 160, @@ -29,9 +28,13 @@ "worker_thread_num" : 16, "core_offset" : 10, "demul_block_size" : 48, - "ue_channel" : "AB", + "ue_channel" : "A", + "ue_rx_gain_a" : [65,65], + "ue_tx_gain_a" : [75,75], + "ue_rx_gain_b" : [65,65], + "ue_tx_gain_b" : [75,75], "hw_framer": false, - "tx_advance" : [144], + "tx_advance" : [144, 144], "ue_core_offset" : 28, "ue_worker_thread_num" : 2 } diff --git a/data/ul-hw.json b/data/ul-hw.json index 8a614e18c..80a32a7b6 100644 --- a/data/ul-hw.json +++ b/data/ul-hw.json @@ -21,17 +21,19 @@ "frame_schedule": [ "BPPGUUUUG" ], + "client_ul_pilot_syms" : 2, + "worker_thread_num" : 20, + "demul_block_size" : 48, + "ue_channel" : "A", + "ue_rx_gain_a" : [65,65], + "ue_tx_gain_a" : [75,75], + "ue_rx_gain_b" : [65,65], + "ue_tx_gain_b" : [75,75], "hw_framer": false, - "max_frame": 100000, "tx_advance": [ 140, 140 ], - "ue_channel" : "A", - "downlink_mode": false, - "client_ul_pilot_syms" : 2, - "worker_thread_num" : 20, - "demul_block_size" : 48, "ue_worker_thread_num": 2, "ue_demul_block_size": 48, "ue_core_offset": 26, diff --git a/src/common/config.cc b/src/common/config.cc index 1b54a65be..8a5712de2 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -79,10 +79,10 @@ Config::Config(const std::string& jsonfile) auto refnode_serial = serials_conf.value("reference", ""); if (refnode_serial.empty()) { - MLPD_INFO("No calibration node ID found in topology file!\n"); + MLPD_INFO("No reference node ID found in topology file!\n"); } else { radio_id_.push_back(refnode_serial); - ref_radio_.push_back(radio_id_.size()); + ref_radio_.push_back(radio_id_.size() - 1); num_radios_++; cell_id_.resize(num_radios_, i); } From fb550038ae6decda861ed2387436a243486136ff Mon Sep 17 00:00:00 2001 From: rdoosty Date: Thu, 16 Dec 2021 11:59:49 -0600 Subject: [PATCH 09/55] POWDER config --- data/dl-powder.json | 40 +++++++++++++++++++++++++++++++ data/topology-powder.json | 50 +++++++++++++++++++++++++++++++++++++++ src/common/config.cc | 17 ++++++------- 3 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 data/dl-powder.json create mode 100644 data/topology-powder.json diff --git a/data/dl-powder.json b/data/dl-powder.json new file mode 100644 index 000000000..363e33657 --- /dev/null +++ b/data/dl-powder.json @@ -0,0 +1,40 @@ +{ + "serial_file" : "data/topology-powder.json", + "cells" : 1, + "channel" : "A", + "frequency" : 3.6e9, + "rx_gain_a" : 65, + "tx_gain_a" : 70, + "rx_gain_b" : 65, + "tx_gain_b" : 70, + "sample_rate" : 5e6, + "ofdm_tx_zero_prefix" : 160, + "ofdm_tx_zero_postfix" : 160, + "ofdm_rx_zero_prefix_bs" : 160, + "ofdm_rx_zero_prefix_cal_dl" : 288, + "ofdm_rx_zero_prefix_cal_ul" : 168, + "cp_size" : 32, + "fft_size" : 2048, + "ofdm_data_num" : 1200, + "modulation" : "16QAM", + "Zc" : 72, + "beamsweep" : false, + "beacon_antenna" : 0, + "frame_schedule": [ + "BGCLGGPPGGDDDGG" + ], + "client_dl_pilot_syms" : 2, + "socket_thread_num" : 1, + "worker_thread_num" : 16, + "core_offset" : 10, + "demul_block_size" : 48, + "ue_channel" : "A", + "ue_rx_gain_a" : [65, 65], + "ue_tx_gain_a" : [70, 70], + "ue_rx_gain_b" : [65, 65], + "ue_tx_gain_b" : [70, 70], + "hw_framer": false, + "tx_advance" : [140, 140], + "ue_core_offset" : 28, + "ue_worker_thread_num" : 2 +} diff --git a/data/topology-powder.json b/data/topology-powder.json new file mode 100644 index 000000000..171f34efa --- /dev/null +++ b/data/topology-powder.json @@ -0,0 +1,50 @@ +{ + "BaseStations": { + "BS0": { + "hub": "FH4B000021", + "rrh": [ + "RH6A000010", + "RH6A000019", + "RH6A000018", + "RH6A000011", + "RH6A000016", + "RH6A000017" + ], + "sdr": [ + "RF3E000246", + "RF3E000490", + "RF3E000749", + "RF3E000697", + "RF3E000724", + "RF3E000740", + "RF3E000532", + "RF3E000716", + /* + "RF3E000674", + "RF3E000704", + "RF3E000676", + "RF3E000668",*/ + "RF3E000340", + "RF3E000744", + "RF3E000161", + "RF3E000735", + "RF3E000387", + "RF3E000389", + "RF3E000206", + "RF3E000211" + /* + "RF3E000256", + "RF3E000383", + "RF3E000304", + "RF3E000303"*/ + ], + "reference": "RF3E000157" + } + }, + "Clients" : { + "sdr": [ + "RF3E000119", + "RF3E000145" + ] + } +} diff --git a/src/common/config.cc b/src/common/config.cc index 8a5712de2..f10306e14 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -233,14 +233,6 @@ Config::Config(const std::string& jsonfile) freq_orthogonal_pilot_ = tdd_conf.value("freq_orthogonal_pilot", false); correct_phase_shift_ = tdd_conf.value("correct_phase_shift", false); - auto tx_advance = tdd_conf.value("tx_advance", json::array()); - if (tx_advance.empty()) { - cl_tx_advance_.resize(ue_num_, 0); - } else { - RtAssert(tx_advance.size() == ue_num_, - "tx_advance size must be same as the number of clients!"); - cl_tx_advance_.assign(tx_advance.begin(), tx_advance.end()); - } hw_framer_ = tdd_conf.value("hw_framer", true); // If frames not specified explicitly, construct default based on frame_type / @@ -419,6 +411,15 @@ Config::Config(const std::string& jsonfile) ue_ant_offset_ = tdd_conf.value("ue_ant_offset", 0); ue_ant_total_ = tdd_conf.value("ue_ant_total", ue_ant_num_); + auto tx_advance = tdd_conf.value("tx_advance", json::array()); + if (tx_advance.empty()) { + cl_tx_advance_.resize(ue_num_, 0); + } else { + RtAssert(tx_advance.size() == ue_num_, + "tx_advance size must be same as the number of clients!"); + cl_tx_advance_.assign(tx_advance.begin(), tx_advance.end()); + } + // Agora configurations frames_to_test_ = tdd_conf.value("max_frame", 9600); core_offset_ = tdd_conf.value("core_offset", 0); From 4ad4689a549b97e8e634d7fb8ac14f455ea48994 Mon Sep 17 00:00:00 2001 From: rdoost Date: Fri, 17 Dec 2021 11:37:22 -0600 Subject: [PATCH 10/55] Change Channel to UeChannel for clients --- src/client/client_radio.cc | 8 ++++---- src/common/config.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 7a7a63b3f..dfa52c44e 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -12,7 +12,7 @@ ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { SoapySDR::Kwargs args; SoapySDR::Kwargs sargs; // load channels - auto channels = Utils::StrToChannels(cfg_->Channel()); + auto channels = Utils::StrToChannels(cfg_->UeChannel()); this->radio_num_ = cfg_->UeNum(); this->antenna_num_ = cfg_->UeAntNum(); @@ -124,7 +124,7 @@ ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { void ClientRadioConfig::InitClientRadio(size_t tid) { // load channels - auto channels = Utils::StrToChannels(cfg_->Channel()); + auto channels = Utils::StrToChannels(cfg_->UeChannel()); SoapySDR::Kwargs args; SoapySDR::Kwargs sargs; @@ -296,7 +296,7 @@ bool ClientRadioConfig::RadioStart() { "TX_SW_DELAY", "30"); // experimentally good value for dev front-end cl_stn_[i]->writeSetting("TDD_MODE", "true"); - for (char const& c : cfg_->Channel()) { + for (char const& c : cfg_->UeChannel()) { std::string tx_ram = "TX_RAM_"; cl_stn_[i]->writeRegisters(tx_ram + c, 0, pilot); } @@ -309,7 +309,7 @@ bool ClientRadioConfig::RadioStart() { cl_stn_[i]->writeRegisters("CORR_COE", 0, cfg_->Coeffs()); cl_stn_[i]->writeSetting("CORR_START", - (cfg_->Channel() == "B") ? "B" : "A"); + (cfg_->UeChannel() == "B") ? "B" : "A"); } else { if (!kUseUHD) { cl_stn_[i]->setHardwareTime(0, "TRIGGER"); diff --git a/src/common/config.h b/src/common/config.h index e820848c6..365ba358e 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -104,6 +104,7 @@ class Config { inline bool ImbalanceCalEn() const { return this->imbalance_cal_en_; } inline bool ExternalRefNode() const { return this->external_ref_node_; } inline std::string Channel() const { return this->channel_; } + inline std::string UeChannel() const { return this->ue_channel_; } inline size_t AntGroupNum() const { return this->ant_group_num_; } inline size_t AntPerGroup() const { return this->ant_per_group_; } From 3da11b05a643e904057a7933e8b314a80a31435e Mon Sep 17 00:00:00 2001 From: rdoost Date: Fri, 17 Dec 2021 15:31:01 -0600 Subject: [PATCH 11/55] Better handling of reference nodes --- src/agora/dofft.cc | 4 +-- src/agora/dozf.cc | 40 +++++++++++++++-------- src/agora/dozf.h | 3 +- src/agora/phy_stats.cc | 8 ++--- src/agora/radio_calibrate.cc | 21 ++++++------ src/agora/radio_lib.cc | 9 +++--- src/agora/txrx/txrx_argos.cc | 4 +-- src/agora/txrx/txrx_usrp.cc | 4 +-- src/client/client_radio.cc | 34 ++++++++++---------- src/common/config.cc | 62 +++++++++++++++++++++++------------- src/common/config.h | 26 ++++++++------- 11 files changed, 123 insertions(+), 92 deletions(-) diff --git a/src/agora/dofft.cc b/src/agora/dofft.cc index 10aec9202..1318b204b 100644 --- a/src/agora/dofft.cc +++ b/src/agora/dofft.cc @@ -193,7 +193,7 @@ EventData DoFFT::Launch(size_t tag) { PartialTranspose(cfg_->GetDataBuf(data_buffer_, frame_id, symbol_id), ant_id, SymbolType::kUL); } else if (sym_type == SymbolType::kCalUL and - ant_id != cfg_->RefAnt().at(cell_id)) { + ant_id != cfg_->RefAnt(cell_id)) { // Only process uplink for antennas that also do downlink in this frame // for consistency with calib downlink processing. if (frame_id >= TX_FRAME_DELTA && @@ -207,7 +207,7 @@ EventData DoFFT::Launch(size_t tag) { phy_stats_->UpdateCalibPilotSnr(frame_grp_id, 1, ant_id, fft_inout_); } } else if (sym_type == SymbolType::kCalDL && - ant_id == cfg_->RefAnt().at(cell_id)) { + ant_id == cfg_->RefAnt(cell_id)) { if (frame_id >= TX_FRAME_DELTA) { size_t frame_grp_id = (frame_id - TX_FRAME_DELTA) / cfg_->AntGroupNum(); size_t frame_grp_slot = frame_grp_id % kFrameWnd; diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index 3173a56fd..09bbed561 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -45,11 +45,22 @@ DoZF::DoZF(Config* config, int tid, Agora_memory::PaddedAlignedAlloc(Agora_memory::Alignment_t::kAlign64, kMaxAntennas * sizeof(complex_float))); - if (cfg_->RefAnt().size() > 0) { - ref_ids.zeros(cfg_->NumCells() * cfg_->NumChannels()); + if (cfg_->Frame().NumDLSyms() > 0) { + num_ext_ref_ = 0; for (size_t i = 0; i < cfg_->NumCells(); i++) - for (size_t j = 0; j < cfg_->NumChannels(); j++) - ref_ids.at(i * cfg_->NumChannels() + j) = cfg_->RefAnt().at(i) + j; + if (cfg_->ExternalRefNode(i) == true) num_ext_ref_++; + if (num_ext_ref_ > 0) { + ext_ref_id_.zeros(num_ext_ref_); + size_t ext_id = 0; + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->ExternalRefNode(i) == true) { + for (size_t j = 0; j < cfg_->NumChannels(); j++) + ext_ref_id_.at(ext_id * cfg_->NumChannels() + j) = + cfg_->RefAnt(i) + j; + ext_id++; + } + } + } } } @@ -112,22 +123,23 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, float scale = 1 / (abs(mat_dl_zf_tmp).max()); mat_dl_zf_tmp *= scale; - if (cfg_->ExternalRefNode()) { - for (size_t i = 0; i < cfg_->NumCells(); i++) + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->ExternalRefNode(i) == true) { mat_dl_zf_tmp.insert_cols( - cfg_->RefRadio().at(i) * cfg_->NumChannels(), - arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), - arma::fill::zeros)); + cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), + arma::fill::zeros)); + } } arma::cx_fmat mat_dl_zf(reinterpret_cast(_mat_dl_zf), cfg_->BsAntNum(), cfg_->UeNum(), false); mat_dl_zf = mat_dl_zf_tmp.st(); } - if (cfg_->ExternalRefNode() == true) { - for (size_t i = 0; i < cfg_->NumCells(); i++) + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->ExternalRefNode(i) == true) { mat_ul_zf_tmp.insert_cols( - cfg_->RefAnt().at(i) * cfg_->NumChannels(), + cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), arma::fill::zeros)); + } } mat_ul_zf = mat_ul_zf_tmp; float rcond = -1; @@ -318,8 +330,8 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { if (cfg_->Frame().NumDLSyms() > 0) { ComputeCalib(frame_id, cur_sc_id); - if (cfg_->ExternalRefNode()) { - mat_csi.shed_rows(ref_ids); + if (num_ext_ref_ > 0) { + mat_csi.shed_rows(ext_ref_id_); } } diff --git a/src/agora/dozf.h b/src/agora/dozf.h index 936a5b369..94951a4f3 100644 --- a/src/agora/dozf.h +++ b/src/agora/dozf.h @@ -97,7 +97,8 @@ class DoZF : public Doer { // Intermediate buffer to gather reciprical calibration data vector complex_float* calib_gather_buffer_; PhyStats* phy_stats_; - arma::uvec ref_ids; + arma::uvec ext_ref_id_; + size_t num_ext_ref_; }; #endif // DOZF_H_ diff --git a/src/agora/phy_stats.cc b/src/agora/phy_stats.cc index 74bdd56ec..bf2ee9a5c 100644 --- a/src/agora/phy_stats.cc +++ b/src/agora/phy_stats.cc @@ -133,8 +133,8 @@ void PhyStats::PrintSnrStats(size_t frame_id) { for (size_t j = 0; j < config_->BsAntNum(); j++) { size_t radio_id = j / config_->NumChannels(); size_t cell_id = config_->CellId().at(radio_id); - if (config_->ExternalRefNode() == true && - radio_id == config_->RefRadio().at(cell_id)) + if (config_->ExternalRefNode(cell_id) == true && + radio_id == config_->RefRadio(cell_id)) continue; if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; @@ -161,8 +161,8 @@ void PhyStats::PrintCalibSnrStats(size_t frame_id) { for (size_t j = 0; j < config_->BsAntNum(); j++) { size_t radio_id = j / config_->NumChannels(); size_t cell_id = config_->CellId().at(radio_id); - if (config_->ExternalRefNode() == true && - radio_id == config_->RefRadio().at(cell_id)) + if (config_->ExternalRefNode(cell_id) == true && + radio_id == config_->RefRadio(cell_id)) continue; if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; diff --git a/src/agora/radio_calibrate.cc b/src/agora/radio_calibrate.cc index 26a8ef6af..f19dea30e 100644 --- a/src/agora/radio_calibrate.cc +++ b/src/agora/radio_calibrate.cc @@ -383,7 +383,7 @@ void RadioConfig::DciqCalibrationProc(size_t channel) { double tone_bb_freq = sample_rate / 7; size_t radio_size = cfg_->NumRadios(); - size_t reference_radio = cfg_->RefRadio().at(0); + size_t reference_radio = cfg_->RefRadio(0); SoapySDR::Device* ref_dev = ba_stn_[reference_radio]; /* @@ -537,9 +537,9 @@ void RadioConfig::DciqCalibrationProc(size_t channel) { void RadioConfig::AdjustDelays(std::vector offset) { // adjust all trigger delay for all radios // with respect to the first non-ref radio - size_t ref_offset = cfg_->RefAnt().at(0) == 0 ? 1 : 0; + size_t ref_offset = cfg_->RefAnt(0) == 0 ? 1 : 0; for (size_t i = 0; i < offset.size(); i++) { - if (i == cfg_->RefAnt().at(0)) { + if (i == cfg_->RefAnt(0)) { continue; } int delta = offset[ref_offset] - offset[i]; @@ -580,7 +580,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { size_t m = cfg_->BsAntNum(); // TODO: Fix for multi-cell size_t r = cfg_->NumRadios(); - size_t ref = cfg_->RefRadio().at(0); + size_t ref = cfg_->RefRadio(0); // allocate for uplink and downlink directions buff.resize(2 * m); for (size_t i = 0; i < 2 * m; i++) { @@ -862,8 +862,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { for (size_t q = 0; q < cfg_->OfdmCaNum(); q++) { sig_dn += std::pow(std::abs(dn.at(i).at(q + start_dn.at(i))), 2); noise_dn += std::pow( - std::abs(noise.at(cfg_->RefAnt().at(0)).at(q + start_dn.at(i))), - 2); + std::abs(noise.at(cfg_->RefAnt(0)).at(q + start_dn.at(i))), 2); } ss0 << 10 * std::log10(sig_dn / noise_dn) << " "; if (kReciprocalCalibPlot) { @@ -879,7 +878,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { plt::plot(up_i); // plt::xlim(0, read_len); plt::ylim(-1, 1); - plt::title("ant " + std::to_string(cfg_->RefAnt().at(0)) + + plt::title("ant " + std::to_string(cfg_->RefAnt(0)) + " (ref) to ant " + std::to_string(i)); plt::legend(); plt::save("up_" + std::to_string(i) + ".png"); @@ -889,7 +888,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { // plt::xlim(0, read_len); plt::ylim(-1, 1); plt::title("ant " + std::to_string(i) + " to ant (ref)" + - std::to_string(cfg_->RefAnt().at(0))); + std::to_string(cfg_->RefAnt(0))); plt::legend(); plt::save("dn_" + std::to_string(i) + ".png"); } @@ -932,10 +931,10 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { for (size_t i = 0; i < m; i++) { size_t id = i; - if (cfg_->ExternalRefNode() && i / cfg_->NumChannels() == ref) { + if (cfg_->ExternalRefNode(0) && i / cfg_->NumChannels() == ref) { continue; } - if (cfg_->ExternalRefNode() && (i / cfg_->NumChannels() > ref)) { + if (cfg_->ExternalRefNode(0) && (i / cfg_->NumChannels() > ref)) { id = i - cfg_->NumChannels(); } if (kVerboseCalibration) { // print time-domain data @@ -965,7 +964,7 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { auto dn_f = CommsLib::FFT(dn_ofdm, cfg_->OfdmCaNum()); auto up_f = CommsLib::FFT(up_ofdm, cfg_->OfdmCaNum()); - if (cfg_->ExternalRefNode() == false && + if (cfg_->ExternalRefNode(0) == false && i / cfg_->NumChannels() == ref) { for (size_t j = 0; j < cfg_->OfdmCaNum(); j++) { dn_f[j] = std::complex(1, 0); diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 71be3fa83..e683c4c78 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -203,6 +203,10 @@ void RadioConfig::InitBsRadio(size_t tid) { ba_stn_[i]->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); ba_stn_[i]->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); } + + // resets the DATA_clk domain logic. + ba_stn_[i]->writeSetting("RESET_DATA_LOGIC", ""); + rx_streams_[i] = ba_stn_[i]->setupStream(SOAPY_SDR_RX, SOAPY_SDR_CS16, channels, sargs); tx_streams_[i] = @@ -214,9 +218,6 @@ void RadioConfig::ConfigureBsRadio(size_t tid) { // load channels auto channels = Utils::StrToChannels(cfg_->Channel()); - // resets the DATA_clk domain logic. - ba_stn_[tid]->writeSetting("RESET_DATA_LOGIC", ""); - // use the TRX antenna port for both tx and rx for (auto ch : channels) { if (kUseUHD == false) { @@ -401,7 +402,7 @@ bool RadioConfig::RadioStart() { size_t ndx = 0; for (size_t i = 0; i < this->radio_num_; i++) { size_t cell_id = cfg_->CellId().at(i); - bool is_ref_radio = (i == cfg_->RefRadio().at(cell_id)); + bool is_ref_radio = (i == cfg_->RefRadio(cell_id)); ba_stn_[i]->writeSetting( "TX_SW_DELAY", "30"); // experimentally good value for dev front-end ba_stn_[i]->writeSetting("TDD_MODE", "true"); diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 1c0c1910a..dd51e1836 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -95,7 +95,7 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, /// \TODO: What if ref_ant is set to the second channel? if ((cfg_->Frame().IsRecCalEnabled() == true) && (cfg_->IsCalDlPilot(frame_id, symbol_id) == true) && - (radio_id == cfg_->RefRadio().at(cell_id)) && (cfg_->AntPerGroup() > 1)) { + (radio_id == cfg_->RefRadio(cell_id)) && (cfg_->AntPerGroup() > 1)) { if (cfg_->AntPerGroup() > cfg_->NumChannels()) { symbol_ids.resize(cfg_->AntPerGroup()); ant_ids.resize(cfg_->AntPerGroup()); @@ -181,7 +181,7 @@ size_t PacketTXRX::DequeueSendArgos(int tid) { std::vector> zeros(cfg_->SampsPerSymbol(), std::complex(0, 0)); for (size_t s = 0; s < cfg_->RadioPerGroup(); s++) { - if (radio_id != cfg_->RefRadio().at(cell_id)) { + if (radio_id != cfg_->RefRadio(cell_id)) { bool calib_turn = (frame_id % cfg_->RadioGroupNum() == radio_id / cfg_->RadioPerGroup() && s == radio_id % cfg_->RadioPerGroup()); diff --git a/src/agora/txrx/txrx_usrp.cc b/src/agora/txrx/txrx_usrp.cc index 9924b20f2..780619d85 100644 --- a/src/agora/txrx/txrx_usrp.cc +++ b/src/agora/txrx/txrx_usrp.cc @@ -201,7 +201,7 @@ int PacketTXRX::DequeueSendUsrp(int tid) { if (kDebugDownlink == true) { std::vector> zeros(c->SampsPerSymbol()); size_t dl_symbol_idx = c->Frame().GetDLSymbolIdx(symbol_id); - if (ant_id != c->RefAnt().at(cell_id)) { + if (ant_id != c->RefAnt(cell_id)) { txbuf[ch] = zeros.data(); } else if (dl_symbol_idx < c->Frame().ClientDlPilotSymbols()) { txbuf[ch] = reinterpret_cast(c->UeSpecificPilotT()[0]); @@ -270,7 +270,7 @@ int PacketTXRX::DequeueSendUsrp(int tid, int frame_id, int symbol_id) { if (kDebugDownlink) { std::vector> zeros(c->SampsPerSymbol()); size_t dl_symbol_idx = c->Frame().GetDLSymbolIdx(symbol_id); - if (ant_id != c->RefAnt().at(cell_id)) { + if (ant_id != c->RefAnt(cell_id)) { txbuf[ch] = zeros.data(); } else if (dl_symbol_idx < c->Frame().ClientDlPilotSymbols()) { txbuf[ch] = reinterpret_cast(c->UeSpecificPilotT()[0]); diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index dfa52c44e..dbd11c080 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -180,13 +180,13 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { // Unified gains for both lime and frontend if (cfg_->SingleGain()) { // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:108] - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, - ch != 0u ? cfg_->ClientRxGainB().at(tid) - : cfg_->ClientRxGainA().at(tid)); + cl_stn_[tid]->setGain( + SOAPY_SDR_RX, ch, + ch != 0u ? cfg_->ClientRxGainB(tid) : cfg_->ClientRxGainA(tid)); // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:105] - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, - ch != 0u ? cfg_->ClientTxGainB().at(tid) - : cfg_->ClientTxGainA().at(tid)); + cl_stn_[tid]->setGain( + SOAPY_SDR_TX, ch, + ch != 0u ? cfg_->ClientTxGainB(tid) : cfg_->ClientTxGainA(tid)); } else { if (info["frontend"].find("CBRS") != std::string::npos) { if (cfg_->Freq() > 3e9) { @@ -200,9 +200,8 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { } cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA", - ch != 0u - ? cfg_->RxGainB() - : cfg_->ClientRxGainA().at(tid)); //[0,30] + ch != 0u ? cfg_->ClientRxGainB(tid) + : cfg_->ClientRxGainA(tid)); //[0,30] cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] @@ -212,17 +211,16 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { } cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[0,12] cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PAD", - ch != 0u - ? cfg_->ClientTxGainB().at(tid) - : cfg_->ClientTxGainA().at(tid)); //[0,30] + ch != 0u ? cfg_->ClientTxGainB(tid) + : cfg_->ClientTxGainA(tid)); //[0,30] } } else { - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA0", - ch != 0u ? cfg_->ClientRxGainB().at(tid) - : cfg_->ClientRxGainA().at(tid)); - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PGA0", - ch != 0u ? cfg_->ClientTxGainB().at(tid) - : cfg_->ClientTxGainA().at(tid)); + cl_stn_[tid]->setGain( + SOAPY_SDR_RX, ch, "PGA0", + ch != 0u ? cfg_->ClientRxGainB(tid) : cfg_->ClientRxGainA(tid)); + cl_stn_[tid]->setGain( + SOAPY_SDR_TX, ch, "PGA0", + ch != 0u ? cfg_->ClientTxGainB(tid) : cfg_->ClientTxGainA(tid)); } } diff --git a/src/common/config.cc b/src/common/config.cc index f10306e14..9558307d8 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -45,11 +45,12 @@ Config::Config(const std::string& jsonfile) SetCpuLayoutOnNumaNodes(true, excluded); num_cells_ = tdd_conf.value("cells", 1); + num_radios_ = 0; + ue_num_ = 0; std::string serials_str; std::string serial_file = tdd_conf.value("serial_file", ""); Utils::LoadTddConfig(serial_file, serials_str); - external_ref_node_ = false; if (serials_str.empty() == false) { const auto j_serials = json::parse(serials_str, nullptr, true, true); @@ -61,6 +62,7 @@ Config::Config(const std::string& jsonfile) ss.clear(); RtAssert(j_bs_serials.size() == num_cells_, "Incorrect cells number!"); + external_ref_node_.resize(num_cells_, false); for (size_t i = 0; i < num_cells_; i++) { json serials_conf; std::string cell_str = "BS" + std::to_string(i); @@ -79,17 +81,24 @@ Config::Config(const std::string& jsonfile) auto refnode_serial = serials_conf.value("reference", ""); if (refnode_serial.empty()) { - MLPD_INFO("No reference node ID found in topology file!\n"); - } else { - radio_id_.push_back(refnode_serial); + MLPD_INFO( + "No reference node ID found in topology file! Taking the last node " + "as reference node!\n"); + refnode_serial = radio_id_.back(); ref_radio_.push_back(radio_id_.size() - 1); - num_radios_++; - cell_id_.resize(num_radios_, i); + } else { + auto serial_iterator = + std::find(sdr_serials.begin(), sdr_serials.end(), refnode_serial); + if (serial_iterator == sdr_serials.end()) { + radio_id_.push_back(refnode_serial); + num_radios_++; + cell_id_.resize(num_radios_, i); + external_ref_node_.at(i) = true; + } else { + ref_radio_.push_back(radio_id_.size() - sdr_serials.size() + + serial_iterator - sdr_serials.begin()); + } } - bool external_ref_node = true; - for (size_t j = 0; j < sdr_serials.size(); j++) - if (sdr_serials.at(j) == refnode_serial) external_ref_node = false; - external_ref_node_ = external_ref_node; } json j_ue_serials; @@ -104,6 +113,7 @@ Config::Config(const std::string& jsonfile) if (radio_id_.empty() == true) { num_radios_ = tdd_conf.value("bs_radio_num", 8); + external_ref_node_.resize(num_cells_, false); cell_id_.resize(num_radios_, 0); } @@ -120,17 +130,18 @@ Config::Config(const std::string& jsonfile) bs_ant_num_ = num_channels_ * num_radios_; ue_ant_num_ = ue_num_ * num_ue_channels_; + bf_ant_num_ = bs_ant_num_; + for (size_t i = 0; i < num_cells_; i++) { + if (external_ref_node_.at(i) == true) + bf_ant_num_ = bs_ant_num_ - num_channels_; + } + if (serials_str.empty() == false) { for (size_t i = 0; i < num_cells_; i++) { ref_ant_.push_back(ref_radio_.at(i) * num_channels_); } } - bf_ant_num_ = bs_ant_num_; - if (external_ref_node_ == true) { - bf_ant_num_ = bs_ant_num_ - num_channels_; - } - if ((kUseArgos == true) || (kUseUHD == true)) { RtAssert(num_radios_ != 0, "Error: No radios exist in Argos mode"); } @@ -272,7 +283,8 @@ Config::Config(const std::string& jsonfile) if ((ul_data_symbol_num_perframe + dl_data_symbol_num_perframe + pilot_symbol_num_perframe) > symbol_num_perframe) { MLPD_ERROR( - "!!!!! Invalid configuration pilot + ul + dl exceeds total symbols " + "!!!!! Invalid configuration pilot + ul + dl exceeds total " + "symbols " "!!!!!\n"); MLPD_ERROR( "Uplink symbols: %zu, Downlink Symbols :%zu, Pilot Symbols: %zu, " @@ -529,12 +541,15 @@ Config::Config(const std::string& jsonfile) this->running_.store(true); MLPD_INFO( "Config: %zu BS antennas, %zu UE antennas, %zu pilot symbols per " - "frame,\n\t%zu uplink data symbols per frame, %zu downlink data symbols " - "per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), modulation " + "frame,\n\t%zu uplink data symbols per frame, %zu downlink data " + "symbols " + "per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), " + "modulation " "%s,\n\t%zu codeblocks per symbol, %zu bytes per code block," "\n\t%zu UL MAC data bytes per frame, %zu UL MAC bytes per frame, " "\n\t%zu DL MAC data bytes per frame, %zu DL MAC bytes per frame, " - "frame time %.3f usec \nUplink Max Mac data tp (Mbps) %.3f \nDownlink " + "frame time %.3f usec \nUplink Max Mac data tp (Mbps) %.3f " + "\nDownlink " "Max Mac data tp (Mbps) %.3f \n", bs_ant_num_, ue_ant_num_, frame_.NumPilotSyms(), frame_.NumULSyms(), frame_.NumDLSyms(), ofdm_ca_num_, ofdm_data_num_, modulation_.c_str(), @@ -646,7 +661,8 @@ void Config::GenData() { auto zc_ue_pilot = Utils::DoubleToCfloat(zc_ue_pilot_double); for (size_t i = 0; i < ue_ant_num_; i++) { auto zc_ue_pilot_i = CommsLib::SeqCyclicShift( - zc_ue_pilot, (i + this->ue_ant_offset_) * (float)M_PI / 6); // LTE DMRS + zc_ue_pilot, + (i + this->ue_ant_offset_) * (float)M_PI / 6); // LTE DMRS for (size_t j = 0; j < this->ofdm_data_num_; j++) { this->ue_specific_pilot_[i][j] = {zc_ue_pilot_i[j].real(), zc_ue_pilot_i[j].imag()}; @@ -718,7 +734,8 @@ void Config::GenData() { sizeof(int8_t), data_bytes_num_persymbol_, fd); if (r < data_bytes_num_persymbol_) { MLPD_ERROR( - " *** Error: Uplink bad read from file %s (batch %zu : %zu) %zu " + " *** Error: Uplink bad read from file %s (batch %zu : %zu) " + "%zu " ": %zu\n", ul_data_file.c_str(), i, j, r, data_bytes_num_persymbol_); } @@ -757,7 +774,8 @@ void Config::GenData() { sizeof(int8_t), data_bytes_num_persymbol_, fd); if (r < data_bytes_num_persymbol_) { MLPD_ERROR( - "***Error: Downlink bad read from file %s (batch %zu : %zu) \n", + "***Error: Downlink bad read from file %s (batch %zu : %zu) " + "\n", dl_data_file.c_str(), i, j); } } diff --git a/src/common/config.h b/src/common/config.h index 365ba358e..ab7e5acec 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -75,17 +75,17 @@ class Config { inline double RxGainB() const { return this->rx_gain_b_; } inline double CalibTxGainA() const { return this->calib_tx_gain_a_; } inline double CalibTxGainB() const { return this->calib_tx_gain_b_; } - inline std::vector ClientTxGainA() const { - return this->client_tx_gain_a_; + inline double ClientTxGainA(size_t id) const { + return this->client_tx_gain_a_.at(id); } - inline std::vector ClientRxGainA() const { - return this->client_rx_gain_a_; + inline double ClientRxGainA(size_t id) const { + return this->client_rx_gain_a_.at(id); } - inline std::vector ClientTxGainB() const { - return this->client_tx_gain_b_; + inline double ClientTxGainB(size_t id) const { + return this->client_tx_gain_b_.at(id); } - inline std::vector ClientRxGainB() const { - return this->client_rx_gain_b_; + inline double ClientRxGainB(size_t id) const { + return this->client_rx_gain_b_.at(id); } inline size_t NumCells() const { return this->num_cells_; } inline size_t NumRadios() const { return this->num_radios_; } @@ -94,15 +94,17 @@ class Config { inline size_t NumAntennas() const { return this->num_antennas_; } inline size_t NumChannels() const { return this->num_channels_; } inline size_t NumUeChannels() const { return this->num_ue_channels_; } - inline std::vector RefAnt() const { return this->ref_ant_; } - inline std::vector RefRadio() const { return this->ref_radio_; } + inline size_t RefAnt(size_t id) const { return this->ref_ant_.at(id); } + inline size_t RefRadio(size_t id) const { return this->ref_radio_.at(id); } inline size_t BeaconAnt() const { return this->beacon_ant_; } inline size_t BeaconLen() const { return this->beacon_len_; } inline bool Beamsweep() const { return this->beamsweep_; } inline bool SampleCalEn() const { return this->sample_cal_en_; } inline bool ImbalanceCalEn() const { return this->imbalance_cal_en_; } - inline bool ExternalRefNode() const { return this->external_ref_node_; } + inline bool ExternalRefNode(size_t id) const { + return this->external_ref_node_.at(id); + } inline std::string Channel() const { return this->channel_; } inline std::string UeChannel() const { return this->ue_channel_; } @@ -525,7 +527,7 @@ class Config { bool beamsweep_; bool sample_cal_en_; bool imbalance_cal_en_; - bool external_ref_node_; + std::vector external_ref_node_; std::string channel_; std::string ue_channel_; size_t ant_group_num_; From 4ec16f004c59adfb616ba7548a42adbe2024f1cd Mon Sep 17 00:00:00 2001 From: rdoosty Date: Fri, 17 Dec 2021 17:16:25 -0600 Subject: [PATCH 12/55] Fix ref radio bug --- data/dl-hw.json | 10 +++++----- src/common/config.cc | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index eae2c76b2..66bc43478 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -29,11 +29,11 @@ "core_offset" : 10, "demul_block_size" : 48, "ue_channel" : "A", - "ue_rx_gain_a" : [65,65], - "ue_tx_gain_a" : [75,75], - "ue_rx_gain_b" : [65,65], - "ue_tx_gain_b" : [75,75], - "hw_framer": false, + "ue_rx_gain_a" : [65, 65], + "ue_tx_gain_a" : [75, 75], + "ue_rx_gain_b" : [65, 65], + "ue_tx_gain_b" : [75, 75], + "ue_hw_framer": false, "tx_advance" : [144, 144], "ue_core_offset" : 28, "ue_worker_thread_num" : 2 diff --git a/src/common/config.cc b/src/common/config.cc index 9558307d8..57803f5e4 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -91,6 +91,7 @@ Config::Config(const std::string& jsonfile) std::find(sdr_serials.begin(), sdr_serials.end(), refnode_serial); if (serial_iterator == sdr_serials.end()) { radio_id_.push_back(refnode_serial); + ref_radio_.push_back(radio_id_.size() - 1); num_radios_++; cell_id_.resize(num_radios_, i); external_ref_node_.at(i) = true; From 246c044b9898933fe4ff3b500c8fd88219e52818 Mon Sep 17 00:00:00 2001 From: rdoosty Date: Fri, 17 Dec 2021 18:30:47 -0600 Subject: [PATCH 13/55] Remove unused txt files --- data/bs-hub-serial.txt | 1 - data/bs-iris-serials.txt | 56 -------------------------------------- data/bs-usrp-addr.txt | 1 - data/ul-hw.json | 2 +- data/user-iris-serials.txt | 4 --- data/user-usrp-addr.txt | 1 - 6 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 data/bs-hub-serial.txt delete mode 100644 data/bs-iris-serials.txt delete mode 100644 data/bs-usrp-addr.txt delete mode 100644 data/user-iris-serials.txt delete mode 100644 data/user-usrp-addr.txt diff --git a/data/bs-hub-serial.txt b/data/bs-hub-serial.txt deleted file mode 100644 index 05b586bbe..000000000 --- a/data/bs-hub-serial.txt +++ /dev/null @@ -1 +0,0 @@ -FH4B000019 diff --git a/data/bs-iris-serials.txt b/data/bs-iris-serials.txt deleted file mode 100644 index d2faf95cf..000000000 --- a/data/bs-iris-serials.txt +++ /dev/null @@ -1,56 +0,0 @@ -#Chain 1 Serial RH3B000002 -RF3E000208 -RF3E000636 -RF3E000632 -RF3E000568 -RF3E000558 -RF3E000633 -RF3E000566 -RF3E000635 -##Chain 2 Serial RH3B000004 -#RF3E000356 -#RF3E000546 -#RF3E000620 -#RF3E000609 -#RF3E000604 -#RF3E000612 -#RF3E000640 -#RF3E000551 -##Chain 3 Serial RH3B000019 -#RF3E000347 -#RF3E000564 -#RF3E000569 -#RF3E000639 -##RF3E000605 -#RF3E000600 -#RF3E000611 -#RF3E000627 -##Chain 4 Serial RH3B000008 -#RF3E000306 -#RF3E000236 -##RF3E000292 -##RF3E000251 -#RF3E000258 -##RF3E000299 -#RF3E000254 -#RF3E000260 -##Chain 5 Serial RH3B000024 -##RF3E000309 -##RF3E000466 -#RF3E000468 -##RF3E000454 -##RF3E000511 -##RF3E000530 -#RF3E000525 -#RF3E000428 -##Chain 6 Serial RH3B000016 -#RF3E000085 -#RF3E000446 -#RF3E000513 -#RF3E000624 -#RF3E000485 -#RF3E000641 -##RF3E000649 -#RF3E000618 -#Chain 7 -RF3E000089 diff --git a/data/bs-usrp-addr.txt b/data/bs-usrp-addr.txt deleted file mode 100644 index cebefe7ef..000000000 --- a/data/bs-usrp-addr.txt +++ /dev/null @@ -1 +0,0 @@ -10.118.3.2 diff --git a/data/ul-hw.json b/data/ul-hw.json index 80a32a7b6..d9ec93934 100644 --- a/data/ul-hw.json +++ b/data/ul-hw.json @@ -29,7 +29,7 @@ "ue_tx_gain_a" : [75,75], "ue_rx_gain_b" : [65,65], "ue_tx_gain_b" : [75,75], - "hw_framer": false, + "ue_hw_framer": false, "tx_advance": [ 140, 140 diff --git a/data/user-iris-serials.txt b/data/user-iris-serials.txt deleted file mode 100644 index be7fc9d82..000000000 --- a/data/user-iris-serials.txt +++ /dev/null @@ -1,4 +0,0 @@ -RF3E000164 -#RF3E000392 -RF3E000241 -#RF3D000016 diff --git a/data/user-usrp-addr.txt b/data/user-usrp-addr.txt deleted file mode 100644 index d4d9c45b1..000000000 --- a/data/user-usrp-addr.txt +++ /dev/null @@ -1 +0,0 @@ -10.118.2.2 From 99a31764cd414f792470e900feb199b0be520f5c Mon Sep 17 00:00:00 2001 From: rdoost Date: Mon, 20 Dec 2021 11:27:15 -0600 Subject: [PATCH 14/55] Fix handling of reference node in uplink-only mode. --- data/dl-hw.json | 25 ++++++++++++++----------- data/topology.json | 18 +++++++++--------- data/ul-hw.json | 26 +++++++++++++------------- src/agora/dozf.cc | 34 ++++++++++++++++------------------ src/agora/radio_lib.cc | 4 ++-- src/common/config.cc | 9 ++++++--- 6 files changed, 60 insertions(+), 56 deletions(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index 66bc43478..5af8ceea3 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -4,10 +4,10 @@ "channel" : "A", "frequency" : 3.6e9, "rx_gain_a" : 65, - "tx_gain_a" : 75, + "tx_gain_a" : 80, "rx_gain_b" : 65, - "tx_gain_b" : 75, - "sample_rate" : 5e6, + "tx_gain_b" : 80, + "sample_rate" : 7.68e6, "ofdm_tx_zero_prefix" : 160, "ofdm_tx_zero_postfix" : 160, "ofdm_rx_zero_prefix_bs" : 160, @@ -15,26 +15,29 @@ "ofdm_rx_zero_prefix_cal_ul" : 168, "cp_size" : 32, "fft_size" : 512, - "ofdm_data_num" : 336, + "ofdm_data_num" : 304, "modulation" : "16QAM", - "Zc" : 20, + "Zc" : 18, "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ - "BGCLGGPPGGDDDGG" + "BCLGPPGDDDD" ], "client_dl_pilot_syms" : 2, - "socket_thread_num" : 1, - "worker_thread_num" : 16, + "socket_thread_num" : 3, + "worker_thread_num" : 10, "core_offset" : 10, "demul_block_size" : 48, "ue_channel" : "A", "ue_rx_gain_a" : [65, 65], - "ue_tx_gain_a" : [75, 75], + "ue_tx_gain_a" : [80, 80], "ue_rx_gain_b" : [65, 65], - "ue_tx_gain_b" : [75, 75], + "ue_tx_gain_b" : [80, 80], "ue_hw_framer": false, - "tx_advance" : [144, 144], + "tx_advance": [ + 144, + 144 + ], "ue_core_offset" : 28, "ue_worker_thread_num" : 2 } diff --git a/data/topology.json b/data/topology.json index 951bd1657..435c74c07 100644 --- a/data/topology.json +++ b/data/topology.json @@ -9,16 +9,16 @@ "RH3B000004" ], "sdr": [ - "RF3E000087", - "RF3E000084", - "RF3E000107", - "RF3E000086", - "RF3E000110", - "RF3E000162", - "RF3E000127", - "RF3E000597" + "RF3E000208", + "RF3E000636", + "RF3E000632", + "RF3E000568", + "RF3E000558", + "RF3E000633", + "RF3E000566", + "RF3E000635" ], - "reference": "RF3E000089" + "reference": "RF3E000089" } }, "Clients" : { diff --git a/data/ul-hw.json b/data/ul-hw.json index 80a32a7b6..7e7dc6303 100644 --- a/data/ul-hw.json +++ b/data/ul-hw.json @@ -4,9 +4,9 @@ "channel" : "A", "frequency" : 3.6e9, "rx_gain_a" : 65, - "tx_gain_a" : 75, + "tx_gain_a" : 80, "rx_gain_b" : 65, - "tx_gain_b" : 75, + "tx_gain_b" : 80, "sample_rate": 7.68e6, "ofdm_tx_zero_prefix" : 160, "ofdm_tx_zero_postfix" : 160, @@ -16,27 +16,27 @@ "ofdm_data_num" : 304, "modulation" : "16QAM", "Zc" : 18, - "beamsweep" : true, + "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ "BPPGUUUUG" ], "client_ul_pilot_syms" : 2, + "socket_thread_num" : 1, "worker_thread_num" : 20, + "core_offset" : 10, "demul_block_size" : 48, "ue_channel" : "A", - "ue_rx_gain_a" : [65,65], - "ue_tx_gain_a" : [75,75], - "ue_rx_gain_b" : [65,65], - "ue_tx_gain_b" : [75,75], - "hw_framer": false, + "ue_rx_gain_a" : [65, 65], + "ue_tx_gain_a" : [80, 80], + "ue_rx_gain_b" : [65, 65], + "ue_tx_gain_b" : [80, 80], + "ue_hw_framer": false, "tx_advance": [ - 140, - 140 + 144, + 144 ], "ue_worker_thread_num": 2, "ue_demul_block_size": 48, - "ue_core_offset": 26, - "ue_mac_rx_port": 9070, - "ue_mac_tx_port": 9080 + "ue_core_offset": 26 } diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index 09bbed561..db37a24e8 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -45,20 +45,18 @@ DoZF::DoZF(Config* config, int tid, Agora_memory::PaddedAlignedAlloc(Agora_memory::Alignment_t::kAlign64, kMaxAntennas * sizeof(complex_float))); - if (cfg_->Frame().NumDLSyms() > 0) { - num_ext_ref_ = 0; - for (size_t i = 0; i < cfg_->NumCells(); i++) - if (cfg_->ExternalRefNode(i) == true) num_ext_ref_++; - if (num_ext_ref_ > 0) { - ext_ref_id_.zeros(num_ext_ref_); - size_t ext_id = 0; - for (size_t i = 0; i < cfg_->NumCells(); i++) { - if (cfg_->ExternalRefNode(i) == true) { - for (size_t j = 0; j < cfg_->NumChannels(); j++) - ext_ref_id_.at(ext_id * cfg_->NumChannels() + j) = - cfg_->RefAnt(i) + j; - ext_id++; - } + num_ext_ref_ = 0; + for (size_t i = 0; i < cfg_->NumCells(); i++) + if (cfg_->ExternalRefNode(i) == true) num_ext_ref_++; + if (num_ext_ref_ > 0) { + ext_ref_id_.zeros(num_ext_ref_ * cfg_->NumChannels()); + size_t ext_id = 0; + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->ExternalRefNode(i) == true) { + for (size_t j = 0; j < cfg_->NumChannels(); j++) + ext_ref_id_.at(ext_id * cfg_->NumChannels() + j) = + cfg_->RefAnt(i) + j; + ext_id++; } } } @@ -134,7 +132,7 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, cfg_->BsAntNum(), cfg_->UeNum(), false); mat_dl_zf = mat_dl_zf_tmp.st(); } - for (size_t i = 0; i < cfg_->NumCells(); i++) { + for (int i = (int)cfg_->NumCells() - 1; i >= 0; i--) { if (cfg_->ExternalRefNode(i) == true) { mat_ul_zf_tmp.insert_cols( cfg_->RefAnt(i), @@ -330,9 +328,9 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { if (cfg_->Frame().NumDLSyms() > 0) { ComputeCalib(frame_id, cur_sc_id); - if (num_ext_ref_ > 0) { - mat_csi.shed_rows(ext_ref_id_); - } + } + if (num_ext_ref_ > 0) { + mat_csi.shed_rows(ext_ref_id_); } double start_tsc3 = GetTime::WorkerRdtsc(); diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index e683c4c78..2d4a28664 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -18,8 +18,8 @@ RadioConfig::RadioConfig(Config* cfg) this->radio_num_ = cfg_->NumRadios(); this->antenna_num_ = cfg_->BsAntNum(); - std::cout << "Radio num is " << this->radio_num_ - << " Antenna num: " << antenna_num_ << std::endl; + std::cout << "BS Radio num is " << this->radio_num_ + << ", Antenna num: " << antenna_num_ << std::endl; if (kUseUHD == false) { for (size_t i = 0; i < cfg_->NumCells(); i++) { if (cfg_->HubId().at(i) != "") { diff --git a/src/common/config.cc b/src/common/config.cc index 57803f5e4..fa237e55c 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -83,7 +83,9 @@ Config::Config(const std::string& jsonfile) if (refnode_serial.empty()) { MLPD_INFO( "No reference node ID found in topology file! Taking the last node " - "as reference node!\n"); + "%s" + "as reference node!\n", + radio_id_.back().c_str()); refnode_serial = radio_id_.back(); ref_radio_.push_back(radio_id_.size() - 1); } else { @@ -96,8 +98,9 @@ Config::Config(const std::string& jsonfile) cell_id_.resize(num_radios_, i); external_ref_node_.at(i) = true; } else { - ref_radio_.push_back(radio_id_.size() - sdr_serials.size() + - serial_iterator - sdr_serials.begin()); + size_t index = radio_id_.size() - sdr_serials.size() + + serial_iterator - sdr_serials.begin(); + ref_radio_.push_back(index); } } } From a10c362964ca74df82b4dad6bf7308c1d2424891 Mon Sep 17 00:00:00 2001 From: rdoost Date: Mon, 20 Dec 2021 15:24:15 -0600 Subject: [PATCH 15/55] Updated JSON --- data/dl-hw.json | 10 +++++----- data/ul-hw.json | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index 5af8ceea3..548f68f22 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -14,18 +14,18 @@ "ofdm_rx_zero_prefix_cal_dl" : 288, "ofdm_rx_zero_prefix_cal_ul" : 168, "cp_size" : 32, - "fft_size" : 512, - "ofdm_data_num" : 304, + "fft_size" : 2048, + "ofdm_data_num" : 1200, "modulation" : "16QAM", - "Zc" : 18, + "Zc" : 72, "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ - "BCLGPPGDDDD" + "BCLGPPGDDD" ], "client_dl_pilot_syms" : 2, "socket_thread_num" : 3, - "worker_thread_num" : 10, + "worker_thread_num" : 12, "core_offset" : 10, "demul_block_size" : 48, "ue_channel" : "A", diff --git a/data/ul-hw.json b/data/ul-hw.json index 7e7dc6303..43f89fa1f 100644 --- a/data/ul-hw.json +++ b/data/ul-hw.json @@ -12,10 +12,10 @@ "ofdm_tx_zero_postfix" : 160, "ofdm_rx_zero_prefix_bs" : 160, "cp_size" : 32, - "fft_size" : 512, - "ofdm_data_num" : 304, + "fft_size" : 2048, + "ofdm_data_num" : 1200, "modulation" : "16QAM", - "Zc" : 18, + "Zc" : 72, "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ From c67771ea7167044aca7e43b288fb0c1ba0f82aba Mon Sep 17 00:00:00 2001 From: rdoost Date: Mon, 20 Dec 2021 15:30:51 -0600 Subject: [PATCH 16/55] Updated JSON 2 --- data/dl-hw.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index 548f68f22..94460ba2f 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -21,7 +21,7 @@ "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ - "BCLGPPGDDD" + "BCLGPPGGDDDGG" ], "client_dl_pilot_syms" : 2, "socket_thread_num" : 3, From 57743a2bca9115cc61299719854a10f9322c9952 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 14:35:01 -0700 Subject: [PATCH 17/55] Small changes --- data/mac-dl-sim.json | 6 +++--- data/reference_config.json | 6 +++--- src/common/config.cc | 22 ++++++++++------------ test/sim_tests/test_e2e_sim.sh | 4 ++-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/data/mac-dl-sim.json b/data/mac-dl-sim.json index f89f0dc27..5ef396a71 100644 --- a/data/mac-dl-sim.json +++ b/data/mac-dl-sim.json @@ -13,13 +13,13 @@ "modulation": "16QAM", "Zc": 24, "frequency": 3.6e9, - "rate": 7.68e6, + "sample_rate": 7.68e6, "ofdm_tx_zero_prefix": 160, "ofdm_tx_zero_postfix": 160, "ofdm_rx_zero_prefix_bs": 160, "ofdm_rx_zero_prefix_client": 160, /* Frame definition */ - "frames": [ + "frame_schedule": [ "BPGDDDDG" ], "client_dl_pilot_syms": 2, @@ -35,4 +35,4 @@ "ue_worker_thread_num": 2, "ue_socket_thread_num": 1, "max_frame": 1 -} +} \ No newline at end of file diff --git a/data/reference_config.json b/data/reference_config.json index 69bcc02fd..8d67b8572 100644 --- a/data/reference_config.json +++ b/data/reference_config.json @@ -14,7 +14,7 @@ "external_ref_node": false, "channel": "A", "radio_num": 8, - "rate": 5e6, + "sample_rate": 5e6, "demul_block_size": 48, "cp_len": 0, "modulation": "16QAM", @@ -65,7 +65,7 @@ "hw_framer": true, /* Frame definition */ /* 2a explicit frame construction */ - "frames": [ + "frame_schedule": [ "BPGUUUUG" ], /* 2b wordy frame construction */ @@ -114,5 +114,5 @@ "core_offset": 0, "worker_thread_num": 25, "socket_thread_num": 4, - "frames_to_test": 9600 + "max_frame": 9600 } \ No newline at end of file diff --git a/src/common/config.cc b/src/common/config.cc index 57ba2a75f..f5db5c22d 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -83,8 +83,7 @@ Config::Config(const std::string& jsonfile) if (refnode_serial.empty()) { MLPD_INFO( "No reference node ID found in topology file! Taking the last node " - "%s" - "as reference node!\n", + "%s as reference node!\n", radio_id_.back().c_str()); refnode_serial = radio_id_.back(); ref_radio_.push_back(radio_id_.size() - 1); @@ -128,9 +127,9 @@ Config::Config(const std::string& jsonfile) } channel_ = tdd_conf.value("channel", "A"); - ue_channel_ = tdd_conf.value("ue_channel", "A"); - num_channels_ = std::min(channel_.size(), (size_t)2); - num_ue_channels_ = std::min(ue_channel_.size(), (size_t)2); + ue_channel_ = tdd_conf.value("ue_channel", channel_); + num_channels_ = std::min(channel_.size(), kMaxChannels); + num_ue_channels_ = std::min(ue_channel_.size(), kMaxChannels); bs_ant_num_ = num_channels_ * num_radios_; ue_ant_num_ = ue_num_ * num_ue_channels_; @@ -249,7 +248,9 @@ Config::Config(const std::string& jsonfile) correct_phase_shift_ = tdd_conf.value("correct_phase_shift", false); hw_framer_ = tdd_conf.value("hw_framer", true); - if (kUseUHD) hw_framer_ = false; + if (kUseUHD) { + hw_framer_ = false; + } ue_hw_framer_ = tdd_conf.value("ue_hw_framer", false); // If frames not specified explicitly, construct default based on frame_type / @@ -289,9 +290,7 @@ Config::Config(const std::string& jsonfile) if ((ul_data_symbol_num_perframe + dl_data_symbol_num_perframe + pilot_symbol_num_perframe) > symbol_num_perframe) { MLPD_ERROR( - "!!!!! Invalid configuration pilot + ul + dl exceeds total " - "symbols " - "!!!!!\n"); + "!!!!! Invalid configuration pilot + ul + dl exceeds total symbols !!!!!\n"); MLPD_ERROR( "Uplink symbols: %zu, Downlink Symbols :%zu, Pilot Symbols: %zu, " "Total Symbols: %zu\n", @@ -308,8 +307,7 @@ Config::Config(const std::string& jsonfile) "!!!!! Invalid configuration ul and dl symbol overlap detected " "!!!!!\n"); MLPD_ERROR( - "Uplink - start: %zu - stop :%zu, Downlink - start: %zu - stop " - "%zu\n", + "Uplink - start: %zu - stop :%zu, Downlink - start: %zu - stop %zu\n", ul_data_symbol_start, ul_data_symbol_stop, dl_data_symbol_start, dl_data_symbol_stop); throw std::runtime_error("Invalid Frame Configuration"); @@ -421,7 +419,7 @@ Config::Config(const std::string& jsonfile) "Number of pilot symbols: " + std::to_string(frame_.NumPilotSyms()) + " does not match number of UEs: " + std::to_string(ue_ant_num_)); } - if ((freq_orthogonal_pilot_ == false) && + if ((freq_orthogonal_pilot_ == false) && (ue_radio_id_.empty() == true) && (tdd_conf.find("ue_radio_num") == tdd_conf.end())) { ue_num_ = frame_.NumPilotSyms(); ue_ant_num_ = ue_num_ * num_ue_channels_; diff --git a/test/sim_tests/test_e2e_sim.sh b/test/sim_tests/test_e2e_sim.sh index 089a77f35..277922c09 100755 --- a/test/sim_tests/test_e2e_sim.sh +++ b/test/sim_tests/test_e2e_sim.sh @@ -19,8 +19,8 @@ done # Setup the config with the number of frames to test cp data/chsim.json data/bs-sim-tmp.json cp data/chsim.json data/ue-sim-tmp.json -sed -i '2i\ \ "frames_to_test": 1000,' data/bs-sim-tmp.json -sed -i '2i\ \ "frames_to_test": 1000,' data/ue-sim-tmp.json +sed -i '2i\ \ "max_frame": 1000,' data/bs-sim-tmp.json +sed -i '2i\ \ "max_frame": 1000,' data/ue-sim-tmp.json echo "===========================================" echo "Generating data for emulated RRU end-to-end test with channel simulator ......" From d5fb63debeb6d6627305d6b2ad0f3a477d3d14dd Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 14:42:25 -0700 Subject: [PATCH 18/55] config update --- data/tddconfig-sim-ul-distributed.json | 52 +++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/data/tddconfig-sim-ul-distributed.json b/data/tddconfig-sim-ul-distributed.json index 1c1eb0fbe..4db950bf2 100644 --- a/data/tddconfig-sim-ul-distributed.json +++ b/data/tddconfig-sim-ul-distributed.json @@ -1,28 +1,28 @@ { - "ofdm_ca_num": 2048, - "ofdm_data_num": 1200, - "socket_thread_num": 1, - "worker_thread_num": 1, - "subcarrier_block_size": 200, - "demul_block_size": 40, - "antenna_num": 16, - "ue_num": 4, - "sender_addr": "192.168.21.183", - "core_offset": 2, - "fft_in_rru": true, - "disable_master": true, - "server_addr_list": [ - "192.168.21.181", - "192.168.21.182" - ], - "frames" : [ - "PPPPU" - ], - "server_addr_idx": 0, - "bs_port": 11000, - "ue_rx_port": 10000, - "ue_tx_port": 9000, - "demod_tx_port": 8100, - "demod_rx_port": 8600, - "frames_to_test": 1 + "ofdm_ca_num": 2048, + "ofdm_data_num": 1200, + "socket_thread_num": 1, + "worker_thread_num": 1, + "subcarrier_block_size": 200, + "demul_block_size": 40, + "antenna_num": 16, + "ue_num": 4, + "sender_addr": "192.168.21.183", + "core_offset": 2, + "fft_in_rru": true, + "disable_master": true, + "server_addr_list": [ + "192.168.21.181", + "192.168.21.182" + ], + "frame_schedule": [ + "PPPPU" + ], + "server_addr_idx": 0, + "bs_port": 11000, + "ue_rx_port": 10000, + "ue_tx_port": 9000, + "demod_tx_port": 8100, + "demod_rx_port": 8600, + "max_frame": 1 } \ No newline at end of file From 713fb1b8c9ddc681ef42e145122a3ea986952cdc Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 14:43:47 -0700 Subject: [PATCH 19/55] Powder wip configs --- data/bs-dl-powder-2.json | 40 ++++++++++++++++++++++++ data/bs-ul-powder-2.json | 59 ++++++++++++++++++++++++++++++++++++ data/topology-powder-ul.json | 48 +++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 data/bs-dl-powder-2.json create mode 100644 data/bs-ul-powder-2.json create mode 100644 data/topology-powder-ul.json diff --git a/data/bs-dl-powder-2.json b/data/bs-dl-powder-2.json new file mode 100644 index 000000000..e97fe2b54 --- /dev/null +++ b/data/bs-dl-powder-2.json @@ -0,0 +1,40 @@ +{ + "hubs": "data/bs-hub-serials-powder.txt", + "irises": "data/bs-iris-serials-powder-dl.txt", + "cells": 1, + "channel": "A", + "frequency": 3.56e9, + "single_gain": false, + "rx_gain_a": 25, + "tx_gain_a": 40, + "rx_gain_b": 25, + "tx_gain_b": 40, + "sample_rate": 5e6, + "ofdm_tx_zero_prefix": 160, + "ofdm_tx_zero_postfix": 160, + "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_cal_dl": 288, + "ofdm_rx_zero_prefix_cal_ul": 168, + "cp_len": 32, + "ofdm_ca_num": 2048, + "ofdm_data_num": 1200, + "modulation": "16QAM", + "zf_block_size": 1, + "demul_block_size": 48, + "Zc": 72, + "beamsweep": false, + "beacon_antenna": 0, + "frame_schedule": [ + "BGCLGGPPGDDDG" + ], + "hw_framer": true, + "client_dl_pilot_syms": 2, + "external_ref_node": true, + "ref_ant": 22, + /* Compute configuration */ + "core_offset": 16, + "exclude_cores": [], + "worker_thread_num": 16, + /* 22 + 1 */ + "socket_thread_num": 6 +} \ No newline at end of file diff --git a/data/bs-ul-powder-2.json b/data/bs-ul-powder-2.json new file mode 100644 index 000000000..459d3ad8b --- /dev/null +++ b/data/bs-ul-powder-2.json @@ -0,0 +1,59 @@ +{ + "serial_file": "data/topology-powder-ul.json", + "cells": 1, + "channel": "AB", + "frequency": 3.56e9, + "single_gain": true, + "rx_gain_a": 60, + "tx_gain_a": 75, + "rx_gain_b": 60, + "tx_gain_b": 75, + "sample_rate": 5e6, + "cp_size": 32, + "fft_size": 2048, + "ofdm_data_num": 1200, + "modulation": "16QAM", + "demul_block_size": 48, + "Zc": 72, + "ofdm_tx_zero_prefix": 160, + "ofdm_tx_zero_postfix": 160, + "ofdm_rx_zero_prefix_bs": 160, + "frame_schedule": [ + "BGGGGGPPPPGGGUUUGGG" + ], + "client_ul_pilot_syms": 2, + "beamsweep": false, + "beacon_antenna": 0, + /* UE configuration */ + "ue_channel": "AB", + "ue_rx_gain_a": [ + 65, + 65 + ], + "ue_tx_gain_a": [ + 75, + 75 + ], + "ue_rx_gain_b": [ + 65, + 65 + ], + "ue_tx_gain_b": [ + 75, + 75 + ], + "tx_advance": [ + 140, + 140 + ], + "ue_worker_thread_num": 4, + "ue_demul_block_size": 48, + "ue_core_offset": 0, + /* Compute configuration */ + "core_offset": 16, + "exclude_cores": [], + "worker_thread_num": 12, + /* 22 bs radios */ + "socket_thread_num": 6, + "max_frame": 10000 +} \ No newline at end of file diff --git a/data/topology-powder-ul.json b/data/topology-powder-ul.json new file mode 100644 index 000000000..414160917 --- /dev/null +++ b/data/topology-powder-ul.json @@ -0,0 +1,48 @@ +{ + "BaseStations": { + "BS0": { + "hub": "FH4B000021", + "rrh": [ + "RH6A000010", + "RH6A000019", + "RH6A000018", + "RH6A000011", + "RH6A000016", + "RH6A000017" + ], + "sdr": [ + "RF3E000246", + "RF3E000490", + "RF3E000749", + "RF3E000697", + "RF3E000724", + "RF3E000740", + "RF3E000532", + "RF3E000716", + "RF3E000674", + "RF3E000704", + "RF3E000676", + /*"RF3E000668",*/ + "RF3E000340", + "RF3E000744", + "RF3E000161", + /*"RF3E000735",*/ + "RF3E000387", + "RF3E000389", + "RF3E000206", + "RF3E000211", + "RF3E000256", + "RF3E000383", + "RF3E000304" + /*"RF3E000303"*/ + ], + "reference": "RF3E000246" + } + }, + "Clients": { + "sdr": [ + "RF3E000119", + "RF3E000145" + ] + } +} \ No newline at end of file From 53d41a729ee93b65d687446ae3a3faa291392598 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 16:31:54 -0700 Subject: [PATCH 20/55] updated configs --- data/bs-dl-powder-2.json | 4 ++-- data/mac-dl-sim.json | 2 +- data/mac-ul-sim.json | 4 ++-- data/reference_config.json | 6 +++--- data/tddconfig-sim-ul-distributed.json | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/data/bs-dl-powder-2.json b/data/bs-dl-powder-2.json index e97fe2b54..a121840f9 100644 --- a/data/bs-dl-powder-2.json +++ b/data/bs-dl-powder-2.json @@ -15,8 +15,8 @@ "ofdm_rx_zero_prefix_bs": 160, "ofdm_rx_zero_prefix_cal_dl": 288, "ofdm_rx_zero_prefix_cal_ul": 168, - "cp_len": 32, - "ofdm_ca_num": 2048, + "cp_size": 32, + "fft_size": 2048, "ofdm_data_num": 1200, "modulation": "16QAM", "zf_block_size": 1, diff --git a/data/mac-dl-sim.json b/data/mac-dl-sim.json index 5ef396a71..e283e6256 100644 --- a/data/mac-dl-sim.json +++ b/data/mac-dl-sim.json @@ -9,7 +9,7 @@ "fft_size": 512, "ofdm_data_num": 400, "demul_block_size": 48, - "cp_len": 32, + "cp_size": 32, "modulation": "16QAM", "Zc": 24, "frequency": 3.6e9, diff --git a/data/mac-ul-sim.json b/data/mac-ul-sim.json index 7f0c80b30..7ab381368 100644 --- a/data/mac-ul-sim.json +++ b/data/mac-ul-sim.json @@ -9,7 +9,7 @@ "fft_size": 512, "ofdm_data_num": 400, "demul_block_size": 48, - "cp_len": 32, + "cp_size": 32, "modulation": "16QAM", "Zc": 24, "ofdm_tx_zero_prefix": 160, @@ -34,4 +34,4 @@ "ue_worker_thread_num": 2, "ue_socket_thread_num": 1, "max_frame": 9600 -} +} \ No newline at end of file diff --git a/data/reference_config.json b/data/reference_config.json index 8d67b8572..192fc488b 100644 --- a/data/reference_config.json +++ b/data/reference_config.json @@ -16,12 +16,12 @@ "radio_num": 8, "sample_rate": 5e6, "demul_block_size": 48, - "cp_len": 0, + "cp_size": 0, "modulation": "16QAM", - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "ofdm_pilot_spacing": 16, - /* (ofdm_ca_num_ - ofdm_data_num_) / 2 */ + /* (fft_size - ofdm_data_num_) / 2 */ "ofdm_data_start": 424, "ofdm_tx_zero_prefix": 0, "ofdm_tx_zero_postfix": 0, diff --git a/data/tddconfig-sim-ul-distributed.json b/data/tddconfig-sim-ul-distributed.json index 4db950bf2..9bba34d18 100644 --- a/data/tddconfig-sim-ul-distributed.json +++ b/data/tddconfig-sim-ul-distributed.json @@ -1,5 +1,5 @@ { - "ofdm_ca_num": 2048, + "fft_size": 2048, "ofdm_data_num": 1200, "socket_thread_num": 1, "worker_thread_num": 1, From 6564149aea9fdc2eaf5368b442f40571cec57479 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 16:32:41 -0700 Subject: [PATCH 21/55] removed uninitialized variable call --- src/agora/radio_lib.cc | 6 +++--- src/agora/radio_lib.h | 1 - src/agora/txrx/txrx_argos.cc | 2 +- src/client/client_radio.cc | 2 +- src/common/config.cc | 12 ++++-------- src/common/config.h | 2 -- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 116c19b57..32f325247 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -437,12 +437,12 @@ bool RadioConfig::RadioStart() { ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); for (char const& c : cfg_->Channel()) { bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); - std::vector beacon_weights(cfg_->NumAntennas(), + std::vector beacon_weights(cfg_->NumRadios() * cfg_->NumChannels(), is_beacon_antenna ? 1 : 0); std::string tx_ram_wgt = "BEACON_RAM_WGT_"; if (cfg_->Beamsweep()) { - for (size_t j = 0; j < cfg_->NumAntennas(); j++) { - beacon_weights[j] = CommsLib::Hadamard2(ndx, j); + for (size_t j = 0; j < beacon_weights.size(); j++) { + beacon_weights.at(j) = CommsLib::Hadamard2(ndx, j); } } ba_stn_[i]->writeRegisters(tx_ram_wgt + c, 0, beacon_weights); diff --git a/src/agora/radio_lib.h b/src/agora/radio_lib.h index 9aa67a3b6..5af527560 100644 --- a/src/agora/radio_lib.h +++ b/src/agora/radio_lib.h @@ -72,7 +72,6 @@ class RadioConfig { Table init_calib_dl_; size_t radio_num_; size_t antenna_num_; - bool is_ue_; bool calib_; size_t calib_meas_num_; diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 65d555226..04687bdc6 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -23,7 +23,7 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { threads_started_.fetch_add(1); - long long time0; + long long time0 = 0; if (cfg_->HwFramer() == false) { // prepare BS beacon in host buffer std::vector beaconbuff(2); diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 54b1cddba..658e513ef 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -240,7 +240,7 @@ bool ClientRadioConfig::RadioStart() { int flags(0); // = SOAPY_SDR_WAIT_TRIGGER; std::vector zeros(cfg_->SampsPerSymbol(), 0); std::vector beacon = cfg_->Beacon(); - std::vector beacon_weights(cfg_->NumAntennas()); + std::vector beacon_weights(cfg_->UeAntNum()); std::vector pilot = cfg_->Pilot(); diff --git a/src/common/config.cc b/src/common/config.cc index f5db5c22d..22cd70be8 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -546,15 +546,12 @@ Config::Config(const std::string& jsonfile) MLPD_INFO( "Config: %zu BS antennas, %zu UE antennas, %zu pilot symbols per " "frame,\n\t%zu uplink data symbols per frame, %zu downlink data " - "symbols " - "per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), " - "modulation " - "%s,\n\t%zu codeblocks per symbol, %zu bytes per code block," + "symbols "per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), " + "modulation %s,\n\t%zu codeblocks per symbol, %zu bytes per code block," "\n\t%zu UL MAC data bytes per frame, %zu UL MAC bytes per frame, " "\n\t%zu DL MAC data bytes per frame, %zu DL MAC bytes per frame, " "frame time %.3f usec \nUplink Max Mac data tp (Mbps) %.3f " - "\nDownlink " - "Max Mac data tp (Mbps) %.3f \n", + "\nDownlink Max Mac data tp (Mbps) %.3f \n", bs_ant_num_, ue_ant_num_, frame_.NumPilotSyms(), frame_.NumULSyms(), frame_.NumDLSyms(), ofdm_ca_num_, ofdm_data_num_, modulation_.c_str(), ldpc_config_.NumBlocksInSymbol(), num_bytes_per_cb_, @@ -739,8 +736,7 @@ void Config::GenData() { if (r < data_bytes_num_persymbol_) { MLPD_ERROR( " *** Error: Uplink bad read from file %s (batch %zu : %zu) " - "%zu " - ": %zu\n", + "%zu : %zu\n", ul_data_file.c_str(), i, j, r, data_bytes_num_persymbol_); } } diff --git a/src/common/config.h b/src/common/config.h index 68c392ee9..981a482c8 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -92,7 +92,6 @@ class Config { inline size_t NumRadios() const { return this->num_radios_; } inline size_t InitCalibRepeat() const { return this->init_calib_repeat_; } - inline size_t NumAntennas() const { return this->num_antennas_; } inline size_t NumChannels() const { return this->num_channels_; } inline size_t NumUeChannels() const { return this->num_ue_channels_; } inline size_t RefAnt(size_t id) const { return this->ref_ant_.at(id); } @@ -520,7 +519,6 @@ class Config { size_t num_cells_; size_t num_radios_; - size_t num_antennas_; size_t num_channels_; size_t num_ue_channels_; size_t beacon_ant_; From bd2baa62c4ac104b8d4425f79c10b020f9433600 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 20 Dec 2021 16:41:59 -0700 Subject: [PATCH 22/55] oops --- src/common/config.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config.cc b/src/common/config.cc index 22cd70be8..b5ccf4928 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -546,7 +546,7 @@ Config::Config(const std::string& jsonfile) MLPD_INFO( "Config: %zu BS antennas, %zu UE antennas, %zu pilot symbols per " "frame,\n\t%zu uplink data symbols per frame, %zu downlink data " - "symbols "per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), " + "symbols per frame,\n\t%zu OFDM subcarriers (%zu data subcarriers), " "modulation %s,\n\t%zu codeblocks per symbol, %zu bytes per code block," "\n\t%zu UL MAC data bytes per frame, %zu UL MAC bytes per frame, " "\n\t%zu DL MAC data bytes per frame, %zu DL MAC bytes per frame, " From 0a51ae1aef94b53beaf999e8fb786ec52a503e9e Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 21 Dec 2021 10:56:36 -0600 Subject: [PATCH 23/55] Updating the e2e test to align cores on falcon --- data/chsim.json | 4 ++-- test/sim_tests/test_e2e_sim.sh | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/data/chsim.json b/data/chsim.json index f7dd7a3c7..b7a1cccd4 100644 --- a/data/chsim.json +++ b/data/chsim.json @@ -15,8 +15,8 @@ "beacon_position": 0, "bs_server_port": 8100, "bs_rru_port": 8200, - "core_offset": 11, - "worker_thread_num": 10, + "core_offset": 5, + "worker_thread_num": 12, "socket_thread_num": 1, "ue_core_offset": 1, "ue_worker_thread_num": 2, diff --git a/test/sim_tests/test_e2e_sim.sh b/test/sim_tests/test_e2e_sim.sh index 277922c09..7111dce53 100755 --- a/test/sim_tests/test_e2e_sim.sh +++ b/test/sim_tests/test_e2e_sim.sh @@ -17,15 +17,13 @@ done # Setup the config with the number of frames to test -cp data/chsim.json data/bs-sim-tmp.json -cp data/chsim.json data/ue-sim-tmp.json -sed -i '2i\ \ "max_frame": 1000,' data/bs-sim-tmp.json -sed -i '2i\ \ "max_frame": 1000,' data/ue-sim-tmp.json +cp data/chsim.json data/chsim-tmp.json +sed -i '2i\ \ "max_frame": 1000,' data/chsim-tmp.json echo "===========================================" echo "Generating data for emulated RRU end-to-end test with channel simulator ......" echo -e "===========================================\n" -./build/data_generator --conf_file data/bs-sim-tmp.json +./build/data_generator --conf_file data/chsim-tmp.json echo "===========================================" echo "Running emulated RRU end-to-end test with channel simulator ......" @@ -33,15 +31,14 @@ echo -e "===========================================\n" echo "Emulated RRU Test" > test_user_output.txt echo "Emulated RRU Test" > test_agora_output.txt echo "Emulated RRU Test" > test_chsim_output.txt -./build/user --conf_file data/ue-sim-tmp.json >> test_user_output.txt & -sleep 1; ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 4 --core_offset 29 --bs_conf_file data/bs-sim-tmp.json --ue_conf_file data/ue-sim-tmp.json >> test_chsim_output.txt & -sleep 1; ./build/agora --conf_file data/bs-sim-tmp.json >> test_agora_output.txt +./build/user --conf_file data/chsim-tmp.json >> test_user_output.txt & +sleep 1; ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 4 --core_offset 19 --bs_conf_file data/chsim-tmp.json --ue_conf_file data/chsim-tmp.json >> test_chsim_output.txt & +sleep 1; ./build/agora --conf_file data/chsim-tmp.json >> test_agora_output.txt sleep 5; # Agora and User is terminated automatically. Manually terminate chsim -rm data/bs-sim-tmp.json -rm data/ue-sim-tmp.json +rm data/chsim-tmp.json pkill -INT chsim pkill -INT user From 1ba2dce9291b99650597971d1433f280e1164b56 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 21 Dec 2021 13:12:27 -0700 Subject: [PATCH 24/55] Modified UeNum to UeAntNum on the basestation side --- src/agora/agora.cc | 48 +++++++++---------- src/agora/dodemul.cc | 34 ++++++------- src/agora/doprecode.cc | 18 +++---- src/agora/dozf.cc | 18 +++---- src/agora/stats.cc | 4 +- src/common/config.cc | 24 ++++++++++ src/common/config.h | 2 + .../ldpc/test_ldpc_baseband.cc | 2 +- test/compute_kernels/ldpc/test_ldpc_mod.cc | 2 +- test/test_agora/main.cc | 6 +-- test/unit_tests/test_demul_threaded.cc | 2 +- test/unit_tests/test_zf.cc | 4 +- 12 files changed, 95 insertions(+), 69 deletions(-) diff --git a/src/agora/agora.cc b/src/agora/agora.cc index 96451fcab..3b98f2f2e 100644 --- a/src/agora/agora.cc +++ b/src/agora/agora.cc @@ -17,17 +17,17 @@ Agora::Agora(Config* const cfg) config_(cfg), stats_(std::make_unique(cfg)), phy_stats_(std::make_unique(cfg, Direction::Uplink)), - csi_buffers_(kFrameWnd, cfg->UeNum(), + csi_buffers_(kFrameWnd, cfg->UeAntNum(), cfg->BsAntNum() * cfg->OfdmDataNum()), ul_zf_matrices_(kFrameWnd, cfg->OfdmDataNum(), - cfg->BsAntNum() * cfg->UeNum()), - demod_buffers_(kFrameWnd, cfg->Frame().NumULSyms(), cfg->UeNum(), + cfg->BsAntNum() * cfg->UeAntNum()), + demod_buffers_(kFrameWnd, cfg->Frame().NumULSyms(), cfg->UeAntNum(), kMaxModType * cfg->OfdmDataNum()), - decoded_buffer_(kFrameWnd, cfg->Frame().NumULSyms(), cfg->UeNum(), + decoded_buffer_(kFrameWnd, cfg->Frame().NumULSyms(), cfg->UeAntNum(), cfg->LdpcConfig().NumBlocksInSymbol() * Roundup<64>(cfg->NumBytesPerCb())), dl_zf_matrices_(kFrameWnd, cfg->OfdmDataNum(), - cfg->UeNum() * cfg->BsAntNum()) { + cfg->UeAntNum() * cfg->BsAntNum()) { std::string directory = TOSTRING(PROJECT_DIRECTORY); std::printf("Agora: project directory [%s], RDTSC frequency = %.2f GHz\n", directory.c_str(), cfg->FreqGhz()); @@ -102,7 +102,7 @@ void Agora::SendSnrReport(EventType event_type, size_t frame_id, size_t symbol_id) { assert(event_type == EventType::kSNRReport); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); - for (size_t i = 0; i < config_->UeNum(); i++) { + for (size_t i = 0; i < config_->UeAntNum(); i++) { EventData snr_report(EventType::kSNRReport, base_tag.tag_); snr_report.num_tags_ = 2; float snr = this->phy_stats_->GetEvmSnr(frame_id, i); @@ -249,7 +249,7 @@ void Agora::ScheduleCodeblocks(EventType event_type, size_t frame_id, size_t symbol_idx) { auto base_tag = gen_tag_t::FrmSymCb(frame_id, symbol_idx, 0); const size_t num_tasks = - config_->UeNum() * config_->LdpcConfig().NumBlocksInSymbol(); + config_->UeAntNum() * config_->LdpcConfig().NumBlocksInSymbol(); size_t num_blocks = num_tasks / config_->EncodeBlockSize(); const size_t num_remainder = num_tasks % config_->EncodeBlockSize(); if (num_remainder > 0) { @@ -277,7 +277,7 @@ void Agora::ScheduleUsers(EventType event_type, size_t frame_id, assert(event_type == EventType::kPacketToMac); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); - for (size_t i = 0; i < config_->UeNum(); i++) { + for (size_t i = 0; i < config_->UeAntNum(); i++) { TryEnqueueFallback(&mac_request_queue_, EventData(EventType::kPacketToMac, base_tag.tag_)); base_tag.ue_id_++; @@ -642,10 +642,8 @@ void Agora::Start() { cfg->OfdmDataNum() * tx_counters_.MaxSymbolCount() * 1000; MLPD_INFO( - "TX %d samples (per-client) to %zu clients " - "in %f secs, throughtput %f bps per-client " - "(16QAM), current tx queue length %zu\n", - samples_num_per_ue, cfg->UeNum(), diff, + "TX %d samples (per-client) to %zu clients in %f secs, throughtput %f bps per-client (16QAM), current tx queue length %zu\n", + samples_num_per_ue, cfg->UeAntNum(), diff, samples_num_per_ue * std::log2(16.0f) / diff, GetConq(EventType::kPacketTX, 0)->size_approx()); unused(diff); @@ -1361,10 +1359,10 @@ void Agora::InitializeUplinkBuffers() { Agora_memory::Alignment_t::kAlign64); equal_buffer_.Malloc(task_buffer_symbol_num_ul, - cfg->OfdmDataNum() * cfg->UeNum(), + cfg->OfdmDataNum() * cfg->UeAntNum(), Agora_memory::Alignment_t::kAlign64); ue_spec_pilot_buffer_.Calloc( - kFrameWnd, cfg->Frame().ClientUlPilotSymbols() * cfg->UeNum(), + kFrameWnd, cfg->Frame().ClientUlPilotSymbols() * cfg->UeAntNum(), Agora_memory::Alignment_t::kAlign64); rx_counters_.num_pkts_per_frame_ = @@ -1388,9 +1386,9 @@ void Agora::InitializeUplinkBuffers() { demul_counters_.Init(cfg->Frame().NumULSyms(), cfg->DemulEventsPerSymbol()); decode_counters_.Init(cfg->Frame().NumULSyms(), - cfg->LdpcConfig().NumBlocksInSymbol() * cfg->UeNum()); + cfg->LdpcConfig().NumBlocksInSymbol() * cfg->UeAntNum()); - tomac_counters_.Init(cfg->Frame().NumULSyms(), cfg->UeNum()); + tomac_counters_.Init(cfg->Frame().NumULSyms(), cfg->UeAntNum()); } void Agora::InitializeDownlinkBuffers() { @@ -1410,9 +1408,9 @@ void Agora::InitializeDownlinkBuffers() { Agora_memory::Alignment_t::kAlign64, 1); size_t dl_bits_buffer_size = kFrameWnd * config_->DlMacBytesNumPerframe(); - this->dl_bits_buffer_.Calloc(config_->UeNum(), dl_bits_buffer_size, + this->dl_bits_buffer_.Calloc(config_->UeAntNum(), dl_bits_buffer_size, Agora_memory::Alignment_t::kAlign64); - this->dl_bits_buffer_status_.Calloc(config_->UeNum(), kFrameWnd, + this->dl_bits_buffer_status_.Calloc(config_->UeAntNum(), kFrameWnd, Agora_memory::Alignment_t::kAlign64); dl_ifft_buffer_.Calloc(config_->BsAntNum() * task_buffer_symbol_num, @@ -1437,12 +1435,12 @@ void Agora::InitializeDownlinkBuffers() { } dl_encoded_buffer_.Calloc( task_buffer_symbol_num, - Roundup<64>(config_->OfdmDataNum()) * config_->UeNum(), + Roundup<64>(config_->OfdmDataNum()) * config_->UeAntNum(), Agora_memory::Alignment_t::kAlign64); encode_counters_.Init( config_->Frame().NumDlDataSyms(), - config_->LdpcConfig().NumBlocksInSymbol() * config_->UeNum()); + config_->LdpcConfig().NumBlocksInSymbol() * config_->UeAntNum()); encode_cur_frame_for_symbol_ = std::vector(config_->Frame().NumDLSyms(), SIZE_MAX); ifft_cur_frame_for_symbol_ = @@ -1454,7 +1452,7 @@ void Agora::InitializeDownlinkBuffers() { ifft_counters_.Init(config_->Frame().NumDLSyms(), config_->BsAntNum()); tx_counters_.Init(config_->Frame().NumDLSyms(), config_->BsAntNum()); // mac data is sent per frame, so we set max symbol to 1 - mac_to_phy_counters_.Init(1, config_->UeNum()); + mac_to_phy_counters_.Init(1, config_->UeAntNum()); } } @@ -1492,7 +1490,7 @@ void Agora::SaveDecodeDataToFile(int frame_id) { FILE* fp = std::fopen(filename.c_str(), "wb"); for (size_t i = 0; i < cfg->Frame().NumULSyms(); i++) { - for (size_t j = 0; j < cfg->UeNum(); j++) { + for (size_t j = 0; j < cfg->UeAntNum(); j++) { int8_t* ptr = decoded_buffer_[(frame_id % kFrameWnd)][i][j]; std::fwrite(ptr, num_decoded_bytes, sizeof(uint8_t), fp); } @@ -1527,7 +1525,7 @@ void Agora::GetEqualData(float** ptr, int* size) { auto offset = cfg->GetTotalDataSymbolIdxUl( max_equaled_frame_, cfg->Frame().ClientUlPilotSymbols()); *ptr = (float*)&equal_buffer_[offset][0]; - *size = cfg->UeNum() * cfg->OfdmDataNum() * 2; + *size = cfg->UeAntNum() * cfg->OfdmDataNum() * 2; } void Agora::CheckIncrementScheduleFrame(size_t frame_id, ScheduleProcessingFlags completed) { @@ -1574,8 +1572,10 @@ bool Agora::CheckFrameComplete(size_t frame_id) { this->ifft_counters_.Reset(frame_id); this->tx_counters_.Reset(frame_id); if (config_->Frame().NumDLSyms() > 0) { - for (size_t ue_id = 0; ue_id < config_->UeNum(); ue_id++) + for (size_t ue_id = 0; ue_id < config_->UeAntNum(); ue_id++) + { this->dl_bits_buffer_status_[ue_id][frame_id % kFrameWnd] = 0; + } } this->cur_proc_frame_id_++; diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index 8c367c363..f7606786e 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -49,9 +49,9 @@ DoDemul::DoDemul( MKL_Complex8 beta = {0, 0}; mkl_jit_status_t status = mkl_jit_create_cgemm( - &jitter_, MKL_COL_MAJOR, MKL_NOTRANS, MKL_NOTRANS, cfg_->UeNum(), 1, - cfg_->BsAntNum(), &alpha, cfg_->UeNum(), cfg_->BsAntNum(), &beta, - cfg_->UeNum()); + &jitter_, MKL_COL_MAJOR, MKL_NOTRANS, MKL_NOTRANS, cfg_->UeAntNum(), 1, + cfg_->BsAntNum(), &alpha, cfg_->UeAntNum(), cfg_->BsAntNum(), &beta, + cfg_->UeAntNum()); if (MKL_JIT_ERROR == status) { std::fprintf( stderr, @@ -185,13 +185,13 @@ EventData DoDemul::Launch(size_t tag) { if (kExportConstellation) { equal_ptr = (arma::cx_float*)(&equal_buffer_[total_data_symbol_idx_ul] - [cur_sc_id * cfg_->UeNum()]); + [cur_sc_id * cfg_->UeAntNum()]); } else { equal_ptr = (arma::cx_float*)(&equaled_buffer_temp_[(cur_sc_id - base_sc_id) * - cfg_->UeNum()]); + cfg_->UeAntNum()]); } - arma::cx_fmat mat_equaled(equal_ptr, cfg_->UeNum(), 1, false); + arma::cx_fmat mat_equaled(equal_ptr, cfg_->UeAntNum(), 1, false); auto* data_ptr = reinterpret_cast( &data_gather_buffer_[j * cfg_->BsAntNum()]); @@ -206,7 +206,7 @@ EventData DoDemul::Launch(size_t tag) { #else arma::cx_fmat mat_data(data_ptr, cfg_->BsAntNum(), 1, false); - arma::cx_fmat mat_ul_zf(ul_zf_ptr, cfg_->UeNum(), cfg_->BsAntNum(), + arma::cx_fmat mat_ul_zf(ul_zf_ptr, cfg_->UeAntNum(), cfg_->BsAntNum(), false); mat_equaled = mat_ul_zf * mat_data; #endif @@ -217,15 +217,15 @@ EventData DoDemul::Launch(size_t tag) { // Reset previous frame auto* phase_shift_ptr = reinterpret_cast( ue_spec_pilot_buffer_[(frame_id - 1) % kFrameWnd]); - arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeNum(), + arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeAntNum(), cfg_->Frame().ClientUlPilotSymbols(), false); mat_phase_shift.fill(0); } auto* phase_shift_ptr = reinterpret_cast( &ue_spec_pilot_buffer_[frame_id % kFrameWnd] - [symbol_idx_ul * cfg_->UeNum()]); - arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeNum(), 1, false); + [symbol_idx_ul * cfg_->UeAntNum()]); + arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeAntNum(), 1, false); arma::cx_fmat shift_sc = sign(mat_equaled % conj(ue_pilot_data_.col(cur_sc_id))); mat_phase_shift += shift_sc; @@ -234,11 +234,11 @@ EventData DoDemul::Launch(size_t tag) { else if (cfg_->Frame().ClientUlPilotSymbols() > 0) { auto* pilot_corr_ptr = reinterpret_cast( ue_spec_pilot_buffer_[frame_id % kFrameWnd]); - arma::cx_fmat pilot_corr_mat(pilot_corr_ptr, cfg_->UeNum(), + arma::cx_fmat pilot_corr_mat(pilot_corr_ptr, cfg_->UeAntNum(), cfg_->Frame().ClientUlPilotSymbols(), false); arma::fmat theta_mat = arg(pilot_corr_mat); - arma::fmat theta_inc = arma::zeros(cfg_->UeNum(), 1); + arma::fmat theta_inc = arma::zeros(cfg_->UeAntNum(), 1); for (size_t s = 1; s < cfg_->Frame().ClientUlPilotSymbols(); s++) { arma::fmat theta_diff = theta_mat.col(s) - theta_mat.col(s - 1); theta_inc += theta_diff; @@ -268,15 +268,15 @@ EventData DoDemul::Launch(size_t tag) { size_t start_tsc3 = GetTime::WorkerRdtsc(); __m256i index2 = _mm256_setr_epi32( - 0, 1, cfg_->UeNum() * 2, cfg_->UeNum() * 2 + 1, cfg_->UeNum() * 4, - cfg_->UeNum() * 4 + 1, cfg_->UeNum() * 6, cfg_->UeNum() * 6 + 1); + 0, 1, cfg_->UeAntNum() * 2, cfg_->UeAntNum() * 2 + 1, cfg_->UeAntNum() * 4, + cfg_->UeAntNum() * 4 + 1, cfg_->UeAntNum() * 6, cfg_->UeAntNum() * 6 + 1); auto* equal_t_ptr = reinterpret_cast(equaled_buffer_temp_transposed_); - for (size_t i = 0; i < cfg_->UeNum(); i++) { + for (size_t i = 0; i < cfg_->UeAntNum(); i++) { float* equal_ptr = nullptr; if (kExportConstellation) { equal_ptr = reinterpret_cast( &equal_buffer_[total_data_symbol_idx_ul] - [base_sc_id * cfg_->UeNum() + i]); + [base_sc_id * cfg_->UeAntNum() + i]); } else { equal_ptr = reinterpret_cast(equaled_buffer_temp_ + i); } @@ -285,7 +285,7 @@ EventData DoDemul::Launch(size_t tag) { __m256 equal_t_temp = _mm256_i32gather_ps(equal_ptr, index2, 4); _mm256_store_ps(equal_t_ptr, equal_t_temp); equal_t_ptr += 8; - equal_ptr += cfg_->UeNum() * k_num_double_in_sim_d256 * 2; + equal_ptr += cfg_->UeAntNum() * k_num_double_in_sim_d256 * 2; } equal_t_ptr = (float*)(equaled_buffer_temp_transposed_); int8_t* demod_ptr = demod_buffers_[frame_slot][symbol_idx_ul][i] + diff --git a/src/agora/doprecode.cc b/src/agora/doprecode.cc index 2e74b5131..6eef0cdbc 100644 --- a/src/agora/doprecode.cc +++ b/src/agora/doprecode.cc @@ -21,7 +21,7 @@ DoPrecode::DoPrecode( duration_stat_ = in_stats_manager->GetDurationStat(DoerType::kPrecode, in_tid); - AllocBuffer1d(&modulated_buffer_temp_, kSCsPerCacheline * cfg_->UeNum(), + AllocBuffer1d(&modulated_buffer_temp_, kSCsPerCacheline * cfg_->UeAntNum(), Agora_memory::Alignment_t::kAlign64, 0); AllocBuffer1d(&precoded_buffer_temp_, cfg_->DemulBlockSize() * cfg_->BsAntNum(), @@ -30,12 +30,12 @@ DoPrecode::DoPrecode( #if USE_MKL_JIT MKL_Complex8 alpha = {1, 0}; MKL_Complex8 beta = {0, 0}; - // Input: A: BsAntNum() x UeNum() , B: UeNum() x 1 + // Input: A: BsAntNum() x UeAntNum() , B: UeAntNum() x 1 // Output: C: BsAntNum() x 1 // Leading dimensions: A: bs_ant_num(), B: ue_num(), C: bs_ant_num() mkl_jit_status_t status = mkl_jit_create_cgemm( &jitter_, MKL_COL_MAJOR, MKL_NOTRANS, MKL_NOTRANS, cfg_->BsAntNum(), 1, - cfg_->UeNum(), &alpha, cfg_->BsAntNum(), cfg_->UeNum(), &beta, + cfg_->UeAntNum(), &alpha, cfg_->BsAntNum(), cfg_->UeAntNum(), &beta, cfg_->BsAntNum()); if (MKL_JIT_ERROR == status) { @@ -101,7 +101,7 @@ EventData DoPrecode::Launch(size_t tag) { if (kUseSpatialLocality) { for (size_t i = 0; i < max_sc_ite; i = i + kSCsPerCacheline) { size_t start_tsc1 = GetTime::WorkerRdtsc(); - for (size_t user_id = 0; user_id < cfg_->UeNum(); user_id++) { + for (size_t user_id = 0; user_id < cfg_->UeAntNum(); user_id++) { for (size_t j = 0; j < kSCsPerCacheline; j++) { LoadInputData(symbol_idx_dl, total_data_symbol_idx, user_id, base_sc_id + i + j, j); @@ -121,7 +121,7 @@ EventData DoPrecode::Launch(size_t tag) { for (size_t i = 0; i < max_sc_ite; i++) { size_t start_tsc1 = GetTime::WorkerRdtsc(); int cur_sc_id = base_sc_id + i; - for (size_t user_id = 0; user_id < cfg_->UeNum(); user_id++) { + for (size_t user_id = 0; user_id < cfg_->UeAntNum(); user_id++) { LoadInputData(symbol_idx_dl, total_data_symbol_idx, user_id, cur_sc_id, 0); } @@ -167,7 +167,7 @@ void DoPrecode::LoadInputData(size_t symbol_idx_dl, size_t total_data_symbol_idx, size_t user_id, size_t sc_id, size_t sc_id_in_block) { complex_float* data_ptr = - modulated_buffer_temp_ + sc_id_in_block * cfg_->UeNum(); + modulated_buffer_temp_ + sc_id_in_block * cfg_->UeAntNum(); if ((symbol_idx_dl < cfg_->Frame().ClientDlPilotSymbols()) || ((sc_id % cfg_->OfdmPilotSpacing()) == 0)) { data_ptr[user_id] = cfg_->UeSpecificPilot()[user_id][sc_id]; @@ -186,7 +186,7 @@ void DoPrecode::PrecodingPerSc(size_t frame_slot, size_t sc_id, dl_zf_matrices_[frame_slot][cfg_->GetZfScId(sc_id)]); auto* data_ptr = reinterpret_cast( modulated_buffer_temp_ + - (kUseSpatialLocality ? (sc_id_in_block % kSCsPerCacheline * cfg_->UeNum()) + (kUseSpatialLocality ? (sc_id_in_block % kSCsPerCacheline * cfg_->UeAntNum()) : 0)); auto* precoded_ptr = reinterpret_cast( precoded_buffer_temp_ + sc_id_in_block * cfg_->BsAntNum()); @@ -194,9 +194,9 @@ void DoPrecode::PrecodingPerSc(size_t frame_slot, size_t sc_id, my_cgemm_(jitter_, (MKL_Complex8*)precoder_ptr, (MKL_Complex8*)data_ptr, (MKL_Complex8*)precoded_ptr); #else - arma::cx_fmat mat_precoder(precoder_ptr, cfg_->BsAntNum(), cfg_->UeNum(), + arma::cx_fmat mat_precoder(precoder_ptr, cfg_->BsAntNum(), cfg_->UeAntNum(), false); - arma::cx_fmat mat_data(data_ptr, cfg_->UeNum(), 1, false); + arma::cx_fmat mat_data(data_ptr, cfg_->UeAntNum(), 1, false); arma::cx_fmat mat_precoded(precoded_ptr, cfg_->BsAntNum(), 1, false); mat_precoded = mat_precoder * mat_data; // cout << "Precoder: \n" << mat_precoder << endl; diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index db37a24e8..825c4c308 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -82,7 +82,7 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, complex_float* calib_ptr, complex_float* _mat_ul_zf, complex_float* _mat_dl_zf) { arma::cx_fmat mat_ul_zf(reinterpret_cast(_mat_ul_zf), - cfg_->UeNum(), cfg_->BsAntNum(), false); + cfg_->UeAntNum(), cfg_->BsAntNum(), false); arma::cx_fmat mat_ul_zf_tmp; if (kUseInverseForZF != 0u) { try { @@ -124,19 +124,19 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, for (size_t i = 0; i < cfg_->NumCells(); i++) { if (cfg_->ExternalRefNode(i) == true) { mat_dl_zf_tmp.insert_cols( - cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), + cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), arma::fill::zeros)); } } arma::cx_fmat mat_dl_zf(reinterpret_cast(_mat_dl_zf), - cfg_->BsAntNum(), cfg_->UeNum(), false); + cfg_->BsAntNum(), cfg_->UeAntNum(), false); mat_dl_zf = mat_dl_zf_tmp.st(); } for (int i = (int)cfg_->NumCells() - 1; i >= 0; i--) { if (cfg_->ExternalRefNode(i) == true) { mat_ul_zf_tmp.insert_cols( cfg_->RefAnt(i), - arma::cx_fmat(cfg_->UeNum(), cfg_->NumChannels(), arma::fill::zeros)); + arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), arma::fill::zeros)); } } mat_ul_zf = mat_ul_zf_tmp; @@ -307,7 +307,7 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { const size_t cur_sc_id = base_sc_id + i; // Gather CSI matrices of each pilot from partially-transposed CSIs. - for (size_t ue_idx = 0; ue_idx < cfg_->UeNum(); ue_idx++) { + for (size_t ue_idx = 0; ue_idx < cfg_->UeAntNum(); ue_idx++) { auto* dst_csi_ptr = reinterpret_cast(csi_gather_buffer_ + cfg_->BsAntNum() * ue_idx); if (kUsePartialTrans) { @@ -324,7 +324,7 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { duration_stat_->task_duration_[1] += start_tsc2 - start_tsc1; arma::cx_fmat mat_csi((arma::cx_float*)csi_gather_buffer_, cfg_->BsAntNum(), - cfg_->UeNum(), false); + cfg_->UeAntNum(), false); if (cfg_->Frame().NumDLSyms() > 0) { ComputeCalib(frame_id, cur_sc_id); @@ -358,14 +358,14 @@ void DoZF::ZfFreqOrthogonal(size_t tag) { std::printf( "In doZF thread %d: frame: %zu, subcarrier: %zu, block: %zu, " "Basestation ant number: %zu\n", - tid_, frame_id, base_sc_id, base_sc_id / cfg_->UeNum(), + tid_, frame_id, base_sc_id, base_sc_id / cfg_->UeAntNum(), cfg_->BsAntNum()); } double start_tsc1 = GetTime::WorkerRdtsc(); // Gather CSIs from partially-transposed CSIs - for (size_t i = 0; i < cfg_->UeNum(); i++) { + for (size_t i = 0; i < cfg_->UeAntNum(); i++) { const size_t cur_sc_id = base_sc_id + i; auto* dst_csi_ptr = reinterpret_cast(csi_gather_buffer_ + cfg_->BsAntNum() * i); @@ -416,7 +416,7 @@ void DoZF::ZfFreqOrthogonal(size_t tag) { duration_stat_->task_duration_[2] += start_tsc3 - start_tsc2; arma::cx_fmat mat_csi(reinterpret_cast(csi_gather_buffer_), - cfg_->BsAntNum(), cfg_->UeNum(), false); + cfg_->BsAntNum(), cfg_->UeAntNum(), false); ComputePrecoder(mat_csi, calib_gather_buffer_, ul_zf_matrices_[frame_slot][cfg_->GetZfScId(base_sc_id)], diff --git a/src/agora/stats.cc b/src/agora/stats.cc index ea09f586b..e8e937315 100644 --- a/src/agora/stats.cc +++ b/src/agora/stats.cc @@ -363,7 +363,7 @@ void Stats::PrintSummary() { (static_cast( num_tasks.at(static_cast(DoerType::kEncode)))) / (this->config_->LdpcConfig().NumBlocksInSymbol() * - this->config_->UeNum() * this->config_->Frame().NumDLSyms()); + this->config_->UeAntNum() * this->config_->Frame().NumDLSyms()); std::printf("Downlink totals (tasks, frames): "); std::printf("CSI (%zu, %.2f), ", num_tasks.at(static_cast(DoerType::kCSI)), @@ -395,7 +395,7 @@ void Stats::PrintSummary() { (static_cast( num_tasks.at(static_cast(DoerType::kDecode)))) / (this->config_->LdpcConfig().NumBlocksInSymbol() * - this->config_->UeNum() * this->config_->Frame().NumULSyms()); + this->config_->UeAntNum() * this->config_->Frame().NumULSyms()); std::printf("Uplink totals (tasks, frames): "); std::printf("CSI (%zu, %.2f), ", num_tasks.at(static_cast(DoerType::kCSI)), diff --git a/src/common/config.cc b/src/common/config.cc index b5ccf4928..c8a4e6e99 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -562,6 +562,8 @@ Config::Config(const std::string& jsonfile) (this->GetFrameDurationSec() * 1e6), (dl_mac_data_bytes_num_perframe_ * 8.0f) / (this->GetFrameDurationSec() * 1e6)); + + Print(); } void Config::GenData() { @@ -1127,6 +1129,28 @@ SymbolType Config::GetSymbolType(size_t symbol_id) const { return kSymbolMap.at(this->frame_.FrameIdentifier().at(symbol_id)); } +void Config::Print( ) const +{ + std::cout << "Freq Ghz: " << freq_ghz_ << std::endl + << "BaseStation ant num: " << bs_ant_num_ << std::endl + << "BeamForming ant num: " << bf_ant_num_ << std::endl + << "Ue num: " << ue_num_ << std::endl + << "Ue ant num: " << ue_ant_num_ << std::endl + << "Ue ant total: " << ue_ant_total_ << std::endl + << "Ue ant offset: " << ue_ant_offset_ << std::endl + << "OFDM Ca num: " << ofdm_ca_num_ << std::endl + << "Cp Len: " << cp_len_ << std::endl + << "Ofdm data num: " << ofdm_data_num_ << std::endl + << "Ofdm data start: " << ofdm_data_start_ << std::endl + << "Ofdm data stop: " << ofdm_data_stop_ << std::endl + << "Ofdm pilot spacing: " << ofdm_pilot_spacing_ << std::endl + << "Hardware framer: " << hw_framer_ << std::endl + << "Ue Hardware framer: " << ue_hw_framer_ << std::endl + << "Freq: " << freq_ << std::endl + << "Rate: " << rate_ << std::endl; +} + + extern "C" { __attribute__((visibility("default"))) Config* ConfigNew(char* filename) { auto* cfg = new Config(filename); diff --git a/src/common/config.h b/src/common/config.h index 981a482c8..6f0ec77dc 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -394,6 +394,8 @@ class Config { } private: + void Print() const; + /* Class constants */ inline static const size_t kDefaultSymbolNumPerFrame = 70; inline static const size_t kDefaultPilotSymPerFrame = 8; diff --git a/test/compute_kernels/ldpc/test_ldpc_baseband.cc b/test/compute_kernels/ldpc/test_ldpc_baseband.cc index e9bc948d6..a56a251de 100644 --- a/test/compute_kernels/ldpc/test_ldpc_baseband.cc +++ b/test/compute_kernels/ldpc/test_ldpc_baseband.cc @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) { std::vector> encoded_codewords(num_codeblocks); for (size_t i = 0; i < num_codeblocks; i++) { data_generator.GenRawData(information.at(i), - i % cfg->UeNum() /* UE ID */); + i % cfg->UeAntNum() /* UE ID */); std::memcpy(input_ptr, information.at(i).data(), input_size); data_generator.GenCodeblock(input_ptr, encoded_codewords.at(i)); } diff --git a/test/compute_kernels/ldpc/test_ldpc_mod.cc b/test/compute_kernels/ldpc/test_ldpc_mod.cc index fa0f0d5ff..5fa6fecd3 100644 --- a/test/compute_kernels/ldpc/test_ldpc_mod.cc +++ b/test/compute_kernels/ldpc/test_ldpc_mod.cc @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) { std::vector> encoded_codewords(num_codeblocks); for (size_t i = 0; i < num_codeblocks; i++) { data_generator.GenRawData(information.at(i), - i % cfg->UeNum() /* UE ID */); + i % cfg->UeAntNum() /* UE ID */); std::memcpy(input_ptr, information.at(i).data(), input_size); data_generator.GenCodeblock(input_ptr, encoded_codewords.at(i)); } diff --git a/test/test_agora/main.cc b/test/test_agora/main.cc index 22de056e1..40fa9fe71 100644 --- a/test/test_agora/main.cc +++ b/test/test_agora/main.cc @@ -30,7 +30,7 @@ static void ReadFromFile(const std::string& filename, Table& data, static void ReadFromFileUl(const std::string& filename, Table& data, int num_bytes_per_ue, Config const* const cfg) { ReadFromFile(filename, data, cfg->Frame().NumULSyms(), - (num_bytes_per_ue * cfg->UeNum()), sizeof(uint8_t)); + (num_bytes_per_ue * cfg->UeAntNum()), sizeof(uint8_t)); } static void ReadFromFileDl(const std::string& filename, Table& data, @@ -40,7 +40,7 @@ static void ReadFromFileDl(const std::string& filename, Table& data, } static unsigned int CheckCorrectnessUl(Config const* const cfg) { - int ue_num = cfg->UeNum(); + int ue_num = cfg->UeAntNum(); int num_uplink_syms = cfg->Frame().NumULSyms(); int ofdm_data_num = cfg->OfdmDataNum(); int ul_pilot_syms = cfg->Frame().ClientUlPilotSymbols(); @@ -48,7 +48,7 @@ static unsigned int CheckCorrectnessUl(Config const* const cfg) { std::string cur_directory = TOSTRING(PROJECT_DIRECTORY); std::string raw_data_filename = cur_directory + "/data/LDPC_orig_ul_data_" + std::to_string(cfg->OfdmCaNum()) + "_ant" + - std::to_string(cfg->UeNum()) + ".bin"; + std::to_string(cfg->UeAntNum()) + ".bin"; std::string output_data_filename = cur_directory + "/data/decode_data.bin"; Table raw_data; diff --git a/test/unit_tests/test_demul_threaded.cc b/test/unit_tests/test_demul_threaded.cc index 1912a1f9d..5fe2d3b3d 100644 --- a/test/unit_tests/test_demul_threaded.cc +++ b/test/unit_tests/test_demul_threaded.cc @@ -136,7 +136,7 @@ TEST(TestDemul, VaryingConfig) { cfg->Frame().ClientUlPilotSymbols() * kMaxUEs, Agora_memory::Alignment_t::kAlign64); PtrCube demod_buffers( - kFrameWnd, cfg->Frame().NumTotalSyms(), cfg->UeNum(), + kFrameWnd, cfg->Frame().NumTotalSyms(), cfg->UeAntNum(), kMaxModType * cfg->OfdmDataNum()); std::printf( "Size of [data_buffer, ul_zf_matrices, equal_buffer, " diff --git a/test/unit_tests/test_zf.cc b/test/unit_tests/test_zf.cc index 84475b5f1..342aad025 100644 --- a/test/unit_tests/test_zf.cc +++ b/test/unit_tests/test_zf.cc @@ -18,9 +18,9 @@ TEST(TestZF, Perf) { csi_buffers.RandAllocCxFloat(cfg->BsAntNum() * cfg->OfdmDataNum()); PtrGrid ul_zf_matrices( - cfg->BsAntNum() * cfg->UeNum()); + cfg->BsAntNum() * cfg->UeAntNum()); PtrGrid dl_zf_matrices( - cfg->UeNum() * cfg->BsAntNum()); + cfg->UeAntNum() * cfg->BsAntNum()); Table calib_dl_msum_buffer; calib_dl_msum_buffer.RandAllocCxFloat(kFrameWnd, From 9dcf78e538e1e7add3efbf2d5fd4e748a0c414f5 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 21 Dec 2021 15:55:54 -0700 Subject: [PATCH 25/55] Config updates --- data/{bs-ul-powder-2.json => ul-powder.json} | 4 +++- src/client/phy-ue.cc | 5 +++-- src/client/txrx_client.cc | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) rename data/{bs-ul-powder-2.json => ul-powder.json} (94%) diff --git a/data/bs-ul-powder-2.json b/data/ul-powder.json similarity index 94% rename from data/bs-ul-powder-2.json rename to data/ul-powder.json index 459d3ad8b..7ade332db 100644 --- a/data/bs-ul-powder-2.json +++ b/data/ul-powder.json @@ -46,14 +46,16 @@ 140, 140 ], + "ue_hw_framer": false, "ue_worker_thread_num": 4, "ue_demul_block_size": 48, "ue_core_offset": 0, /* Compute configuration */ + "hw_framer": true, "core_offset": 16, "exclude_cores": [], "worker_thread_num": 12, - /* 22 bs radios */ + /* 21 bs radios */ "socket_thread_num": 6, "max_frame": 10000 } \ No newline at end of file diff --git a/src/client/phy-ue.cc b/src/client/phy-ue.cc index 135e50b01..53aa2e65f 100644 --- a/src/client/phy-ue.cc +++ b/src/client/phy-ue.cc @@ -61,9 +61,9 @@ PhyUe::PhyUe(Config* config) kFrameWnd * config_->Frame().NumTotalSyms() * config_->UeAntNum() * kDefaultQueueSize); tx_queue_ = moodycamel::ConcurrentQueue( - kFrameWnd * config_->UeNum() * kDefaultQueueSize); + kFrameWnd * config_->UeAntNum() * kDefaultQueueSize); to_mac_queue_ = moodycamel::ConcurrentQueue( - kFrameWnd * config_->UeNum() * kDefaultQueueSize); + kFrameWnd * config_->UeAntNum() * kDefaultQueueSize); for (size_t i = 0; i < rx_thread_num_; i++) { rx_ptoks_ptr_[i] = new moodycamel::ProducerToken(complete_queue_); @@ -118,6 +118,7 @@ PhyUe::PhyUe(Config* config) config_->UeAntNum()); fft_dldata_counters_.Init(dl_data_symbol_perframe_, config_->UeAntNum()); + /* Each UE / Radio will send a TxComplete */ tx_counters_.Init(config_->UeNum()); encode_counter_.Init(ul_data_symbol_perframe_, config_->UeNum()); modulation_counters_.Init(ul_data_symbol_perframe_, config_->UeNum()); diff --git a/src/client/txrx_client.cc b/src/client/txrx_client.cc index 6072cf243..afdbb20be 100644 --- a/src/client/txrx_client.cc +++ b/src/client/txrx_client.cc @@ -433,7 +433,7 @@ struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, void* RadioTxRx::LoopTxRxArgos(size_t tid) { PinToCoreWithOffset(ThreadType::kWorkerTXRX, core_id_, tid); auto& c = config_; - size_t num_radios = c->UeNum(); + const size_t num_radios = c->UeNum(); size_t radio_lo = tid * num_radios / thread_num_; size_t radio_hi = (tid + 1) * num_radios / thread_num_; std::printf("RadioTxRx thread %zu has radios %zu to %zu (%zu)\n", tid, From 3dcf5529a9706e032c23297cb91136209dda3d1c Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 21 Dec 2021 16:52:38 -0700 Subject: [PATCH 26/55] working uplink --- data/dl-powder.json | 97 ++++++++++++++++++++++-------------- data/topology-powder-dl.json | 48 ++++++++++++++++++ data/ul-powder.json | 16 +++--- 3 files changed, 117 insertions(+), 44 deletions(-) create mode 100644 data/topology-powder-dl.json diff --git a/data/dl-powder.json b/data/dl-powder.json index 363e33657..00a6c527b 100644 --- a/data/dl-powder.json +++ b/data/dl-powder.json @@ -1,40 +1,63 @@ { - "serial_file" : "data/topology-powder.json", - "cells" : 1, - "channel" : "A", - "frequency" : 3.6e9, - "rx_gain_a" : 65, - "tx_gain_a" : 70, - "rx_gain_b" : 65, - "tx_gain_b" : 70, - "sample_rate" : 5e6, - "ofdm_tx_zero_prefix" : 160, - "ofdm_tx_zero_postfix" : 160, - "ofdm_rx_zero_prefix_bs" : 160, - "ofdm_rx_zero_prefix_cal_dl" : 288, - "ofdm_rx_zero_prefix_cal_ul" : 168, - "cp_size" : 32, - "fft_size" : 2048, - "ofdm_data_num" : 1200, - "modulation" : "16QAM", - "Zc" : 72, - "beamsweep" : false, - "beacon_antenna" : 0, + "serial_file": "data/topology-powder-dl.json", + "cells": 1, + "channel": "A", + "frequency": 3.6e9, + "rx_gain_a": 65, + "tx_gain_a": 80, + "rx_gain_b": 65, + "tx_gain_b": 80, + "sample_rate": 5e6, + "ofdm_tx_zero_prefix": 160, + "ofdm_tx_zero_postfix": 160, + "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_client": 160, + "ofdm_rx_zero_prefix_cal_dl": 288, + "ofdm_rx_zero_prefix_cal_ul": 168, + "cp_size": 32, + "fft_size": 2048, + "ofdm_data_num": 1200, + "modulation": "16QAM", + "Zc": 72, + "beamsweep": false, + "beacon_antenna": 0, "frame_schedule": [ - "BGCLGGPPGGDDDGG" + "BCLGPPGGDDDGG" ], - "client_dl_pilot_syms" : 2, - "socket_thread_num" : 1, - "worker_thread_num" : 16, - "core_offset" : 10, - "demul_block_size" : 48, - "ue_channel" : "A", - "ue_rx_gain_a" : [65, 65], - "ue_tx_gain_a" : [70, 70], - "ue_rx_gain_b" : [65, 65], - "ue_tx_gain_b" : [70, 70], - "hw_framer": false, - "tx_advance" : [140, 140], - "ue_core_offset" : 28, - "ue_worker_thread_num" : 2 -} + "client_dl_pilot_syms": 2, + "demul_block_size": 48, + "ue_demul_block_size": 48, + "ue_channel": "A", + "ue_rx_gain_a": [ + 65, + 65 + ], + "ue_tx_gain_a": [ + 80, + 80 + ], + "ue_rx_gain_b": [ + 65, + 65 + ], + "ue_tx_gain_b": [ + 80, + 80 + ], + "tx_advance": [ + 140, + 140 + ], + "ue_hw_framer": false, + "hw_framer": true, + /* Compute configuration */ + "exclude_cores": [], + "ue_core_offset": 12, + "ue_worker_thread_num": 4, + "ue_socket_thread_num": 2, + "core_offset": 16, + "worker_thread_num": 16, + /* 22 bs radios + 1 ref*/ + "socket_thread_num": 6, + "max_frame": 10000 +} \ No newline at end of file diff --git a/data/topology-powder-dl.json b/data/topology-powder-dl.json new file mode 100644 index 000000000..d21feed66 --- /dev/null +++ b/data/topology-powder-dl.json @@ -0,0 +1,48 @@ +{ + "BaseStations": { + "BS0": { + "hub": "FH4B000021", + "rrh": [ + "RH6A000010", + "RH6A000019", + "RH6A000018", + "RH6A000011", + "RH6A000016", + "RH6A000017" + ], + "sdr": [ + "RF3E000246", + "RF3E000490", + "RF3E000749", + "RF3E000697", + "RF3E000724", + "RF3E000740", + "RF3E000532", + "RF3E000716", + "RF3E000674", + "RF3E000704", + "RF3E000676", + /*"RF3E000668",*/ + "RF3E000340", + "RF3E000744", + "RF3E000161", + "RF3E000735", + "RF3E000387", + "RF3E000389", + "RF3E000206", + "RF3E000211", + "RF3E000256", + "RF3E000383", + "RF3E000304" + /*"RF3E000303"*/ + ], + "reference": "RF3E000157" + } + }, + "Clients": { + "sdr": [ + "RF3E000119", + "RF3E000145" + ] + } +} \ No newline at end of file diff --git a/data/ul-powder.json b/data/ul-powder.json index 7ade332db..468e034c2 100644 --- a/data/ul-powder.json +++ b/data/ul-powder.json @@ -14,10 +14,12 @@ "ofdm_data_num": 1200, "modulation": "16QAM", "demul_block_size": 48, + "ue_demul_block_size": 48, "Zc": 72, "ofdm_tx_zero_prefix": 160, "ofdm_tx_zero_postfix": 160, "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_client": 160, "frame_schedule": [ "BGGGGGPPPPGGGUUUGGG" ], @@ -47,15 +49,15 @@ 140 ], "ue_hw_framer": false, - "ue_worker_thread_num": 4, - "ue_demul_block_size": 48, - "ue_core_offset": 0, - /* Compute configuration */ "hw_framer": true, - "core_offset": 16, + /* Compute configuration */ "exclude_cores": [], - "worker_thread_num": 12, - /* 21 bs radios */ + "ue_core_offset": 12, + "ue_worker_thread_num": 4, + "ue_socket_thread_num": 2, + "core_offset": 16, + "worker_thread_num": 12 + /* 21 bs radios */ , "socket_thread_num": 6, "max_frame": 10000 } \ No newline at end of file From aa94bf712e40167e68d57c2595262ad27ebdc226 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Wed, 22 Dec 2021 06:00:22 -0700 Subject: [PATCH 27/55] working --- data/dl-powder.json | 2 -- data/ul-powder.json | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/data/dl-powder.json b/data/dl-powder.json index 00a6c527b..4cbc3bd08 100644 --- a/data/dl-powder.json +++ b/data/dl-powder.json @@ -11,7 +11,6 @@ "ofdm_tx_zero_prefix": 160, "ofdm_tx_zero_postfix": 160, "ofdm_rx_zero_prefix_bs": 160, - "ofdm_rx_zero_prefix_client": 160, "ofdm_rx_zero_prefix_cal_dl": 288, "ofdm_rx_zero_prefix_cal_ul": 168, "cp_size": 32, @@ -54,7 +53,6 @@ "exclude_cores": [], "ue_core_offset": 12, "ue_worker_thread_num": 4, - "ue_socket_thread_num": 2, "core_offset": 16, "worker_thread_num": 16, /* 22 bs radios + 1 ref*/ diff --git a/data/ul-powder.json b/data/ul-powder.json index 468e034c2..a77d3865b 100644 --- a/data/ul-powder.json +++ b/data/ul-powder.json @@ -19,7 +19,6 @@ "ofdm_tx_zero_prefix": 160, "ofdm_tx_zero_postfix": 160, "ofdm_rx_zero_prefix_bs": 160, - "ofdm_rx_zero_prefix_client": 160, "frame_schedule": [ "BGGGGGPPPPGGGUUUGGG" ], @@ -54,10 +53,9 @@ "exclude_cores": [], "ue_core_offset": 12, "ue_worker_thread_num": 4, - "ue_socket_thread_num": 2, "core_offset": 16, - "worker_thread_num": 12 - /* 21 bs radios */ , + "worker_thread_num": 12, + /* 21 bs radios */ "socket_thread_num": 6, "max_frame": 10000 } \ No newline at end of file From 2cde53c54d566de9ee12ecec416763e8754b8c05 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Wed, 22 Dec 2021 08:41:55 -0700 Subject: [PATCH 28/55] working uplink and downlink --- data/dl-powder.json | 7 ++++--- data/topology-powder-dl.json | 12 ++++++------ data/ul-powder.json | 2 +- src/common/symbols.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/data/dl-powder.json b/data/dl-powder.json index 4cbc3bd08..41bc8cd5e 100644 --- a/data/dl-powder.json +++ b/data/dl-powder.json @@ -4,13 +4,14 @@ "channel": "A", "frequency": 3.6e9, "rx_gain_a": 65, - "tx_gain_a": 80, + "tx_gain_a": 75, "rx_gain_b": 65, "tx_gain_b": 80, "sample_rate": 5e6, "ofdm_tx_zero_prefix": 160, "ofdm_tx_zero_postfix": 160, "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_client": 160, "ofdm_rx_zero_prefix_cal_dl": 288, "ofdm_rx_zero_prefix_cal_ul": 168, "cp_size": 32, @@ -54,8 +55,8 @@ "ue_core_offset": 12, "ue_worker_thread_num": 4, "core_offset": 16, - "worker_thread_num": 16, + "worker_thread_num": 12, /* 22 bs radios + 1 ref*/ - "socket_thread_num": 6, + "socket_thread_num": 3, "max_frame": 10000 } \ No newline at end of file diff --git a/data/topology-powder-dl.json b/data/topology-powder-dl.json index d21feed66..d780d05f4 100644 --- a/data/topology-powder-dl.json +++ b/data/topology-powder-dl.json @@ -19,10 +19,10 @@ "RF3E000740", "RF3E000532", "RF3E000716", - "RF3E000674", + /*"RF3E000674", "RF3E000704", "RF3E000676", - /*"RF3E000668",*/ + "RF3E000668",*/ "RF3E000340", "RF3E000744", "RF3E000161", @@ -30,11 +30,11 @@ "RF3E000387", "RF3E000389", "RF3E000206", - "RF3E000211", - "RF3E000256", + "RF3E000211" + /*"RF3E000256", "RF3E000383", - "RF3E000304" - /*"RF3E000303"*/ + "RF3E000304", + "RF3E000303"*/ ], "reference": "RF3E000157" } diff --git a/data/ul-powder.json b/data/ul-powder.json index a77d3865b..998da1c84 100644 --- a/data/ul-powder.json +++ b/data/ul-powder.json @@ -54,7 +54,7 @@ "ue_core_offset": 12, "ue_worker_thread_num": 4, "core_offset": 16, - "worker_thread_num": 12, + "worker_thread_num": 16, /* 21 bs radios */ "socket_thread_num": 6, "max_frame": 10000 diff --git a/src/common/symbols.h b/src/common/symbols.h index d9f7c91ea..c66bc2bdf 100644 --- a/src/common/symbols.h +++ b/src/common/symbols.h @@ -150,7 +150,7 @@ static constexpr bool kUsePartialTrans = true; static constexpr bool kExportConstellation = false; static constexpr bool kPrintPhyStats = true; static constexpr bool kCollectPhyStats = true; -static constexpr bool kPrintZfStats = false; +static constexpr bool kPrintZfStats = true; static constexpr bool kStatsPrintFrameSummary = true; static constexpr bool kDebugPrintPerFrameDone = true; From 44d3bab79e86aec46169c4274acca25c962cc5bd Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Wed, 22 Dec 2021 11:14:53 -0600 Subject: [PATCH 29/55] Updated radio layout --- data/topology-vulture-ul.json | 44 ++++++++++++++++++++++++ data/ul-vulture.json | 63 +++++++++++++++++++++++++++++++++++ src/common/config.cc | 43 ++++++++++++++++++++---- 3 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 data/topology-vulture-ul.json create mode 100644 data/ul-vulture.json diff --git a/data/topology-vulture-ul.json b/data/topology-vulture-ul.json new file mode 100644 index 000000000..55fe20918 --- /dev/null +++ b/data/topology-vulture-ul.json @@ -0,0 +1,44 @@ +{ + "BaseStations": { + "BS0": { + "hub": "FH4B000019", + "rrh": [ + "RH6A000001", + "RH6A000020", + "RH6A000010", + "RH6A000004", + "RH6A000002" + ], + "sdr": [ + "RF3E000087", + "RF3E000084", + "RF3E000107", + "RF3E000086", + "RF3E000110", + "RF3E000162", + "RF3E000127", + "RF3E000597", + "RF3E000346", + "RF3E000543", + "RF3E000594", + "RF3E000404", + "RF3E000616", + "RF3E000622", + "RF3E000601", + "RF3E000602", + "RF3E000146", + "RF3E000122", + "RF3E000150", + "RF3E000128", + "RF3E000168" + ], + "reference": "RF3E000087" + } + }, + "Clients": { + "sdr": [ + "RF3E000164", + "RF3E000241" + ] + } +} \ No newline at end of file diff --git a/data/ul-vulture.json b/data/ul-vulture.json new file mode 100644 index 000000000..76eb017e8 --- /dev/null +++ b/data/ul-vulture.json @@ -0,0 +1,63 @@ +{ + "serial_file": "data/topology-vulture-ul.json", + "cells": 1, + "channel": "AB", + "frequency": 3.56e9, + "single_gain": true, + "rx_gain_a": 60, + "tx_gain_a": 75, + "rx_gain_b": 60, + "tx_gain_b": 75, + "sample_rate": 5e6, + "cp_size": 32, + "fft_size": 2048, + "ofdm_data_num": 1200, + "modulation": "16QAM", + "demul_block_size": 48, + "ue_demul_block_size": 48, + "Zc": 72, + "ofdm_tx_zero_prefix": 160, + "ofdm_tx_zero_postfix": 160, + "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_client": 160, + "frame_schedule": [ + "BGGGGGPPPPGGGUUUGGG" + ], + "client_ul_pilot_syms": 2, + "beamsweep": false, + "beacon_antenna": 0, + /* UE configuration */ + "ue_channel": "AB", + "ue_rx_gain_a": [ + 65, + 65 + ], + "ue_tx_gain_a": [ + 75, + 75 + ], + "ue_rx_gain_b": [ + 65, + 65 + ], + "ue_tx_gain_b": [ + 75, + 75 + ], + "tx_advance": [ + 140, + 140 + ], + "ue_hw_framer": false, + "hw_framer": true, + /* Compute configuration */ + "exclude_cores": [], + "ue_core_offset": 0, + "ue_worker_thread_num": 4, + "ue_socket_thread_num": 2, + "core_offset": 0, + "worker_thread_num": 4, + /* 21 bs radios */ + "socket_thread_num": 2, + "max_frame": 5000 +} \ No newline at end of file diff --git a/src/common/config.cc b/src/common/config.cc index c8a4e6e99..417c87383 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -248,8 +248,8 @@ Config::Config(const std::string& jsonfile) correct_phase_shift_ = tdd_conf.value("correct_phase_shift", false); hw_framer_ = tdd_conf.value("hw_framer", true); - if (kUseUHD) { - hw_framer_ = false; + if (kUseUHD) { + hw_framer_ = false; } ue_hw_framer_ = tdd_conf.value("ue_hw_framer", false); @@ -290,7 +290,8 @@ Config::Config(const std::string& jsonfile) if ((ul_data_symbol_num_perframe + dl_data_symbol_num_perframe + pilot_symbol_num_perframe) > symbol_num_perframe) { MLPD_ERROR( - "!!!!! Invalid configuration pilot + ul + dl exceeds total symbols !!!!!\n"); + "!!!!! Invalid configuration pilot + ul + dl exceeds total symbols " + "!!!!!\n"); MLPD_ERROR( "Uplink symbols: %zu, Downlink Symbols :%zu, Pilot Symbols: %zu, " "Total Symbols: %zu\n", @@ -1129,8 +1130,7 @@ SymbolType Config::GetSymbolType(size_t symbol_id) const { return kSymbolMap.at(this->frame_.FrameIdentifier().at(symbol_id)); } -void Config::Print( ) const -{ +void Config::Print() const { std::cout << "Freq Ghz: " << freq_ghz_ << std::endl << "BaseStation ant num: " << bs_ant_num_ << std::endl << "BeamForming ant num: " << bf_ant_num_ << std::endl @@ -1147,10 +1147,39 @@ void Config::Print( ) const << "Hardware framer: " << hw_framer_ << std::endl << "Ue Hardware framer: " << ue_hw_framer_ << std::endl << "Freq: " << freq_ << std::endl - << "Rate: " << rate_ << std::endl; + << "Rate: " << rate_ << std::endl + << "NCO: " << nco_ << std::endl + << "Scrambler Enabled: " << scramble_enabled_ << std::endl + << "Radio Rf Freq: " << radio_rf_freq_ << std::endl + << "Bw filter: " << bw_filter_ << std::endl + << "Single Gain: " << single_gain_ << std::endl + << "Tx Gain A: " << tx_gain_a_ << std::endl + << "Rx Gain A: " << rx_gain_a_ << std::endl + << "Tx Gain B: " << tx_gain_b_ << std::endl + << "Rx Gain B: " << rx_gain_b_ << std::endl + << "Calib Tx Gain A: " << calib_tx_gain_a_ << std::endl + << "Calib Tx Gain B: " << calib_tx_gain_b_ << std::endl + << "Num Cells: " << num_cells_ << std::endl + << "Num Bs Radios: " << num_radios_ << std::endl + << "Num Bs Channels: " << num_channels_ << std::endl + << "Num Ue Channels: " << num_ue_channels_ << std::endl + << "Beacon Ant: " << beacon_ant_ << std::endl + << "Beacon len: " << beacon_len_ << std::endl + << "Calib init repeat: " << init_calib_repeat_ << std::endl + << "Beamsweep " << beamsweep_ << std::endl + << "Sample Cal En: " << sample_cal_en_ << std::endl + << "Imbalance Cal: " << imbalance_cal_en_ << std::endl + << "Bs Channel: " << channel_ << std::endl + << "Ue Channel: " << ue_channel_ << std::endl + << "Ant Group num: " << ant_group_num_ << std::endl + << "Ant Per Group: " << ant_per_group_ << std::endl + << "Max Frames: " << frames_to_test_ << std::endl + << "Transport Block Size: " << transport_block_size_ << std::endl + << "Noise Level: " << noise_level_ << std::endl + << "Bytes per CB: " << num_bytes_per_cb_ << std::endl + << "FFT in rru: " << fft_in_rru_ << std::endl; } - extern "C" { __attribute__((visibility("default"))) Config* ConfigNew(char* filename) { auto* cfg = new Config(filename); From 7360d3880c5fb3f089768ba1b941e943529a9823 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Thu, 23 Dec 2021 10:44:17 -0600 Subject: [PATCH 30/55] Corrected formatting --- simulator/channel_sim.h | 1 - src/agora/agora.cc | 12 +++++++----- src/agora/dodemul.cc | 10 ++++++---- src/agora/doprecode.cc | 5 +++-- src/agora/dozf.cc | 9 +++++---- src/agora/radio_lib.cc | 4 ++-- src/client/client_radio.cc | 3 --- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/simulator/channel_sim.h b/simulator/channel_sim.h index ccc0ad838..dada322e2 100644 --- a/simulator/channel_sim.h +++ b/simulator/channel_sim.h @@ -99,7 +99,6 @@ class ChannelSim { const Config* const uecfg_; std::unique_ptr channel_; - // Data buffer for received symbols from BS antennas (downlink) AlignedByteVector rx_buffer_bs_; diff --git a/src/agora/agora.cc b/src/agora/agora.cc index 3b98f2f2e..fd4e6a247 100644 --- a/src/agora/agora.cc +++ b/src/agora/agora.cc @@ -642,7 +642,9 @@ void Agora::Start() { cfg->OfdmDataNum() * tx_counters_.MaxSymbolCount() * 1000; MLPD_INFO( - "TX %d samples (per-client) to %zu clients in %f secs, throughtput %f bps per-client (16QAM), current tx queue length %zu\n", + "TX %d samples (per-client) to %zu clients in %f secs, " + "throughtput %f bps per-client (16QAM), current tx queue " + "length %zu\n", samples_num_per_ue, cfg->UeAntNum(), diff, samples_num_per_ue * std::log2(16.0f) / diff, GetConq(EventType::kPacketTX, 0)->size_approx()); @@ -1385,8 +1387,9 @@ void Agora::InitializeUplinkBuffers() { demul_counters_.Init(cfg->Frame().NumULSyms(), cfg->DemulEventsPerSymbol()); - decode_counters_.Init(cfg->Frame().NumULSyms(), - cfg->LdpcConfig().NumBlocksInSymbol() * cfg->UeAntNum()); + decode_counters_.Init( + cfg->Frame().NumULSyms(), + cfg->LdpcConfig().NumBlocksInSymbol() * cfg->UeAntNum()); tomac_counters_.Init(cfg->Frame().NumULSyms(), cfg->UeAntNum()); } @@ -1572,8 +1575,7 @@ bool Agora::CheckFrameComplete(size_t frame_id) { this->ifft_counters_.Reset(frame_id); this->tx_counters_.Reset(frame_id); if (config_->Frame().NumDLSyms() > 0) { - for (size_t ue_id = 0; ue_id < config_->UeAntNum(); ue_id++) - { + for (size_t ue_id = 0; ue_id < config_->UeAntNum(); ue_id++) { this->dl_bits_buffer_status_[ue_id][frame_id % kFrameWnd] = 0; } } diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index f7606786e..a29a0b7c0 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -225,7 +225,8 @@ EventData DoDemul::Launch(size_t tag) { auto* phase_shift_ptr = reinterpret_cast( &ue_spec_pilot_buffer_[frame_id % kFrameWnd] [symbol_idx_ul * cfg_->UeAntNum()]); - arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeAntNum(), 1, false); + arma::cx_fmat mat_phase_shift(phase_shift_ptr, cfg_->UeAntNum(), 1, + false); arma::cx_fmat shift_sc = sign(mat_equaled % conj(ue_pilot_data_.col(cur_sc_id))); mat_phase_shift += shift_sc; @@ -267,9 +268,10 @@ EventData DoDemul::Launch(size_t tag) { } size_t start_tsc3 = GetTime::WorkerRdtsc(); - __m256i index2 = _mm256_setr_epi32( - 0, 1, cfg_->UeAntNum() * 2, cfg_->UeAntNum() * 2 + 1, cfg_->UeAntNum() * 4, - cfg_->UeAntNum() * 4 + 1, cfg_->UeAntNum() * 6, cfg_->UeAntNum() * 6 + 1); + __m256i index2 = + _mm256_setr_epi32(0, 1, cfg_->UeAntNum() * 2, cfg_->UeAntNum() * 2 + 1, + cfg_->UeAntNum() * 4, cfg_->UeAntNum() * 4 + 1, + cfg_->UeAntNum() * 6, cfg_->UeAntNum() * 6 + 1); auto* equal_t_ptr = reinterpret_cast(equaled_buffer_temp_transposed_); for (size_t i = 0; i < cfg_->UeAntNum(); i++) { float* equal_ptr = nullptr; diff --git a/src/agora/doprecode.cc b/src/agora/doprecode.cc index 6eef0cdbc..49c8c1c31 100644 --- a/src/agora/doprecode.cc +++ b/src/agora/doprecode.cc @@ -186,8 +186,9 @@ void DoPrecode::PrecodingPerSc(size_t frame_slot, size_t sc_id, dl_zf_matrices_[frame_slot][cfg_->GetZfScId(sc_id)]); auto* data_ptr = reinterpret_cast( modulated_buffer_temp_ + - (kUseSpatialLocality ? (sc_id_in_block % kSCsPerCacheline * cfg_->UeAntNum()) - : 0)); + (kUseSpatialLocality + ? (sc_id_in_block % kSCsPerCacheline * cfg_->UeAntNum()) + : 0)); auto* precoded_ptr = reinterpret_cast( precoded_buffer_temp_ + sc_id_in_block * cfg_->BsAntNum()); #if USE_MKL_JIT diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index 825c4c308..f666f66f3 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -124,8 +124,9 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, for (size_t i = 0; i < cfg_->NumCells(); i++) { if (cfg_->ExternalRefNode(i) == true) { mat_dl_zf_tmp.insert_cols( - cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), - arma::fill::zeros)); + cfg_->RefAnt(i), + arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), + arma::fill::zeros)); } } arma::cx_fmat mat_dl_zf(reinterpret_cast(_mat_dl_zf), @@ -135,8 +136,8 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, for (int i = (int)cfg_->NumCells() - 1; i >= 0; i--) { if (cfg_->ExternalRefNode(i) == true) { mat_ul_zf_tmp.insert_cols( - cfg_->RefAnt(i), - arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), arma::fill::zeros)); + cfg_->RefAnt(i), arma::cx_fmat(cfg_->UeAntNum(), cfg_->NumChannels(), + arma::fill::zeros)); } } mat_ul_zf = mat_ul_zf_tmp; diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 32f325247..16cf75095 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -437,8 +437,8 @@ bool RadioConfig::RadioStart() { ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); for (char const& c : cfg_->Channel()) { bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); - std::vector beacon_weights(cfg_->NumRadios() * cfg_->NumChannels(), - is_beacon_antenna ? 1 : 0); + std::vector beacon_weights( + cfg_->NumRadios() * cfg_->NumChannels(), is_beacon_antenna ? 1 : 0); std::string tx_ram_wgt = "BEACON_RAM_WGT_"; if (cfg_->Beamsweep()) { for (size_t j = 0; j < beacon_weights.size(); j++) { diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 658e513ef..3c45b4811 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -238,10 +238,7 @@ bool ClientRadioConfig::RadioStart() { // send through the first radio for now // int beacon_ant = 1; int flags(0); // = SOAPY_SDR_WAIT_TRIGGER; - std::vector zeros(cfg_->SampsPerSymbol(), 0); std::vector beacon = cfg_->Beacon(); - std::vector beacon_weights(cfg_->UeAntNum()); - std::vector pilot = cfg_->Pilot(); // beaconSize + 82 (BS FE delay) + 68 (path delay) + 17 (correlator delay) + From f025e715ef79b9c724a3ed1d588e92fccbdbc1f4 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Thu, 23 Dec 2021 18:36:18 -0700 Subject: [PATCH 31/55] Powder sim test files - 1 machine --- data/ul-sim-hwparams.json | 40 +++++++++++++++++++++++++++++++++++++++ src/common/config.cc | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 data/ul-sim-hwparams.json diff --git a/data/ul-sim-hwparams.json b/data/ul-sim-hwparams.json new file mode 100644 index 000000000..683a273f4 --- /dev/null +++ b/data/ul-sim-hwparams.json @@ -0,0 +1,40 @@ +{ + "cells": 1, + "bs_radio_num": 42, + "channel": "A", + "ue_radio_num": 4, + "ue_channel": "A", + "frequency": 3.56e9, + "single_gain": true, + "sample_rate": 5e6, + "cp_size": 32, + "fft_size": 2048, + "ofdm_data_num": 1200, + "modulation": "16QAM", + "demul_block_size": 48, + "ue_demul_block_size": 48, + "Zc": 72, + "ofdm_tx_zero_prefix": 160, + "ofdm_tx_zero_postfix": 160, + "ofdm_rx_zero_prefix_bs": 160, + "ofdm_rx_zero_prefix_client": 160, + "frame_schedule": [ + "BGGGGGPPPPGGGUUUGGG" + ], + "client_ul_pilot_syms": 2, + "beamsweep": false, + "beacon_antenna": 0, + /* UE configuration */ + "ue_hw_framer": false, + "hw_framer": true, + /* Compute configuration */ + "exclude_cores": [], + "ue_core_offset": 30, + "ue_worker_thread_num": 4, + "ue_socket_thread_num": 2, + "core_offset": 16, + "worker_thread_num": 8, + /* 21 bs radios */ + "socket_thread_num": 4, + "max_frame": 5000 +} \ No newline at end of file diff --git a/src/common/config.cc b/src/common/config.cc index 417c87383..b6a8d0b48 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -520,7 +520,7 @@ Config::Config(const std::string& jsonfile) dl_packet_length_ = Packet::kOffsetOfData + (samps_per_symbol_ * 4); //Don't check for jumbo frames when using the hardware, this might be temp - if (kUseArgos == false) { + if (false) { RtAssert(packet_length_ < 9000, "Packet size must be smaller than jumbo frame"); } From 621352c8bfa08c74ca2d2dd3a028228c12127c03 Mon Sep 17 00:00:00 2001 From: rdoost Date: Mon, 27 Dec 2021 13:04:41 -0600 Subject: [PATCH 32/55] Separate Function for Reciprocal Calib functions --- data/dl-hw.json | 6 +- data/ul-hw.json | 4 +- src/agora/dofft.cc | 9 ++- src/agora/radio_lib.cc | 12 +--- src/agora/txrx/txrx.cc | 6 +- src/agora/txrx/txrx.h | 6 +- src/agora/txrx/txrx_argos.cc | 126 +++++++++++++++++++---------------- src/client/client_radio.cc | 4 +- 8 files changed, 87 insertions(+), 86 deletions(-) diff --git a/data/dl-hw.json b/data/dl-hw.json index 94460ba2f..8350015ea 100644 --- a/data/dl-hw.json +++ b/data/dl-hw.json @@ -11,8 +11,8 @@ "ofdm_tx_zero_prefix" : 160, "ofdm_tx_zero_postfix" : 160, "ofdm_rx_zero_prefix_bs" : 160, - "ofdm_rx_zero_prefix_cal_dl" : 288, - "ofdm_rx_zero_prefix_cal_ul" : 168, + "ofdm_rx_zero_prefix_cal_dl" : 320, + "ofdm_rx_zero_prefix_cal_ul" : 140, "cp_size" : 32, "fft_size" : 2048, "ofdm_data_num" : 1200, @@ -21,7 +21,7 @@ "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ - "BCLGPPGGDDDGG" + "BGCLGGPPGGDDDGG" ], "client_dl_pilot_syms" : 2, "socket_thread_num" : 3, diff --git a/data/ul-hw.json b/data/ul-hw.json index 43f89fa1f..e7ef679d2 100644 --- a/data/ul-hw.json +++ b/data/ul-hw.json @@ -19,14 +19,14 @@ "beamsweep" : false, "beacon_antenna" : 0, "frame_schedule": [ - "BPPGUUUUG" + "BPPPPGUUUUG" ], "client_ul_pilot_syms" : 2, "socket_thread_num" : 1, "worker_thread_num" : 20, "core_offset" : 10, "demul_block_size" : 48, - "ue_channel" : "A", + "ue_channel" : "AB", "ue_rx_gain_a" : [65, 65], "ue_tx_gain_a" : [80, 80], "ue_rx_gain_b" : [65, 65], diff --git a/src/agora/dofft.cc b/src/agora/dofft.cc index c797858af..e204339a3 100644 --- a/src/agora/dofft.cc +++ b/src/agora/dofft.cc @@ -221,9 +221,12 @@ EventData DoFFT::Launch(size_t tag) { phy_stats_->UpdateCalibPilotSnr(frame_grp_id, 0, cur_ant, fft_inout_); } } else { - std::string error_message = "Unknown or unsupported symbol type " + - std::to_string(static_cast(sym_type)) + - "\n"; + std::string error_message = + "Unknown or unsupported symbol type " + + std::to_string(static_cast(sym_type)) + std::string(" at frame ") + + std::to_string(frame_id) + std::string(" symbol ") + + std::to_string(symbol_id) + std::string(" antenna ") + + std::to_string(ant_id) + "\n"; RtAssert(false, error_message); } diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 16cf75095..b2ae6c2ea 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -387,8 +387,6 @@ bool RadioConfig::RadioStart() { } std::vector zeros(cfg_->SampsPerSymbol(), 0); - std::vector beacon = cfg_->Beacon(); - std::vector pilot = cfg_->Pilot(); DrainBuffers(); nlohmann::json conf; @@ -434,7 +432,7 @@ bool RadioConfig::RadioStart() { std::string conf_string = conf.dump(); ba_stn_[i]->writeSetting("TDD_CONFIG", conf_string); - ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); + ba_stn_[i]->writeRegisters("BEACON_RAM", 0, cfg_->Beacon()); for (char const& c : cfg_->Channel()) { bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); std::vector beacon_weights( @@ -449,14 +447,6 @@ bool RadioConfig::RadioStart() { ++ndx; } ba_stn_[i]->writeSetting("BEACON_START", std::to_string(radio_num_)); - if (cfg_->Frame().IsRecCalEnabled()) { - if (is_ref_radio) { - // Write to the first channel TX_RAM on the calibration node for - // ref-to-array transmission - ba_stn_[i]->writeRegisters( - std::string("TX_RAM_") + cfg_->Channel().at(0), 0, pilot); - } - } } if (!kUseUHD) { diff --git a/src/agora/txrx/txrx.cc b/src/agora/txrx/txrx.cc index 275c77367..eac7542b5 100644 --- a/src/agora/txrx/txrx.cc +++ b/src/agora/txrx/txrx.cc @@ -118,7 +118,7 @@ bool PacketTXRX::StartTxRx(Table& buffer, size_t packet_num_in_buffer, return true; } -void PacketTXRX::SendBeacon(int tid, size_t frame_id) { +void PacketTXRX::TxBeacon(int tid, size_t frame_id) { static double send_time = 0; double time_now = GetTime::GetTimeUs() / 1000; size_t radio_lo = tid * cfg_->NumRadios() / socket_thread_num_; @@ -203,12 +203,12 @@ void PacketTXRX::LoopTxRx(size_t tid) { size_t tx_frame_id = 0; size_t send_time = delay_tsc + tx_frame_start; // Send Beacons for the first time to kick off sim - // SendBeacon(tid, tx_frame_id++); + // TxBeacon(tid, tx_frame_id++); while (cfg_->Running() == true) { size_t rdtsc_now = GetTime::Rdtsc(); if (rdtsc_now > send_time) { - SendBeacon(tid, tx_frame_id++); + TxBeacon(tid, tx_frame_id++); if (kEnableSlowStart) { if (tx_frame_id == slow_start_thresh1) { diff --git a/src/agora/txrx/txrx.h b/src/agora/txrx/txrx.h index c59acfb52..8170c135d 100644 --- a/src/agora/txrx/txrx.h +++ b/src/agora/txrx/txrx.h @@ -99,8 +99,10 @@ class PacketTXRX { Table& calib_dl_buffer_, Table& calib_ul_buffer_); - void SendBeacon(int tid, size_t frame_id); - void SendBeaconHW(size_t frame_id, size_t radio_id, long long time0); + void TxBeacon(int tid, size_t frame_id); + void TxBeaconHW(size_t frame_id, size_t radio_id, long long time0); + void TxReciprocityCalibPilots(size_t frame_id, size_t radio_id, + long long time0); private: void LoopTxRx(size_t tid); // The thread function for thread [tid] diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 04687bdc6..f46c7fdf2 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -25,13 +25,15 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { long long time0 = 0; if (cfg_->HwFramer() == false) { + size_t beacon_radio = cfg_->BeaconAnt() / cfg_->NumChannels(); + size_t beacon_chan = cfg_->BeaconAnt() % cfg_->NumChannels(); // prepare BS beacon in host buffer std::vector beaconbuff(2); std::vector zeros(2); zeros[0] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); zeros[1] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); - beaconbuff[0] = cfg_->BeaconCi16().data(); - beaconbuff[1] = zeros[0]; + beaconbuff[beacon_chan] = cfg_->BeaconCi16().data(); + if (cfg_->NumChannels() > 1) beaconbuff[1 - beacon_chan] = zeros[0]; std::vector> samp_buffer0(cfg_->SampsPerSymbol(), 0); std::vector> samp_buffer1(cfg_->SampsPerSymbol(), 0); @@ -60,7 +62,6 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { for (auto radio = radio_lo + 1; radio < radio_hi; radio++) radioconfig_->RadioRx(radio_lo, samp_buffer.data(), rx_time_bs); // Schedule the first beacon in the future - size_t beacon_radio = cfg_->BeaconAnt() / cfg_->NumChannels(); for (auto radio = radio_lo; radio < radio_hi; radio++) { if (radio == beacon_radio) tx_ret = radioconfig_->RadioTx(radio, beaconbuff.data(), 2, tx_time_bs); @@ -137,7 +138,7 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { global_frame_id++; if (cfg_->Frame().NumDLSyms() == 0) { for (size_t radio = radio_lo; radio <= radio_hi; radio++) - this->SendBeaconHW(global_frame_id, radio, time0); + this->TxBeaconHW(global_frame_id, radio, time0); } } } @@ -206,14 +207,17 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, } size_t frame_id = global_frame_id; size_t symbol_id = global_symbol_id; + if (cfg_->HwFramer() == true) { frame_id = (size_t)(frame_time >> 32); symbol_id = (size_t)((frame_time >> 16) & 0xFFFF); - symbol_ids.clear(); - symbol_ids.resize(cfg_->NumChannels(), symbol_id); + for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) + symbol_ids.at(ch) = symbol_id; - // additional read for DL Calibration in two-chan case - /// \TODO: What if ref_ant is set to the second channel? + // Additional read for DL Calibration in two-chan case. + // In HW framer mode we need to be specific about + // which symbols to read a.o.t SW framer mode where + // we read all symbols and discard unused ones later. if ((cfg_->Frame().IsRecCalEnabled() == true) && (cfg_->IsCalDlPilot(frame_id, symbol_id) == true) && (radio_id == cfg_->RefRadio(cell_id)) && (cfg_->AntPerGroup() > 1)) { @@ -259,8 +263,7 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, } } -void PacketTXRX::SendBeaconHW(size_t frame_id, size_t radio_id, - long long time0) { +void PacketTXRX::TxBeaconHW(size_t frame_id, size_t radio_id, long long time0) { std::vector beaconbuff(2); std::vector zeros(2); zeros[0] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); @@ -288,6 +291,53 @@ void PacketTXRX::SendBeaconHW(size_t frame_id, size_t radio_id, } } +void PacketTXRX::TxReciprocityCalibPilots(size_t frame_id, size_t radio_id, + long long time0) { + size_t cell_id = cfg_->CellId().at(radio_id); + std::vector> zeros(cfg_->SampsPerSymbol(), + std::complex(0, 0)); + // Transmit downlink calibration (array to ref) pilot + std::vector caltxbuf(cfg_->NumChannels()); + for (size_t s = 0; s < cfg_->RadioPerGroup(); s++) { + if (radio_id != cfg_->RefRadio(cell_id)) { + bool calib_turn = (frame_id % cfg_->RadioGroupNum() == + radio_id / cfg_->RadioPerGroup() && + s == radio_id % cfg_->RadioPerGroup()); + for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) { + caltxbuf.at(ch) = calib_turn ? cfg_->PilotCi16().data() : zeros.data(); + if (cfg_->NumChannels() > 1) caltxbuf.at(1 - ch) = zeros.data(); + long long frame_time = 0; + if (cfg_->HwFramer() == false) + frame_time = + time0 + + cfg_->SampsPerSymbol() * + ((frame_id + TX_FRAME_DELTA) * cfg_->Frame().NumTotalSyms() + + cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch)); + else + frame_time = + ((long long)(frame_id + TX_FRAME_DELTA) << 32) | + (cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch) + << 16); + radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); + } + } else { + // We choose to use channel A to tx from the reference radio + caltxbuf.at(0) = cfg_->PilotCi16().data(); + if (cfg_->NumChannels() > 1) caltxbuf.at(1) = zeros.data(); + long long frame_time = 0; + if (cfg_->HwFramer() == false) + frame_time = + time0 + cfg_->SampsPerSymbol() * ((frame_id + TX_FRAME_DELTA) * + cfg_->Frame().NumTotalSyms() + + cfg_->Frame().GetULCalSymbol(0)); + else + frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | + (cfg_->Frame().GetULCalSymbol(0) << 16); + radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); + } + } +} + size_t PacketTXRX::DequeueSendArgos(int tid, long long time0) { const size_t max_dequeue_items = (cfg_->BsAntNum() / cfg_->SocketThreadNum()) + 1; @@ -308,7 +358,6 @@ size_t PacketTXRX::DequeueSendArgos(int tid, long long time0) { const size_t symbol_id = gen_tag_t(current_event.tags_[0u]).symbol_id_; const size_t ant_id = gen_tag_t(current_event.tags_[0u]).ant_id_; const size_t radio_id = ant_id / cfg_->NumChannels(); - size_t cell_id = cfg_->CellId().at(radio_id); // See if this is the last antenna on the radio. Assume that we receive the // last one @@ -326,57 +375,16 @@ size_t PacketTXRX::DequeueSendArgos(int tid, long long time0) { ant_id; if (last_antenna) { - // Schedule beacon in the future - if (cfg_->HwFramer() == false && symbol_id == 0) { - this->SendBeaconHW(frame_id, radio_id, time0); - } + if (symbol_id == cfg_->Frame().GetDLSymbol(0)) { + // Schedule beacon in the future + if (cfg_->HwFramer() == false) { + this->TxBeaconHW(frame_id, radio_id, time0); + } - // Transmit downlink calibration (array to ref) pilot - std::vector caltxbuf(cfg_->NumChannels()); - if ((cfg_->Frame().IsRecCalEnabled() == true) && - (symbol_id == cfg_->Frame().GetDLSymbol(0))) { - std::vector> zeros(cfg_->SampsPerSymbol(), - std::complex(0, 0)); - for (size_t s = 0; s < cfg_->RadioPerGroup(); s++) { - if (radio_id != cfg_->RefRadio(cell_id)) { - bool calib_turn = (frame_id % cfg_->RadioGroupNum() == - radio_id / cfg_->RadioPerGroup() && - s == radio_id % cfg_->RadioPerGroup()); - for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) { - caltxbuf.at(ch) = - calib_turn ? cfg_->PilotCi16().data() : zeros.data(); - if (cfg_->NumChannels() > 1) caltxbuf.at(1 - ch) = zeros.data(); - long long frame_time = 0; - if (cfg_->HwFramer() == false) - frame_time = time0 + cfg_->SampsPerSymbol() * - ((frame_id + TX_FRAME_DELTA) * - cfg_->Frame().NumTotalSyms() + - cfg_->Frame().GetDLCalSymbol( - s * cfg_->NumChannels() + ch)); - else - frame_time = - ((long long)(frame_id + TX_FRAME_DELTA) << 32) | - (cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch) - << 16); - radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); - } - } else { - caltxbuf.at(0) = cfg_->PilotCi16().data(); - if (cfg_->NumChannels() > 1) caltxbuf.at(1) = zeros.data(); - long long frame_time = 0; - if (cfg_->HwFramer() == false) - frame_time = time0 + cfg_->SampsPerSymbol() * - ((frame_id + TX_FRAME_DELTA) * - cfg_->Frame().NumTotalSyms() + - cfg_->Frame().GetULCalSymbol(0)); - else - frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | - (cfg_->Frame().GetULCalSymbol(0) << 16); - radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); - } + if (cfg_->Frame().IsRecCalEnabled() == true) { + this->TxReciprocityCalibPilots(frame_id, radio_id, time0); } } - std::vector txbuf(cfg_->NumChannels()); if (kDebugDownlink == true) { std::vector> zeros(cfg_->SampsPerSymbol()); diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 3c45b4811..df2695578 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -238,8 +238,6 @@ bool ClientRadioConfig::RadioStart() { // send through the first radio for now // int beacon_ant = 1; int flags(0); // = SOAPY_SDR_WAIT_TRIGGER; - std::vector beacon = cfg_->Beacon(); - std::vector pilot = cfg_->Pilot(); // beaconSize + 82 (BS FE delay) + 68 (path delay) + 17 (correlator delay) + // 82 (Client FE Delay) @@ -293,7 +291,7 @@ bool ClientRadioConfig::RadioStart() { cl_stn_[i]->writeSetting("TDD_MODE", "true"); for (char const& c : cfg_->UeChannel()) { std::string tx_ram = "TX_RAM_"; - cl_stn_[i]->writeRegisters(tx_ram + c, 0, pilot); + cl_stn_[i]->writeRegisters(tx_ram + c, 0, cfg_->Pilot()); } cl_stn_[i]->activateStream(this->rx_streams_[i], flags, 0); cl_stn_[i]->activateStream(this->tx_streams_[i]); From 1cc8296d918aaa94686a70f4b3988e72792075b0 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 28 Dec 2021 11:04:29 -0700 Subject: [PATCH 33/55] updated powder configs --- .../topology-powder-dl.json | 0 .../topology-powder-ul.json | 6 +-- data/{ => anechoic_conf}/topology-powder.json | 16 ++++---- data/bs-dl-powder-2.json | 40 ------------------- data/dl-powder.json | 9 +++-- data/ul-powder.json | 7 ++-- 6 files changed, 20 insertions(+), 58 deletions(-) rename data/{ => anechoic_conf}/topology-powder-dl.json (100%) rename data/{ => anechoic_conf}/topology-powder-ul.json (85%) rename data/{ => anechoic_conf}/topology-powder.json (81%) delete mode 100644 data/bs-dl-powder-2.json diff --git a/data/topology-powder-dl.json b/data/anechoic_conf/topology-powder-dl.json similarity index 100% rename from data/topology-powder-dl.json rename to data/anechoic_conf/topology-powder-dl.json diff --git a/data/topology-powder-ul.json b/data/anechoic_conf/topology-powder-ul.json similarity index 85% rename from data/topology-powder-ul.json rename to data/anechoic_conf/topology-powder-ul.json index 414160917..373801636 100644 --- a/data/topology-powder-ul.json +++ b/data/anechoic_conf/topology-powder-ul.json @@ -22,11 +22,11 @@ "RF3E000674", "RF3E000704", "RF3E000676", - /*"RF3E000668",*/ + /*"RF3E000668",Removed for rf reasons*/ "RF3E000340", "RF3E000744", "RF3E000161", - /*"RF3E000735",*/ + /*"RF3E000735", Removed for compute reasons*/ "RF3E000387", "RF3E000389", "RF3E000206", @@ -34,7 +34,7 @@ "RF3E000256", "RF3E000383", "RF3E000304" - /*"RF3E000303"*/ + /*"RF3E000303, Remove for front end config reasons"*/ ], "reference": "RF3E000246" } diff --git a/data/topology-powder.json b/data/anechoic_conf/topology-powder.json similarity index 81% rename from data/topology-powder.json rename to data/anechoic_conf/topology-powder.json index 171f34efa..635d66350 100644 --- a/data/topology-powder.json +++ b/data/anechoic_conf/topology-powder.json @@ -19,11 +19,11 @@ "RF3E000740", "RF3E000532", "RF3E000716", - /* "RF3E000674", "RF3E000704", "RF3E000676", - "RF3E000668",*/ + "RF3E000668", + /* 668 has rf issues */ "RF3E000340", "RF3E000744", "RF3E000161", @@ -31,20 +31,20 @@ "RF3E000387", "RF3E000389", "RF3E000206", - "RF3E000211" - /* + "RF3E000211", "RF3E000256", "RF3E000383", "RF3E000304", - "RF3E000303"*/ + /* 303 has front end issues */ + "RF3E000303" ], - "reference": "RF3E000157" + "reference": "RF3E000246" } }, - "Clients" : { + "Clients": { "sdr": [ "RF3E000119", "RF3E000145" ] } -} +} \ No newline at end of file diff --git a/data/bs-dl-powder-2.json b/data/bs-dl-powder-2.json deleted file mode 100644 index a121840f9..000000000 --- a/data/bs-dl-powder-2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "hubs": "data/bs-hub-serials-powder.txt", - "irises": "data/bs-iris-serials-powder-dl.txt", - "cells": 1, - "channel": "A", - "frequency": 3.56e9, - "single_gain": false, - "rx_gain_a": 25, - "tx_gain_a": 40, - "rx_gain_b": 25, - "tx_gain_b": 40, - "sample_rate": 5e6, - "ofdm_tx_zero_prefix": 160, - "ofdm_tx_zero_postfix": 160, - "ofdm_rx_zero_prefix_bs": 160, - "ofdm_rx_zero_prefix_cal_dl": 288, - "ofdm_rx_zero_prefix_cal_ul": 168, - "cp_size": 32, - "fft_size": 2048, - "ofdm_data_num": 1200, - "modulation": "16QAM", - "zf_block_size": 1, - "demul_block_size": 48, - "Zc": 72, - "beamsweep": false, - "beacon_antenna": 0, - "frame_schedule": [ - "BGCLGGPPGDDDG" - ], - "hw_framer": true, - "client_dl_pilot_syms": 2, - "external_ref_node": true, - "ref_ant": 22, - /* Compute configuration */ - "core_offset": 16, - "exclude_cores": [], - "worker_thread_num": 16, - /* 22 + 1 */ - "socket_thread_num": 6 -} \ No newline at end of file diff --git a/data/dl-powder.json b/data/dl-powder.json index 41bc8cd5e..4dbbea7f9 100644 --- a/data/dl-powder.json +++ b/data/dl-powder.json @@ -1,5 +1,6 @@ { - "serial_file": "data/topology-powder-dl.json", + /* Tested with 17 bs radios 2 ue, 1 channel each */ + "serial_file": "data/anechoic_conf/topology-powder-dl.json", "cells": 1, "channel": "A", "frequency": 3.6e9, @@ -22,7 +23,7 @@ "beamsweep": false, "beacon_antenna": 0, "frame_schedule": [ - "BCLGPPGGDDDGG" + "BCLGPPGGDDDGGGG" ], "client_dl_pilot_syms": 2, "demul_block_size": 48, @@ -56,7 +57,7 @@ "ue_worker_thread_num": 4, "core_offset": 16, "worker_thread_num": 12, - /* 22 bs radios + 1 ref*/ - "socket_thread_num": 3, + /* 17 bs radios + 1 ref*/ + "socket_thread_num": 4, "max_frame": 10000 } \ No newline at end of file diff --git a/data/ul-powder.json b/data/ul-powder.json index 998da1c84..4d308497f 100644 --- a/data/ul-powder.json +++ b/data/ul-powder.json @@ -1,5 +1,6 @@ { - "serial_file": "data/topology-powder-ul.json", + /* Tested with 21 bs radios and 2 ue radios */ + "serial_file": "data/anechoic_conf/topology-powder-ul.json", "cells": 1, "channel": "AB", "frequency": 3.56e9, @@ -54,8 +55,8 @@ "ue_core_offset": 12, "ue_worker_thread_num": 4, "core_offset": 16, - "worker_thread_num": 16, + "worker_thread_num": 8, /* 21 bs radios */ - "socket_thread_num": 6, + "socket_thread_num": 4, "max_frame": 10000 } \ No newline at end of file From a5e55697121aa6646f4a5b3420c83b403921132a Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 28 Dec 2021 11:14:56 -0700 Subject: [PATCH 34/55] removed debug output --- src/common/config.cc | 99 +++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index b6a8d0b48..ab73da88b 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -19,6 +19,7 @@ using json = nlohmann::json; static const size_t kMacAlignmentBytes = 64u; +static constexpr size_t kDebugPrintConfiguration = false; Config::Config(const std::string& jsonfile) : freq_ghz_(GetTime::MeasureRdtscFreq()), @@ -563,7 +564,6 @@ Config::Config(const std::string& jsonfile) (this->GetFrameDurationSec() * 1e6), (dl_mac_data_bytes_num_perframe_ * 8.0f) / (this->GetFrameDurationSec() * 1e6)); - Print(); } @@ -1131,53 +1131,56 @@ SymbolType Config::GetSymbolType(size_t symbol_id) const { } void Config::Print() const { - std::cout << "Freq Ghz: " << freq_ghz_ << std::endl - << "BaseStation ant num: " << bs_ant_num_ << std::endl - << "BeamForming ant num: " << bf_ant_num_ << std::endl - << "Ue num: " << ue_num_ << std::endl - << "Ue ant num: " << ue_ant_num_ << std::endl - << "Ue ant total: " << ue_ant_total_ << std::endl - << "Ue ant offset: " << ue_ant_offset_ << std::endl - << "OFDM Ca num: " << ofdm_ca_num_ << std::endl - << "Cp Len: " << cp_len_ << std::endl - << "Ofdm data num: " << ofdm_data_num_ << std::endl - << "Ofdm data start: " << ofdm_data_start_ << std::endl - << "Ofdm data stop: " << ofdm_data_stop_ << std::endl - << "Ofdm pilot spacing: " << ofdm_pilot_spacing_ << std::endl - << "Hardware framer: " << hw_framer_ << std::endl - << "Ue Hardware framer: " << ue_hw_framer_ << std::endl - << "Freq: " << freq_ << std::endl - << "Rate: " << rate_ << std::endl - << "NCO: " << nco_ << std::endl - << "Scrambler Enabled: " << scramble_enabled_ << std::endl - << "Radio Rf Freq: " << radio_rf_freq_ << std::endl - << "Bw filter: " << bw_filter_ << std::endl - << "Single Gain: " << single_gain_ << std::endl - << "Tx Gain A: " << tx_gain_a_ << std::endl - << "Rx Gain A: " << rx_gain_a_ << std::endl - << "Tx Gain B: " << tx_gain_b_ << std::endl - << "Rx Gain B: " << rx_gain_b_ << std::endl - << "Calib Tx Gain A: " << calib_tx_gain_a_ << std::endl - << "Calib Tx Gain B: " << calib_tx_gain_b_ << std::endl - << "Num Cells: " << num_cells_ << std::endl - << "Num Bs Radios: " << num_radios_ << std::endl - << "Num Bs Channels: " << num_channels_ << std::endl - << "Num Ue Channels: " << num_ue_channels_ << std::endl - << "Beacon Ant: " << beacon_ant_ << std::endl - << "Beacon len: " << beacon_len_ << std::endl - << "Calib init repeat: " << init_calib_repeat_ << std::endl - << "Beamsweep " << beamsweep_ << std::endl - << "Sample Cal En: " << sample_cal_en_ << std::endl - << "Imbalance Cal: " << imbalance_cal_en_ << std::endl - << "Bs Channel: " << channel_ << std::endl - << "Ue Channel: " << ue_channel_ << std::endl - << "Ant Group num: " << ant_group_num_ << std::endl - << "Ant Per Group: " << ant_per_group_ << std::endl - << "Max Frames: " << frames_to_test_ << std::endl - << "Transport Block Size: " << transport_block_size_ << std::endl - << "Noise Level: " << noise_level_ << std::endl - << "Bytes per CB: " << num_bytes_per_cb_ << std::endl - << "FFT in rru: " << fft_in_rru_ << std::endl; + if (kDebugPrintConfiguration == true) + { + std::cout << "Freq Ghz: " << freq_ghz_ << std::endl + << "BaseStation ant num: " << bs_ant_num_ << std::endl + << "BeamForming ant num: " << bf_ant_num_ << std::endl + << "Ue num: " << ue_num_ << std::endl + << "Ue ant num: " << ue_ant_num_ << std::endl + << "Ue ant total: " << ue_ant_total_ << std::endl + << "Ue ant offset: " << ue_ant_offset_ << std::endl + << "OFDM Ca num: " << ofdm_ca_num_ << std::endl + << "Cp Len: " << cp_len_ << std::endl + << "Ofdm data num: " << ofdm_data_num_ << std::endl + << "Ofdm data start: " << ofdm_data_start_ << std::endl + << "Ofdm data stop: " << ofdm_data_stop_ << std::endl + << "Ofdm pilot spacing: " << ofdm_pilot_spacing_ << std::endl + << "Hardware framer: " << hw_framer_ << std::endl + << "Ue Hardware framer: " << ue_hw_framer_ << std::endl + << "Freq: " << freq_ << std::endl + << "Rate: " << rate_ << std::endl + << "NCO: " << nco_ << std::endl + << "Scrambler Enabled: " << scramble_enabled_ << std::endl + << "Radio Rf Freq: " << radio_rf_freq_ << std::endl + << "Bw filter: " << bw_filter_ << std::endl + << "Single Gain: " << single_gain_ << std::endl + << "Tx Gain A: " << tx_gain_a_ << std::endl + << "Rx Gain A: " << rx_gain_a_ << std::endl + << "Tx Gain B: " << tx_gain_b_ << std::endl + << "Rx Gain B: " << rx_gain_b_ << std::endl + << "Calib Tx Gain A: " << calib_tx_gain_a_ << std::endl + << "Calib Tx Gain B: " << calib_tx_gain_b_ << std::endl + << "Num Cells: " << num_cells_ << std::endl + << "Num Bs Radios: " << num_radios_ << std::endl + << "Num Bs Channels: " << num_channels_ << std::endl + << "Num Ue Channels: " << num_ue_channels_ << std::endl + << "Beacon Ant: " << beacon_ant_ << std::endl + << "Beacon len: " << beacon_len_ << std::endl + << "Calib init repeat: " << init_calib_repeat_ << std::endl + << "Beamsweep " << beamsweep_ << std::endl + << "Sample Cal En: " << sample_cal_en_ << std::endl + << "Imbalance Cal: " << imbalance_cal_en_ << std::endl + << "Bs Channel: " << channel_ << std::endl + << "Ue Channel: " << ue_channel_ << std::endl + << "Ant Group num: " << ant_group_num_ << std::endl + << "Ant Per Group: " << ant_per_group_ << std::endl + << "Max Frames: " << frames_to_test_ << std::endl + << "Transport Block Size: " << transport_block_size_ << std::endl + << "Noise Level: " << noise_level_ << std::endl + << "Bytes per CB: " << num_bytes_per_cb_ << std::endl + << "FFT in rru: " << fft_in_rru_ << std::endl; + } } extern "C" { From d8fec0499f6e5e77e7e62c60ea2718eb11b61a66 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 28 Dec 2021 15:42:55 -0700 Subject: [PATCH 35/55] added another antenna --- data/anechoic_conf/topology-powder-ul.json | 2 +- src/agora/dodemul.cc | 49 ++++++++++++++-------- src/agora/dozf.cc | 28 +++++++------ src/common/config.cc | 2 + 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/data/anechoic_conf/topology-powder-ul.json b/data/anechoic_conf/topology-powder-ul.json index 373801636..b5a69c88b 100644 --- a/data/anechoic_conf/topology-powder-ul.json +++ b/data/anechoic_conf/topology-powder-ul.json @@ -26,7 +26,7 @@ "RF3E000340", "RF3E000744", "RF3E000161", - /*"RF3E000735", Removed for compute reasons*/ + "RF3E000735", "RF3E000387", "RF3E000389", "RF3E000206", diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index a29a0b7c0..725af39b1 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -114,16 +114,21 @@ EventData DoDemul::Launch(size_t tag) { ((base_sc_id + i) / kTransposeBlockSize) * (kTransposeBlockSize * cfg_->BsAntNum()); +#ifdef __AVX512F__ + static constexpr size_t kAntNumPerSimd = 8; +#else + static constexpr size_t kAntNumPerSimd = 4; +#endif + size_t ant_start = 0; - if (kUseSIMDGather and cfg_->BsAntNum() % 4 == 0 and kUsePartialTrans) { + if (kUseSIMDGather && kUsePartialTrans && (cfg_->BsAntNum() % kAntNumPerSimd) == 0) { // Gather data for all antennas and 8 subcarriers in the same cache // line, 1 subcarrier and 4 (AVX2) or 8 (AVX512) ants per iteration size_t cur_sc_offset = partial_transpose_block_base + (base_sc_id + i) % kTransposeBlockSize; - const auto* src = (const float*)&data_buf[cur_sc_offset]; - auto* dst = (float*)data_gather_buffer_; + const float* src = reinterpret_cast(&data_buf[cur_sc_offset]); + float* dst = reinterpret_cast(data_gather_buffer_); #ifdef __AVX512F__ - size_t ant_num_per_simd = 8; __m512i index = _mm512_setr_epi32( 0, 1, kTransposeBlockSize * 2, kTransposeBlockSize * 2 + 1, kTransposeBlockSize * 4, kTransposeBlockSize * 4 + 1, @@ -133,35 +138,43 @@ EventData DoDemul::Launch(size_t tag) { kTransposeBlockSize * 12, kTransposeBlockSize * 12 + 1, kTransposeBlockSize * 14, kTransposeBlockSize * 14 + 1); for (size_t ant_i = 0; ant_i < cfg_->BsAntNum(); - ant_i += ant_num_per_simd) { + ant_i += kAntNumPerSimd) { for (size_t j = 0; j < kSCsPerCacheline; j++) { __m512 data_rx = kTransposeBlockSize == 1 - ? _mm512_load_ps(src + j * cfg_->BsAntNum() * 2) - : _mm512_i32gather_ps(index, src + j * 2, 4); - _mm512_store_ps(dst + j * cfg_->BsAntNum() * 2, data_rx); + ? _mm512_load_ps(&src[j * cfg_->BsAntNum() * 2]) + : _mm512_i32gather_ps(index, &src[j * 2], 4); + + //if ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 64) > 0) + //{ + // std::printf("Ant: %zu:%zu subcarrier: %zu:%zu base address %zu\n", ant_i, cfg_->BsAntNum(), base_sc_id, j, reinterpret_cast(dst)); + //} + assert( ( reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 64) == 0); + _mm512_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } - src += ant_num_per_simd * kTransposeBlockSize * 2; - dst += ant_num_per_simd * 2; + src += kAntNumPerSimd * kTransposeBlockSize * 2; + dst += kAntNumPerSimd * 2; } #else - size_t ant_num_per_simd = 4; __m256i index = _mm256_setr_epi32( 0, 1, kTransposeBlockSize * 2, kTransposeBlockSize * 2 + 1, kTransposeBlockSize * 4, kTransposeBlockSize * 4 + 1, kTransposeBlockSize * 6, kTransposeBlockSize * 6 + 1); for (size_t ant_i = 0; ant_i < cfg_->BsAntNum(); - ant_i += ant_num_per_simd) { + ant_i += kAntNumPerSimd) { for (size_t j = 0; j < kSCsPerCacheline; j++) { - __m256 data_rx = _mm256_i32gather_ps(src + j * 2, index, 4); - _mm256_store_ps(dst + j * cfg_->BsAntNum() * 2, data_rx); + std::printf("Ant: %zu Local sc: %zu\n", ant_i, j); + assert((reinterpret_cast((&src[j * 2]) % 32) == 0) && ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 32) == 0)); + __m256 data_rx = _mm256_i32gather_ps(&src[j * 2], index, 4); + _mm256_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } - src += ant_num_per_simd * kTransposeBlockSize * 2; - dst += ant_num_per_simd * 2; + src += kAntNumPerSimd * kTransposeBlockSize * 2; + dst += kAntNumPerSimd * 2; } #endif // Set the remaining number of antennas for non-SIMD gather - ant_start = cfg_->BsAntNum() % 4; - } else { + ant_start = cfg_->BsAntNum() - (cfg_->BsAntNum() % kAntNumPerSimd); + } + if (ant_start < cfg_->BsAntNum()) { complex_float* dst = data_gather_buffer_ + ant_start; for (size_t j = 0; j < kSCsPerCacheline; j++) { for (size_t ant_i = ant_start; ant_i < cfg_->BsAntNum(); ant_i++) { diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index f666f66f3..89a7ab0e2 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -220,8 +220,15 @@ void DoZF::ComputeCalib(size_t frame_id, size_t sc_id) { static inline void PartialTransposeGather(size_t cur_sc_id, float* src, float*& dst, size_t bs_ant_num) { // The SIMD and non-SIMD methods are equivalent. + +#ifdef __AVX512F__ + static constexpr size_t kAntNumPerSimd = 8; +#else + static constexpr size_t kAntNumPerSimd = 4; +#endif + size_t ant_start = 0; - if (kUseSIMDGather and bs_ant_num >= 4) { + if (kUseSIMDGather && (bs_ant_num >= kAntNumPerSimd)) { const size_t transpose_block_id = cur_sc_id / kTransposeBlockSize; const size_t sc_inblock_idx = cur_sc_id % kTransposeBlockSize; const size_t offset_in_src_buffer = @@ -229,7 +236,6 @@ static inline void PartialTransposeGather(size_t cur_sc_id, float* src, src = src + offset_in_src_buffer * 2; #ifdef __AVX512F__ - size_t ant_num_per_simd = 8; __m512i index = _mm512_setr_epi32( 0, 1, kTransposeBlockSize * 2, kTransposeBlockSize * 2 + 1, kTransposeBlockSize * 4, kTransposeBlockSize * 4 + 1, @@ -239,32 +245,30 @@ static inline void PartialTransposeGather(size_t cur_sc_id, float* src, kTransposeBlockSize * 12, kTransposeBlockSize * 12 + 1, kTransposeBlockSize * 14, kTransposeBlockSize * 14 + 1); for (size_t ant_idx = 0; ant_idx < bs_ant_num; - ant_idx += ant_num_per_simd) { + ant_idx += kAntNumPerSimd) { // fetch 4 complex floats for 4 ants - - __m512 t = kTransposeBlockSize == 1 ? _mm512_load_ps(src) + __m512 t = (kTransposeBlockSize == 1) ? _mm512_load_ps(src) : _mm512_i32gather_ps(index, src, 4); _mm512_storeu_ps(dst, t); - src += ant_num_per_simd * kTransposeBlockSize * 2; - dst += ant_num_per_simd * 2; + src += kAntNumPerSimd * kTransposeBlockSize * 2; + dst += kAntNumPerSimd * 2; } #else - size_t ant_num_per_simd = 4; __m256i index = _mm256_setr_epi32( 0, 1, kTransposeBlockSize * 2, kTransposeBlockSize * 2 + 1, kTransposeBlockSize * 4, kTransposeBlockSize * 4 + 1, kTransposeBlockSize * 6, kTransposeBlockSize * 6 + 1); for (size_t ant_idx = 0; ant_idx < bs_ant_num; - ant_idx += ant_num_per_simd) { + ant_idx += kAntNumPerSimd) { // fetch 4 complex floats for 4 ants __m256 t = _mm256_i32gather_ps(src, index, 4); _mm256_storeu_ps(dst, t); - src += ant_num_per_simd * kTransposeBlockSize * 2; - dst += ant_num_per_simd * 2; + src += kAntNumPerSimd * kTransposeBlockSize * 2; + dst += kAntNumPerSimd * 2; } #endif // Set the of the remaining antennas to use non-SIMD gather - ant_start = bs_ant_num / 4 * 4; + ant_start = bs_ant_num - (bs_ant_num % kAntNumPerSimd); } if (ant_start < bs_ant_num) { const size_t pt_base_offset = diff --git a/src/common/config.cc b/src/common/config.cc index ab73da88b..605d5e0f8 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -1122,6 +1122,8 @@ bool Config::IsDownlink(size_t frame_id, size_t symbol_id) const { char s = frame_.FrameIdentifier().at(symbol_id); #ifdef DEBUG3 std::printf("IsDownlink(%zu, %zu) = %c\n", frame_id, symbol_id, s); +#else + unused(frame_id); #endif return (s == 'D'); } From 98aae03a19e9afd09faa2694be4f8359d0ada50d Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 28 Dec 2021 16:06:16 -0700 Subject: [PATCH 36/55] added antennas to dl config --- data/anechoic_conf/topology-powder-dl.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/anechoic_conf/topology-powder-dl.json b/data/anechoic_conf/topology-powder-dl.json index d780d05f4..995dee83b 100644 --- a/data/anechoic_conf/topology-powder-dl.json +++ b/data/anechoic_conf/topology-powder-dl.json @@ -30,11 +30,11 @@ "RF3E000387", "RF3E000389", "RF3E000206", - "RF3E000211" - /*"RF3E000256", + "RF3E000211", + "RF3E000256", "RF3E000383", - "RF3E000304", - "RF3E000303"*/ + "RF3E000304" + /*"RF3E000303"*/ ], "reference": "RF3E000157" } From a8804fdd56ecde4468f44bf27301b03acb774177 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Tue, 28 Dec 2021 16:16:58 -0700 Subject: [PATCH 37/55] remove debug output --- src/agora/dodemul.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index 725af39b1..fd003cc45 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -162,7 +162,7 @@ EventData DoDemul::Launch(size_t tag) { for (size_t ant_i = 0; ant_i < cfg_->BsAntNum(); ant_i += kAntNumPerSimd) { for (size_t j = 0; j < kSCsPerCacheline; j++) { - std::printf("Ant: %zu Local sc: %zu\n", ant_i, j); + //std::printf("Ant: %zu Local sc: %zu\n", ant_i, j); assert((reinterpret_cast((&src[j * 2]) % 32) == 0) && ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 32) == 0)); __m256 data_rx = _mm256_i32gather_ps(&src[j * 2], index, 4); _mm256_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); From 9b75f42cd6c7c25849a86c30607364cb6d884252 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Wed, 29 Dec 2021 13:41:45 -0600 Subject: [PATCH 38/55] Formatting --- src/agora/dodemul.cc | 13 +++++++++---- src/agora/dozf.cc | 15 +++++++-------- src/common/config.cc | 3 +-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index fd003cc45..79fa15e44 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -121,12 +121,14 @@ EventData DoDemul::Launch(size_t tag) { #endif size_t ant_start = 0; - if (kUseSIMDGather && kUsePartialTrans && (cfg_->BsAntNum() % kAntNumPerSimd) == 0) { + if (kUseSIMDGather && kUsePartialTrans && + (cfg_->BsAntNum() % kAntNumPerSimd) == 0) { // Gather data for all antennas and 8 subcarriers in the same cache // line, 1 subcarrier and 4 (AVX2) or 8 (AVX512) ants per iteration size_t cur_sc_offset = partial_transpose_block_base + (base_sc_id + i) % kTransposeBlockSize; - const float* src = reinterpret_cast(&data_buf[cur_sc_offset]); + const float* src = + reinterpret_cast(&data_buf[cur_sc_offset]); float* dst = reinterpret_cast(data_gather_buffer_); #ifdef __AVX512F__ __m512i index = _mm512_setr_epi32( @@ -148,7 +150,8 @@ EventData DoDemul::Launch(size_t tag) { //{ // std::printf("Ant: %zu:%zu subcarrier: %zu:%zu base address %zu\n", ant_i, cfg_->BsAntNum(), base_sc_id, j, reinterpret_cast(dst)); //} - assert( ( reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 64) == 0); + assert((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % + 64) == 0); _mm512_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } src += kAntNumPerSimd * kTransposeBlockSize * 2; @@ -163,7 +166,9 @@ EventData DoDemul::Launch(size_t tag) { ant_i += kAntNumPerSimd) { for (size_t j = 0; j < kSCsPerCacheline; j++) { //std::printf("Ant: %zu Local sc: %zu\n", ant_i, j); - assert((reinterpret_cast((&src[j * 2]) % 32) == 0) && ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 32) == 0)); + assert((reinterpret_cast((&src[j * 2]) % 32) == 0) && + ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % + 32) == 0)); __m256 data_rx = _mm256_i32gather_ps(&src[j * 2], index, 4); _mm256_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index 89a7ab0e2..c865cb27b 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -222,9 +222,9 @@ static inline void PartialTransposeGather(size_t cur_sc_id, float* src, // The SIMD and non-SIMD methods are equivalent. #ifdef __AVX512F__ - static constexpr size_t kAntNumPerSimd = 8; + static constexpr size_t kAntNumPerSimd = 8; #else - static constexpr size_t kAntNumPerSimd = 4; + static constexpr size_t kAntNumPerSimd = 4; #endif size_t ant_start = 0; @@ -244,11 +244,11 @@ static inline void PartialTransposeGather(size_t cur_sc_id, float* src, kTransposeBlockSize * 10, kTransposeBlockSize * 10 + 1, kTransposeBlockSize * 12, kTransposeBlockSize * 12 + 1, kTransposeBlockSize * 14, kTransposeBlockSize * 14 + 1); - for (size_t ant_idx = 0; ant_idx < bs_ant_num; - ant_idx += kAntNumPerSimd) { + for (size_t ant_idx = 0; ant_idx < bs_ant_num; ant_idx += kAntNumPerSimd) { // fetch 4 complex floats for 4 ants - __m512 t = (kTransposeBlockSize == 1) ? _mm512_load_ps(src) - : _mm512_i32gather_ps(index, src, 4); + __m512 t = (kTransposeBlockSize == 1) + ? _mm512_load_ps(src) + : _mm512_i32gather_ps(index, src, 4); _mm512_storeu_ps(dst, t); src += kAntNumPerSimd * kTransposeBlockSize * 2; dst += kAntNumPerSimd * 2; @@ -258,8 +258,7 @@ static inline void PartialTransposeGather(size_t cur_sc_id, float* src, 0, 1, kTransposeBlockSize * 2, kTransposeBlockSize * 2 + 1, kTransposeBlockSize * 4, kTransposeBlockSize * 4 + 1, kTransposeBlockSize * 6, kTransposeBlockSize * 6 + 1); - for (size_t ant_idx = 0; ant_idx < bs_ant_num; - ant_idx += kAntNumPerSimd) { + for (size_t ant_idx = 0; ant_idx < bs_ant_num; ant_idx += kAntNumPerSimd) { // fetch 4 complex floats for 4 ants __m256 t = _mm256_i32gather_ps(src, index, 4); _mm256_storeu_ps(dst, t); diff --git a/src/common/config.cc b/src/common/config.cc index 605d5e0f8..fc765d90b 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -1133,8 +1133,7 @@ SymbolType Config::GetSymbolType(size_t symbol_id) const { } void Config::Print() const { - if (kDebugPrintConfiguration == true) - { + if (kDebugPrintConfiguration == true) { std::cout << "Freq Ghz: " << freq_ghz_ << std::endl << "BaseStation ant num: " << bs_ant_num_ << std::endl << "BeamForming ant num: " << bf_ant_num_ << std::endl From b361eb347f7f23cc87cd84fe4eb7d6d79cae9105 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Wed, 29 Dec 2021 15:13:58 -0700 Subject: [PATCH 39/55] final downlink check --- data/anechoic_conf/topology-powder-dl.json | 8 ++++---- data/dl-powder.json | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/anechoic_conf/topology-powder-dl.json b/data/anechoic_conf/topology-powder-dl.json index 995dee83b..4b991ba8c 100644 --- a/data/anechoic_conf/topology-powder-dl.json +++ b/data/anechoic_conf/topology-powder-dl.json @@ -19,10 +19,10 @@ "RF3E000740", "RF3E000532", "RF3E000716", - /*"RF3E000674", - "RF3E000704", - "RF3E000676", - "RF3E000668",*/ + /*"RF3E000674",*/ + /*"RF3E000704",*/ + /*"RF3E000676",*/ + /*"RF3E000668",*/ "RF3E000340", "RF3E000744", "RF3E000161", diff --git a/data/dl-powder.json b/data/dl-powder.json index 4dbbea7f9..376ffe34d 100644 --- a/data/dl-powder.json +++ b/data/dl-powder.json @@ -1,5 +1,5 @@ { - /* Tested with 17 bs radios 2 ue, 1 channel each */ + /* Tested with 20 bs + 1 external ref + 2 ue radios, 1 channel each */ "serial_file": "data/anechoic_conf/topology-powder-dl.json", "cells": 1, "channel": "A", @@ -57,7 +57,7 @@ "ue_worker_thread_num": 4, "core_offset": 16, "worker_thread_num": 12, - /* 17 bs radios + 1 ref*/ + /* 20 bs radios + 1 ref*/ "socket_thread_num": 4, - "max_frame": 10000 + "max_frame": 9900 } \ No newline at end of file From 60adf94c5d276ddf671dbaf3790cf1d91d4db981 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Thu, 30 Dec 2021 11:14:32 -0700 Subject: [PATCH 40/55] Fixed memory leak and added retry to hub discovery --- src/agora/radio_lib.cc | 283 +++++++++++++++++++++++------------------ 1 file changed, 161 insertions(+), 122 deletions(-) diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 16cf75095..2321654ce 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -8,6 +8,7 @@ #include "nlohmann/json.hpp" static constexpr bool kPrintCalibrationMats = false; +static constexpr size_t kSoapyMakeMaxAttemps = 3; RadioConfig::RadioConfig(Config* cfg) : cfg_(cfg), num_radios_initialized_(0), num_radios_configured_(0) { @@ -22,14 +23,29 @@ RadioConfig::RadioConfig(Config* cfg) << ", Antenna num: " << antenna_num_ << std::endl; if (kUseUHD == false) { for (size_t i = 0; i < cfg_->NumCells(); i++) { + SoapySDR::Device* hub_device = nullptr; if (cfg_->HubId().at(i) != "") { args["driver"] = "remote"; args["timeout"] = "1000000"; args["serial"] = cfg_->HubId().at(i); - hubs_.push_back(SoapySDR::Device::make(args)); - } else { - hubs_.push_back(nullptr); + + for (size_t tries = 0; tries < kSoapyMakeMaxAttemps; tries++) { + try { + hub_device = SoapySDR::Device::make(args); + break; + } catch (const std::runtime_error& e) { + auto* message = e.what(); + std::printf("Soapy error[%zu] -- %s\n", tries, message); + } + } + if (hub_device == nullptr) { + std::printf( + "SoapySDR failed to locate the hub device %s in %zu tries\n", + cfg_->HubId().at(i).c_str(), kSoapyMakeMaxAttemps); + throw std::runtime_error("SoapySDR failed to locate the hub device"); + } } + hubs_.push_back(hub_device); } } @@ -106,66 +122,66 @@ RadioConfig::RadioConfig(Config* cfg) for (size_t i = 0; i < this->radio_num_; i++) { std::cout << cfg_->RadioId().at(i) << ": Front end " - << ba_stn_[i]->getHardwareInfo()["frontend"] << std::endl; + << ba_stn_.at(i)->getHardwareInfo()["frontend"] << std::endl; for (auto c : channels) { - if (c < ba_stn_[i]->getNumChannels(SOAPY_SDR_RX)) { + if (c < ba_stn_.at(i)->getNumChannels(SOAPY_SDR_RX)) { std::printf("RX Channel %zu\n", c); std::printf("Actual RX sample rate: %fMSps...\n", - (ba_stn_[i]->getSampleRate(SOAPY_SDR_RX, c) / 1e6)); + (ba_stn_.at(i)->getSampleRate(SOAPY_SDR_RX, c) / 1e6)); std::printf("Actual RX frequency: %fGHz...\n", - (ba_stn_[i]->getFrequency(SOAPY_SDR_RX, c) / 1e9)); + (ba_stn_.at(i)->getFrequency(SOAPY_SDR_RX, c) / 1e9)); std::printf("Actual RX gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c))); if (!kUseUHD) { std::printf("Actual RX LNA gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA"))); std::printf("Actual RX PGA gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c, "PGA"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "PGA"))); std::printf("Actual RX TIA gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c, "TIA"))); - if (ba_stn_[i]->getHardwareInfo()["frontend"].find("CBRS") != + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "TIA"))); + if (ba_stn_.at(i)->getHardwareInfo()["frontend"].find("CBRS") != std::string::npos) { std::printf("Actual RX LNA1 gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA1"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA1"))); std::printf("Actual RX LNA2 gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA2"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA2"))); } } std::printf("Actual RX bandwidth: %fM...\n", - (ba_stn_[i]->getBandwidth(SOAPY_SDR_RX, c) / 1e6)); + (ba_stn_.at(i)->getBandwidth(SOAPY_SDR_RX, c) / 1e6)); std::printf("Actual RX antenna: %s...\n", - (ba_stn_[i]->getAntenna(SOAPY_SDR_RX, c).c_str())); + (ba_stn_.at(i)->getAntenna(SOAPY_SDR_RX, c).c_str())); } } for (auto c : channels) { - if (c < ba_stn_[i]->getNumChannels(SOAPY_SDR_TX)) { + if (c < ba_stn_.at(i)->getNumChannels(SOAPY_SDR_TX)) { std::printf("TX Channel %zu\n", c); std::printf("Actual TX sample rate: %fMSps...\n", - (ba_stn_[i]->getSampleRate(SOAPY_SDR_TX, c) / 1e6)); + (ba_stn_.at(i)->getSampleRate(SOAPY_SDR_TX, c) / 1e6)); std::printf("Actual TX frequency: %fGHz...\n", - (ba_stn_[i]->getFrequency(SOAPY_SDR_TX, c) / 1e9)); + (ba_stn_.at(i)->getFrequency(SOAPY_SDR_TX, c) / 1e9)); std::printf("Actual TX gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c))); if (!kUseUHD) { std::printf("Actual TX PAD gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c, "PAD"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PAD"))); std::printf("Actual TX IAMP gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c, "IAMP"))); - if (ba_stn_[i]->getHardwareInfo()["frontend"].find("CBRS") != + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "IAMP"))); + if (ba_stn_.at(i)->getHardwareInfo()["frontend"].find("CBRS") != std::string::npos) { std::printf("Actual TX PA1 gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA1"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA1"))); std::printf("Actual TX PA2 gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA2"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA2"))); std::printf("Actual TX PA3 gain: %f...\n", - (ba_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA3"))); + (ba_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA3"))); } } std::printf("Actual TX bandwidth: %fM...\n", - (ba_stn_[i]->getBandwidth(SOAPY_SDR_TX, c) / 1e6)); + (ba_stn_.at(i)->getBandwidth(SOAPY_SDR_TX, c) / 1e6)); std::printf("Actual TX antenna: %s...\n", - (ba_stn_[i]->getAntenna(SOAPY_SDR_TX, c).c_str())); + (ba_stn_.at(i)->getAntenna(SOAPY_SDR_TX, c).c_str())); } } std::cout << std::endl; @@ -175,7 +191,7 @@ RadioConfig::RadioConfig(Config* cfg) if (kUseUHD == false) { for (size_t i = 0; i < cfg_->NumCells(); i++) { if (hubs_.at(i) == nullptr) { - ba_stn_[i]->writeSetting("SYNC_DELAYS", ""); + ba_stn_.at(i)->writeSetting("SYNC_DELAYS", ""); } else { hubs_[i]->writeSetting("SYNC_DELAYS", ""); } @@ -198,19 +214,19 @@ void RadioConfig::InitBsRadio(size_t tid) { args["driver"] = "uhd"; args["addr"] = cfg_->RadioId().at(i); } - ba_stn_[i] = SoapySDR::Device::make(args); + ba_stn_.at(i) = SoapySDR::Device::make(args); for (auto ch : {0, 1}) { - ba_stn_[i]->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); - ba_stn_[i]->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); + ba_stn_.at(i)->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); + ba_stn_.at(i)->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); } // resets the DATA_clk domain logic. - ba_stn_[i]->writeSetting("RESET_DATA_LOGIC", ""); + ba_stn_.at(i)->writeSetting("RESET_DATA_LOGIC", ""); - rx_streams_[i] = - ba_stn_[i]->setupStream(SOAPY_SDR_RX, SOAPY_SDR_CS16, channels, sargs); - tx_streams_[i] = - ba_stn_[i]->setupStream(SOAPY_SDR_TX, SOAPY_SDR_CS16, channels, sargs); + rx_streams_.at(i) = + ba_stn_.at(i)->setupStream(SOAPY_SDR_RX, SOAPY_SDR_CS16, channels, sargs); + tx_streams_.at(i) = + ba_stn_.at(i)->setupStream(SOAPY_SDR_TX, SOAPY_SDR_CS16, channels, sargs); this->num_radios_initialized_.fetch_add(1); } @@ -221,76 +237,77 @@ void RadioConfig::ConfigureBsRadio(size_t tid) { // use the TRX antenna port for both tx and rx for (auto ch : channels) { if (kUseUHD == false) { - ba_stn_[tid]->setAntenna(SOAPY_SDR_RX, ch, "TRX"); + ba_stn_.at(tid)->setAntenna(SOAPY_SDR_RX, ch, "TRX"); } else { - ba_stn_[tid]->setAntenna(SOAPY_SDR_RX, ch, "RX2"); - ba_stn_[tid]->setAntenna(SOAPY_SDR_TX, ch, "TX/RX"); + ba_stn_.at(tid)->setAntenna(SOAPY_SDR_RX, ch, "RX2"); + ba_stn_.at(tid)->setAntenna(SOAPY_SDR_TX, ch, "TX/RX"); } } - SoapySDR::Kwargs info = ba_stn_[tid]->getHardwareInfo(); + SoapySDR::Kwargs info = ba_stn_.at(tid)->getHardwareInfo(); for (auto ch : channels) { if (kUseUHD == false) { - ba_stn_[tid]->setBandwidth(SOAPY_SDR_RX, ch, cfg_->BwFilter()); - ba_stn_[tid]->setBandwidth(SOAPY_SDR_TX, ch, cfg_->BwFilter()); + ba_stn_.at(tid)->setBandwidth(SOAPY_SDR_RX, ch, cfg_->BwFilter()); + ba_stn_.at(tid)->setBandwidth(SOAPY_SDR_TX, ch, cfg_->BwFilter()); } - // ba_stn_[tid]->setSampleRate(SOAPY_SDR_RX, ch, cfg->Rate()); - // ba_stn_[tid]->setSampleRate(SOAPY_SDR_TX, ch, cfg->Rate()); + // ba_stn_.at(tid)->setSampleRate(SOAPY_SDR_RX, ch, cfg->Rate()); + // ba_stn_.at(tid)->setSampleRate(SOAPY_SDR_TX, ch, cfg->Rate()); - ba_stn_[tid]->setFrequency(SOAPY_SDR_RX, ch, "RF", cfg_->RadioRfFreq()); - ba_stn_[tid]->setFrequency(SOAPY_SDR_RX, ch, "BB", - kUseUHD ? 0 : cfg_->Nco()); - ba_stn_[tid]->setFrequency(SOAPY_SDR_TX, ch, "RF", cfg_->RadioRfFreq()); - ba_stn_[tid]->setFrequency(SOAPY_SDR_TX, ch, "BB", - kUseUHD ? 0 : cfg_->Nco()); + ba_stn_.at(tid)->setFrequency(SOAPY_SDR_RX, ch, "RF", cfg_->RadioRfFreq()); + ba_stn_.at(tid)->setFrequency(SOAPY_SDR_RX, ch, "BB", + kUseUHD ? 0 : cfg_->Nco()); + ba_stn_.at(tid)->setFrequency(SOAPY_SDR_TX, ch, "RF", cfg_->RadioRfFreq()); + ba_stn_.at(tid)->setFrequency(SOAPY_SDR_TX, ch, "BB", + kUseUHD ? 0 : cfg_->Nco()); if (kUseUHD == false) { // Unified gains for both lime and frontend if (cfg_->SingleGain()) { // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:108] - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, + ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:105] - ba_stn_[tid]->setGain(SOAPY_SDR_TX, ch, - ch != 0u ? cfg_->TxGainB() : cfg_->TxGainA()); + ba_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, + ch != 0u ? cfg_->TxGainB() : cfg_->TxGainA()); } else { if (info["frontend"].find("CBRS") != std::string::npos) { if (cfg_->Freq() > 3e9) { - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -6); //[-18,0] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -6); //[-18,0] } else if ((cfg_->Freq() > 2e9) && (cfg_->Freq() < 3e9)) { - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -18); //[-18,0] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -18); //[-18,0] } else { - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -12); //[-18,0] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -12); //[-18,0] } - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA2", 17); //[0,17] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "LNA2", 17); //[0,17] } - ba_stn_[tid]->setGain( + ba_stn_.at(tid)->setGain( SOAPY_SDR_RX, ch, "LNA", - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); //[0,30] - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] + ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); //[0,30] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] if (info["frontend"].find("CBRS") != std::string::npos) { - ba_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "ATTN", -6); //[-18,0] by 3 - ba_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PA2", 0); //[0|15] + ba_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "ATTN", + -6); //[-18,0] by 3 + ba_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "PA2", 0); //[0|15] } - ba_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[-12,12] - ba_stn_[tid]->setGain( + ba_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[-12,12] + ba_stn_.at(tid)->setGain( SOAPY_SDR_TX, ch, "PAD", ch != 0u ? cfg_->TxGainB() : cfg_->TxGainA()); //[0,30] } } else { - ba_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA0", - ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); - ba_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PGA0", - ch != 0u ? cfg_->TxGainB() : cfg_->TxGainA()); + ba_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "PGA0", + ch != 0u ? cfg_->RxGainB() : cfg_->RxGainA()); + ba_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "PGA0", + ch != 0u ? cfg_->TxGainB() : cfg_->TxGainA()); } } for (auto ch : channels) { - ba_stn_[tid]->setDCOffsetMode(SOAPY_SDR_RX, ch, true); + ba_stn_.at(tid)->setDCOffsetMode(SOAPY_SDR_RX, ch, true); } this->num_radios_configured_.fetch_add(1); } @@ -404,9 +421,10 @@ bool RadioConfig::RadioStart() { size_t cell_id = cfg_->CellId().at(i); bool is_ref_radio = (i == cfg_->RefRadio(cell_id)); if (cfg_->HwFramer() == true) { - ba_stn_[i]->writeSetting( - "TX_SW_DELAY", "30"); // experimentally good value for dev front-end - ba_stn_[i]->writeSetting("TDD_MODE", "true"); + ba_stn_.at(i)->writeSetting( + "TX_SW_DELAY", + "30"); // experimentally good value for dev front-end + ba_stn_.at(i)->writeSetting("TDD_MODE", "true"); std::vector tdd_sched; std::string sched = cfg_->Frame().FrameIdentifier(); @@ -432,9 +450,9 @@ bool RadioConfig::RadioStart() { conf["frames"] = tdd_sched; std::string conf_string = conf.dump(); - ba_stn_[i]->writeSetting("TDD_CONFIG", conf_string); + ba_stn_.at(i)->writeSetting("TDD_CONFIG", conf_string); - ba_stn_[i]->writeRegisters("BEACON_RAM", 0, beacon); + ba_stn_.at(i)->writeRegisters("BEACON_RAM", 0, beacon); for (char const& c : cfg_->Channel()) { bool is_beacon_antenna = !cfg_->Beamsweep() && ndx == cfg_->BeaconAnt(); std::vector beacon_weights( @@ -445,32 +463,32 @@ bool RadioConfig::RadioStart() { beacon_weights.at(j) = CommsLib::Hadamard2(ndx, j); } } - ba_stn_[i]->writeRegisters(tx_ram_wgt + c, 0, beacon_weights); + ba_stn_.at(i)->writeRegisters(tx_ram_wgt + c, 0, beacon_weights); ++ndx; } - ba_stn_[i]->writeSetting("BEACON_START", std::to_string(radio_num_)); + ba_stn_.at(i)->writeSetting("BEACON_START", std::to_string(radio_num_)); if (cfg_->Frame().IsRecCalEnabled()) { if (is_ref_radio) { // Write to the first channel TX_RAM on the calibration node for // ref-to-array transmission - ba_stn_[i]->writeRegisters( + ba_stn_.at(i)->writeRegisters( std::string("TX_RAM_") + cfg_->Channel().at(0), 0, pilot); } } } if (!kUseUHD) { - ba_stn_[i]->setHardwareTime(0, "TRIGGER"); + ba_stn_.at(i)->setHardwareTime(0, "TRIGGER"); if (cfg_->HwFramer() == true) { - ba_stn_[i]->activateStream(this->rx_streams_[i]); - ba_stn_[i]->activateStream(this->tx_streams_[i]); + ba_stn_.at(i)->activateStream(this->rx_streams_.at(i)); + ba_stn_.at(i)->activateStream(this->tx_streams_.at(i)); } } else { - ba_stn_[i]->setHardwareTime(0, "UNKNOWN_PPS"); - ba_stn_[i]->activateStream(this->rx_streams_[i], SOAPY_SDR_HAS_TIME, 1e9, - 0); - ba_stn_[i]->activateStream(this->tx_streams_[i], SOAPY_SDR_HAS_TIME, 1e9, - 0); + ba_stn_.at(i)->setHardwareTime(0, "UNKNOWN_PPS"); + ba_stn_.at(i)->activateStream(this->rx_streams_.at(i), SOAPY_SDR_HAS_TIME, + 1e9, 0); + ba_stn_.at(i)->activateStream(this->tx_streams_.at(i), SOAPY_SDR_HAS_TIME, + 1e9, 0); } } @@ -478,8 +496,8 @@ bool RadioConfig::RadioStart() { this->Go(); // to set all radio timestamps to zero int flags = SOAPY_SDR_HAS_TIME; for (size_t i = 0; i < this->radio_num_; i++) { - ba_stn_[i]->activateStream(this->rx_streams_[i], flags, 1e9, 0); - ba_stn_[i]->activateStream(this->tx_streams_[i], flags, 1e9, 0); + ba_stn_.at(i)->activateStream(this->rx_streams_.at(i), flags, 1e9, 0); + ba_stn_.at(i)->activateStream(this->tx_streams_.at(i), flags, 1e9, 0); } } std::cout << "radio start done!" << std::endl; @@ -491,7 +509,7 @@ void RadioConfig::Go() { if (kUseUHD == false) { for (size_t i = 0; i < cfg_->NumCells(); i++) { if (hubs_.at(i) == nullptr) { - ba_stn_[i]->writeSetting("TRIGGER_GEN", ""); + ba_stn_.at(i)->writeSetting("TRIGGER_GEN", ""); } else { hubs_[i]->writeSetting("TRIGGER_GEN", ""); } @@ -503,8 +521,9 @@ void RadioConfig::RadioTx(void** buffs) { int flags = 0; long long frame_time(0); for (size_t i = 0; i < this->radio_num_; i++) { - ba_stn_[i]->writeStream(this->tx_streams_[i], buffs, cfg_->SampsPerSymbol(), - flags, frame_time, 1000000); + ba_stn_.at(i)->writeStream(this->tx_streams_.at(i), buffs, + cfg_->SampsPerSymbol(), flags, frame_time, + 1000000); } } @@ -520,22 +539,22 @@ int RadioConfig::RadioTx(size_t r /*radio id*/, void** buffs, int flags, int w; if (cfg_->HwFramer() == true) { - w = ba_stn_[r]->writeStream(this->tx_streams_[r], buffs, - cfg_->SampsPerSymbol(), tx_flags, frameTime, - 1000000); + w = ba_stn_.at(r)->writeStream(this->tx_streams_[r], buffs, + cfg_->SampsPerSymbol(), tx_flags, frameTime, + 1000000); } else { // For UHD device xmit from host using frameTimeNs long long frame_time_ns = SoapySDR::ticksToTimeNs(frameTime, cfg_->Rate()); - w = ba_stn_[r]->writeStream(this->tx_streams_[r], buffs, - cfg_->SampsPerSymbol(), tx_flags, frame_time_ns, - 1000000); + w = ba_stn_.at(r)->writeStream(this->tx_streams_[r], buffs, + cfg_->SampsPerSymbol(), tx_flags, + frame_time_ns, 1000000); } if (kDebugRadioTX) { size_t chan_mask; long timeout_us(0); int status_flag = 0; - int s = ba_stn_[r]->readStreamStatus(this->tx_streams_[r], chan_mask, - status_flag, frameTime, timeout_us); + int s = ba_stn_.at(r)->readStreamStatus(this->tx_streams_[r], chan_mask, + status_flag, frameTime, timeout_us); std::cout << "radio " << r << " tx returned " << w << " and status " << s << " when flags was " << flags << std::endl; } @@ -547,8 +566,9 @@ void RadioConfig::RadioRx(void** buffs) { long long frame_time(0); for (size_t i = 0; i < this->radio_num_; i++) { void** buff = buffs + (i * 2); - ba_stn_[i]->readStream(this->rx_streams_[i], buff, cfg_->SampsPerSymbol(), - flags, frame_time, 1000000); + ba_stn_.at(i)->readStream(this->rx_streams_.at(i), buff, + cfg_->SampsPerSymbol(), flags, frame_time, + 1000000); } } @@ -557,9 +577,9 @@ int RadioConfig::RadioRx(size_t r /*radio id*/, void** buffs, int flags = 0; if (r < this->radio_num_) { long long frame_time_ns = 0; - int ret = ba_stn_[r]->readStream(this->rx_streams_[r], buffs, - cfg_->SampsPerSymbol(), flags, - frame_time_ns, 1000000); + int ret = ba_stn_.at(r)->readStream(this->rx_streams_[r], buffs, + cfg_->SampsPerSymbol(), flags, + frame_time_ns, 1000000); if (cfg_->HwFramer() == true) { // SoapySDR::timeNsToTicks(frameTimeNs, _rate); @@ -590,7 +610,7 @@ void RadioConfig::DrainBuffers() { dummybuffs[0] = dummy_buff0.data(); dummybuffs[1] = dummy_buff1.data(); for (size_t i = 0; i < cfg_->NumRadios(); i++) { - RadioConfig::DrainRxBuffer(ba_stn_[i], rx_streams_[i], dummybuffs, + RadioConfig::DrainRxBuffer(ba_stn_.at(i), rx_streams_.at(i), dummybuffs, cfg_->SampsPerSymbol()); } } @@ -614,20 +634,24 @@ void RadioConfig::DrainRxBuffer(SoapySDR::Device* ibsSdrs, void RadioConfig::ReadSensors() { for (size_t i = 0; i < this->radio_num_; i++) { std::cout << "TEMPs on Iris " << i << std::endl; - std::cout << "ZYNQ_TEMP: " << ba_stn_[i]->readSensor("ZYNQ_TEMP") + std::cout << "ZYNQ_TEMP: " << ba_stn_.at(i)->readSensor("ZYNQ_TEMP") << std::endl; - std::cout << "LMS7_TEMP : " << ba_stn_[i]->readSensor("LMS7_TEMP") + std::cout << "LMS7_TEMP : " << ba_stn_.at(i)->readSensor("LMS7_TEMP") << std::endl; - std::cout << "FE_TEMP : " << ba_stn_[i]->readSensor("FE_TEMP") + std::cout << "FE_TEMP : " << ba_stn_.at(i)->readSensor("FE_TEMP") << std::endl; std::cout << "TX0 TEMP : " - << ba_stn_[i]->readSensor(SOAPY_SDR_TX, 0, "TEMP") << std::endl; + << ba_stn_.at(i)->readSensor(SOAPY_SDR_TX, 0, "TEMP") + << std::endl; std::cout << "TX1 TEMP : " - << ba_stn_[i]->readSensor(SOAPY_SDR_TX, 1, "TEMP") << std::endl; + << ba_stn_.at(i)->readSensor(SOAPY_SDR_TX, 1, "TEMP") + << std::endl; std::cout << "RX0 TEMP : " - << ba_stn_[i]->readSensor(SOAPY_SDR_RX, 0, "TEMP") << std::endl; + << ba_stn_.at(i)->readSensor(SOAPY_SDR_RX, 0, "TEMP") + << std::endl; std::cout << "RX1 TEMP : " - << ba_stn_[i]->readSensor(SOAPY_SDR_RX, 1, "TEMP") << std::endl; + << ba_stn_.at(i)->readSensor(SOAPY_SDR_RX, 1, "TEMP") + << std::endl; std::cout << std::endl; } } @@ -637,19 +661,34 @@ void RadioConfig::RadioStop() { std::string corr_conf_str = "{\"corr_enabled\":false}"; std::string tdd_conf_str = "{\"tdd_enabled\":false}"; for (size_t i = 0; i < this->radio_num_; i++) { - ba_stn_[i]->deactivateStream(this->rx_streams_[i]); - ba_stn_[i]->deactivateStream(this->tx_streams_[i]); - ba_stn_[i]->writeSetting("TDD_MODE", "false"); - ba_stn_[i]->writeSetting("TDD_CONFIG", tdd_conf_str); + ba_stn_.at(i)->deactivateStream(this->rx_streams_.at(i)); + ba_stn_.at(i)->deactivateStream(this->tx_streams_.at(i)); + ba_stn_.at(i)->writeSetting("TDD_MODE", "false"); + ba_stn_.at(i)->writeSetting("TDD_CONFIG", tdd_conf_str); } } RadioConfig::~RadioConfig() { FreeBuffer1d(&init_calib_dl_processed_); FreeBuffer1d(&init_calib_ul_processed_); - for (size_t i = 0; i < this->radio_num_; i++) { - ba_stn_[i]->closeStream(this->rx_streams_[i]); - ba_stn_[i]->closeStream(this->tx_streams_[i]); - SoapySDR::Device::unmake(ba_stn_[i]); + + if ((radio_num_ != ba_stn_.size()) || (rx_streams_.size() != radio_num_) || + (tx_streams_.size() != radio_num_)) { + std::printf( + "**************************** BAD NEWS ****************************"); + std::printf("radio_num_ != the size of the radio array!"); + } + + for (size_t i = 0; i < radio_num_; i++) { + ba_stn_.at(i)->closeStream(rx_streams_.at(i)); + ba_stn_.at(i)->closeStream(tx_streams_.at(i)); + SoapySDR::Device::unmake(ba_stn_.at(i)); + ba_stn_.at(i) = nullptr; + } + ba_stn_.clear(); + + for (auto hub : hubs_) { + SoapySDR::Device::unmake(hub); } + hubs_.clear(); } From 69a9c190bf5f39c6adeda681ce50d7173eb99b75 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Thu, 30 Dec 2021 12:56:00 -0600 Subject: [PATCH 41/55] Added additional retries on all ::make calls --- src/agora/radio_lib.cc | 21 ++- src/client/client_radio.cc | 272 ++++++++++++++++++++----------------- src/client/client_radio.h | 1 - 3 files changed, 165 insertions(+), 129 deletions(-) diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index 2321654ce..67a27c037 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -8,7 +8,7 @@ #include "nlohmann/json.hpp" static constexpr bool kPrintCalibrationMats = false; -static constexpr size_t kSoapyMakeMaxAttemps = 3; +static constexpr size_t kSoapyMakeMaxAttemps = 2; RadioConfig::RadioConfig(Config* cfg) : cfg_(cfg), num_radios_initialized_(0), num_radios_configured_(0) { @@ -214,7 +214,24 @@ void RadioConfig::InitBsRadio(size_t tid) { args["driver"] = "uhd"; args["addr"] = cfg_->RadioId().at(i); } - ba_stn_.at(i) = SoapySDR::Device::make(args); + + SoapySDR::Device* bs_device = nullptr; + for (size_t tries = 0; tries < kSoapyMakeMaxAttemps; tries++) { + try { + bs_device = SoapySDR::Device::make(args); + break; + } catch (const std::runtime_error& e) { + auto* message = e.what(); + std::printf("InitBsRadio[%zu] - Soapy error try %zu -- %s\n", tid, tries, + message); + } + } + if (bs_device == nullptr) { + std::printf("SoapySDR failed to locate the Bs radio %s in %zu attempts\n", + cfg_->RadioId().at(tid).c_str(), kSoapyMakeMaxAttemps); + throw std::runtime_error("SoapySDR failed to locate the Bs radio"); + } + ba_stn_.at(i) = bs_device; for (auto ch : {0, 1}) { ba_stn_.at(i)->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); ba_stn_.at(i)->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index 3c45b4811..5db865d68 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -8,6 +8,8 @@ #include "comms-lib.h" #include "nlohmann/json.hpp" +static constexpr size_t kSoapyMakeMaxAttemps = 2; + ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { SoapySDR::Kwargs args; SoapySDR::Kwargs sargs; @@ -55,66 +57,66 @@ ClientRadioConfig::ClientRadioConfig(const Config* const cfg) : cfg_(cfg) { for (size_t i = 0; i < this->radio_num_; i++) { std::cout << cfg_->UeRadioId().at(i) << ": Front end " - << cl_stn_[i]->getHardwareInfo()["frontend"] << std::endl; + << cl_stn_.at(i)->getHardwareInfo()["frontend"] << std::endl; for (auto c : channels) { - if (c < cl_stn_[i]->getNumChannels(SOAPY_SDR_RX)) { + if (c < cl_stn_.at(i)->getNumChannels(SOAPY_SDR_RX)) { std::printf("RX Channel %zu\n", c); std::printf("Actual RX sample rate: %fMSps...\n", - (cl_stn_[i]->getSampleRate(SOAPY_SDR_RX, c) / 1e6)); + (cl_stn_.at(i)->getSampleRate(SOAPY_SDR_RX, c) / 1e6)); std::printf("Actual RX frequency: %fGHz...\n", - (cl_stn_[i]->getFrequency(SOAPY_SDR_RX, c) / 1e9)); + (cl_stn_.at(i)->getFrequency(SOAPY_SDR_RX, c) / 1e9)); std::printf("Actual RX gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c))); if (!kUseUHD) { std::printf("Actual RX LNA gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA"))); std::printf("Actual RX PGA gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c, "PGA"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "PGA"))); std::printf("Actual RX TIA gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c, "TIA"))); - if (cl_stn_[i]->getHardwareInfo()["frontend"].find("CBRS") != + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "TIA"))); + if (cl_stn_.at(i)->getHardwareInfo()["frontend"].find("CBRS") != std::string::npos) { std::printf("Actual RX LNA1 gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA1"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA1"))); std::printf("Actual RX LNA2 gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_RX, c, "LNA2"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_RX, c, "LNA2"))); } } std::printf("Actual RX bandwidth: %fM...\n", - (cl_stn_[i]->getBandwidth(SOAPY_SDR_RX, c) / 1e6)); + (cl_stn_.at(i)->getBandwidth(SOAPY_SDR_RX, c) / 1e6)); std::printf("Actual RX antenna: %s...\n", - (cl_stn_[i]->getAntenna(SOAPY_SDR_RX, c).c_str())); + (cl_stn_.at(i)->getAntenna(SOAPY_SDR_RX, c).c_str())); } } for (auto c : channels) { - if (c < cl_stn_[i]->getNumChannels(SOAPY_SDR_TX)) { + if (c < cl_stn_.at(i)->getNumChannels(SOAPY_SDR_TX)) { std::printf("TX Channel %zu\n", c); std::printf("Actual TX sample rate: %fMSps...\n", - (cl_stn_[i]->getSampleRate(SOAPY_SDR_TX, c) / 1e6)); + (cl_stn_.at(i)->getSampleRate(SOAPY_SDR_TX, c) / 1e6)); std::printf("Actual TX frequency: %fGHz...\n", - (cl_stn_[i]->getFrequency(SOAPY_SDR_TX, c) / 1e9)); + (cl_stn_.at(i)->getFrequency(SOAPY_SDR_TX, c) / 1e9)); std::printf("Actual TX gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c))); if (!kUseUHD) { std::printf("Actual TX PAD gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c, "PAD"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PAD"))); std::printf("Actual TX IAMP gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c, "IAMP"))); - if (cl_stn_[i]->getHardwareInfo()["frontend"].find("CBRS") != + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "IAMP"))); + if (cl_stn_.at(i)->getHardwareInfo()["frontend"].find("CBRS") != std::string::npos) { std::printf("Actual TX PA1 gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA1"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA1"))); std::printf("Actual TX PA2 gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA2"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA2"))); std::printf("Actual TX PA3 gain: %f...\n", - (cl_stn_[i]->getGain(SOAPY_SDR_TX, c, "PA3"))); + (cl_stn_.at(i)->getGain(SOAPY_SDR_TX, c, "PA3"))); } } std::printf("Actual TX bandwidth: %fM...\n", - (cl_stn_[i]->getBandwidth(SOAPY_SDR_TX, c) / 1e6)); + (cl_stn_.at(i)->getBandwidth(SOAPY_SDR_TX, c) / 1e6)); std::printf("Actual TX antenna: %s...\n", - (cl_stn_[i]->getAntenna(SOAPY_SDR_TX, c).c_str())); + (cl_stn_.at(i)->getAntenna(SOAPY_SDR_TX, c).c_str())); } } std::cout << std::endl; @@ -136,99 +138,118 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { args["driver"] = "uhd"; args["addr"] = cfg_->UeRadioId().at(tid); } - cl_stn_[tid] = SoapySDR::Device::make(args); + + SoapySDR::Device* ue_device = nullptr; + for (size_t tries = 0; tries < kSoapyMakeMaxAttemps; tries++) { + try { + ue_device = SoapySDR::Device::make(args); + break; + } catch (const std::runtime_error& e) { + auto* message = e.what(); + std::printf("InitClientRadio[%zu] - Soapy error try %zu -- %s\n", tid, + tries, message); + } + } + if (ue_device == nullptr) { + std::printf("SoapySDR failed to locate the Ue device %s in %zu attempts\n", + cfg_->UeRadioId().at(tid).c_str(), kSoapyMakeMaxAttemps); + throw std::runtime_error("SoapySDR failed to locate the Ue device"); + } + cl_stn_.at(tid) = ue_device; + for (auto ch : channels) { - cl_stn_[tid]->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); - cl_stn_[tid]->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); + cl_stn_.at(tid)->setSampleRate(SOAPY_SDR_RX, ch, cfg_->Rate()); + cl_stn_.at(tid)->setSampleRate(SOAPY_SDR_TX, ch, cfg_->Rate()); } - rx_streams_[tid] = - cl_stn_[tid]->setupStream(SOAPY_SDR_RX, SOAPY_SDR_CS16, channels, sargs); - tx_streams_[tid] = - cl_stn_[tid]->setupStream(SOAPY_SDR_TX, SOAPY_SDR_CS16, channels, sargs); + rx_streams_.at(tid) = cl_stn_.at(tid)->setupStream( + SOAPY_SDR_RX, SOAPY_SDR_CS16, channels, sargs); + tx_streams_.at(tid) = cl_stn_.at(tid)->setupStream( + SOAPY_SDR_TX, SOAPY_SDR_CS16, channels, sargs); // resets the DATA_clk domain logic. if (!kUseUHD) { - cl_stn_[tid]->writeSetting("RESET_DATA_LOGIC", ""); + cl_stn_.at(tid)->writeSetting("RESET_DATA_LOGIC", ""); } // use the TRX antenna port for both tx and rx for (auto ch : channels) { if (!kUseUHD) { - cl_stn_[tid]->setAntenna(SOAPY_SDR_RX, ch, "TRX"); + cl_stn_.at(tid)->setAntenna(SOAPY_SDR_RX, ch, "TRX"); } else { - cl_stn_[tid]->setAntenna(SOAPY_SDR_RX, ch, "RX2"); - cl_stn_[tid]->setAntenna(SOAPY_SDR_TX, ch, "TX/RX"); + cl_stn_.at(tid)->setAntenna(SOAPY_SDR_RX, ch, "RX2"); + cl_stn_.at(tid)->setAntenna(SOAPY_SDR_TX, ch, "TX/RX"); } } - SoapySDR::Kwargs info = cl_stn_[tid]->getHardwareInfo(); + SoapySDR::Kwargs info = cl_stn_.at(tid)->getHardwareInfo(); for (auto ch : channels) { - cl_stn_[tid]->setBandwidth(SOAPY_SDR_RX, ch, cfg_->BwFilter()); - cl_stn_[tid]->setBandwidth(SOAPY_SDR_TX, ch, cfg_->BwFilter()); + cl_stn_.at(tid)->setBandwidth(SOAPY_SDR_RX, ch, cfg_->BwFilter()); + cl_stn_.at(tid)->setBandwidth(SOAPY_SDR_TX, ch, cfg_->BwFilter()); - // cl_stn_[tid]->setSampleRate(SOAPY_SDR_RX, ch, cfg->rate); - // cl_stn_[tid]->setSampleRate(SOAPY_SDR_TX, ch, cfg->rate); + // cl_stn_.at(tid)->setSampleRate(SOAPY_SDR_RX, ch, cfg->rate); + // cl_stn_.at(tid)->setSampleRate(SOAPY_SDR_TX, ch, cfg->rate); - cl_stn_[tid]->setFrequency(SOAPY_SDR_RX, ch, "RF", cfg_->RadioRfFreq()); - cl_stn_[tid]->setFrequency(SOAPY_SDR_RX, ch, "BB", - kUseUHD ? 0 : cfg_->Nco()); - cl_stn_[tid]->setFrequency(SOAPY_SDR_TX, ch, "RF", cfg_->RadioRfFreq()); - cl_stn_[tid]->setFrequency(SOAPY_SDR_TX, ch, "BB", - kUseUHD ? 0 : cfg_->Nco()); + cl_stn_.at(tid)->setFrequency(SOAPY_SDR_RX, ch, "RF", cfg_->RadioRfFreq()); + cl_stn_.at(tid)->setFrequency(SOAPY_SDR_RX, ch, "BB", + kUseUHD ? 0 : cfg_->Nco()); + cl_stn_.at(tid)->setFrequency(SOAPY_SDR_TX, ch, "RF", cfg_->RadioRfFreq()); + cl_stn_.at(tid)->setFrequency(SOAPY_SDR_TX, ch, "BB", + kUseUHD ? 0 : cfg_->Nco()); if (!kUseUHD) { // Unified gains for both lime and frontend if (cfg_->SingleGain()) { // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:108] - cl_stn_[tid]->setGain( + cl_stn_.at(tid)->setGain( SOAPY_SDR_RX, ch, ch != 0u ? cfg_->ClientRxGainB(tid) : cfg_->ClientRxGainA(tid)); // w/CBRS 3.6GHz [0:105], 2.5GHZ [0:105] - cl_stn_[tid]->setGain( + cl_stn_.at(tid)->setGain( SOAPY_SDR_TX, ch, ch != 0u ? cfg_->ClientTxGainB(tid) : cfg_->ClientTxGainA(tid)); } else { if (info["frontend"].find("CBRS") != std::string::npos) { if (cfg_->Freq() > 3e9) { - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -6); //[-18,0] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -6); //[-18,0] } else if ((cfg_->Freq() > 2e9) && (cfg_->Freq() < 3e9)) { - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -18); //[-18,0] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -18); //[-18,0] } else { - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "ATTN", -12); //[-18,0] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "ATTN", -12); //[-18,0] } - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA2", 17); //[0,17] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "LNA2", 17); //[0,17] } - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "LNA", - ch != 0u ? cfg_->ClientRxGainB(tid) - : cfg_->ClientRxGainA(tid)); //[0,30] - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] - cl_stn_[tid]->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "LNA", + ch != 0u ? cfg_->ClientRxGainB(tid) + : cfg_->ClientRxGainA(tid)); //[0,30] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "TIA", 0); //[0,12] + cl_stn_.at(tid)->setGain(SOAPY_SDR_RX, ch, "PGA", 0); //[-12,19] if (info["frontend"].find("CBRS") != std::string::npos) { - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "ATTN", -6); //[-18,0] by 3 - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PA2", 0); //[0|15] + cl_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "ATTN", + -6); //[-18,0] by 3 + cl_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "PA2", 0); //[0|15] } - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[0,12] - cl_stn_[tid]->setGain(SOAPY_SDR_TX, ch, "PAD", - ch != 0u ? cfg_->ClientTxGainB(tid) - : cfg_->ClientTxGainA(tid)); //[0,30] + cl_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "IAMP", 0); //[0,12] + cl_stn_.at(tid)->setGain(SOAPY_SDR_TX, ch, "PAD", + ch != 0u ? cfg_->ClientTxGainB(tid) + : cfg_->ClientTxGainA(tid)); //[0,30] } } else { - cl_stn_[tid]->setGain( + cl_stn_.at(tid)->setGain( SOAPY_SDR_RX, ch, "PGA0", ch != 0u ? cfg_->ClientRxGainB(tid) : cfg_->ClientRxGainA(tid)); - cl_stn_[tid]->setGain( + cl_stn_.at(tid)->setGain( SOAPY_SDR_TX, ch, "PGA0", ch != 0u ? cfg_->ClientTxGainB(tid) : cfg_->ClientTxGainA(tid)); } } for (auto ch : channels) { - // cl_stn_[tid]->writeSetting(SOAPY_SDR_RX, ch, "CALIBRATE", "SKLK"); - // cl_stn_[tid]->writeSetting(SOAPY_SDR_TX, ch, "CALIBRATE", ""); + // cl_stn_.at(tid)->writeSetting(SOAPY_SDR_RX, ch, "CALIBRATE", "SKLK"); + // cl_stn_.at(tid)->writeSetting(SOAPY_SDR_TX, ch, "CALIBRATE", ""); if (!kUseUHD) { - cl_stn_[tid]->setDCOffsetMode(SOAPY_SDR_RX, ch, true); + cl_stn_.at(tid)->setDCOffsetMode(SOAPY_SDR_RX, ch, true); } } this->num_client_radios_initialized_.fetch_add(1); @@ -283,40 +304,40 @@ bool ClientRadioConfig::RadioStart() { conf["frames"] = jframes; conf["symbol_size"] = cfg_->SampsPerSymbol(); std::string conf_string = conf.dump(); - cl_stn_[i]->writeSetting("TDD_CONFIG", conf_string); - cl_stn_[i]->setHardwareTime( + cl_stn_.at(i)->writeSetting("TDD_CONFIG", conf_string); + cl_stn_.at(i)->setHardwareTime( SoapySDR::ticksToTimeNs((sf_start << 16) | sp_start, cfg_->Rate()), "TRIGGER"); - cl_stn_[i]->writeSetting( + cl_stn_.at(i)->writeSetting( "TX_SW_DELAY", "30"); // experimentally good value for dev front-end - cl_stn_[i]->writeSetting("TDD_MODE", "true"); + cl_stn_.at(i)->writeSetting("TDD_MODE", "true"); for (char const& c : cfg_->UeChannel()) { std::string tx_ram = "TX_RAM_"; - cl_stn_[i]->writeRegisters(tx_ram + c, 0, pilot); + cl_stn_.at(i)->writeRegisters(tx_ram + c, 0, pilot); } - cl_stn_[i]->activateStream(this->rx_streams_[i], flags, 0); - cl_stn_[i]->activateStream(this->tx_streams_[i]); + cl_stn_.at(i)->activateStream(this->rx_streams_.at(i), flags, 0); + cl_stn_.at(i)->activateStream(this->tx_streams_.at(i)); std::string corr_conf_string = R"({"corr_enabled":true,"corr_threshold":)" + std::to_string(1) + "}"; - cl_stn_[i]->writeSetting("CORR_CONFIG", corr_conf_string); - cl_stn_[i]->writeRegisters("CORR_COE", 0, cfg_->Coeffs()); + cl_stn_.at(i)->writeSetting("CORR_CONFIG", corr_conf_string); + cl_stn_.at(i)->writeRegisters("CORR_COE", 0, cfg_->Coeffs()); - cl_stn_[i]->writeSetting("CORR_START", - (cfg_->UeChannel() == "B") ? "B" : "A"); + cl_stn_.at(i)->writeSetting("CORR_START", + (cfg_->UeChannel() == "B") ? "B" : "A"); } else { if (!kUseUHD) { - cl_stn_[i]->setHardwareTime(0, "TRIGGER"); - cl_stn_[i]->activateStream(this->rx_streams_[i], flags, 0); - cl_stn_[i]->activateStream(this->tx_streams_[i]); - cl_stn_[i]->writeSetting("TRIGGER_GEN", ""); + cl_stn_.at(i)->setHardwareTime(0, "TRIGGER"); + cl_stn_.at(i)->activateStream(this->rx_streams_.at(i), flags, 0); + cl_stn_.at(i)->activateStream(this->tx_streams_.at(i)); + cl_stn_.at(i)->writeSetting("TRIGGER_GEN", ""); } else { - cl_stn_[i]->setHardwareTime(0, "UNKNOWN_PPS"); - cl_stn_[i]->activateStream(this->rx_streams_[i], SOAPY_SDR_HAS_TIME, - 1e9, 0); - cl_stn_[i]->activateStream(this->tx_streams_[i], SOAPY_SDR_HAS_TIME, - 1e9, 0); + cl_stn_.at(i)->setHardwareTime(0, "UNKNOWN_PPS"); + cl_stn_.at(i)->activateStream(this->rx_streams_.at(i), + SOAPY_SDR_HAS_TIME, 1e9, 0); + cl_stn_.at(i)->activateStream(this->tx_streams_.at(i), + SOAPY_SDR_HAS_TIME, 1e9, 0); } } } @@ -327,13 +348,8 @@ bool ClientRadioConfig::RadioStart() { void ClientRadioConfig::Go() { if (!kUseUHD) { - if (hubs_.empty()) { - // std::cout << "triggering first Iris ..." << std::endl; - cl_stn_[0]->writeSetting("TRIGGER_GEN", ""); - } else { - // std::cout << "triggering Hub ..." << std::endl; - hubs_[0]->writeSetting("TRIGGER_GEN", ""); - } + // std::cout << "triggering first Iris ..." << std::endl; + cl_stn_.at(0)->writeSetting("TRIGGER_GEN", ""); } } @@ -348,19 +364,19 @@ int ClientRadioConfig::RadioTx(size_t r /*radio id*/, void** buffs, } int w(0); if (cfg_->UeHwFramer()) { - w = cl_stn_[r]->writeStream(this->tx_streams_[r], buffs, num_samps, - tx_flags, frameTime, 1000000); + w = cl_stn_.at(r)->writeStream(this->tx_streams_.at(r), buffs, num_samps, + tx_flags, frameTime, 1000000); } else { long long frame_time_ns = SoapySDR::ticksToTimeNs(frameTime, cfg_->Rate()); - w = cl_stn_[r]->writeStream(this->tx_streams_[r], buffs, num_samps, - tx_flags, frame_time_ns, 1000000); + w = cl_stn_.at(r)->writeStream(this->tx_streams_.at(r), buffs, num_samps, + tx_flags, frame_time_ns, 1000000); } if (kDebugRadioTX) { size_t chan_mask; long timeout_us(0); int status_flag = 0; - int s = cl_stn_[r]->readStreamStatus(this->tx_streams_[r], chan_mask, - status_flag, frameTime, timeout_us); + int s = cl_stn_.at(r)->readStreamStatus(this->tx_streams_.at(r), chan_mask, + status_flag, frameTime, timeout_us); std::cout << "radio " << r << " tx returned " << w << " and status " << s << " when flags was " << flags << std::endl; } @@ -373,12 +389,12 @@ int ClientRadioConfig::RadioRx(size_t r /*radio id*/, void** buffs, if (r < this->radio_num_) { int ret(0); if (cfg_->UeHwFramer()) { - ret = cl_stn_[r]->readStream(this->rx_streams_[r], buffs, num_samps, - flags, frameTime, 1000000); + ret = cl_stn_.at(r)->readStream(this->rx_streams_.at(r), buffs, num_samps, + flags, frameTime, 1000000); } else { long long frame_time_ns = 0; - ret = cl_stn_[r]->readStream(this->rx_streams_[r], buffs, num_samps, - flags, frame_time_ns, 1000000); + ret = cl_stn_.at(r)->readStream(this->rx_streams_.at(r), buffs, num_samps, + flags, frame_time_ns, 1000000); frameTime = SoapySDR::timeNsToTicks(frame_time_ns, cfg_->Rate()); } if (kDebugRadioRX) { @@ -402,8 +418,8 @@ void ClientRadioConfig::DrainBuffers() { dummybuffs[0] = dummy_buff0.data(); dummybuffs[1] = dummy_buff1.data(); for (size_t i = 0; i < cfg_->UeNum(); i++) { - ClientRadioConfig::DrainRxBuffer(cl_stn_[i], rx_streams_[i], dummybuffs, - cfg_->SampsPerSymbol()); + ClientRadioConfig::DrainRxBuffer(cl_stn_.at(i), rx_streams_.at(i), + dummybuffs, cfg_->SampsPerSymbol()); } } @@ -425,26 +441,30 @@ void ClientRadioConfig::DrainRxBuffer(SoapySDR::Device* dev, } int ClientRadioConfig::Triggers(int i) { - return std::stoi(cl_stn_[i]->readSetting("TRIGGER_COUNT")); + return std::stoi(cl_stn_.at(i)->readSetting("TRIGGER_COUNT")); } void ClientRadioConfig::ReadSensors() { for (size_t i = 0; i < this->radio_num_; i++) { std::cout << "TEMPs on Iris " << i << std::endl; - std::cout << "ZYNQ_TEMP: " << cl_stn_[i]->readSensor("ZYNQ_TEMP") + std::cout << "ZYNQ_TEMP: " << cl_stn_.at(i)->readSensor("ZYNQ_TEMP") << std::endl; - std::cout << "LMS7_TEMP : " << cl_stn_[i]->readSensor("LMS7_TEMP") + std::cout << "LMS7_TEMP : " << cl_stn_.at(i)->readSensor("LMS7_TEMP") << std::endl; - std::cout << "FE_TEMP : " << cl_stn_[i]->readSensor("FE_TEMP") + std::cout << "FE_TEMP : " << cl_stn_.at(i)->readSensor("FE_TEMP") << std::endl; std::cout << "TX0 TEMP : " - << cl_stn_[i]->readSensor(SOAPY_SDR_TX, 0, "TEMP") << std::endl; + << cl_stn_.at(i)->readSensor(SOAPY_SDR_TX, 0, "TEMP") + << std::endl; std::cout << "TX1 TEMP : " - << cl_stn_[i]->readSensor(SOAPY_SDR_TX, 1, "TEMP") << std::endl; + << cl_stn_.at(i)->readSensor(SOAPY_SDR_TX, 1, "TEMP") + << std::endl; std::cout << "RX0 TEMP : " - << cl_stn_[i]->readSensor(SOAPY_SDR_RX, 0, "TEMP") << std::endl; + << cl_stn_.at(i)->readSensor(SOAPY_SDR_RX, 0, "TEMP") + << std::endl; std::cout << "RX1 TEMP : " - << cl_stn_[i]->readSensor(SOAPY_SDR_RX, 1, "TEMP") << std::endl; + << cl_stn_.at(i)->readSensor(SOAPY_SDR_RX, 1, "TEMP") + << std::endl; std::cout << std::endl; } } @@ -452,21 +472,21 @@ void ClientRadioConfig::ReadSensors() { void ClientRadioConfig::RadioStop() { std::string corr_conf_str = "{\"corr_enabled\":false}"; std::string tdd_conf_str = "{\"tdd_enabled\":false}"; - for (size_t i = 0; i < this->radio_num_; i++) { - cl_stn_[i]->deactivateStream(this->rx_streams_[i]); - cl_stn_[i]->deactivateStream(this->tx_streams_[i]); + for (size_t i = 0; i < radio_num_; i++) { + cl_stn_.at(i)->deactivateStream(rx_streams_.at(i)); + cl_stn_.at(i)->deactivateStream(tx_streams_.at(i)); if (cfg_->UeHwFramer()) { - cl_stn_[i]->writeSetting("TDD_MODE", "false"); - cl_stn_[i]->writeSetting("TDD_CONFIG", tdd_conf_str); - cl_stn_[i]->writeSetting("CORR_CONFIG", corr_conf_str); + cl_stn_.at(i)->writeSetting("TDD_MODE", "false"); + cl_stn_.at(i)->writeSetting("TDD_CONFIG", tdd_conf_str); + cl_stn_.at(i)->writeSetting("CORR_CONFIG", corr_conf_str); } } } ClientRadioConfig::~ClientRadioConfig() { - for (size_t i = 0; i < this->radio_num_; i++) { - cl_stn_[i]->closeStream(this->rx_streams_[i]); - cl_stn_[i]->closeStream(this->tx_streams_[i]); - SoapySDR::Device::unmake(cl_stn_[i]); + for (size_t i = 0; i < radio_num_; i++) { + cl_stn_.at(i)->closeStream(rx_streams_.at(i)); + cl_stn_.at(i)->closeStream(tx_streams_.at(i)); + SoapySDR::Device::unmake(cl_stn_.at(i)); } } diff --git a/src/client/client_radio.h b/src/client/client_radio.h index 2cf30a540..af5f299df 100644 --- a/src/client/client_radio.h +++ b/src/client/client_radio.h @@ -50,7 +50,6 @@ class ClientRadioConfig { void InitClientRadio(size_t tid); const Config* const cfg_; - std::vector hubs_; std::vector cl_stn_; SoapySDR::Device* ref_; SoapySDR::Stream* ref_rx_stream_; From 5719a3a94cc43c533e4b44307b27ed88bc933c3f Mon Sep 17 00:00:00 2001 From: rdoost Date: Thu, 30 Dec 2021 11:38:27 -0600 Subject: [PATCH 42/55] Use single JSON config in channel simulator --- simulator/channel.cc | 20 ++--- simulator/channel.h | 7 +- simulator/channel_sim.cc | 146 ++++++++++++++++----------------- simulator/channel_sim.h | 13 ++- simulator/chsim_main.cc | 14 +--- test/sim_tests/test_e2e_sim.sh | 2 +- 6 files changed, 93 insertions(+), 109 deletions(-) diff --git a/simulator/channel.cc b/simulator/channel.cc index a7e2f96be..9503cb078 100644 --- a/simulator/channel.cc +++ b/simulator/channel.cc @@ -9,15 +9,14 @@ static constexpr bool kPrintChannelOutput = false; static constexpr bool kPrintSNRCheck = false; -Channel::Channel(const Config* const config_bs, const Config* const config_ue, - std::string& in_channel_type, double in_channel_snr) - : bscfg_(config_bs), - uecfg_(config_ue), +Channel::Channel(const Config* const config, std::string& in_channel_type, + double in_channel_snr) + : cfg_(config), sim_chan_model_(std::move(in_channel_type)), channel_snr_db_(in_channel_snr) { - bs_ant_ = bscfg_->BsAntNum(); - ue_ant_ = uecfg_->UeAntNum(); - n_samps_ = bscfg_->SampsPerSymbol(); + bs_ant_ = cfg_->BsAntNum(); + ue_ant_ = cfg_->UeAntNum(); + n_samps_ = cfg_->SampsPerSymbol(); if (sim_chan_model_ == "AWGN") { chan_model_ = kAwgn; @@ -64,7 +63,7 @@ void Channel::ApplyChan(const arma::cx_fmat& fmat_src, arma::cx_fmat& fmat_dst, } } if (is_downlink) { - fmat_h = fmat_src * h_.st() / std::sqrt(bscfg_->BsAntNum()); + fmat_h = fmat_src * h_.st() / std::sqrt(cfg_->BsAntNum()); } else { fmat_h = fmat_src * h_; } @@ -118,9 +117,8 @@ void Channel::Awgn(const arma::cx_fmat& src, arma::cx_fmat& dst) const { void Channel::Lte3gpp(const arma::cx_fmat& fmat_src, arma::cx_fmat& fmat_dst) { // TODO - In progress (Use Rayleigh for now...) - arma::cx_fmat h( - arma::randn(uecfg_->UeAntNum(), bscfg_->BsAntNum()), - arma::randn(uecfg_->UeAntNum(), bscfg_->BsAntNum())); + arma::cx_fmat h(arma::randn(cfg_->UeAntNum(), cfg_->BsAntNum()), + arma::randn(cfg_->UeAntNum(), cfg_->BsAntNum())); h = (1 / sqrt(2)) * h; fmat_dst = fmat_src * h; } diff --git a/simulator/channel.h b/simulator/channel.h index adfe17d1c..437cf3626 100644 --- a/simulator/channel.h +++ b/simulator/channel.h @@ -23,8 +23,8 @@ class Channel { public: - Channel(const Config* const config_bs, const Config* const config_ue, - std::string& channel_type, double channel_snr); + Channel(const Config* const config, std::string& channel_type, + double channel_snr); ~Channel(); // Dimensions of fmat_src: ( bscfg->sampsPerSymbol, uecfg->UE_ANT_NUM ) @@ -49,8 +49,7 @@ class Channel { void Lte3gpp(const arma::cx_fmat& fmat_src, arma::cx_fmat& fmat_dst); private: - const Config* const bscfg_; - const Config* const uecfg_; + const Config* const cfg_; Channel* channel_; size_t bs_ant_; diff --git a/simulator/channel_sim.cc b/simulator/channel_sim.cc index d80ed3935..08d1f4d15 100644 --- a/simulator/channel_sim.cc +++ b/simulator/channel_sim.cc @@ -47,17 +47,15 @@ struct SocketRxBuffer { uint8_t* data_ = nullptr; }; -ChannelSim::ChannelSim(const Config* const config_bs, - const Config* const config_ue, size_t bs_thread_num, +ChannelSim::ChannelSim(const Config* const config, size_t bs_thread_num, size_t user_thread_num, size_t worker_thread_num, size_t in_core_offset, std::string in_chan_type, double in_chan_snr) - : bscfg_(config_bs), - uecfg_(config_ue), + : cfg_(config), bs_thread_num_(bs_thread_num), user_thread_num_(user_thread_num), - bs_socket_num_(config_bs->BsAntNum()), - user_socket_num_(config_ue->UeAntNum()), + bs_socket_num_(config->BsAntNum()), + user_socket_num_(config->UeAntNum()), worker_thread_num_(worker_thread_num), core_offset_(in_core_offset), channel_type_(std::move(in_chan_type)), @@ -65,9 +63,9 @@ ChannelSim::ChannelSim(const Config* const config_bs, // initialize parameters from config srand(time(nullptr)); dl_data_plus_beacon_symbols_ = - bscfg_->Frame().NumDLSyms() + bscfg_->Frame().NumBeaconSyms(); + cfg_->Frame().NumDLSyms() + cfg_->Frame().NumBeaconSyms(); ul_data_plus_pilot_symbols_ = - bscfg_->Frame().NumULSyms() + bscfg_->Frame().NumPilotSyms(); + cfg_->Frame().NumULSyms() + cfg_->Frame().NumPilotSyms(); server_bs_.resize(bs_socket_num_); client_bs_.resize(bs_socket_num_); @@ -75,25 +73,25 @@ ChannelSim::ChannelSim(const Config* const config_bs, client_ue_.resize(user_socket_num_); task_queue_bs_ = moodycamel::ConcurrentQueue( - kFrameWnd * dl_data_plus_beacon_symbols_ * bscfg_->BsAntNum() * + kFrameWnd * dl_data_plus_beacon_symbols_ * cfg_->BsAntNum() * kDefaultQueueSize); task_queue_user_ = moodycamel::ConcurrentQueue( - kFrameWnd * ul_data_plus_pilot_symbols_ * uecfg_->UeAntNum() * + kFrameWnd * ul_data_plus_pilot_symbols_ * cfg_->UeAntNum() * kDefaultQueueSize); message_queue_ = moodycamel::ConcurrentQueue( - kFrameWnd * bscfg_->Frame().NumTotalSyms() * - (bscfg_->BsAntNum() + uecfg_->UeAntNum()) * kDefaultQueueSize); + kFrameWnd * cfg_->Frame().NumTotalSyms() * + (cfg_->BsAntNum() + cfg_->UeAntNum()) * kDefaultQueueSize); - assert(bscfg_->PacketLength() == uecfg_->PacketLength()); - payload_length_ = bscfg_->PacketLength() - Packet::kOffsetOfData; + assert(cfg_->PacketLength() == cfg_->PacketLength()); + payload_length_ = cfg_->PacketLength() - Packet::kOffsetOfData; // initialize bs-facing and client-facing data buffers size_t rx_buffer_ue_size = kFrameWnd * ul_data_plus_pilot_symbols_ * - uecfg_->UeAntNum() * payload_length_; + cfg_->UeAntNum() * payload_length_; rx_buffer_ue_.resize(rx_buffer_ue_size); size_t rx_buffer_bs_size = kFrameWnd * dl_data_plus_beacon_symbols_ * - bscfg_->BsAntNum() * payload_length_; + cfg_->BsAntNum() * payload_length_; rx_buffer_bs_.resize(rx_buffer_bs_size); // initilize rx and tx counters @@ -109,8 +107,7 @@ ChannelSim::ChannelSim(const Config* const config_bs, user_tx_counter_.fill(0); // Initialize channel - channel_ = std::make_unique(config_bs, config_ue, channel_type_, - channel_snr_); + channel_ = std::make_unique(cfg_, channel_type_, channel_snr_); for (size_t i = 0; i < worker_thread_num; i++) { task_ptok_[i] = new moodycamel::ProducerToken(message_queue_); @@ -193,26 +190,24 @@ void ChannelSim::Start() { // received a packet from a client antenna if (type == gen_tag_t::TagType::kUsers) { const size_t pilot_symbol_id = - uecfg_->Frame().GetPilotSymbolIdx(symbol_id); - const size_t ul_symbol_id = - uecfg_->Frame().GetULSymbolIdx(symbol_id); + cfg_->Frame().GetPilotSymbolIdx(symbol_id); + const size_t ul_symbol_id = cfg_->Frame().GetULSymbolIdx(symbol_id); size_t total_symbol_id = pilot_symbol_id; if (pilot_symbol_id == SIZE_MAX) { - total_symbol_id = ul_symbol_id + bscfg_->Frame().NumPilotSyms(); + total_symbol_id = ul_symbol_id + cfg_->Frame().NumPilotSyms(); } const size_t frame_offset = (frame_id % kFrameWnd) * ul_data_plus_pilot_symbols_ + total_symbol_id; user_rx_counter_[frame_offset]++; // when received all client antennas on this symbol, kick-off BS TX - if (user_rx_counter_[frame_offset] == uecfg_->UeAntNum()) { + if (user_rx_counter_[frame_offset] == cfg_->UeAntNum()) { user_rx_counter_[frame_offset] = 0; if (kDebugPrintPerSymbolDone) { std::printf( "Scheduling uplink transmission of frame %zu, symbol %zu, " "from %zu user to %zu BS antennas\n", - frame_id, symbol_id, uecfg_->UeAntNum(), - bscfg_->BsAntNum()); + frame_id, symbol_id, cfg_->UeAntNum(), cfg_->BsAntNum()); } ScheduleTask(EventData(EventType::kPacketTX, event.tags_[0]), &task_queue_bs_, ptok_bs); @@ -232,14 +227,13 @@ void ChannelSim::Start() { // symbol_id, bs_rx_counter_[frame_offset]); // when received all BS antennas on this symbol, kick-off client TX - if (bs_rx_counter_[frame_offset] == bscfg_->BsAntNum()) { + if (bs_rx_counter_[frame_offset] == cfg_->BsAntNum()) { bs_rx_counter_[frame_offset] = 0; if (kDebugPrintPerSymbolDone) { std::printf( "Scheduling downlink transmission in frame %zu, symbol " "%zu, from %zu BS to %zu user antennas\n", - frame_id, symbol_id, bscfg_->BsAntNum(), - uecfg_->UeAntNum()); + frame_id, symbol_id, cfg_->BsAntNum(), cfg_->UeAntNum()); } ScheduleTask(EventData(EventType::kPacketTX, event.tags_[0]), &task_queue_user_, ptok_user); @@ -304,47 +298,47 @@ void* ChannelSim::TaskThread(size_t tid) { moodycamel::ConsumerToken ue_consumer_token(task_queue_user_); size_t tx_buffer_ue_size = - dl_data_plus_beacon_symbols_ * uecfg_->UeAntNum() * payload_length_; + dl_data_plus_beacon_symbols_ * cfg_->UeAntNum() * payload_length_; AlignedByteVector tx_buffer_ue(tx_buffer_ue_size); size_t tx_buffer_bs_size = - ul_data_plus_pilot_symbols_ * bscfg_->BsAntNum() * payload_length_; + ul_data_plus_pilot_symbols_ * cfg_->BsAntNum() * payload_length_; AlignedByteVector tx_buffer_bs(tx_buffer_bs_size); void* bs_input_float_storage = PaddedAlignedAlloc( Agora_memory::Alignment_t::kAlign64, - (bscfg_->SampsPerSymbol() * bscfg_->BsAntNum() * sizeof(arma::cx_float))); + (cfg_->SampsPerSymbol() * cfg_->BsAntNum() * sizeof(arma::cx_float))); void* bs_output_float_storage = PaddedAlignedAlloc( Agora_memory::Alignment_t::kAlign64, - (bscfg_->SampsPerSymbol() * uecfg_->UeAntNum() * sizeof(arma::cx_float))); + (cfg_->SampsPerSymbol() * cfg_->UeAntNum() * sizeof(arma::cx_float))); void* ue_input_float_storage = PaddedAlignedAlloc( Agora_memory::Alignment_t::kAlign64, - (bscfg_->SampsPerSymbol() * uecfg_->UeAntNum() * sizeof(arma::cx_float))); + (cfg_->SampsPerSymbol() * cfg_->UeAntNum() * sizeof(arma::cx_float))); void* ue_output_float_storage = PaddedAlignedAlloc( Agora_memory::Alignment_t::kAlign64, - (bscfg_->SampsPerSymbol() * bscfg_->BsAntNum() * sizeof(arma::cx_float))); + (cfg_->SampsPerSymbol() * cfg_->BsAntNum() * sizeof(arma::cx_float))); arma::cx_fmat bs_input_matrix( reinterpret_cast(bs_input_float_storage), - bscfg_->SampsPerSymbol(), bscfg_->BsAntNum(), false, true); - bs_input_matrix.zeros(bscfg_->SampsPerSymbol(), bscfg_->BsAntNum()); + cfg_->SampsPerSymbol(), cfg_->BsAntNum(), false, true); + bs_input_matrix.zeros(cfg_->SampsPerSymbol(), cfg_->BsAntNum()); arma::cx_fmat bs_output_matrix( reinterpret_cast(bs_output_float_storage), - bscfg_->SampsPerSymbol(), uecfg_->UeAntNum(), false, true); - bs_output_matrix.zeros(bscfg_->SampsPerSymbol(), uecfg_->UeAntNum()); + cfg_->SampsPerSymbol(), cfg_->UeAntNum(), false, true); + bs_output_matrix.zeros(cfg_->SampsPerSymbol(), cfg_->UeAntNum()); arma::cx_fmat ue_input_matrix( reinterpret_cast(ue_input_float_storage), - bscfg_->SampsPerSymbol(), uecfg_->UeAntNum(), false, true); - ue_input_matrix.zeros(bscfg_->SampsPerSymbol(), uecfg_->UeAntNum()); + cfg_->SampsPerSymbol(), cfg_->UeAntNum(), false, true); + ue_input_matrix.zeros(cfg_->SampsPerSymbol(), cfg_->UeAntNum()); arma::cx_fmat ue_output_matrix( reinterpret_cast(ue_output_float_storage), - bscfg_->SampsPerSymbol(), bscfg_->BsAntNum(), false, true); - ue_output_matrix.zeros(bscfg_->SampsPerSymbol(), bscfg_->BsAntNum()); + cfg_->SampsPerSymbol(), cfg_->BsAntNum(), false, true); + ue_output_matrix.zeros(cfg_->SampsPerSymbol(), cfg_->BsAntNum()); - AlignedByteVector udp_tx_buffer(bscfg_->PacketLength()); + AlignedByteVector udp_tx_buffer(cfg_->PacketLength()); WorkerThreadStorage thread_store; thread_store.tid_ = tid; @@ -385,18 +379,18 @@ void* ChannelSim::BsRxLoop(size_t tid) { // initialize bs-facing sockets static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; for (size_t socket_id = socket_lo; socket_id < socket_hi; ++socket_id) { - const size_t local_port_id = bscfg_->BsRruPort() + socket_id; + const size_t local_port_id = cfg_->BsRruPort() + socket_id; server_bs_.at(socket_id) = std::make_unique(local_port_id, sock_buf_size); client_bs_.at(socket_id) = std::make_unique(); std::printf( "ChannelSim::BsRxLoop[%zu]: set up UDP socket server listening to port " "%zu with remote address %s:%zu\n", - tid, local_port_id, bscfg_->BsServerAddr().c_str(), - bscfg_->BsServerPort() + socket_id); + tid, local_port_id, cfg_->BsServerAddr().c_str(), + cfg_->BsServerPort() + socket_id); } - const size_t rx_packet_size = bscfg_->PacketLength(); + const size_t rx_packet_size = cfg_->PacketLength(); const size_t buffer_size = (rx_packet_size) + kUdpMTU; std::vector thread_rx_buffers_(total_sockets); for (auto& buffer : thread_rx_buffers_) { @@ -445,7 +439,7 @@ void* ChannelSim::BsRxLoop(size_t tid) { const size_t symbol_offset = (frame_id % kFrameWnd) * dl_data_plus_beacon_symbols_ + dl_symbol_id; - const size_t dest_offset = symbol_offset * bscfg_->BsAntNum() + ant_id; + const size_t dest_offset = symbol_offset * cfg_->BsAntNum() + ant_id; std::memcpy(&rx_buffer_bs_[dest_offset * payload_length_], pkt->data_, payload_length_); @@ -502,7 +496,7 @@ void* ChannelSim::UeRxLoop(size_t tid) { // initialize client-facing sockets static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; for (size_t socket_id = socket_lo; socket_id < socket_hi; ++socket_id) { - size_t local_port_id = uecfg_->UeRruPort() + socket_id; + size_t local_port_id = cfg_->UeRruPort() + socket_id; server_ue_.at(socket_id) = std::make_unique(local_port_id, sock_buf_size); client_ue_.at(socket_id) = std::make_unique(); @@ -510,11 +504,11 @@ void* ChannelSim::UeRxLoop(size_t tid) { std::printf( "ChannelSim::UeRxLoop[%zu]: set up UDP socket server listening to port " "%zu with remote address %s:%zu\n", - tid, local_port_id, uecfg_->UeServerAddr().c_str(), - uecfg_->UeServerPort() + socket_id); + tid, local_port_id, cfg_->UeServerAddr().c_str(), + cfg_->UeServerPort() + socket_id); } - const size_t rx_packet_size = bscfg_->PacketLength(); + const size_t rx_packet_size = cfg_->PacketLength(); const size_t buffer_size = rx_packet_size + kUdpMTU; std::vector thread_rx_buffers_(total_sockets); for (auto& buffer : thread_rx_buffers_) { @@ -554,17 +548,17 @@ void* ChannelSim::UeRxLoop(size_t tid) { const size_t ant_id = pkt->ant_id_; const size_t pilot_symbol_id = - uecfg_->Frame().GetPilotSymbolIdx(symbol_id); - const size_t ul_symbol_id = uecfg_->Frame().GetULSymbolIdx(symbol_id); + cfg_->Frame().GetPilotSymbolIdx(symbol_id); + const size_t ul_symbol_id = cfg_->Frame().GetULSymbolIdx(symbol_id); size_t total_symbol_id = pilot_symbol_id; if (pilot_symbol_id == SIZE_MAX) { - total_symbol_id = ul_symbol_id + bscfg_->Frame().NumPilotSyms(); + total_symbol_id = ul_symbol_id + cfg_->Frame().NumPilotSyms(); } const size_t symbol_offset = (frame_id % kFrameWnd) * ul_data_plus_pilot_symbols_ + total_symbol_id; - size_t offset = symbol_offset * uecfg_->UeAntNum() + ant_id; + size_t offset = symbol_offset * cfg_->UeAntNum() + ant_id; auto* rx_data_destination = &rx_buffer_ue_.at(offset * payload_length_); std::memcpy(rx_data_destination, pkt->data_, payload_length_); @@ -624,7 +618,7 @@ void ChannelSim::DoTx(size_t frame_id, size_t symbol_id, size_t max_ant, std::vector>& udp_clients, const std::string& dest_address, size_t dest_port) { // The 2 is from complex float -> float - const size_t convert_length = (2 * bscfg_->SampsPerSymbol() * max_ant); + const size_t convert_length = (2 * cfg_->SampsPerSymbol() * max_ant); auto* dst_ptr = reinterpret_cast(tx_buffer); #if defined(CHSIM_DEBUG_MEMORY) @@ -658,11 +652,11 @@ void ChannelSim::DoTxBs(WorkerThreadStorage& local, size_t tag) { const size_t frame_id = gen_tag_t(tag).frame_id_; const size_t symbol_id = gen_tag_t(tag).symbol_id_; // Modify this to check the symbol type - const size_t pilot_symbol_id = bscfg_->Frame().GetPilotSymbolIdx(symbol_id); - const size_t ul_symbol_id = bscfg_->Frame().GetULSymbolIdx(symbol_id); + const size_t pilot_symbol_id = cfg_->Frame().GetPilotSymbolIdx(symbol_id); + const size_t ul_symbol_id = cfg_->Frame().GetULSymbolIdx(symbol_id); size_t total_symbol_id = pilot_symbol_id; if (pilot_symbol_id == SIZE_MAX) { - total_symbol_id = ul_symbol_id + bscfg_->Frame().NumPilotSyms(); + total_symbol_id = ul_symbol_id + cfg_->Frame().NumPilotSyms(); } if (kPrintDebugTxBs) { @@ -676,9 +670,9 @@ void ChannelSim::DoTxBs(WorkerThreadStorage& local, size_t tag) { const size_t symbol_offset = (frame_id % kFrameWnd) * ul_data_plus_pilot_symbols_ + total_symbol_id; const size_t total_offset_ue = - symbol_offset * payload_length_ * uecfg_->UeAntNum(); + symbol_offset * payload_length_ * cfg_->UeAntNum(); const size_t total_offset_bs = - total_symbol_id * payload_length_ * bscfg_->BsAntNum(); + total_symbol_id * payload_length_ * cfg_->BsAntNum(); auto* src_ptr = reinterpret_cast(&rx_buffer_ue_.at(total_offset_ue)); @@ -692,9 +686,9 @@ void ChannelSim::DoTxBs(WorkerThreadStorage& local, size_t tag) { "Channel Sim[%zu]: DoTxBs processing frame %zu, symbol %zu, ul symbol " "%zu, samples per symbol %zu ue ant num %zu offset %zu ue plus %zu " "location %zu\n", - local.tid_, frame_id, symbol_id, total_symbol_id, - bscfg_->SampsPerSymbol(), uecfg_->UeAntNum(), total_offset_ue, - ul_data_plus_pilot_symbols_, (size_t)src_ptr); + local.tid_, frame_id, symbol_id, total_symbol_id, cfg_->SampsPerSymbol(), + cfg_->UeAntNum(), total_offset_ue, ul_data_plus_pilot_symbols_, + (size_t)src_ptr); MLPD_TRACE( "Channel Sim[%zu]: SimdConvertShortToFloat: DoTxBs Length %lld samps " @@ -733,10 +727,10 @@ void ChannelSim::DoTxBs(WorkerThreadStorage& local, size_t tag) { Utils::PrintMat(fmat_noisy, "rx_ul"); } - DoTx(frame_id, symbol_id, bscfg_->BsAntNum(), + DoTx(frame_id, symbol_id, cfg_->BsAntNum(), &local.bs_tx_buffer_->at(total_offset_bs), fmat_noisy.memptr(), - local.udp_tx_buffer_, client_bs_, bscfg_->BsServerAddr(), - bscfg_->BsServerPort()); + local.udp_tx_buffer_, client_bs_, cfg_->BsServerAddr(), + cfg_->BsServerPort()); RtAssert(message_queue_.enqueue( *task_ptok_[local.tid_], @@ -762,9 +756,9 @@ void ChannelSim::DoTxUser(WorkerThreadStorage& local, size_t tag) { const size_t symbol_offset = (frame_id % kFrameWnd) * dl_data_plus_beacon_symbols_ + dl_symbol_id; const size_t total_offset_bs = - symbol_offset * payload_length_ * bscfg_->BsAntNum(); + symbol_offset * payload_length_ * cfg_->BsAntNum(); const size_t total_offset_ue = - dl_symbol_id * payload_length_ * uecfg_->UeAntNum(); + dl_symbol_id * payload_length_ * cfg_->UeAntNum(); auto* src_ptr = reinterpret_cast(&rx_buffer_bs_.at(total_offset_bs)); @@ -777,8 +771,8 @@ void ChannelSim::DoTxUser(WorkerThreadStorage& local, size_t tag) { MLPD_FRAME( "Channel Sim[%zu]: DoTxUser processing frame %zu, symbol %zu, dl symbol " "%zu, samples per symbol %zu bs ant num %zu offset %zu location %zu\n", - local.tid_, frame_id, symbol_id, dl_symbol_id, bscfg_->SampsPerSymbol(), - uecfg_->BsAntNum(), total_offset_bs, (size_t)src_ptr); + local.tid_, frame_id, symbol_id, dl_symbol_id, cfg_->SampsPerSymbol(), + cfg_->BsAntNum(), total_offset_bs, (size_t)src_ptr); MLPD_TRACE( "Channel Sim[%zu]: SimdConvertShortToFloat: DoTxUser Length %lld samps " @@ -816,14 +810,14 @@ void ChannelSim::DoTxUser(WorkerThreadStorage& local, size_t tag) { Utils::PrintMat(fmat_noisy, "rx_dl"); } - DoTx(frame_id, symbol_id, uecfg_->UeAntNum(), + DoTx(frame_id, symbol_id, cfg_->UeAntNum(), &local.ue_tx_buffer_->at(total_offset_ue), fmat_noisy.memptr(), - local.udp_tx_buffer_, client_ue_, uecfg_->UeServerAddr(), - uecfg_->UeServerPort()); + local.udp_tx_buffer_, client_ue_, cfg_->UeServerAddr(), + cfg_->UeServerPort()); RtAssert(message_queue_.enqueue( *task_ptok_[local.tid_], EventData(EventType::kPacketTX, gen_tag_t::FrmSymUe(frame_id, symbol_id, 0).tag_)), "UE TX message enqueue failed!\n"); -} \ No newline at end of file +} diff --git a/simulator/channel_sim.h b/simulator/channel_sim.h index dada322e2..926582875 100644 --- a/simulator/channel_sim.h +++ b/simulator/channel_sim.h @@ -52,9 +52,9 @@ struct WorkerThreadStorage { */ class ChannelSim { public: - ChannelSim(const Config* const config_bs, const Config* const config_ue, - size_t bs_thread_num, size_t user_thread_num, - size_t worker_thread_num, size_t in_core_offset = 30, + ChannelSim(const Config* const config, size_t bs_thread_num, + size_t user_thread_num, size_t worker_thread_num, + size_t in_core_offset = 30, std::string in_chan_type = std::string("RAYLEIGH"), double in_chan_snr = 20); ~ChannelSim(); @@ -95,8 +95,7 @@ class ChannelSim { // UE-facing sockets std::vector> server_ue_; - const Config* const bscfg_; - const Config* const uecfg_; + const Config* const cfg_; std::unique_ptr channel_; // Data buffer for received symbols from BS antennas (downlink) @@ -140,9 +139,9 @@ class ChannelSim { if (symbol_id == 0) { return 0; } else { - return bscfg_->Frame().GetDLSymbolIdx(symbol_id) + 1; + return cfg_->Frame().GetDLSymbolIdx(symbol_id) + 1; } } }; -#endif // CHANNEL_SIM_H_ \ No newline at end of file +#endif // CHANNEL_SIM_H_ diff --git a/simulator/chsim_main.cc b/simulator/chsim_main.cc index 96e7f1ac2..0b2389243 100644 --- a/simulator/chsim_main.cc +++ b/simulator/chsim_main.cc @@ -16,12 +16,8 @@ DEFINE_uint64( "Number of worker threads handling packet transmissions to BS and UE " "Antennas"); DEFINE_uint64(core_offset, 0, "Core ID of the first channel_sim thread"); -DEFINE_string(bs_conf_file, - TOSTRING(PROJECT_DIRECTORY) "/data/tddconfig-sim-bs.json", - "BS Config filename"); -DEFINE_string(ue_conf_file, - TOSTRING(PROJECT_DIRECTORY) "/data/tddconfig-sim-ue.json", - "UE Config filename"); +DEFINE_string(conf_file, TOSTRING(PROJECT_DIRECTORY) "/data/tddconfig-sim.json", + "Config filename"); DEFINE_string(chan_model, "RAYLEIGH", "Simulator Channel Type: RAYLEIGH/AWGN"); DEFINE_double(chan_snr, 20.0, "Signal-to-Noise Ratio"); @@ -30,9 +26,7 @@ int main(int argc, char* argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); gflags::SetVersionString(GetAgoraProjectVersion()); std::printf("Base Station configuration\n"); - auto bs_config = std::make_unique(FLAGS_bs_conf_file); - std::printf("User configuration\n"); - auto ue_config = std::make_unique(FLAGS_ue_conf_file); + auto config = std::make_unique(FLAGS_conf_file); { try { SignalHandler signal_handler; @@ -40,7 +34,7 @@ int main(int argc, char* argv[]) { // Register signal handler to handle kill signal signal_handler.SetupSignalHandlers(); auto sim = std::make_unique( - bs_config.get(), ue_config.get(), FLAGS_bs_threads, FLAGS_ue_threads, + config.get(), FLAGS_bs_threads, FLAGS_ue_threads, FLAGS_worker_threads, FLAGS_core_offset, FLAGS_chan_model, FLAGS_chan_snr); sim->Start(); diff --git a/test/sim_tests/test_e2e_sim.sh b/test/sim_tests/test_e2e_sim.sh index 7111dce53..696b4fd5e 100755 --- a/test/sim_tests/test_e2e_sim.sh +++ b/test/sim_tests/test_e2e_sim.sh @@ -32,7 +32,7 @@ echo "Emulated RRU Test" > test_user_output.txt echo "Emulated RRU Test" > test_agora_output.txt echo "Emulated RRU Test" > test_chsim_output.txt ./build/user --conf_file data/chsim-tmp.json >> test_user_output.txt & -sleep 1; ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 4 --core_offset 19 --bs_conf_file data/chsim-tmp.json --ue_conf_file data/chsim-tmp.json >> test_chsim_output.txt & +sleep 1; ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 4 --core_offset 19 --conf_file data/chsim-tmp.json >> test_chsim_output.txt & sleep 1; ./build/agora --conf_file data/chsim-tmp.json >> test_agora_output.txt sleep 5; From 2b030797a1a169039b71eb5f115c2843460e755a Mon Sep 17 00:00:00 2001 From: rdoost Date: Thu, 30 Dec 2021 13:05:44 -0600 Subject: [PATCH 43/55] Update README --- README.md | 107 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index f7bea2539..6c92d4231 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Some highlights: * Install [Intel FlexRAN's FEC SDK](https://software.intel.com/en-us/articles/flexran-lte-and-5g-nr-fec-software-development-kit-modules) for LDPC encoding and decoding: * **NOTE**: Compiling FlexRAN requires Intel compiler with version <= 19.0.4. - Newer versions of Intel compiler can also work, but require a patch for resolving conflicts with FlexRAN. + Newer versions of Intel compiler can also work, but require a patch for resolving conflicts with FlexRAN.\ Please [contact](#contact) the current Agora developers to get the patch. * Download Intel FlexRAN's FEC SDK to `/opt`. * Compile FlexRAN as follows: @@ -58,9 +58,11 @@ Some highlights: * Refer to [DPDK_README.md](DPDK_README.md) for configuration and installation instructions. ## Building and running with emulated RRU -We provide a high performance [packet generator](simulator) to emulate the RRU. This generator allows Agora to run and be tested without actual RRU hardware. The following are steps to set up both Agora and the packet generator. +We provide a high performance [packet generator](simulator) to emulate the RRU. This generator allows Agora to run and be tested without actual RRU hardware.\ +The following are steps to set up both Agora and the packet generator: - * Build Agora. This step also builds the emulated RRU, a data generator that generates random input data files, an end-to-end test that checks correctness of end results for both uplink and downlink, and several unit tests for testing either performance or correctness of individual functions. + * Build Agora. This step also builds the emulated RRU, a data generator that generates random input data files, an end-to-end test that checks correctness of end results for both uplink and downlink,\ + and several unit tests for testing either performance or correctness of individual functions.
     $ cd Agora
     $ mkdir build
@@ -75,11 +77,11 @@ We provide a high performance [packet generator](simulator) to emulate the RRU.
     
* Run Agora with emulated RRU traffic - * **NOTE**: We recommend running Agora and the emulated RRU on two different machines. - If you are running them on the same machine, make sure Agora and the emulated RRU are using different set of cores, + * **NOTE**: We recommend running Agora and the emulated RRU on two different machines.\ + If you are running them on the same machine, make sure Agora and the emulated RRU are using different set of cores, otherwise there will be performance slow down. - When running Agora and the emulated RRU on two different machines, the following steps - use Linux networking stack for packet I/O. + + When running Agora and the emulated RRU on two different machines, the following steps use Linux networking stack for packet I/O.\ Agora also supports using DPDK to bypass the kernel for packet I/O. See [DPDK_README.md](DPDK_README.md) for instructions of running emulated RRU and Agora with DPDK. @@ -103,22 +105,22 @@ We provide a high performance [packet generator](simulator) to emulate the RRU. * Run Agora with channel simulator and clients * First, return to the base directory (`cd ..`), then run
-   $ ./build/data_generator --conf_file data/bs-sim.json
+   $ ./build/data_generator --conf_file data/chsim.json
    
to generate data files. * In one terminal, run
-   $ ./build/user --conf_file data/ue-sim.json
+   $ ./build/user --conf_file data/chsim.json
    
to start clients with combined uplink & downlink configuration. * In another terminal, run
-   $ ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 2 --core_offset 24 --bs_conf_file data/bs-sim.json --ue_conf_file data/ue-sim.json
+   $ ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 2 --core_offset 24 --conf_file data/chsim.json
    
* In another terminal, run
-   $ ./build/agora data/bs-sim.json
+   $ ./build/agora --conf_file data/chsim.json
    
to start Agora with the combined configuration. * Note: make sure Agora and sender are using different set of cores, otherwise there will be performance slow down. @@ -128,36 +130,36 @@ We provide a high performance [packet generator](simulator) to emulate the RRU.
    $ cmake .. -DENABLE_MAC=true
    
- * Uplink Testing (`--conf_file ue-mac-ul-sim.json / bs-mac-ul-sim.json`) - * Downlink Testing (`--conf_file ue-mac-dl-sim.json / bs-mac-dl-sim.json`) - * Combined Testing (`--conf_file ue-mac-sim.json / bs-mac-sim.json`) + * Uplink Testing (`--conf_file mac-ul-sim.json`) + * Downlink Testing (`--conf_file mac-dl-sim.json`) + * Combined Testing (`--conf_file mac-sim.json`) * Terminal 1:
-       $./build/data_generator --conf_file data/ue-mac-sim.json
+       $./build/data_generator --conf_file data/mac-sim.json
      
to generate data files.
-       $./build/user --conf_file data/ue-mac-sim.json
+       $./build/user --conf_file data/mac-sim.json
      
to start users. * Terminal 2:
-     $ ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 2 --core_offset 28 --bs_conf_file data/bs-mac-sim.json --ue_conf_file data/ue-mac-sim.json
+     $ ./build/chsim --bs_threads 1 --ue_threads 1 --worker_threads 2 --core_offset 28 --bs_conf_file data/mac-sim.json --ue_conf_file data/mac-sim.json
      
to run the channel simulator * Terminal 3:
-       $ ./build/macuser --enable_slow_start 1 --conf_file data/ue-mac-sim.json
+       $ ./build/macuser --enable_slow_start 1 --conf_file data/mac-sim.json
      
to run to user mac app. Specify `--data_file ""` to generate patterned data and `--conf_file` options as necessary. * Terminal 4:
-     $ ./build/agora --conf_file data/bs-mac-sim.json
+     $ ./build/agora --conf_file data/mac-sim.json
      
run agora before running macbs. Run macuser -> agora -> macbs in quick succession. * Terminal 5:
-     $ ./build/macbs --enable_slow_start 1 --conf_file data/bs-mac-sim.json
+     $ ./build/macbs --enable_slow_start 1 --conf_file data/mac-sim.json
      
to run to base station mac app. specify `--data_file ""` to generate patterned data and `--conf_file` options as necessary. * Note: make sure agora / user / chsim / macuser / macbs are using different set of cores, otherwise there will be performance slow down. @@ -166,56 +168,57 @@ We provide a high performance [packet generator](simulator) to emulate the RRU. [Agora with real RRU](#agora-with-real-rru) section below. ## Building and running with real RRU -Agora supports a 64-antenna Faros base station as RRU and Iris UE devices. Both are commercially available from -[Skylark Wireless](https://skylarkwireless.com) and are used in the [POWER-RENEW PAWR testbed](https://powderwireless.net/). -Both Faros and Iris have their roots in the [Argos massive MIMO base station](https://www.yecl.org/argos/), especially [ArgosV3](https://www.yecl.org/argos/pubs/Shepard-MobiCom17-Demo.pdf). Agora also supports USRP-based RRU and UEs. +Agora supports a 64-antenna Faros base station as RRU and Iris UE devices. Both are commercially available from [Skylark Wireless](https://skylarkwireless.com) and are used in the [POWER-RENEW PAWR testbed](https://powderwireless.net/).\ +Both Faros and Iris have their roots in the [Argos massive MIMO base station](https://www.yecl.org/argos/), especially [ArgosV3](https://www.yecl.org/argos/pubs/Shepard-MobiCom17-Demo.pdf). +Agora also supports USRP-based RRU and UEs. We use command line variables of `cmake`\ +to switch between emulated RRU and real RRU. We use `-DUSE_AGROS` for Faros RRU and Iris UEs, and `-DUSE_UHD` for USRP-based RRU and UEs. -We use command line variables of cmake to switch between emulated RRU and real RRU. -We use `-DUSE_AGROS` for Faros RRU and Iris UEs, and `-DUSE_UHD` for USRP-based RRU and UEs. - -Agora supports both uplink and downlink with real RRU and UEs. -For downlink, a reference node outside the array (and synchronized) is required for reciprocity calibration. We recommend using one server for controlling the RRU and running Agora, and another server for controlling the UEs and running the UE code. -Below we describe how to get the uplink and downlink demos working. + +The hardware connected to the server can be discovered using the [pyfaros](https://github.com/skylarkwireless/pyfaros) tool. + +The command `python3 -m pyfaros.discover --json-out` outputs a JSON file used as a configuration input for Agora as explained below. + +Agora supports both uplink and downlink with real RRU and UEs. + +For downlink, a reference node outside the array (and synchronized) is required for reciprocity calibration. +It should also be indicated in the hardware JSON file. + +We describe how to get the uplink and downlink demos working. Below XX can be replaced with either `ul` and `dl`. * Rebuild the code on both servers for RRU side the UE side. * For Faros RRU and Iris UEs, pass `-DUSE_ARGOS=on -DUSE_UHD=off` to cmake * For USRP-based RRU and UEs, pass `-DUSE_ARGOS=off -DUSE_UHD=on` to cmake * Run `make -j` to recompile the code. * Run the UE code on the server connected to the Iris UEs - * Modify `data/user-iris-serials.txt` by adding serials of two client Irises - from your setup. - * Run `./build/data_generator --conf_file data/ue-ul-hw.json` to generate required data files. - * Run `./build/user --conf_file data/ue-ul-hw.json`. - * For downlink, use `data/ue-dl-hw.json` in the last two steps. + * Use pyfaros tool to generate a + * Modify `data/topology.json` by adding/removing serials of client Irises you'd like to include + from your setup. This file can be generated using the `pyfaros` tool as described above. + * Run `./build/data_generator --conf_file data/XX-hw.json` to generate required data files. + * Run `./build/user --conf_file data/XX-hw.json`. * Run Agora on the server connected to the Faros RRU - * scp over the generated file `data/LDPC_orig_data_512_ant2.bin` from the client + * scp over the generated file `data/LDPC_orig_XX_data_512_ant2.bin` from the client machine to the server's `data` directory. * Rebuild the code * Run `make -j` to compile the code. - * Modify `data/bs-iris-serials.txt` and `data/bs-hub-serial.txt` by adding - serials of your RRU Irises and hub, respectively. - * Run `./build/agora --conf_file data/bs-ul-hw.json`. - * For downlink, put the serial of the reference node in the last line - of `data/bs-iris-serials.txt` and modify/add `"ref_ant"` in `data/bs-dl-hw.json` - to reflect the antenna index of the reference node. + * Modify `data/topology.json` by adding/removing serials of your RRU Irises, and the hub. + * Run `./build/agora --conf_file data/XX-hw.json`. ## Running performance test -To test the real-time performance of Agora for processing 64x16 MU-MIMO with 20 MHz bandwidth and 64QAM modulation, -we recommend using two servers -(one for Agora and another for the emulated RRU) and DPDK for networking. +To test the real-time performance of Agora for processing 64x16 MU-MIMO with 20 MHz bandwidth and 64QAM modulation, we recommend using two servers +(one for Agora and another for the emulated RRU) and DPDK\ +for networking. In our experiments, we use 2 servers each with 4 Intel Xeon Gold 6130 CPUs. The servers are connected by 40 GbE Intel XL710 dual-port NICs. -* **NOTE**: We recommend using at least 10 GbE NIC and a server with more than 10 cores -for testing real-time performance of 8x8 MU-MIMO. -For 8x8 MU-MIMO, our test on a machine with AVX-512 and CPU frequency of 2.3 GHz support shows that at least 7 worker cores are required to achieve real-time performance. Additionally, Agora requires one core for the manager thread and at least 1 core for network threads. We change "worker_thread_num" and "socket_thread_num" to change the number cores assigned to of worker threads and network threads in the json files, e.g., data/tddconfig-sim-ul.json. -If you do not have a powerful server or high throughput NICs, -we recommend increasing the value of `--frame_duration` when you run `./build/sender`, -which will increase frame duration and reduce throughput. +* **NOTE**: We recommend using at least 10 GbE NIC and a server with more than 10 cores for testing real-time performance of 8x8 MU-MIMO. For 8x8 MU-MIMO, our test on a machine with AVX-512 and CPU frequency\ +of 2.3 GHz support shows that at least 7 worker cores are required to achieve real-time performance. Additionally, Agora requires one core for the manager thread and at least 1 core for network threads.\ + +We change "worker_thread_num" and "socket_thread_num" to change the number cores assigned to of worker threads and network threads in the json files, e.g., data/tddconfig-sim-ul.json.\ +If you do not have a powerful server or high throughput NICs, we recommend increasing the value of `--frame_duration` when you run `./build/sender`, which will increase frame duration and reduce throughput. To process 64x16 MU-MIMO in real-time, we use both ports of 40 GbE Intel XL710 NIC with DPDK (see [DPDK_README.md](DPDK_README.md)) -to get enough throughput for the traffic of 64 antennas. +to get enough throughput for the traffic of 64 antennas. \ (**NOTE**: For 100 GbE NIC, we just need to use one port to get enough thoughput.) To reduce performance variations, we did the following configurations for the server that runs Agora: @@ -241,7 +244,7 @@ To reduce performance variations, we did the following configurations for the se The steps to collect and analyze timestamp traces are as follows: * Enable DPDK in Agora. Make sure it is compiled / configured for supporting your specific hardware NICs (see [DPDK_README.md](DPDK_README.md)). - * We use data/tddconfig-sim-ul.json for uplink experiments and data/tddconfig-sim-dl.json for downlink experiments. + * We use data/tddconfig-sim-ul.json for uplink experiments and data/tddconfig-sim-dl.json for downlink experiments.\ In our [paper](#documentation), we change “antenna_num”, “ue_num” and “symbol_num_perframe” to different values to collect different data points in the figures. * Generate source data files by running From 2a3af2a5fb2cb2ebadc369b4899e24840d9a8f39 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Thu, 30 Dec 2021 13:54:17 -0700 Subject: [PATCH 44/55] Terminating the radio config after all the workers have exited --- src/agora/txrx/txrx.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/agora/txrx/txrx.cc b/src/agora/txrx/txrx.cc index 275c77367..dbb17fee3 100644 --- a/src/agora/txrx/txrx.cc +++ b/src/agora/txrx/txrx.cc @@ -43,15 +43,16 @@ PacketTXRX::PacketTXRX(Config* cfg, size_t core_offset, } PacketTXRX::~PacketTXRX() { - if (kUseArgos || kUseUHD) { - radioconfig_->RadioStop(); - } - for (auto& worker : socket_std_threads_) { if (worker.joinable() == true) { worker.join(); } } + + if (kUseArgos || kUseUHD) { + radioconfig_->RadioStop(); + } + MLPD_INFO("PacketTXRX workers joined\n"); } bool PacketTXRX::StartTxRx(Table& buffer, size_t packet_num_in_buffer, From fcdf0f14b02b580d60531655ae4e7477147d4b61 Mon Sep 17 00:00:00 2001 From: rdoost Date: Thu, 30 Dec 2021 21:40:32 -0600 Subject: [PATCH 45/55] Fix out of bound rx buffer offset --- src/agora/txrx/txrx_argos.cc | 11 +++++++---- src/client/ue_worker.cc | 11 ++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 04687bdc6..fc7c4a4db 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -163,12 +163,13 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, std::vector samp(cfg_->NumChannels()); for (size_t ch = 0; ch < cfg_->NumChannels(); ++ch) { - RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); + size_t next_rx_slot = (rx_slot + ch) % buffers_per_socket_; + RxPacket& rx = rx_packets_.at(tid).at(next_rx_slot); // if rx_buffer is full, exit if (rx.Empty() == false) { MLPD_ERROR("TXRX thread %zu rx_buffer full, rx slot: %zu\n", tid, - rx_slot); + next_rx_slot); cfg_->Running(false); break; } @@ -222,7 +223,8 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, ant_ids.resize(cfg_->AntPerGroup()); } for (size_t s = 1; s < cfg_->AntPerGroup(); s++) { - RxPacket& rx = rx_packets_.at(tid).at(rx_slot + s); + size_t next_rx_slot = (rx_slot + s) % buffers_per_socket_; + RxPacket& rx = rx_packets_.at(tid).at(next_rx_slot); std::vector tmp_samp(cfg_->NumChannels()); std::vector dummy_buff(packet_length); @@ -241,7 +243,8 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, } std::vector pkt; for (size_t ch = 0; ch < symbol_ids.size(); ++ch) { - RxPacket& rx = rx_packets_.at(tid).at(rx_slot + ch); + size_t next_rx_slot = (rx_slot + ch) % buffers_per_socket_; + RxPacket& rx = rx_packets_.at(tid).at(next_rx_slot); pkt.push_back(rx.RawPacket()); new (rx.RawPacket()) Packet(frame_id, symbol_ids.at(ch), cell_id, ant_ids.at(ch)); diff --git a/src/client/ue_worker.cc b/src/client/ue_worker.cc index 6785f18db..3a0ac7911 100644 --- a/src/client/ue_worker.cc +++ b/src/client/ue_worker.cc @@ -165,12 +165,12 @@ void UeWorker::DoFftData(size_t tag) { if (kRecordDownlinkFrame) { if (frame_id == kRecordFrameIndex) { - std::string fname = "rxdata" + std::to_string(symbol_id) + "_" + + std::string fname = "rxdata" + std::to_string(dl_symbol_id) + "_" + std::to_string(ant_id) + ".bin"; FILE* f = std::fopen(fname.c_str(), "wb"); std::fwrite(pkt->data_, 2 * sizeof(int16_t), config_.SampsPerSymbol(), f); std::fclose(f); - fname = "txdata" + std::to_string(symbol_id) + "_" + + fname = "txdata" + std::to_string(dl_symbol_id) + "_" + std::to_string(ant_id) + ".bin"; f = std::fopen(fname.c_str(), "wb"); std::fwrite(config_.DlIqF()[dl_symbol_id] + ant_id * config_.OfdmCaNum(), @@ -298,7 +298,9 @@ void UeWorker::DoFftPilot(size_t tag) { tid_, frame_id, symbol_id, ant_id); } + size_t dl_symbol_id = config_.Frame().GetDLSymbolIdx(symbol_id); size_t sig_offset = config_.OfdmRxZeroPrefixClient(); + if (kPrintDownlinkPilotStats) { SimdConvertShortToFloat(pkt->data_, reinterpret_cast(rx_samps_tmp_), 2 * config_.SampsPerSymbol()); @@ -329,12 +331,12 @@ void UeWorker::DoFftPilot(size_t tag) { if (kRecordDownlinkFrame) { if (frame_id == kRecordFrameIndex) { - std::string fname = "rxpilot" + std::to_string(symbol_id) + "_" + + std::string fname = "rxpilot" + std::to_string(dl_symbol_id) + "_" + std::to_string(ant_id) + ".bin"; FILE* f = std::fopen(fname.c_str(), "wb"); std::fwrite(pkt->data_, 2 * sizeof(int16_t), config_.SampsPerSymbol(), f); std::fclose(f); - fname = "txpilot_f_" + std::to_string(symbol_id) + "_" + + fname = "txpilot_f_" + std::to_string(dl_symbol_id) + "_" + std::to_string(ant_id) + ".bin"; f = std::fopen(fname.c_str(), "wb"); std::fwrite(config_.UeSpecificPilot()[ant_id], 2 * sizeof(float), @@ -344,7 +346,6 @@ void UeWorker::DoFftPilot(size_t tag) { } // remove CP, do FFT - size_t dl_symbol_id = config_.Frame().GetDLSymbolIdx(symbol_id); size_t total_dl_symbol_id = (frame_slot * config_.Frame().NumDLSyms()) + dl_symbol_id; size_t fft_buffer_target_id = From 3386713def80a9e9253d825ed604a58f36792cd2 Mon Sep 17 00:00:00 2001 From: rdoost Date: Fri, 31 Dec 2021 13:56:24 -0600 Subject: [PATCH 46/55] Update README --- README.md | 33 ++++++++++++++++----------------- matlab/inspect_agora_results.m | 12 ++++++------ 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 6c92d4231..9aeb6bbc4 100644 --- a/README.md +++ b/README.md @@ -169,38 +169,37 @@ The following are steps to set up both Agora and the packet generator: ## Building and running with real RRU Agora supports a 64-antenna Faros base station as RRU and Iris UE devices. Both are commercially available from [Skylark Wireless](https://skylarkwireless.com) and are used in the [POWER-RENEW PAWR testbed](https://powderwireless.net/).\ -Both Faros and Iris have their roots in the [Argos massive MIMO base station](https://www.yecl.org/argos/), especially [ArgosV3](https://www.yecl.org/argos/pubs/Shepard-MobiCom17-Demo.pdf). -Agora also supports USRP-based RRU and UEs. We use command line variables of `cmake`\ -to switch between emulated RRU and real RRU. We use `-DUSE_AGROS` for Faros RRU and Iris UEs, and `-DUSE_UHD` for USRP-based RRU and UEs. +Both Faros and Iris have their roots in the [Argos massive MIMO base station](https://www.yecl.org/argos/), especially [ArgosV3](https://www.yecl.org/argos/pubs/Shepard-MobiCom17-Demo.pdf). +Agora also supports USRP-based RRU and UEs. -We recommend using one server for controlling the RRU and running Agora, +We recommend using one server for controlling the RRU and running Agora, and another server for controlling the UEs and running the UE code. - -The hardware connected to the server can be discovered using the [pyfaros](https://github.com/skylarkwireless/pyfaros) tool. - -The command `python3 -m pyfaros.discover --json-out` outputs a JSON file used as a configuration input for Agora as explained below. - -Agora supports both uplink and downlink with real RRU and UEs. - -For downlink, a reference node outside the array (and synchronized) is required for reciprocity calibration. -It should also be indicated in the hardware JSON file. + +Agora supports both uplink and downlink with real RRU and UEs. For downlink, a reference node outside the array (and synchronized) is required for reciprocity calibration.\ +**Note:** Faros RRU and Iris UEs can be discovered using the [pyfaros](https://github.com/skylarkwireless/pyfaros) tool. You can use this tool to find the topology of the hardware connected to the server. We describe how to get the uplink and downlink demos working. Below XX can be replaced with either `ul` and `dl`. * Rebuild the code on both servers for RRU side the UE side. * For Faros RRU and Iris UEs, pass `-DUSE_ARGOS=on -DUSE_UHD=off` to cmake - * For USRP-based RRU and UEs, pass `-DUSE_ARGOS=off -DUSE_UHD=on` to cmake + * For USRP-based RRU and UEs, pass `-DUSE_ARGOS=off -DUSE_UHD=on` to cmake * Run `make -j` to recompile the code. * Run the UE code on the server connected to the Iris UEs - * Use pyfaros tool to generate a + * For Iris UEs, run the pyfaros tool in the `data` directory as follows: +
+     $ python3 -m pyfaros.discover --json-out
+     
+ This will output a file named `topology.json` with all the discoverable serial IDs included. * Modify `data/topology.json` by adding/removing serials of client Irises you'd like to include - from your setup. This file can be generated using the `pyfaros` tool as described above. - * Run `./build/data_generator --conf_file data/XX-hw.json` to generate required data files. + from your setup. + * For USRP-based RRU and UEs, modify the existing `data/topology.json` and enter the appropriate IDs. + * Run `./build/data_generator --conf_file data/XX-hw.json` to generate required data files. * Run `./build/user --conf_file data/XX-hw.json`. * Run Agora on the server connected to the Faros RRU * scp over the generated file `data/LDPC_orig_XX_data_512_ant2.bin` from the client machine to the server's `data` directory. * Rebuild the code * Run `make -j` to compile the code. + * For Faros RRU, use the pyfaros tool the same as with the UEs to generate a new `data/topology.json` * Modify `data/topology.json` by adding/removing serials of your RRU Irises, and the hub. * Run `./build/agora --conf_file data/XX-hw.json`. diff --git a/matlab/inspect_agora_results.m b/matlab/inspect_agora_results.m index c1299acb4..20b653377 100644 --- a/matlab/inspect_agora_results.m +++ b/matlab/inspect_agora_results.m @@ -1,14 +1,14 @@ clear; close all; -symbol_size = 864; -fft_size = 512; -data_size = 336; +symbol_size = 2400; +fft_size = 2048; +data_size = 1200; offset = 160; cp = 32; n_user = 2; -pig = 10:11; -dig = [12]; +pig = 0:1; +dig = [2]; nz_start_idx = (fft_size - data_size)/2; nz_sc_idx = nz_start_idx+1:nz_start_idx+data_size; @@ -102,4 +102,4 @@ end snr -evm \ No newline at end of file +evm From 3973b2af7baf3293c8861668ee8f32603a14e7ae Mon Sep 17 00:00:00 2001 From: rdoosty Date: Sun, 2 Jan 2022 21:42:19 -0600 Subject: [PATCH 47/55] Pick last peak in FindBeacon --- src/common/comms-lib-avx.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/comms-lib-avx.cc b/src/common/comms-lib-avx.cc index ed60a9a31..1a7ecbbd8 100644 --- a/src/common/comms-lib-avx.cc +++ b/src/common/comms-lib-avx.cc @@ -24,7 +24,7 @@ /// Correlation and Peak detection of a beacon with Gold code (2 repetitions) int CommsLib::FindBeaconAvx(const std::vector>& iq, const std::vector>& seq) { - std::queue valid_peaks; + std::vector valid_peaks; // Original LTS sequence int seq_len = seq.size(); @@ -67,7 +67,7 @@ int CommsLib::FindBeaconAvx(const std::vector>& iq, clock_gettime(CLOCK_MONOTONIC, &tv); for (size_t i = 0; i < gold_corr_avx_2.size(); i++) { if (gold_corr_avx_2[i] > thresh_avx[i]) { - valid_peaks.push(i); + valid_peaks.push_back(i); } } clock_gettime(CLOCK_MONOTONIC, &tv2); @@ -82,7 +82,7 @@ int CommsLib::FindBeaconAvx(const std::vector>& iq, std::cout << "Thresh calc AVX took " << diff3 << " usec" << std::endl; std::cout << "Peak Detect AVX took " << diff4 << " usec" << std::endl; std::printf("Saving Corr data\n"); - std::string filename = "corr_simd.bin"; + std::string filename("corr_simd.bin"); FILE* fc = std::fopen(filename.c_str(), "wb"); float* cdata_ptr = (float*)gold_corr_avx_2.data(); std::fwrite(cdata_ptr, gold_corr_avx_2.size(), sizeof(float), fc); @@ -100,10 +100,10 @@ int CommsLib::FindBeaconAvx(const std::vector>& iq, #endif if (valid_peaks.empty()) { - valid_peaks.push(-1); + valid_peaks.push_back(-1); } - return valid_peaks.front(); + return valid_peaks.back(); } static inline __m256i M256ComplexCs16Mult(__m256i data1, __m256i data2, From eea73ec2794ce8cb095dbd8687495c6bb1d75873 Mon Sep 17 00:00:00 2001 From: rdoost Date: Sun, 2 Jan 2022 23:03:12 -0600 Subject: [PATCH 48/55] Some comments about HW Framer --- src/agora/txrx/txrx_argos.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index ef39fec56..3618aada0 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -24,7 +24,16 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { threads_started_.fetch_add(1); long long time0 = 0; + // When Hw Framer is enabled, frame time keeping is done by hardware. + // In particular, the Hw only forward useful receive (no Guard) symbols. + // In this mode, the format of rx timestamp (64 bits)is frame number at + // 32-bits msb and symbol number at 16-bit msb of 32-bit lsb. + // When Hw Framer is disabled (false), frame time keeping in done entirely + // in software as it is implemented here. All time domain symbols are transfered + // to the host by HW where software will decide how to handle each symbol. if (cfg_->HwFramer() == false) { + // Read some dummy symbols to get the hardware time and then schedule + // TX/RX accordingly size_t beacon_radio = cfg_->BeaconAnt() / cfg_->NumChannels(); size_t beacon_chan = cfg_->BeaconAnt() % cfg_->NumChannels(); // prepare BS beacon in host buffer From f216fba90b7e81f165e893fd14731f71000d007c Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 11:13:03 -0600 Subject: [PATCH 49/55] Readability --- simulator/channel_sim.cc | 28 +++--- src/agora/agora.cc | 16 ++-- src/agora/doencode.cc | 7 +- src/agora/dozf.cc | 23 +++-- src/agora/phy_stats.cc | 57 ++++++++---- src/agora/radio_calibrate.cc | 14 ++- src/agora/radio_lib.cc | 8 +- src/agora/txrx/txrx.cc | 4 +- src/agora/txrx/txrx.h | 2 +- src/agora/txrx/txrx_argos.cc | 61 ++++++++----- src/client/client_radio.cc | 2 +- src/client/phy-ue.cc | 4 +- src/client/txrx_client.cc | 10 +- src/client/ue_worker.cc | 6 +- src/common/buffer.h | 2 +- src/common/config.cc | 7 +- src/common/config.h | 4 +- src/common/modulation.cc | 122 ++++++++++++++++++++----- src/common/symbols.h | 2 +- src/common/udp_server.h | 2 +- src/common/utils.cc | 12 ++- src/data_generator/data_generator.cc | 6 +- src/mac/mac_basestation.cc | 12 +-- src/mac/mac_client.cc | 12 +-- src/mac/mac_receiver.cc | 4 +- src/mac/mac_receiver.h | 2 +- src/mac/mac_sender.cc | 2 +- src/mac/mac_sender.h | 2 +- src/mac/mac_thread_basestation.cc | 16 ++-- src/mac/mac_thread_client.cc | 18 ++-- test/unit_tests/test_256qam_demod.cc | 48 +++++----- test/unit_tests/test_demul_threaded.cc | 2 +- test/unit_tests/test_zf.cc | 2 +- test/unit_tests/test_zf_threaded.cc | 2 +- 34 files changed, 338 insertions(+), 183 deletions(-) diff --git a/simulator/channel_sim.cc b/simulator/channel_sim.cc index 08d1f4d15..003a644e5 100644 --- a/simulator/channel_sim.cc +++ b/simulator/channel_sim.cc @@ -377,11 +377,11 @@ void* ChannelSim::BsRxLoop(size_t tid) { PinToCoreWithOffset(ThreadType::kWorkerTXRX, core_offset_ + 1, tid); // initialize bs-facing sockets - static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; + static constexpr size_t kSockBufSize = (1024 * 1024 * 64 * 8) - 1; for (size_t socket_id = socket_lo; socket_id < socket_hi; ++socket_id) { const size_t local_port_id = cfg_->BsRruPort() + socket_id; server_bs_.at(socket_id) = - std::make_unique(local_port_id, sock_buf_size); + std::make_unique(local_port_id, kSockBufSize); client_bs_.at(socket_id) = std::make_unique(); std::printf( "ChannelSim::BsRxLoop[%zu]: set up UDP socket server listening to port " @@ -392,8 +392,8 @@ void* ChannelSim::BsRxLoop(size_t tid) { const size_t rx_packet_size = cfg_->PacketLength(); const size_t buffer_size = (rx_packet_size) + kUdpMTU; - std::vector thread_rx_buffers_(total_sockets); - for (auto& buffer : thread_rx_buffers_) { + std::vector thread_rx_buffers(total_sockets); + for (auto& buffer : thread_rx_buffers) { buffer.data_ = reinterpret_cast( PaddedAlignedAlloc(Agora_memory::Alignment_t::kAlign64, buffer_size)); buffer.data_size_ = 0; @@ -406,7 +406,7 @@ void* ChannelSim::BsRxLoop(size_t tid) { size_t socket_id = socket_lo; while (running) { - SocketRxBuffer& rx_buffer = thread_rx_buffers_.at(socket_id - socket_lo); + SocketRxBuffer& rx_buffer = thread_rx_buffers.at(socket_id - socket_lo); const size_t rx_buffer_rem_size = buffer_size - rx_buffer.data_size_; const int rx_bytes = server_bs_.at(socket_id)->Recv( &rx_buffer.data_[rx_buffer.data_size_], rx_buffer_rem_size); @@ -476,7 +476,7 @@ void* ChannelSim::BsRxLoop(size_t tid) { } } // running - for (auto& buffer : thread_rx_buffers_) { + for (auto& buffer : thread_rx_buffers) { std::free(buffer.data_); buffer.data_ = nullptr; buffer.data_size_ = 0; @@ -494,11 +494,11 @@ void* ChannelSim::UeRxLoop(size_t tid) { core_offset_ + 1 + bs_thread_num_, tid); // initialize client-facing sockets - static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; + static constexpr size_t kSockBufSize = (1024 * 1024 * 64 * 8) - 1; for (size_t socket_id = socket_lo; socket_id < socket_hi; ++socket_id) { size_t local_port_id = cfg_->UeRruPort() + socket_id; server_ue_.at(socket_id) = - std::make_unique(local_port_id, sock_buf_size); + std::make_unique(local_port_id, kSockBufSize); client_ue_.at(socket_id) = std::make_unique(); std::printf( @@ -510,8 +510,8 @@ void* ChannelSim::UeRxLoop(size_t tid) { const size_t rx_packet_size = cfg_->PacketLength(); const size_t buffer_size = rx_packet_size + kUdpMTU; - std::vector thread_rx_buffers_(total_sockets); - for (auto& buffer : thread_rx_buffers_) { + std::vector thread_rx_buffers(total_sockets); + for (auto& buffer : thread_rx_buffers) { buffer.data_ = reinterpret_cast( PaddedAlignedAlloc(Agora_memory::Alignment_t::kAlign64, buffer_size)); buffer.data_size_ = 0; @@ -524,7 +524,7 @@ void* ChannelSim::UeRxLoop(size_t tid) { size_t socket_id = socket_lo; while (running) { - SocketRxBuffer& rx_buffer = thread_rx_buffers_.at(socket_id - socket_lo); + SocketRxBuffer& rx_buffer = thread_rx_buffers.at(socket_id - socket_lo); const size_t rx_buffer_rem_size = buffer_size - rx_buffer.data_size_; const int rx_bytes = server_ue_.at(socket_id)->Recv( &rx_buffer.data_[rx_buffer.data_size_], rx_buffer_rem_size); @@ -603,7 +603,7 @@ void* ChannelSim::UeRxLoop(size_t tid) { } } // running - for (auto& buffer : thread_rx_buffers_) { + for (auto& buffer : thread_rx_buffers) { std::free(buffer.data_); buffer.data_ = nullptr; buffer.data_size_ = 0; @@ -674,7 +674,7 @@ void ChannelSim::DoTxBs(WorkerThreadStorage& local, size_t tag) { const size_t total_offset_bs = total_symbol_id * payload_length_ * cfg_->BsAntNum(); - auto* src_ptr = + const auto* src_ptr = reinterpret_cast(&rx_buffer_ue_.at(total_offset_ue)); arma::cx_fmat& fmat_src = *local.ue_input_matrix_; @@ -760,7 +760,7 @@ void ChannelSim::DoTxUser(WorkerThreadStorage& local, size_t tag) { const size_t total_offset_ue = dl_symbol_id * payload_length_ * cfg_->UeAntNum(); - auto* src_ptr = + const auto* src_ptr = reinterpret_cast(&rx_buffer_bs_.at(total_offset_bs)); arma::cx_fmat& fmat_src = *local.bs_input_matrix_; diff --git a/src/agora/agora.cc b/src/agora/agora.cc index fd4e6a247..453df696f 100644 --- a/src/agora/agora.cc +++ b/src/agora/agora.cc @@ -16,7 +16,7 @@ Agora::Agora(Config* const cfg) : base_worker_core_offset_(cfg->CoreOffset() + 1 + cfg->SocketThreadNum()), config_(cfg), stats_(std::make_unique(cfg)), - phy_stats_(std::make_unique(cfg, Direction::Uplink)), + phy_stats_(std::make_unique(cfg, Direction::kUplink)), csi_buffers_(kFrameWnd, cfg->UeAntNum(), cfg->BsAntNum() * cfg->OfdmDataNum()), ul_zf_matrices_(kFrameWnd, cfg->OfdmDataNum(), @@ -98,7 +98,7 @@ void Agora::Stop() { packet_tx_rx_.reset(); } -void Agora::SendSnrReport(EventType event_type, size_t frame_id, +void Agora::SendSnrReport(EventType /*event_type*/, size_t frame_id, size_t symbol_id) { assert(event_type == EventType::kSNRReport); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); @@ -272,7 +272,7 @@ void Agora::ScheduleCodeblocks(EventType event_type, size_t frame_id, } } -void Agora::ScheduleUsers(EventType event_type, size_t frame_id, +void Agora::ScheduleUsers(EventType /*event_type*/, size_t frame_id, size_t symbol_id) { assert(event_type == EventType::kPacketToMac); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); @@ -371,7 +371,9 @@ void Agora::Start() { zf_last_frame_ = frame_id; PrintPerFrameDone(PrintType::kZF, frame_id); this->zf_counters_.Reset(frame_id); - if (kPrintZfStats) this->phy_stats_->PrintZfStats(frame_id); + if (kPrintZfStats) { + this->phy_stats_->PrintZfStats(frame_id); + } for (size_t i = 0; i < cfg->Frame().NumULSyms(); i++) { if (this->fft_cur_frame_for_symbol_.at(i) == frame_id) { @@ -809,7 +811,7 @@ void Agora::Worker(int tid) { this->dl_encoded_buffer_, this->stats_.get()); auto compute_encoding = std::make_unique( - config_, tid, Direction::Downlink, + config_, tid, Direction::kDownlink, (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), (kEnableMac == true) ? kFrameWnd : 1, dl_encoded_buffer_, this->stats_.get()); @@ -951,7 +953,7 @@ void Agora::WorkerDecode(int tid) { PinToCoreWithOffset(ThreadType::kWorkerDecode, base_worker_core_offset_, tid); std::unique_ptr compute_encoding( - new DoEncode(config_, tid, Direction::Downlink, + new DoEncode(config_, tid, Direction::kDownlink, (kEnableMac == true) ? dl_bits_buffer_ : config_->DlBits(), (kEnableMac == true) ? kFrameWnd : 1, dl_encoded_buffer_, this->stats_.get())); @@ -1530,7 +1532,7 @@ void Agora::GetEqualData(float** ptr, int* size) { *ptr = (float*)&equal_buffer_[offset][0]; *size = cfg->UeAntNum() * cfg->OfdmDataNum() * 2; } -void Agora::CheckIncrementScheduleFrame(size_t frame_id, +void Agora::CheckIncrementScheduleFrame(size_t /*frame_id*/, ScheduleProcessingFlags completed) { this->schedule_process_flags_ += completed; assert(this->cur_sche_frame_id_ == frame_id); diff --git a/src/agora/doencode.cc b/src/agora/doencode.cc index da5d9ccd1..31dec7ccc 100644 --- a/src/agora/doencode.cc +++ b/src/agora/doencode.cc @@ -57,8 +57,9 @@ EventData DoEncode::Launch(size_t tag) { size_t start_tsc = GetTime::WorkerRdtsc(); - size_t symbol_idx, symbol_idx_data; - if (dir_ == Direction::Downlink) { + size_t symbol_idx; + size_t symbol_idx_data; + if (dir_ == Direction::kDownlink) { symbol_idx = cfg_->Frame().GetDLSymbolIdx(symbol_id); assert(symbol_idx >= cfg_->Frame().ClientDlPilotSymbols()); symbol_idx_data = symbol_idx - cfg_->Frame().ClientDlPilotSymbols(); @@ -120,7 +121,7 @@ EventData DoEncode::Launch(size_t tag) { int8_t* final_output_ptr = cfg_->GetEncodedBuf( encoded_buffer_, dir_, frame_id, symbol_idx, ue_id, cur_cb_id); - if (kPrintRawMacData && dir_ == Direction::Uplink) { + if (kPrintRawMacData && dir_ == Direction::kUplink) { std::printf("Encoded data - placed at location (%zu %zu %zu) %zu\n", frame_id, symbol_idx, ue_id, (size_t)final_output_ptr); } diff --git a/src/agora/dozf.cc b/src/agora/dozf.cc index c865cb27b..a0474bc4f 100644 --- a/src/agora/dozf.cc +++ b/src/agora/dozf.cc @@ -46,16 +46,20 @@ DoZF::DoZF(Config* config, int tid, kMaxAntennas * sizeof(complex_float))); num_ext_ref_ = 0; - for (size_t i = 0; i < cfg_->NumCells(); i++) - if (cfg_->ExternalRefNode(i) == true) num_ext_ref_++; + for (size_t i = 0; i < cfg_->NumCells(); i++) { + if (cfg_->ExternalRefNode(i) == true) { + num_ext_ref_++; + } + } if (num_ext_ref_ > 0) { ext_ref_id_.zeros(num_ext_ref_ * cfg_->NumChannels()); size_t ext_id = 0; for (size_t i = 0; i < cfg_->NumCells(); i++) { if (cfg_->ExternalRefNode(i) == true) { - for (size_t j = 0; j < cfg_->NumChannels(); j++) + for (size_t j = 0; j < cfg_->NumChannels(); j++) { ext_ref_id_.at(ext_id * cfg_->NumChannels() + j) = cfg_->RefAnt(i) + j; + } ext_id++; } } @@ -142,7 +146,9 @@ float DoZF::ComputePrecoder(const arma::cx_fmat& mat_csi, } mat_ul_zf = mat_ul_zf_tmp; float rcond = -1; - if (kPrintZfStats) rcond = arma::rcond(mat_csi.t() * mat_csi); + if (kPrintZfStats) { + rcond = arma::rcond(mat_csi.t() * mat_csi); + } return rcond; } @@ -205,14 +211,15 @@ void DoZF::ComputeCalib(size_t frame_id, size_t sc_id) { pre_calib_ul_msum_mat.row(sc_id) - old_calib_ul_mat.row(sc_id); - if (cfg_->InitCalibRepeat() == 0u && frame_grp_id == 0) + if (cfg_->InitCalibRepeat() == 0u && frame_grp_id == 0) { // fill with one until one full sweep // of calibration data is done calib_vec.fill(arma::cx_float(1, 0)); - else + } else { calib_vec = (cur_calib_dl_msum_mat.row(sc_id) / cur_calib_ul_msum_mat.row(sc_id)) .st(); + } } // Gather data of one symbol from partially-transposed buffer @@ -343,7 +350,9 @@ void DoZF::ZfTimeOrthogonal(size_t tag) { auto rcond = ComputePrecoder(mat_csi, calib_gather_buffer_, ul_zf_matrices_[frame_slot][cur_sc_id], dl_zf_matrices_[frame_slot][cur_sc_id]); - if (kPrintZfStats) phy_stats_->UpdateCsiCond(frame_id, cur_sc_id, rcond); + if (kPrintZfStats) { + phy_stats_->UpdateCsiCond(frame_id, cur_sc_id, rcond); + } duration_stat_->task_duration_[3] += GetTime::WorkerRdtsc() - start_tsc3; duration_stat_->task_count_++; diff --git a/src/agora/phy_stats.cc b/src/agora/phy_stats.cc index 31872e73e..4683cd15e 100644 --- a/src/agora/phy_stats.cc +++ b/src/agora/phy_stats.cc @@ -8,7 +8,7 @@ #include PhyStats::PhyStats(Config* const cfg, Direction dir) : config_(cfg), dir_(dir) { - if (dir_ == Direction::Downlink) { + if (dir_ == Direction::kDownlink) { num_rx_symbols_ = cfg->Frame().NumDLSyms(); } else { num_rx_symbols_ = cfg->Frame().NumULSyms(); @@ -34,7 +34,7 @@ PhyStats::PhyStats(Config* const cfg, Direction dir) : config_(cfg), dir_(dir) { Agora_memory::Alignment_t::kAlign64); if (num_rx_symbols_ > 0) { - if (dir_ == Direction::Downlink) { + if (dir_ == Direction::kDownlink) { auto* dl_iq_f_ptr = reinterpret_cast( cfg->DlIqF()[cfg->Frame().ClientDlPilotSymbols()]); arma::cx_fmat dl_iq_f_mat(dl_iq_f_ptr, cfg->OfdmCaNum(), cfg->UeAntNum(), @@ -76,7 +76,7 @@ PhyStats::~PhyStats() { void PhyStats::PrintPhyStats() { const size_t task_buffer_symbol_num = num_rx_symbols_ * kFrameWnd; std::string tx_type; - if (dir_ == Direction::Downlink) { + if (dir_ == Direction::kDownlink) { tx_type = "Downlink"; } else { tx_type = "Uplink"; @@ -136,13 +136,22 @@ void PhyStats::PrintSnrStats(size_t frame_id) { size_t radio_id = j / config_->NumChannels(); size_t cell_id = config_->CellId().at(radio_id); if (config_->ExternalRefNode(cell_id) == true && - radio_id == config_->RefRadio(cell_id)) + radio_id == config_->RefRadio(cell_id)) { continue; - if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; - if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; + } + if (frame_snr[j] < min_snr) { + min_snr = frame_snr[j]; + } + if (frame_snr[j] > max_snr) { + max_snr = frame_snr[j]; + } + } + if (min_snr == FLT_MAX) { + min_snr = -100; + } + if (max_snr == FLT_MIN) { + max_snr = -100; } - if (min_snr == FLT_MAX) min_snr = -100; - if (max_snr == FLT_MIN) max_snr = -100; ss << "User " << i << ": [" << min_snr << "," << max_snr << "]" << " "; } @@ -164,17 +173,27 @@ void PhyStats::PrintCalibSnrStats(size_t frame_id) { size_t radio_id = j / config_->NumChannels(); size_t cell_id = config_->CellId().at(radio_id); if (config_->ExternalRefNode(cell_id) == true && - radio_id == config_->RefRadio(cell_id)) + radio_id == config_->RefRadio(cell_id)) { continue; - if (frame_snr[j] < min_snr) min_snr = frame_snr[j]; - if (frame_snr[j] > max_snr) max_snr = frame_snr[j]; + } + if (frame_snr[j] < min_snr) { + min_snr = frame_snr[j]; + } + if (frame_snr[j] > max_snr) { + max_snr = frame_snr[j]; + } + } + if (min_snr == FLT_MAX) { + min_snr = -100; } - if (min_snr == FLT_MAX) min_snr = -100; - if (max_snr == FLT_MIN) max_snr = -100; - if (i == 0) + if (max_snr == FLT_MIN) { + max_snr = -100; + } + if (i == 0) { ss << "Downlink "; - else + } else { ss << "Uplink "; + } ss << ": [" << min_snr << "," << max_snr << "] "; } ss << std::endl; @@ -225,8 +244,12 @@ void PhyStats::PrintZfStats(size_t frame_id) { float max_cond = 0; float min_cond = 1; for (size_t j = 0; j < config_->OfdmDataNum(); j++) { - if (cond_vec.at(j) < min_cond) min_cond = cond_vec.at(j); - if (cond_vec.at(j) > max_cond) max_cond = cond_vec.at(j); + if (cond_vec.at(j) < min_cond) { + min_cond = cond_vec.at(j); + } + if (cond_vec.at(j) > max_cond) { + max_cond = cond_vec.at(j); + } } ss << "[" << min_cond << "," << max_cond << "], Mean: " << arma::mean(cond_vec); diff --git a/src/agora/radio_calibrate.cc b/src/agora/radio_calibrate.cc index f19dea30e..869a49ee9 100644 --- a/src/agora/radio_calibrate.cc +++ b/src/agora/radio_calibrate.cc @@ -614,7 +614,9 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { if (good_csi == false) { break; } - if (i == ref) continue; + if (i == ref) { + continue; + } // Send a separate pilot from each antenna for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) { @@ -649,8 +651,9 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { std::cout << "bad read (" << ret << ") at node " << ref << " from node " << i << std::endl; retry++; - } else + } else { break; + } } if (bad_read) { good_csi = false; @@ -687,7 +690,9 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { if (good_csi == false) { break; } - if (i == ref) continue; + if (i == ref) { + continue; + } std::vector rxbuff(2); rxbuff.at(0) = buff.at(m + cfg_->NumChannels() * i).data(); if (cfg_->NumChannels() == 2) { @@ -704,8 +709,9 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { } if (bad_read) { retry++; - } else + } else { break; + } } if (bad_read) { good_csi = false; diff --git a/src/agora/radio_lib.cc b/src/agora/radio_lib.cc index e843d1dfb..5dea5056b 100644 --- a/src/agora/radio_lib.cc +++ b/src/agora/radio_lib.cc @@ -24,7 +24,7 @@ RadioConfig::RadioConfig(Config* cfg) if (kUseUHD == false) { for (size_t i = 0; i < cfg_->NumCells(); i++) { SoapySDR::Device* hub_device = nullptr; - if (cfg_->HubId().at(i) != "") { + if (!cfg_->HubId().at(i).empty()) { args["driver"] = "remote"; args["timeout"] = "1000000"; args["serial"] = cfg_->HubId().at(i); @@ -34,7 +34,7 @@ RadioConfig::RadioConfig(Config* cfg) hub_device = SoapySDR::Device::make(args); break; } catch (const std::runtime_error& e) { - auto* message = e.what(); + const auto* message = e.what(); std::printf("Soapy error[%zu] -- %s\n", tries, message); } } @@ -221,7 +221,7 @@ void RadioConfig::InitBsRadio(size_t tid) { bs_device = SoapySDR::Device::make(args); break; } catch (const std::runtime_error& e) { - auto* message = e.what(); + const auto* message = e.what(); std::printf("InitBsRadio[%zu] - Soapy error try %zu -- %s\n", tid, tries, message); } @@ -694,7 +694,7 @@ RadioConfig::~RadioConfig() { } ba_stn_.clear(); - for (auto hub : hubs_) { + for (auto* hub : hubs_) { SoapySDR::Device::unmake(hub); } hubs_.clear(); diff --git a/src/agora/txrx/txrx.cc b/src/agora/txrx/txrx.cc index 050eb716f..bb698a3e1 100644 --- a/src/agora/txrx/txrx.cc +++ b/src/agora/txrx/txrx.cc @@ -179,12 +179,12 @@ void PacketTXRX::LoopTxRx(size_t tid) { const size_t radio_hi = std::min((radio_lo + radios_per_thread), cfg_->BsAntNum()) - 1; - static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; + static constexpr size_t kSockBufSize = (1024 * 1024 * 64 * 8) - 1; for (size_t radio_id = radio_lo; radio_id <= radio_hi; ++radio_id) { size_t local_port_id = cfg_->BsServerPort() + radio_id; udp_servers_.at(radio_id) = - std::make_unique(local_port_id, sock_buf_size); + std::make_unique(local_port_id, kSockBufSize); udp_clients_.at(radio_id) = std::make_unique(); MLPD_FRAME( "TXRX thread %d: set up UDP socket server listening to port %d" diff --git a/src/agora/txrx/txrx.h b/src/agora/txrx/txrx.h index 8170c135d..57d842152 100644 --- a/src/agora/txrx/txrx.h +++ b/src/agora/txrx/txrx.h @@ -107,7 +107,7 @@ class PacketTXRX { private: void LoopTxRx(size_t tid); // The thread function for thread [tid] size_t DequeueSend(int tid); - Packet* RecvEnqueue(size_t tid, size_t radio_id, size_t rx_offset); + Packet* RecvEnqueue(size_t tid, size_t radio_id, size_t rx_slot); void LoopTxRxArgos(size_t tid); size_t DequeueSendArgos(int tid, long long time0); diff --git a/src/agora/txrx/txrx_argos.cc b/src/agora/txrx/txrx_argos.cc index 3618aada0..c88d334be 100644 --- a/src/agora/txrx/txrx_argos.cc +++ b/src/agora/txrx/txrx_argos.cc @@ -42,7 +42,9 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { zeros[0] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); zeros[1] = calloc(cfg_->SampsPerSymbol(), sizeof(int16_t) * 2); beaconbuff[beacon_chan] = cfg_->BeaconCi16().data(); - if (cfg_->NumChannels() > 1) beaconbuff[1 - beacon_chan] = zeros[0]; + if (cfg_->NumChannels() > 1) { + beaconbuff[1 - beacon_chan] = zeros[0]; + } std::vector> samp_buffer0(cfg_->SampsPerSymbol(), 0); std::vector> samp_buffer1(cfg_->SampsPerSymbol(), 0); @@ -60,39 +62,44 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { int rx_ret = 0; int tx_ret = 0; while ((rx_ret = radioconfig_->RadioRx(radio_lo, samp_buffer.data(), - rx_time_bs)) < 0) + rx_time_bs)) < 0) { ; + } tx_time_bs = rx_time_bs + frame_time * TX_FRAME_DELTA; time0 = tx_time_bs; std::cout << "Received first data at time " << rx_time_bs << " on thread " << tid << std::endl; std::cout << "Transmit first beacon at time " << tx_time_bs << " on thread " << tid << std::endl; - for (auto radio = radio_lo + 1; radio < radio_hi; radio++) + for (auto radio = radio_lo + 1; radio < radio_hi; radio++) { radioconfig_->RadioRx(radio_lo, samp_buffer.data(), rx_time_bs); + } // Schedule the first beacon in the future for (auto radio = radio_lo; radio < radio_hi; radio++) { - if (radio == beacon_radio) + if (radio == beacon_radio) { tx_ret = radioconfig_->RadioTx(radio, beaconbuff.data(), 2, tx_time_bs); - else + } else { tx_ret = radioconfig_->RadioTx(radio, zeros.data(), 2, tx_time_bs); + } if (tx_ret != (int)cfg_->SampsPerSymbol()) { std::cerr << "BAD Transmit(" << tx_ret << "/" << cfg_->SampsPerSymbol() << ") at Time " << tx_time_bs << std::endl; } } for (size_t sym = 1; sym < cfg_->Frame().NumTotalSyms(); sym++) { - for (auto radio = radio_lo; radio < radio_hi; radio++) + for (auto radio = radio_lo; radio < radio_hi; radio++) { radioconfig_->RadioRx(radio, samp_buffer.data(), rx_time_bs); + } } for (size_t frm = 1; frm < TX_FRAME_DELTA; frm++) { tx_time_bs += frame_time; for (auto radio = radio_lo; radio < radio_hi; radio++) { - if (radio == beacon_radio) + if (radio == beacon_radio) { tx_ret = radioconfig_->RadioTx(radio, beaconbuff.data(), 2, tx_time_bs); - else + } else { tx_ret = radioconfig_->RadioTx(radio, zeros.data(), 2, tx_time_bs); + } if (tx_ret != (int)cfg_->SampsPerSymbol()) { std::cerr << "BAD Transmit(" << tx_ret << "/" << cfg_->SampsPerSymbol() << ") at Time " << tx_time_bs @@ -125,7 +132,7 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { // receive data auto pkts = RecvEnqueueArgos(tid, radio_id, rx_slot, global_frame_id, global_symbol_id); - if (pkts.size() > 0) { + if (!pkts.empty()) { rx_slot = (rx_slot + pkts.size()) % buffers_per_socket_; RtAssert(pkts.size() == cfg_->NumChannels(), "Received data but it was the wrong dimension"); @@ -146,8 +153,9 @@ void PacketTXRX::LoopTxRxArgos(size_t tid) { global_symbol_id = 0; global_frame_id++; if (cfg_->Frame().NumDLSyms() == 0) { - for (size_t radio = radio_lo; radio <= radio_hi; radio++) + for (size_t radio = radio_lo; radio <= radio_hi; radio++) { this->TxBeaconHW(global_frame_id, radio, time0); + } } } } @@ -205,8 +213,9 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, if (cfg_->NumChannels() == 2) { samp_buffer[1] = samp_buffer1.data(); } - if (cfg_->Running() == true) + if (cfg_->Running() == true) { radioconfig_->RadioRx(radio_id, samp_buffer.data(), frame_time); + } std::vector empty_pkt; return empty_pkt; } else { @@ -221,8 +230,9 @@ std::vector PacketTXRX::RecvEnqueueArgos(size_t tid, size_t radio_id, if (cfg_->HwFramer() == true) { frame_id = (size_t)(frame_time >> 32); symbol_id = (size_t)((frame_time >> 16) & 0xFFFF); - for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) + for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) { symbol_ids.at(ch) = symbol_id; + } // Additional read for DL Calibration in two-chan case. // In HW framer mode we need to be specific about @@ -289,7 +299,9 @@ void PacketTXRX::TxBeaconHW(size_t frame_id, size_t radio_id, long long time0) { beaconbuff[0] = zeros[0]; beaconbuff[1] = zeros[1]; } - if (cfg_->NumChannels() > 1) beaconbuff[1] = zeros[0]; + if (cfg_->NumChannels() > 1) { + beaconbuff[1] = zeros[0]; + } // assuming beacon is first symbol long long frame_time = time0 + (frame_id + TX_FRAME_DELTA) * cfg_->SampsPerSymbol() * @@ -317,34 +329,40 @@ void PacketTXRX::TxReciprocityCalibPilots(size_t frame_id, size_t radio_id, s == radio_id % cfg_->RadioPerGroup()); for (size_t ch = 0; ch < cfg_->NumChannels(); ch++) { caltxbuf.at(ch) = calib_turn ? cfg_->PilotCi16().data() : zeros.data(); - if (cfg_->NumChannels() > 1) caltxbuf.at(1 - ch) = zeros.data(); + if (cfg_->NumChannels() > 1) { + caltxbuf.at(1 - ch) = zeros.data(); + } long long frame_time = 0; - if (cfg_->HwFramer() == false) + if (cfg_->HwFramer() == false) { frame_time = time0 + cfg_->SampsPerSymbol() * ((frame_id + TX_FRAME_DELTA) * cfg_->Frame().NumTotalSyms() + cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch)); - else + } else { frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | (cfg_->Frame().GetDLCalSymbol(s * cfg_->NumChannels() + ch) << 16); + } radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); } } else { // We choose to use channel A to tx from the reference radio caltxbuf.at(0) = cfg_->PilotCi16().data(); - if (cfg_->NumChannels() > 1) caltxbuf.at(1) = zeros.data(); + if (cfg_->NumChannels() > 1) { + caltxbuf.at(1) = zeros.data(); + } long long frame_time = 0; - if (cfg_->HwFramer() == false) + if (cfg_->HwFramer() == false) { frame_time = time0 + cfg_->SampsPerSymbol() * ((frame_id + TX_FRAME_DELTA) * cfg_->Frame().NumTotalSyms() + cfg_->Frame().GetULCalSymbol(0)); - else + } else { frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | (cfg_->Frame().GetULCalSymbol(0) << 16); + } radioconfig_->RadioTx(radio_id, caltxbuf.data(), 1, frame_time); } } @@ -426,14 +444,15 @@ size_t PacketTXRX::DequeueSendArgos(int tid, long long time0) { const int flags = (symbol_id != last) ? 1 // HAS_TIME : 2; // HAS_TIME & END_BURST, fixme long long frame_time = 0; - if (cfg_->HwFramer() == false) + if (cfg_->HwFramer() == false) { frame_time = time0 + cfg_->SampsPerSymbol() * ((frame_id + TX_FRAME_DELTA) * cfg_->Frame().NumTotalSyms() + symbol_id); - else + } else { frame_time = ((long long)(frame_id + TX_FRAME_DELTA) << 32) | (symbol_id << 16); + } radioconfig_->RadioTx(radio_id, txbuf.data(), flags, frame_time); } diff --git a/src/client/client_radio.cc b/src/client/client_radio.cc index dc66bb08e..3d0917f57 100644 --- a/src/client/client_radio.cc +++ b/src/client/client_radio.cc @@ -145,7 +145,7 @@ void ClientRadioConfig::InitClientRadio(size_t tid) { ue_device = SoapySDR::Device::make(args); break; } catch (const std::runtime_error& e) { - auto* message = e.what(); + const auto* message = e.what(); std::printf("InitClientRadio[%zu] - Soapy error try %zu -- %s\n", tid, tries, message); } diff --git a/src/client/phy-ue.cc b/src/client/phy-ue.cc index 53aa2e65f..8761035d9 100644 --- a/src/client/phy-ue.cc +++ b/src/client/phy-ue.cc @@ -20,7 +20,7 @@ static const size_t kDefaultQueueSize = 36; PhyUe::PhyUe(Config* config) : stats_(std::make_unique(config)), - phy_stats_(std::make_unique(config, Direction::Downlink)), + phy_stats_(std::make_unique(config, Direction::kDownlink)), demod_buffer_(kFrameWnd, config->Frame().NumDLSyms(), config->UeAntNum(), kMaxModType * config->OfdmDataNum()), decoded_buffer_(kFrameWnd, config->Frame().NumDLSyms(), @@ -563,7 +563,7 @@ void PhyUe::Start() { RtAssert(radio_buf_id == (expected_frame_id_from_mac_ % kFrameWnd), "Radio buffer id does not match expected"); - auto* pkt = reinterpret_cast( + const auto* pkt = reinterpret_cast( &ul_bits_buffer_[ue_id][radio_buf_id * config_->UlMacBytesNumPerframe()]); diff --git a/src/client/txrx_client.cc b/src/client/txrx_client.cc index afdbb20be..211f929d5 100644 --- a/src/client/txrx_client.cc +++ b/src/client/txrx_client.cc @@ -137,7 +137,7 @@ struct Packet* RadioTxRx::RecvEnqueue(size_t tid, size_t ant_id, } int RadioTxRx::DequeueSend(int tid) { - auto& c = config_; + const auto& c = config_; EventData event; if (task_queue_->try_dequeue_from_producer(*tx_ptoks_[tid], event) == false) { return -1; @@ -260,7 +260,7 @@ void* RadioTxRx::LoopTxRx(size_t tid) { // dequeue_send_sdr int RadioTxRx::DequeueSendArgos(int tid, long long time0) { - auto& c = config_; + const auto& c = config_; auto& radio = radioconfig_; size_t packet_length = c->PacketLength(); size_t num_samps = c->SampsPerSymbol(); @@ -371,7 +371,7 @@ int RadioTxRx::DequeueSendArgos(int tid, long long time0) { struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, size_t& frame_id, size_t& symbol_id, size_t rx_slot, bool dummy_enqueue) { - auto& c = config_; + const auto& c = config_; moodycamel::ProducerToken* local_ptok = rx_ptoks_[tid]; size_t num_samps = c->SampsPerSymbol(); @@ -432,7 +432,7 @@ struct Packet* RadioTxRx::RecvEnqueueArgos(size_t tid, size_t radio_id, void* RadioTxRx::LoopTxRxArgos(size_t tid) { PinToCoreWithOffset(ThreadType::kWorkerTXRX, core_id_, tid); - auto& c = config_; + const auto& c = config_; const size_t num_radios = c->UeNum(); size_t radio_lo = tid * num_radios / thread_num_; size_t radio_hi = (tid + 1) * num_radios / thread_num_; @@ -494,7 +494,7 @@ void* RadioTxRx::LoopTxRxArgos(size_t tid) { void* RadioTxRx::LoopTxRxArgosSync(size_t tid) { ///\todo FIXME: This only works when there is 1 radio per thread. PinToCoreWithOffset(ThreadType::kWorkerTXRX, core_id_, tid); - auto& c = config_; + const auto& c = config_; size_t num_samps = c->SampsPerSymbol(); size_t frm_num_samps = num_samps * c->Frame().NumTotalSyms(); ClientRadioConfig* radio = radioconfig_.get(); diff --git a/src/client/ue_worker.cc b/src/client/ue_worker.cc index 3a0ac7911..331eb72ad 100644 --- a/src/client/ue_worker.cc +++ b/src/client/ue_worker.cc @@ -39,7 +39,7 @@ UeWorker::UeWorker( PtrCube& decoded_buffer, std::vector>>& ue_pilot_vec) : tid_(tid), - thread_(), + notify_queue_(notify_queue), work_queue_(work_queue), work_producer_token_(work_producer), @@ -94,7 +94,7 @@ void UeWorker::TaskThread(size_t core_offset) { PinToCoreWithOffset(ThreadType::kWorker, core_offset, tid_); auto encoder = std::make_unique( - &config_, (int)tid_, Direction::Uplink, + &config_, (int)tid_, Direction::kUplink, (kEnableMac == true) ? ul_bits_buffer_ : config_.UlBits(), (kEnableMac == true) ? kFrameWnd : 1, encoded_buffer_, &stats_); @@ -538,7 +538,7 @@ void UeWorker::DoModul(size_t tag) { complex_float* modul_buf = &modul_buffer_[total_ul_data_symbol_id][ant_id * config_.OfdmDataNum()]; - auto* ul_bits = config_.GetEncodedBuf(encoded_buffer_, Direction::Uplink, + auto* ul_bits = config_.GetEncodedBuf(encoded_buffer_, Direction::kUplink, frame_id, ul_symbol_idx, ant_id, 0); if (kDebugPrintModul) { diff --git a/src/common/buffer.h b/src/common/buffer.h index d8a5173c4..d3daeeeb0 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -194,7 +194,7 @@ class RxPacket { public: RxPacket() : references_(0) { packet_ = nullptr; } explicit RxPacket(Packet *in) : references_(0) { Set(in); } - explicit RxPacket(const RxPacket ©) : packet_(copy.packet_) { + RxPacket(const RxPacket ©) : packet_(copy.packet_) { references_.store(copy.references_.load()); } virtual ~RxPacket() = default; diff --git a/src/common/config.cc b/src/common/config.cc index fc765d90b..b9685b5f5 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -19,7 +19,7 @@ using json = nlohmann::json; static const size_t kMacAlignmentBytes = 64u; -static constexpr size_t kDebugPrintConfiguration = false; +static constexpr bool kDebugPrintConfiguration = false; Config::Config(const std::string& jsonfile) : freq_ghz_(GetTime::MeasureRdtscFreq()), @@ -75,7 +75,7 @@ Config::Config(const std::string& jsonfile) auto hub_serial = serials_conf.value("hub", ""); hub_id_.push_back(hub_serial); auto sdr_serials = serials_conf.value("sdr", json::array()); - RtAssert(sdr_serials.size() != 0, "BS has zero sdrs!"); + RtAssert(!sdr_serials.empty(), "BS has zero sdrs!"); radio_id_.insert(radio_id_.end(), sdr_serials.begin(), sdr_serials.end()); num_radios_ += sdr_serials.size(); cell_id_.resize(num_radios_, i); @@ -136,8 +136,9 @@ Config::Config(const std::string& jsonfile) bf_ant_num_ = bs_ant_num_; for (size_t i = 0; i < num_cells_; i++) { - if (external_ref_node_.at(i) == true) + if (external_ref_node_.at(i) == true) { bf_ant_num_ = bs_ant_num_ - num_channels_; + } } if (ref_radio_.empty() == false) { diff --git a/src/common/config.h b/src/common/config.h index 6f0ec77dc..f0af9db2b 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -349,7 +349,7 @@ class Config { size_t frame_id, size_t symbol_id, size_t ue_id, size_t cb_id) const { size_t mac_bytes_perframe; - if (dir == Direction::Downlink) { + if (dir == Direction::kDownlink) { mac_bytes_perframe = dl_mac_bytes_num_perframe_; } else { mac_bytes_perframe = ul_mac_bytes_num_perframe_; @@ -373,7 +373,7 @@ class Config { size_t cb_id) const { size_t total_data_symbol_id; - if (dir == Direction::Downlink) { + if (dir == Direction::kDownlink) { total_data_symbol_id = GetTotalDataSymbolIdxDl(frame_id, symbol_id); } else { total_data_symbol_id = GetTotalDataSymbolIdxUl(frame_id, symbol_id); diff --git a/src/common/modulation.cc b/src/common/modulation.cc index 2a00846ee..d68ea069d 100644 --- a/src/common/modulation.cc +++ b/src/common/modulation.cc @@ -174,7 +174,8 @@ void InitQam64Table(Table& qam64_table) { */ void InitQam256Table(Table& qam256_table) { float scale = 1 / sqrt(170); - uint8_t imag_i, real_i; + uint8_t imag_i; + uint8_t real_i; /** * To generate this table, first create a 4 bit gray code. Then, generate a * vector of the scales you want for your QAM table. Finally, use the gray @@ -1303,16 +1304,54 @@ void Demod256qamHardLoop(const float* vec_in, uint8_t* vec_out, int num) { } void Demod256qamHardSse(float* vec_in, uint8_t* vec_out, int num) { - __m128 symbol1, symbol2, symbol3, symbol4; - __m128i intsymbol1, intsymbol2, intsymbol3, intsymbol4, symbol12, symbol34, - symbol_abs, symbol_gt_0, symbol_gt_threshold1, symbol_gt_threshold2, - symbol_lt_threshold3, symbol_lt_threshold4, symbol_gt_threshold5, - symbol_lt_threshold6, symbol_lt_threshold7, symbol12_bit0, symbol12_bit1, - symbol12_bit2, symbol12_bit3, symbol12_bit4, symbol12_bit5, symbol12_bit6, - symbol12_bit7, symbol34_bit0, symbol34_bit1, symbol34_bit2, symbol34_bit3, - symbol34_bit4, symbol34_bit5, symbol34_bit6, symbol34_bit7, bit7, bit6, - bit5, bit4, bit3, bit2, bit1, bit0, result, symbol_bit01, symbol_bit23, - symbol_bit45, symbol_bit67 __attribute__((aligned(16))); + __m128 symbol1; + __m128 symbol2; + __m128 symbol3; + __m128 symbol4; + __m128i intsymbol1; + __m128i intsymbol2; + __m128i intsymbol3; + __m128i intsymbol4; + __m128i symbol12; + __m128i symbol34; + __m128i symbol_abs; + __m128i symbol_gt_0; + __m128i symbol_gt_threshold1; + __m128i symbol_gt_threshold2; + __m128i symbol_lt_threshold3; + __m128i symbol_lt_threshold4; + __m128i symbol_gt_threshold5; + __m128i symbol_lt_threshold6; + __m128i symbol_lt_threshold7; + __m128i symbol12_bit0; + __m128i symbol12_bit1; + __m128i symbol12_bit2; + __m128i symbol12_bit3; + __m128i symbol12_bit4; + __m128i symbol12_bit5; + __m128i symbol12_bit6; + __m128i symbol12_bit7; + __m128i symbol34_bit0; + __m128i symbol34_bit1; + __m128i symbol34_bit2; + __m128i symbol34_bit3; + __m128i symbol34_bit4; + __m128i symbol34_bit5; + __m128i symbol34_bit6; + __m128i symbol34_bit7; + __m128i bit7; + __m128i bit6; + __m128i bit5; + __m128i bit4; + __m128i bit3; + __m128i bit2; + __m128i bit1; + __m128i bit0; + __m128i result; + __m128i symbol_bit01; + __m128i symbol_bit23; + __m128i symbol_bit45; + __m128i symbol_bit67 __attribute__((aligned(16))); auto* result_ptr = reinterpret_cast<__m64*>(vec_out); int remaining_symbols; /* @@ -1507,16 +1546,54 @@ void Demod256qamHardSse(float* vec_in, uint8_t* vec_out, int num) { void Demod256qamHardAvx2(float* vec_in, uint8_t* vec_out, int num) { float* symbols_ptr = vec_in; auto* result_ptr = reinterpret_cast<__m128i*>(vec_out); - __m256 symbol1, symbol2, symbol3, symbol4; - __m256i intsymbol1, intsymbol2, intsymbol3, intsymbol4, symbol12, symbol34, - symbol_abs, symbol_gt_0, symbol_gt_threshold1, symbol_gt_threshold2, - symbol_lt_threshold3, symbol_lt_threshold4, symbol_gt_threshold5, - symbol_lt_threshold6, symbol_lt_threshold7, symbol12_bit0, symbol12_bit1, - symbol12_bit2, symbol12_bit3, symbol12_bit4, symbol12_bit5, symbol12_bit6, - symbol12_bit7, symbol34_bit0, symbol34_bit1, symbol34_bit2, symbol34_bit3, - symbol34_bit4, symbol34_bit5, symbol34_bit6, symbol34_bit7, bit7, bit6, - bit5, bit4, bit3, bit2, bit1, bit0, result, symbol_bit01, symbol_bit23, - symbol_bit45, symbol_bit67; + __m256 symbol1; + __m256 symbol2; + __m256 symbol3; + __m256 symbol4; + __m256i intsymbol1; + __m256i intsymbol2; + __m256i intsymbol3; + __m256i intsymbol4; + __m256i symbol12; + __m256i symbol34; + __m256i symbol_abs; + __m256i symbol_gt_0; + __m256i symbol_gt_threshold1; + __m256i symbol_gt_threshold2; + __m256i symbol_lt_threshold3; + __m256i symbol_lt_threshold4; + __m256i symbol_gt_threshold5; + __m256i symbol_lt_threshold6; + __m256i symbol_lt_threshold7; + __m256i symbol12_bit0; + __m256i symbol12_bit1; + __m256i symbol12_bit2; + __m256i symbol12_bit3; + __m256i symbol12_bit4; + __m256i symbol12_bit5; + __m256i symbol12_bit6; + __m256i symbol12_bit7; + __m256i symbol34_bit0; + __m256i symbol34_bit1; + __m256i symbol34_bit2; + __m256i symbol34_bit3; + __m256i symbol34_bit4; + __m256i symbol34_bit5; + __m256i symbol34_bit6; + __m256i symbol34_bit7; + __m256i bit7; + __m256i bit6; + __m256i bit5; + __m256i bit4; + __m256i bit3; + __m256i bit2; + __m256i bit1; + __m256i bit0; + __m256i result; + __m256i symbol_bit01; + __m256i symbol_bit23; + __m256i symbol_bit45; + __m256i symbol_bit67; int next_start; /* @@ -2027,7 +2104,8 @@ void Demod256qamSoftLoop(const float* vec_in, int8_t* llr, int num) { * Equations 7, 8, and 9 */ int i; - int8_t re, im; + int8_t re; + int8_t im; const uint8_t t1 = QAM256_THRESHOLD_4 * SCALE_BYTE_CONV_QAM256; const uint8_t t2 = QAM256_THRESHOLD_2 * SCALE_BYTE_CONV_QAM256; const uint8_t t3 = QAM256_THRESHOLD_1 * SCALE_BYTE_CONV_QAM256; diff --git a/src/common/symbols.h b/src/common/symbols.h index c66bc2bdf..69cac4b9b 100644 --- a/src/common/symbols.h +++ b/src/common/symbols.h @@ -36,7 +36,7 @@ static constexpr inline bool IsPowerOfTwo(T x) { return x && ((x & T(x - 1)) == 0); } -enum class Direction : int { Downlink, Uplink }; +enum class Direction : int { kDownlink, kUplink }; // TODO: Merge EventType and DoerType into WorkType enum class EventType : int { diff --git a/src/common/udp_server.h b/src/common/udp_server.h index 76b3cbb20..8768c8ed8 100644 --- a/src/common/udp_server.h +++ b/src/common/udp_server.h @@ -201,7 +201,7 @@ class UDPServer { * @brief Configures the socket in blocking mode. Any calls to recv / send * will now block */ - void MakeBlocking(size_t timeout_sec = 0) { + void MakeBlocking(size_t timeout_sec = 0) const { int current_flags = fcntl(sock_fd_, F_GETFL); if (current_flags == -1) { throw std::runtime_error("UDPServer: fcntl failed to get flags"); diff --git a/src/common/utils.cc b/src/common/utils.cc index 4e74e5cec..8a722690e 100644 --- a/src/common/utils.cc +++ b/src/common/utils.cc @@ -58,7 +58,7 @@ static void PrintCoreList(const std::list& clist) { std::printf(" CORE LIST SUMMARY \n"); std::printf("=================================\n"); std::printf("Total Number of Cores: %d : %d \n", numa_max_cpus, system_cpus); - for (auto& iter : clist) { + for (const auto& iter : clist) { std::printf( "|| Core ID: %2zu || Requested: %2zu || ThreadType: %-16s || " "ThreadId: %zu \n", @@ -397,10 +397,11 @@ void Utils::SaveMat(arma::cx_fmat c, const std::string& filename, const std::string& ss, const bool append) { std::stringstream so; std::ofstream of; - if (append == true) + if (append == true) { of.open(filename, std::ios_base::app); - else + } else { of.open(filename); + } so << ss << " = ["; for (size_t i = 0; i < c.n_cols; i++) { so << "["; @@ -436,10 +437,11 @@ void Utils::SaveVec(arma::cx_fvec c, const std::string& filename, const std::string& ss, const bool append) { std::stringstream so; std::ofstream of; - if (append == true) + if (append == true) { of.open(filename, std::ios_base::app); - else + } else { of.open(filename); + } so << ss << " = ["; for (size_t j = 0; j < c.size(); j++) { so << std::fixed << std::setw(5) << std::setprecision(3) << c.at(j).real() diff --git a/src/data_generator/data_generator.cc b/src/data_generator/data_generator.cc index 4b3e8478d..92468925a 100644 --- a/src/data_generator/data_generator.cc +++ b/src/data_generator/data_generator.cc @@ -40,7 +40,7 @@ static float RandFloatFromShort(float min, float max) { void DataGenerator::DoDataGeneration(const std::string& directory) { srand(time(nullptr)); auto scrambler = std::make_unique(); - std::unique_ptr crc_obj_ = std::make_unique(); + std::unique_ptr crc_obj = std::make_unique(); size_t input_size = cfg_->NumBytesPerCb(); // size_t input_size = // LdpcEncodingInputBufSize(this->cfg_->LdpcConfig().BaseGraph(), @@ -66,7 +66,7 @@ void DataGenerator::DoDataGeneration(const std::string& directory) { pkt->Set(0, pkt_id, ue_id, cfg_->MacPayloadMaxLength()); this->GenMacData(pkt, ue_id); pkt->Crc((uint16_t)( - crc_obj_->CalculateCrc24(pkt->Data(), cfg_->MacPayloadMaxLength()) & + crc_obj->CalculateCrc24(pkt->Data(), cfg_->MacPayloadMaxLength()) & 0xFFFF)); } } @@ -339,7 +339,7 @@ void DataGenerator::DoDataGeneration(const std::string& directory) { pkt->Set(0, pkt_id, ue_id, cfg_->MacPayloadMaxLength()); this->GenMacData(pkt, ue_id); pkt->Crc((uint16_t)( - crc_obj_->CalculateCrc24(pkt->Data(), cfg_->MacPayloadMaxLength()) & + crc_obj->CalculateCrc24(pkt->Data(), cfg_->MacPayloadMaxLength()) & 0xFFFF)); } } diff --git a/src/mac/mac_basestation.cc b/src/mac/mac_basestation.cc index de8dcbe7b..8dd89e634 100644 --- a/src/mac/mac_basestation.cc +++ b/src/mac/mac_basestation.cc @@ -44,8 +44,8 @@ int main(int argc, char* argv[]) { std::string filename = FLAGS_conf_file; std::string data_filename = FLAGS_data_file; - auto frame_start = new double[kNumStatsFrames]; - auto frame_end = new double[kNumStatsFrames]; + auto* frame_start = new double[kNumStatsFrames]; + auto* frame_end = new double[kNumStatsFrames]; int ret = EXIT_FAILURE; { @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { cfg->GenData(); // Generate pattern file for testing - if (data_filename == "") { + if (data_filename.empty()) { std::ofstream create_file; data_filename = TOSTRING(PROJECT_DIRECTORY) + std::string("/data/dl_increment_file.bin"); @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) { std::unique_ptr receiver; std::vector rx_threads; //+1 for main thread a - const size_t kNumTotalSenderThreads = + const size_t k_num_total_sender_threads = FLAGS_num_sender_worker_threads + FLAGS_num_sender_update_threads; size_t thread_start = FLAGS_core_offset; @@ -99,11 +99,11 @@ int main(int argc, char* argv[]) { thread_start, FLAGS_num_sender_worker_threads, FLAGS_num_sender_update_threads, FLAGS_frame_duration, 0, FLAGS_enable_slow_start, true); - thread_start += kNumTotalSenderThreads; + thread_start += k_num_total_sender_threads; sender->StartTXfromMain(frame_start, frame_end); } if (cfg->Frame().NumUlDataSyms() > 0) { - if ((FLAGS_fwd_udp_port != 0) && (FLAGS_fwd_udp_address != "")) { + if ((FLAGS_fwd_udp_port != 0) && (!FLAGS_fwd_udp_address.empty())) { receiver = std::make_unique( cfg.get(), cfg->UlMacDataBytesNumPerframe(), cfg->BsServerAddr(), cfg->BsMacTxPort(), FLAGS_fwd_udp_address, FLAGS_fwd_udp_port, diff --git a/src/mac/mac_client.cc b/src/mac/mac_client.cc index 412128901..6ccee3e93 100644 --- a/src/mac/mac_client.cc +++ b/src/mac/mac_client.cc @@ -43,8 +43,8 @@ int main(int argc, char* argv[]) { std::string filename = FLAGS_conf_file; std::string data_filename = FLAGS_data_file; - auto frame_start = new double[kNumStatsFrames]; - auto frame_end = new double[kNumStatsFrames]; + auto* frame_start = new double[kNumStatsFrames]; + auto* frame_end = new double[kNumStatsFrames]; int ret = EXIT_FAILURE; { @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) { cfg->GenData(); // Generate pattern file for testing - if (data_filename == "") { + if (data_filename.empty()) { std::ofstream create_file; data_filename = TOSTRING(PROJECT_DIRECTORY) + std::string("/data/ul_increment_file.bin"); @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) { std::unique_ptr receiver; std::vector rx_threads; //+1 for main thread - const size_t kNumTotalSenderThreads = + const size_t k_num_total_sender_threads = FLAGS_num_sender_worker_threads + FLAGS_num_sender_update_threads; size_t thread_start = FLAGS_core_offset; @@ -99,12 +99,12 @@ int main(int argc, char* argv[]) { thread_start, FLAGS_num_sender_worker_threads, FLAGS_num_sender_update_threads, FLAGS_frame_duration, 0, FLAGS_enable_slow_start, true); - thread_start += kNumTotalSenderThreads; + thread_start += k_num_total_sender_threads; sender->StartTXfromMain(frame_start, frame_end); } if (cfg->Frame().NumDlDataSyms() > 0) { - if ((FLAGS_fwd_udp_port != 0) && (FLAGS_fwd_udp_address != "")) { + if ((FLAGS_fwd_udp_port != 0) && (!FLAGS_fwd_udp_address.empty())) { receiver = std::make_unique( cfg.get(), cfg->DlMacDataBytesNumPerframe(), cfg->UeServerAddr(), cfg->UeMacTxPort(), FLAGS_fwd_udp_address, FLAGS_fwd_udp_port, diff --git a/src/mac/mac_receiver.cc b/src/mac/mac_receiver.cc index a8b1940d1..a729474ce 100644 --- a/src/mac/mac_receiver.cc +++ b/src/mac/mac_receiver.cc @@ -56,9 +56,9 @@ void* MacReceiver::LoopRecv(size_t tid) { size_t core_offset = core_id_ + rx_thread_num_; PinToCoreWithOffset(ThreadType::kWorkerRX, core_offset, tid); - static constexpr size_t sock_buf_size = (1024 * 1024 * 64 * 8) - 1; + static constexpr size_t kSockBufSize = (1024 * 1024 * 64 * 8) - 1; auto udp_server = - std::make_unique(phy_port_ + ue_id, sock_buf_size); + std::make_unique(phy_port_ + ue_id, kSockBufSize); std::unique_ptr udp_streamer; if (enable_udp_output_) { diff --git a/src/mac/mac_receiver.h b/src/mac/mac_receiver.h index 2cdcffaff..2ebf5d612 100644 --- a/src/mac/mac_receiver.h +++ b/src/mac/mac_receiver.h @@ -30,7 +30,7 @@ class MacReceiver { const std::string phy_address_; const size_t phy_port_; - const size_t enable_udp_output_; + const bool enable_udp_output_; const size_t udp_dest_port_; const std::string udp_dest_address_; diff --git a/src/mac/mac_sender.cc b/src/mac/mac_sender.cc index 6574c6ac8..285344d93 100644 --- a/src/mac/mac_sender.cc +++ b/src/mac/mac_sender.cc @@ -326,7 +326,7 @@ void* MacSender::WorkerThread(size_t tid) { for (size_t packet = 0; packet < packets_per_frame_; packet++) { ///\todo Use assume_aligned when code has /// c++20 support - auto* tx_packet = + const auto* tx_packet = reinterpret_cast(mac_packet_location); const size_t mac_packet_tx_size = diff --git a/src/mac/mac_sender.h b/src/mac/mac_sender.h index 7cf8adf94..d522968a6 100644 --- a/src/mac/mac_sender.h +++ b/src/mac/mac_sender.h @@ -69,7 +69,7 @@ class MacSender { // Launch threads to run worker with thread IDs from tid_start to tid_end void CreateWorkerThreads(size_t num_workers); - void UpdateTxBuffer(MacDataReceiver* video, gen_tag_t tag); + void UpdateTxBuffer(MacDataReceiver* data_source, gen_tag_t tag); void WriteStatsToFile(size_t tx_frame_count) const; void ScheduleFrame(size_t frame); diff --git a/src/mac/mac_thread_basestation.cc b/src/mac/mac_thread_basestation.cc index 178daff6f..522ff9045 100644 --- a/src/mac/mac_thread_basestation.cc +++ b/src/mac/mac_thread_basestation.cc @@ -139,7 +139,7 @@ void MacThreadBaseStation::ProcessCodeblocksFromPhy(EventData event) { // Only non-pilot data symbols have application data. if (symbol_array_index >= num_pilot_symbols) { // The decoded symbol knows nothing about the padding / storage of the data - auto* pkt = reinterpret_cast(src_data); + const auto* pkt = reinterpret_cast(src_data); // Destination only contains "payload" const size_t dest_packet_size = cfg_->MacPayloadMaxLength(); @@ -265,7 +265,9 @@ void MacThreadBaseStation::ProcessUdpPacketsFromApps() { const size_t max_data_bytes_per_frame = cfg_->DlMacDataBytesNumPerframe(); const size_t num_mac_packets_per_frame = cfg_->DlMacPacketsPerframe(); - if (0 == max_data_bytes_per_frame) return; + if (0 == max_data_bytes_per_frame) { + return; + } // Processes the packets of an entire frame (remove variable later) const size_t packets_required = num_mac_packets_per_frame; @@ -310,8 +312,9 @@ void MacThreadBaseStation::ProcessUdpPacketsFromApps() { while ((packets_received < packets_required) && (current_packet_bytes >= header_size)) { // See if we have enough data and process the MacPacket header - auto* rx_mac_packet_header = reinterpret_cast( - &udp_pkt_buf_.at(current_packet_start_index)); + const auto* rx_mac_packet_header = + reinterpret_cast( + &udp_pkt_buf_.at(current_packet_start_index)); const size_t current_packet_size = header_size + rx_mac_packet_header->PayloadLength(); @@ -369,7 +372,8 @@ void MacThreadBaseStation::ProcessUdpPacketsFromAppsBs(const char* payload) { size_t symbol_id = 0; size_t frame_id = 0; for (size_t packet = 0u; packet < num_mac_packets_per_frame; packet++) { - auto* pkt = reinterpret_cast(&payload[pkt_offset]); + const auto* pkt = + reinterpret_cast(&payload[pkt_offset]); // std::printf("Frame %d, Packet %zu, symbol %d, user %d\n", pkt->Frame(), // packet, pkt->Symbol(), pkt->Ue()); @@ -439,7 +443,7 @@ void MacThreadBaseStation::ProcessUdpPacketsFromAppsBs(const char* payload) { size_t src_pkt_offset = 0; // Copy from the packet rx buffer into ul_bits memory (unpacked) for (size_t pkt_id = 0; pkt_id < num_mac_packets_per_frame; pkt_id++) { - auto* src_packet = + const auto* src_packet = reinterpret_cast(&payload[src_pkt_offset]); const size_t symbol_idx = cfg_->Frame().GetDLSymbolIdx(src_packet->Symbol()); diff --git a/src/mac/mac_thread_client.cc b/src/mac/mac_thread_client.cc index e2c53578e..912a0bf3d 100644 --- a/src/mac/mac_thread_client.cc +++ b/src/mac/mac_thread_client.cc @@ -150,7 +150,7 @@ void MacThreadClient::ProcessCodeblocksFromPhy(EventData event) { // Only non-pilot data symbols have application data. if (symbol_array_index >= num_pilot_symbols) { // The decoded symbol knows nothing about the padding / storage of the data - auto* pkt = reinterpret_cast(src_data); + const auto* pkt = reinterpret_cast(src_data); // Destination only contains "payload" const size_t dest_packet_size = cfg_->MacPayloadMaxLength(); @@ -282,7 +282,9 @@ void MacThreadClient::ProcessUdpPacketsFromApps(RBIndicator ri) { const size_t max_data_bytes_per_frame = cfg_->UlMacDataBytesNumPerframe(); const size_t num_mac_packets_per_frame = cfg_->UlMacPacketsPerframe(); - if (0 == max_data_bytes_per_frame) return; + if (0 == max_data_bytes_per_frame) { + return; + } // Processes the packets of an entire frame (remove variable later) const size_t packets_required = num_mac_packets_per_frame; @@ -327,8 +329,9 @@ void MacThreadClient::ProcessUdpPacketsFromApps(RBIndicator ri) { while ((packets_received < packets_required) && (current_packet_bytes >= header_size)) { // See if we have enough data and process the MacPacket header - auto* rx_mac_packet_header = reinterpret_cast( - &udp_pkt_buf_.at(current_packet_start_index)); + const auto* rx_mac_packet_header = + reinterpret_cast( + &udp_pkt_buf_.at(current_packet_start_index)); const size_t current_packet_size = header_size + rx_mac_packet_header->PayloadLength(); @@ -376,7 +379,7 @@ void MacThreadClient::ProcessUdpPacketsFromApps(RBIndicator ri) { } void MacThreadClient::ProcessUdpPacketsFromAppsClient(const char* payload, - RBIndicator ri) { + RBIndicator /*ri*/) { const size_t num_mac_packets_per_frame = cfg_->UlMacPacketsPerframe(); const size_t num_pilot_symbols = cfg_->Frame().ClientUlPilotSymbols(); // Data integrity check @@ -385,7 +388,8 @@ void MacThreadClient::ProcessUdpPacketsFromAppsClient(const char* payload, size_t symbol_id = 0; size_t frame_id = 0; for (size_t packet = 0u; packet < num_mac_packets_per_frame; packet++) { - auto* pkt = reinterpret_cast(&payload[pkt_offset]); + const auto* pkt = + reinterpret_cast(&payload[pkt_offset]); // std::printf("Frame %d, Packet %zu, symbol %d, user %d\n", pkt->Frame(), // packet, pkt->Symbol(), pkt->Ue()); @@ -448,7 +452,7 @@ void MacThreadClient::ProcessUdpPacketsFromAppsClient(const char* payload, size_t src_pkt_offset = 0; // Copy from the packet rx buffer into ul_bits memory for (size_t pkt_id = 0; pkt_id < num_mac_packets_per_frame; pkt_id++) { - auto* src_packet = + const auto* src_packet = reinterpret_cast(&payload[src_pkt_offset]); const size_t symbol_idx = cfg_->Frame().GetULSymbolIdx(src_packet->Symbol()); diff --git a/test/unit_tests/test_256qam_demod.cc b/test/unit_tests/test_256qam_demod.cc index ec96020ef..20ef69748 100644 --- a/test/unit_tests/test_256qam_demod.cc +++ b/test/unit_tests/test_256qam_demod.cc @@ -17,9 +17,11 @@ * @param len: length of input and output signal (number of symbols) * @param snr: desired SNR in dB */ -static void apply_awgn(complex_float *signal, complex_float *output, int len, - float snr) { - float gamma, power, N0; +static void ApplyAwgn(complex_float *signal, complex_float *output, int len, + float snr) { + float gamma; + float power; + float n0; int i; std::default_random_engine generator; // Normal distribution @@ -32,10 +34,10 @@ static void apply_awgn(complex_float *signal, complex_float *output, int len, power += (signal[i].re * signal[i].re) + (signal[i].im * signal[i].im); } power = power / ((float)len); - N0 = power / gamma; // Noise spectral density + n0 = power / gamma; // Noise spectral density for (i = 0; i < len; i++) { - output[i].re = signal[i].re + sqrtf(N0 / 2) * distribution(generator); - output[i].im = signal[i].im + sqrtf(N0 / 2) * distribution(generator); + output[i].re = signal[i].re + sqrtf(n0 / 2) * distribution(generator); + output[i].im = signal[i].im + sqrtf(n0 / 2) * distribution(generator); } } @@ -46,20 +48,24 @@ static void apply_awgn(complex_float *signal, complex_float *output, int len, * @param demod_func: Function to use for demodulation * @param func_desc: string describing function */ -static void run_256QAM_soft_demod(void (*demod_func)(const float *, int8_t *, - int), - const char *func_desc) { - uint8_t *input_symbols, *output_symbols; +static void Run256QamSoftDemod(void (*demod_func)(const float *, int8_t *, int), + const char *func_desc) { + uint8_t *input_symbols; + uint8_t *output_symbols; complex_float *channel_input; Table mod_table; complex_float *channel_output; int8_t *output_demod; int shift_offset = 7; - unsigned int i, j, snr_idx; + unsigned int i; + unsigned int j; + unsigned int snr_idx; unsigned int num = NUM_SYMBOLS; - double runtime, start_time; - float SNR_vals[] = {10.0, 25.0, 50.0, 100.0}; - float SNR, err_rate; + double runtime; + double start_time; + float snr_vals[] = {10.0, 25.0, 50.0, 100.0}; + float snr; + float err_rate; // Allocate storage buffers AllocBuffer1d(&input_symbols, num, Agora_memory::Alignment_t::kAlign64, 1); @@ -76,8 +82,8 @@ static void run_256QAM_soft_demod(void (*demod_func)(const float *, int8_t *, * 25 db * 50 db */ - for (snr_idx = 0; snr_idx < sizeof(SNR_vals) / sizeof(float); snr_idx++) { - SNR = SNR_vals[snr_idx]; + for (snr_idx = 0; snr_idx < sizeof(snr_vals) / sizeof(float); snr_idx++) { + snr = snr_vals[snr_idx]; err_rate = 0.0; for (i = 0; i < NUM_ITERATIONS; i++) { for (j = 0; j < num; j++) { @@ -88,7 +94,7 @@ static void run_256QAM_soft_demod(void (*demod_func)(const float *, int8_t *, channel_input[j] = ModSingle(input_symbols[j], mod_table); } // Add noise to symbols - apply_awgn(channel_input, channel_output, num, SNR); + ApplyAwgn(channel_input, channel_output, num, snr); // Demodulate Symbols start_time = GetTime::GetTimeUs(); demod_func((float *)channel_output, output_demod, num); @@ -124,7 +130,7 @@ static void run_256QAM_soft_demod(void (*demod_func)(const float *, int8_t *, num, runtime / NUM_ITERATIONS, NUM_ITERATIONS); err_rate = (err_rate * 100) / (NUM_SYMBOLS * NUM_ITERATIONS); std::printf("Soft Demod Error Rate for 256 QAM was %.2f%% at %f db SNR\n", - err_rate, SNR); + err_rate, snr); } /* * For the last SNR, assert that the error rate is zero. Although a @@ -140,15 +146,15 @@ static void run_256QAM_soft_demod(void (*demod_func)(const float *, int8_t *, } TEST(TestDemod256QAM, SoftLoop) { - run_256QAM_soft_demod(Demod256qamSoftLoop, "Demod256qamSoftLoop"); + Run256QamSoftDemod(Demod256qamSoftLoop, "Demod256qamSoftLoop"); } TEST(TestDemod256QAM, SoftSSE) { - run_256QAM_soft_demod(Demod256qamSoftSse, "Demod256qamSoftSse"); + Run256QamSoftDemod(Demod256qamSoftSse, "Demod256qamSoftSse"); } TEST(TestDemod256QAM, SoftAVX2) { - run_256QAM_soft_demod(Demod256qamSoftAvx2, "Demod256qamSoftAvx2"); + Run256QamSoftDemod(Demod256qamSoftAvx2, "Demod256qamSoftAvx2"); } #ifdef __AVX512F__ diff --git a/test/unit_tests/test_demul_threaded.cc b/test/unit_tests/test_demul_threaded.cc index 5fe2d3b3d..190440234 100644 --- a/test/unit_tests/test_demul_threaded.cc +++ b/test/unit_tests/test_demul_threaded.cc @@ -153,7 +153,7 @@ TEST(TestDemul, VaryingConfig) { kMaxUEs * 1.0f / 1024 / 1024); auto stats = std::make_unique(cfg.get()); - auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); + auto phy_stats = std::make_unique(cfg.get(), Direction::kUplink); std::vector threads; threads.emplace_back(MasterToWorkerDynamicMaster, cfg.get(), diff --git a/test/unit_tests/test_zf.cc b/test/unit_tests/test_zf.cc index 342aad025..15f9203e6 100644 --- a/test/unit_tests/test_zf.cc +++ b/test/unit_tests/test_zf.cc @@ -42,7 +42,7 @@ TEST(TestZF, Perf) { cfg->OfdmDataNum() * cfg->BsAntNum(), Agora_memory::Alignment_t::kAlign64); - auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); + auto phy_stats = std::make_unique(cfg.get(), Direction::kUplink); auto stats = std::make_unique(cfg.get()); auto compute_zf = std::make_unique( diff --git a/test/unit_tests/test_zf_threaded.cc b/test/unit_tests/test_zf_threaded.cc index 6b5ec7bc5..3031537cf 100644 --- a/test/unit_tests/test_zf_threaded.cc +++ b/test/unit_tests/test_zf_threaded.cc @@ -136,7 +136,7 @@ TEST(TestZF, VaryingConfig) { calib_ul_buffer.RandAllocCxFloat(kFrameWnd, kMaxDataSCs * kMaxAntennas, Agora_memory::Alignment_t::kAlign64); - auto phy_stats = std::make_unique(cfg.get(), Direction::Uplink); + auto phy_stats = std::make_unique(cfg.get(), Direction::kUplink); auto stats = std::make_unique(cfg.get()); std::vector threads; From 64ff06017f3c47ef0ec43767335c2a0c6404bf6b Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 11:17:37 -0600 Subject: [PATCH 50/55] Modernize --- src/agora/radio_calibrate.cc | 12 ++++++------ src/common/buffer.h | 2 +- src/mac/file_receiver.h | 4 ++-- src/mac/mac_data_receiver.h | 2 +- src/mac/mac_receiver.cc | 6 ++++-- src/mac/mac_sender.cc | 5 +++-- src/mac/video_receiver.h | 4 ++-- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/agora/radio_calibrate.cc b/src/agora/radio_calibrate.cc index 869a49ee9..e5428698a 100644 --- a/src/agora/radio_calibrate.cc +++ b/src/agora/radio_calibrate.cc @@ -812,15 +812,15 @@ bool RadioConfig::InitialCalib(bool sample_adjust) { << "/" << peak_dn << std::endl; if (kVerboseCalibration) { std::cout << "dn(" << i << ")="; - for (size_t s = 0; s < dn.at(i).size(); s++) { - std::cout << dn.at(i).at(s).real() << "+1j*" - << dn.at(i).at(s).imag() << " "; + for (auto & s : dn.at(i)) { + std::cout << s.real() << "+1j*" + << s.imag() << " "; } std::cout << std::endl; std::cout << "up(" << i << ")="; - for (size_t s = 0; s < up.at(i).size(); s++) { - std::cout << up.at(i).at(s).real() << "+1j*" - << up.at(i).at(s).imag() << " "; + for (auto & s : up.at(i)) { + std::cout << s.real() << "+1j*" + << s.imag() << " "; } std::cout << std::endl; } diff --git a/src/common/buffer.h b/src/common/buffer.h index d3daeeeb0..01b22f1e4 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -189,7 +189,7 @@ class RxPacket { std::atomic references_; Packet *packet_; - inline virtual void GcPacket(void) {} + inline virtual void GcPacket() {} public: RxPacket() : references_(0) { packet_ = nullptr; } diff --git a/src/mac/file_receiver.h b/src/mac/file_receiver.h index 45668723c..1d3f5233b 100644 --- a/src/mac/file_receiver.h +++ b/src/mac/file_receiver.h @@ -22,10 +22,10 @@ class FileReceiver : public MacDataReceiver { static constexpr size_t kFileStreamLocalRxBufSize = (kFileStreamRxSize * 10u); explicit FileReceiver(std::string &file_name); - virtual ~FileReceiver(); + ~FileReceiver() override; size_t Load(unsigned char *destination, - size_t requested_bytes) override final; + size_t requested_bytes) final; private: std::string file_name_; diff --git a/src/mac/mac_data_receiver.h b/src/mac/mac_data_receiver.h index 02d74f8f5..7cb3f1c72 100644 --- a/src/mac/mac_data_receiver.h +++ b/src/mac/mac_data_receiver.h @@ -15,7 +15,7 @@ class MacDataReceiver { virtual size_t Load(unsigned char *destination, size_t requested_bytes) = 0; protected: - inline MacDataReceiver(){}; + inline MacDataReceiver() = default;; virtual ~MacDataReceiver() = default; }; diff --git a/src/mac/mac_receiver.cc b/src/mac/mac_receiver.cc index a729474ce..694b45493 100644 --- a/src/mac/mac_receiver.cc +++ b/src/mac/mac_receiver.cc @@ -4,6 +4,8 @@ */ #include "mac_receiver.h" +#include + #include "logger.h" #include "signal_handler.h" #include "udp_client.h" @@ -15,7 +17,7 @@ MacReceiver::MacReceiver(Config* const cfg, size_t num_frame_data_bytes, std::string phy_server_address, size_t phy_port, size_t rx_thread_num, size_t core_offset) : data_bytes_(num_frame_data_bytes), - phy_address_(phy_server_address), + phy_address_(std::move(phy_server_address)), phy_port_(phy_port), enable_udp_output_(false), udp_dest_port_(0), @@ -29,7 +31,7 @@ MacReceiver::MacReceiver(Config* const cfg, size_t num_frame_data_bytes, std::string fwd_data_udp_address, size_t fwd_port, size_t rx_thread_num, size_t core_offset) : data_bytes_(num_frame_data_bytes), - phy_address_(phy_server_address), + phy_address_(std::move(phy_server_address)), phy_port_(phy_port), enable_udp_output_(true), udp_dest_port_(fwd_port), diff --git a/src/mac/mac_sender.cc b/src/mac/mac_sender.cc index 285344d93..7bb421c3a 100644 --- a/src/mac/mac_sender.cc +++ b/src/mac/mac_sender.cc @@ -5,6 +5,7 @@ #include "mac_sender.h" #include +#include #include "datatype_conversion.h" #include "file_receiver.h" @@ -63,9 +64,9 @@ MacSender::MacSender(Config* cfg, std::string& data_filename, data_filename_(data_filename), // end -- Ul / Dl UE / BS packets_per_frame_(packets_per_frame), - server_address_(server_address), + server_address_(std::move(server_address)), server_rx_port_(server_rx_port), - get_data_symbol_id_(get_data_symbol_id) + get_data_symbol_id_(std::move(get_data_symbol_id)) // end -- Ul / Dl UE / BS { if (frame_duration_us == 0) { diff --git a/src/mac/video_receiver.h b/src/mac/video_receiver.h index e4135aba2..a818c5ca6 100644 --- a/src/mac/video_receiver.h +++ b/src/mac/video_receiver.h @@ -28,10 +28,10 @@ class VideoReceiver : public MacDataReceiver { kVideoStreamMaxRxSize * 10; explicit VideoReceiver(size_t port); - virtual ~VideoReceiver() = default; + ~VideoReceiver() override = default; size_t Load(unsigned char *destination, - size_t requested_bytes) override final; + size_t requested_bytes) final; private: UDPServer udp_video_receiver_; From da8174b721591c0674d69e1583e6b38273bddccf Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 11:32:06 -0600 Subject: [PATCH 51/55] Missed a rename --- test/unit_tests/test_256qam_demod.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_tests/test_256qam_demod.cc b/test/unit_tests/test_256qam_demod.cc index 20ef69748..d5b57db20 100644 --- a/test/unit_tests/test_256qam_demod.cc +++ b/test/unit_tests/test_256qam_demod.cc @@ -159,7 +159,7 @@ TEST(TestDemod256QAM, SoftAVX2) { #ifdef __AVX512F__ TEST(TestDemod256QAM, SoftAVX512) { - run_256QAM_soft_demod(Demod256qamSoftAvx512, "Demod256qamSoftAvx512"); + Run256QAMSoftDemod(Demod256qamSoftAvx512, "Demod256qamSoftAvx512"); } #endif From 55bb9471f45f21fd6793cbedfde7e88cba675e48 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 11:33:22 -0600 Subject: [PATCH 52/55] Cannot spell --- test/unit_tests/test_256qam_demod.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_tests/test_256qam_demod.cc b/test/unit_tests/test_256qam_demod.cc index d5b57db20..868719818 100644 --- a/test/unit_tests/test_256qam_demod.cc +++ b/test/unit_tests/test_256qam_demod.cc @@ -159,7 +159,7 @@ TEST(TestDemod256QAM, SoftAVX2) { #ifdef __AVX512F__ TEST(TestDemod256QAM, SoftAVX512) { - Run256QAMSoftDemod(Demod256qamSoftAvx512, "Demod256qamSoftAvx512"); + Run256QamSoftDemod(Demod256qamSoftAvx512, "Demod256qamSoftAvx512"); } #endif From 9922a878b37fd9c6151c9f2710b08c38958326ca Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 13:38:18 -0600 Subject: [PATCH 53/55] Cleanup for the debug build --- src/agora/agora.cc | 9 ++++++--- src/agora/dodemul.cc | 16 +++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/agora/agora.cc b/src/agora/agora.cc index 453df696f..075a07f11 100644 --- a/src/agora/agora.cc +++ b/src/agora/agora.cc @@ -98,9 +98,10 @@ void Agora::Stop() { packet_tx_rx_.reset(); } -void Agora::SendSnrReport(EventType /*event_type*/, size_t frame_id, +void Agora::SendSnrReport(EventType event_type, size_t frame_id, size_t symbol_id) { assert(event_type == EventType::kSNRReport); + unused(event_type); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); for (size_t i = 0; i < config_->UeAntNum(); i++) { EventData snr_report(EventType::kSNRReport, base_tag.tag_); @@ -272,9 +273,10 @@ void Agora::ScheduleCodeblocks(EventType event_type, size_t frame_id, } } -void Agora::ScheduleUsers(EventType /*event_type*/, size_t frame_id, +void Agora::ScheduleUsers(EventType event_type, size_t frame_id, size_t symbol_id) { assert(event_type == EventType::kPacketToMac); + unused(event_type); auto base_tag = gen_tag_t::FrmSymUe(frame_id, symbol_id, 0); for (size_t i = 0; i < config_->UeAntNum(); i++) { @@ -1532,10 +1534,11 @@ void Agora::GetEqualData(float** ptr, int* size) { *ptr = (float*)&equal_buffer_[offset][0]; *size = cfg->UeAntNum() * cfg->OfdmDataNum() * 2; } -void Agora::CheckIncrementScheduleFrame(size_t /*frame_id*/, +void Agora::CheckIncrementScheduleFrame(size_t frame_id, ScheduleProcessingFlags completed) { this->schedule_process_flags_ += completed; assert(this->cur_sche_frame_id_ == frame_id); + unused(frame_id); if (this->schedule_process_flags_ == static_cast(ScheduleProcessingFlags::kProcessingComplete)) { diff --git a/src/agora/dodemul.cc b/src/agora/dodemul.cc index 79fa15e44..82f2421ef 100644 --- a/src/agora/dodemul.cc +++ b/src/agora/dodemul.cc @@ -146,12 +146,10 @@ EventData DoDemul::Launch(size_t tag) { ? _mm512_load_ps(&src[j * cfg_->BsAntNum() * 2]) : _mm512_i32gather_ps(index, &src[j * 2], 4); - //if ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % 64) > 0) - //{ - // std::printf("Ant: %zu:%zu subcarrier: %zu:%zu base address %zu\n", ant_i, cfg_->BsAntNum(), base_sc_id, j, reinterpret_cast(dst)); - //} assert((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % - 64) == 0); + (kAntNumPerSimd * sizeof(float) * 2)) == 0); + assert((reinterpret_cast(&src[j * cfg_->BsAntNum() * 2]) % + (kAntNumPerSimd * sizeof(float) * 2)) == 0); _mm512_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } src += kAntNumPerSimd * kTransposeBlockSize * 2; @@ -165,10 +163,10 @@ EventData DoDemul::Launch(size_t tag) { for (size_t ant_i = 0; ant_i < cfg_->BsAntNum(); ant_i += kAntNumPerSimd) { for (size_t j = 0; j < kSCsPerCacheline; j++) { - //std::printf("Ant: %zu Local sc: %zu\n", ant_i, j); - assert((reinterpret_cast((&src[j * 2]) % 32) == 0) && - ((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % - 32) == 0)); + assert((reinterpret_cast(&src[j * 2]) % + (kAntNumPerSimd * sizeof(float) * 2)) == 0); + assert((reinterpret_cast(&dst[j * cfg_->BsAntNum() * 2]) % + (kAntNumPerSimd * sizeof(float) * 2)) == 0); __m256 data_rx = _mm256_i32gather_ps(&src[j * 2], index, 4); _mm256_store_ps(&dst[j * cfg_->BsAntNum() * 2], data_rx); } From 279884cc5ea3a476be3807b834249ea78ee02cbd Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 13:43:14 -0600 Subject: [PATCH 54/55] Disabled untested configurations --- src/common/config.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/config.cc b/src/common/config.cc index b9685b5f5..cf775cb73 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -252,8 +252,15 @@ Config::Config(const std::string& jsonfile) hw_framer_ = tdd_conf.value("hw_framer", true); if (kUseUHD) { hw_framer_ = false; + } else { + RtAssert(ue_hw_framer_ == true, + "Base Station hardware framer (hw_framer) set to false is " + "unsupported in this version of Agora"); } ue_hw_framer_ = tdd_conf.value("ue_hw_framer", false); + RtAssert(ue_hw_framer_ == false, + "User equiptment hardware framer (ue_hw_framer) set to true is " + "unsupported in this version of Agora"); // If frames not specified explicitly, construct default based on frame_type / // symbol_num_perframe / pilot_num / ul_symbol_num_perframe / From 342f36df230b7504a10e9f0ec709ec68b5519bf5 Mon Sep 17 00:00:00 2001 From: Andrew Sedlmayr Date: Mon, 3 Jan 2022 13:48:46 -0600 Subject: [PATCH 55/55] Typo --- src/common/config.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config.cc b/src/common/config.cc index cf775cb73..1f4b4fd07 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -253,7 +253,7 @@ Config::Config(const std::string& jsonfile) if (kUseUHD) { hw_framer_ = false; } else { - RtAssert(ue_hw_framer_ == true, + RtAssert(hw_framer_ == true, "Base Station hardware framer (hw_framer) set to false is " "unsupported in this version of Agora"); }