From 8df6ed07c665254104e2a63577a044caea9a0572 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 20 May 2021 18:24:16 +0100 Subject: [PATCH] sched small fixes - use 0.930 instead of 0.932 for max coderate. Allow computing mcs/tbs based on max coderate directly. Other small fixes --- lib/include/srsran/adt/accumulators.h | 13 ++++++---- srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h | 13 ++++++++++ .../src/stack/mac/sched_phy_ch/sched_dci.cc | 24 +++++++++++++------ srsenb/src/stack/mac/sched_ue.cc | 8 +------ .../stack/mac/sched_ue_ctrl/sched_ue_cell.cc | 6 +++++ srsenb/test/mac/sched_benchmark.cc | 2 +- 6 files changed, 46 insertions(+), 20 deletions(-) diff --git a/lib/include/srsran/adt/accumulators.h b/lib/include/srsran/adt/accumulators.h index 29b4ece6b..e6b8d639b 100644 --- a/lib/include/srsran/adt/accumulators.h +++ b/lib/include/srsran/adt/accumulators.h @@ -38,8 +38,10 @@ private: template struct exp_average_fast_start { - exp_average_fast_start(T alpha_, uint32_t start_size = 100) : alpha(alpha_), start_count_size(start_size) + exp_average_fast_start(T alpha_val) : exp_average_fast_start(alpha_val, 1.0 / alpha_val) {} + exp_average_fast_start(T alpha_val, uint32_t start_size) : alpha_(alpha_val), start_count_size(start_size) { + assert(alpha_ < 1); assert(start_size > 0); } void push(T sample) @@ -48,16 +50,18 @@ struct exp_average_fast_start { avg_ += (sample - avg_) / (count + 1); count++; } else { - avg_ = (1 - alpha) * avg_ + alpha * sample; + avg_ = (1 - alpha_) * avg_ + alpha_ * sample; } } - T value() const { return count == 0 ? 0 : avg_; } + T value() const { return count == 0 ? 0 : avg_; } + T alpha() const { return alpha_; } + bool is_exp_average_mode() const { return count >= start_count_size; } private: T avg_ = 0; uint32_t count = 0; uint32_t start_count_size; - T alpha; + T alpha_; }; namespace detail { @@ -112,7 +116,6 @@ private: template struct null_sliding_average { - null_sliding_average(uint32_t N) : window(N, null_value()) {} void push(T sample) { window.push(sample); } void push_hole() { window.push(null_value()); } diff --git a/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h b/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h index 07a5c6e00..97eb9b44b 100644 --- a/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h +++ b/srsenb/hdr/stack/mac/sched_phy_ch/sched_dci.h @@ -47,6 +47,19 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, bool ulqam64_enabled, bool use_tbs_index_alt); +/** + * Compute MCS, TBS based on maximum coderate, N_prb + * \remark See TS 36.213 - Table 7.1.7.1-1/1A + * @return resulting TBS (in bytes) and mcs. TBS=-1 if no valid solution was found. + */ +tbs_info compute_mcs_and_tbs(uint32_t nof_prb, + uint32_t nof_re, + float max_coderate, + uint32_t max_mcs, + bool is_ul, + bool ulqam64_enabled, + bool use_tbs_index_alt); + /** * Compute lowest MCS, TBS based on CQI, N_prb that satisfies TBS >= req_bytes (best effort) * \remark See TS 36.213 - Table 7.1.7.1-1/1A diff --git a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc index ed0c044ac..2df511b97 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc @@ -77,16 +77,26 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, bool is_ul, bool ulqam64_enabled, bool use_tbs_index_alt) +{ + float max_coderate = srsran_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); + return compute_mcs_and_tbs(nof_prb, nof_re, max_coderate, max_mcs, is_ul, ulqam64_enabled, use_tbs_index_alt); +} + +tbs_info compute_mcs_and_tbs(uint32_t nof_prb, + uint32_t nof_re, + float max_coderate, + uint32_t max_mcs, + bool is_ul, + bool ulqam64_enabled, + bool use_tbs_index_alt) { assert((not is_ul or not use_tbs_index_alt) && "UL cannot use Alt CQI Table"); assert((is_ul or not ulqam64_enabled) && "DL cannot use UL-QAM64 enable flag"); - float max_coderate = srsran_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); - uint32_t max_Qm = (is_ul) ? (ulqam64_enabled ? 6 : 4) : (use_tbs_index_alt ? 8 : 6); - max_coderate = std::min(max_coderate, 0.932F * max_Qm); + uint32_t max_Qm = (is_ul) ? (ulqam64_enabled ? 6 : 4) : (use_tbs_index_alt ? 8 : 6); + max_coderate = std::min(max_coderate, 0.930F * max_Qm); - int mcs = 0; - float prev_max_coderate = 0; + int mcs = 0; do { // update max TBS based on max coderate int max_tbs = coderate_to_tbs(max_coderate, nof_re); @@ -113,7 +123,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, // update max coderate based on mcs srsran_mod_t mod = (is_ul) ? srsran_ra_ul_mod_from_mcs(mcs) : srsran_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt); uint32_t Qm = srsran_mod_bits_x_symbol(mod); - max_coderate = std::min(0.932F * Qm, max_coderate); + max_coderate = std::min(0.930F * Qm, max_coderate); if (coderate <= max_coderate) { // solution was found @@ -125,7 +135,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, // start with smaller max mcs in next iteration max_mcs = mcs - 1; - } while (mcs > 0 and max_coderate != prev_max_coderate); + } while (mcs > 0); return tbs_info{}; } diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index 5acba07ea..67a8badf7 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -93,15 +93,9 @@ void sched_ue::new_subframe(tti_point tti_rx, uint32_t enb_cc_idx) current_tti = tti_rx; lch_handler.new_tti(); for (auto& cc : cells) { - if (cc.configured()) { - cc.harq_ent.new_tti(tti_rx); - } + cc.new_tti(tti_rx); } } - - if (cells[enb_cc_idx].configured()) { - cells[enb_cc_idx].tpc_fsm.new_tti(); - } } /******************************************************* diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc index 416b11981..9b8d84396 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc @@ -114,8 +114,14 @@ void sched_ue_cell::set_ue_cfg(const sched_interface::ue_cfg_t& ue_cfg_) void sched_ue_cell::new_tti(tti_point tti_rx) { + if (not configured()) { + return; + } current_tti = tti_rx; + harq_ent.new_tti(tti_rx); + tpc_fsm.new_tti(); + // Check if cell state needs to be updated if (ue_cc_idx > 0 and cc_state_ == cc_st::deactivating) { // wait for all ACKs to be received before completely deactivating SCell diff --git a/srsenb/test/mac/sched_benchmark.cc b/srsenb/test/mac/sched_benchmark.cc index c26980a87..8af5e24ad 100644 --- a/srsenb/test/mac/sched_benchmark.cc +++ b/srsenb/test/mac/sched_benchmark.cc @@ -246,7 +246,7 @@ run_data expected_run_result(run_params params) break; default: ret.avg_dl_throughput *= 0.96; - ret.avg_ul_throughput *= 0.85; + ret.avg_ul_throughput *= 0.84; break; } return ret;