correct verification of sched rates in sched benchmark test

master
Francisco 4 years ago committed by Francisco Paisana
parent d334907afe
commit ac4d058fbf

@ -895,7 +895,7 @@ void sf_sched::set_ul_sched_result(const sf_cch_allocator::alloc_result_t& dci_r
fmt::format_to(str_buffer, fmt::format_to(str_buffer,
"SCHED: {} {} rnti=0x{:x}, cc={}, pid={}, dci=({},{}), prb={}, n_rtx={}, tbs={}, bsr={} ({}-{})", "SCHED: {} {} rnti=0x{:x}, cc={}, pid={}, dci=({},{}), prb={}, n_rtx={}, tbs={}, bsr={} ({}-{})",
ul_alloc.is_msg3 ? "Msg3" : "UL", ul_alloc.is_msg3 ? "Msg3" : "UL",
ul_alloc.is_retx() ? "retx" : "newtx", ul_alloc.is_retx() ? "retx" : "tx",
user->get_rnti(), user->get_rnti(),
cc_cfg->enb_cc_idx, cc_cfg->enb_cc_idx,
h->get_id(), h->get_id(),

@ -83,7 +83,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb,
float max_coderate = srslte_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); float max_coderate = srslte_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); uint32_t max_Qm = (is_ul) ? (ulqam64_enabled ? 6 : 4) : (use_tbs_index_alt ? 8 : 6);
max_coderate = std::min(max_coderate, 0.93F * max_Qm); max_coderate = std::min(max_coderate, 0.932F * max_Qm);
int mcs = 0; int mcs = 0;
float prev_max_coderate = 0; float prev_max_coderate = 0;
@ -113,7 +113,7 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb,
// update max coderate based on mcs // update max coderate based on mcs
srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(mcs) : srslte_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt); srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(mcs) : srslte_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt);
uint32_t Qm = srslte_mod_bits_x_symbol(mod); uint32_t Qm = srslte_mod_bits_x_symbol(mod);
max_coderate = std::min(0.93F * Qm, max_coderate); max_coderate = std::min(0.932F * Qm, max_coderate);
if (coderate <= max_coderate) { if (coderate <= max_coderate) {
// solution was found // solution was found
@ -217,7 +217,7 @@ int generate_ra_bc_dci_format1a_common(srslte_dci_dl_t& dci,
// Compute effective code rate and verify it doesn't exceed max code rate // Compute effective code rate and verify it doesn't exceed max code rate
uint32_t nof_re = cell_params.get_dl_nof_res(tti_tx_dl, dci, current_cfi); uint32_t nof_re = cell_params.get_dl_nof_res(tti_tx_dl, dci, current_cfi);
if (srslte_coderate(tbs, nof_re) >= 0.93F * Qm) { if (srslte_coderate(tbs, nof_re) >= 0.932F * Qm) {
return -1; return -1;
} }

@ -234,7 +234,7 @@ tbs_info cqi_to_tbs_dl(const sched_ue_cell& cell,
ret = compute_min_mcs_and_tbs_from_required_bytes( ret = compute_min_mcs_and_tbs_from_required_bytes(
nof_prb, nof_re, cell.dl_cqi, cell.max_mcs_dl, req_bytes, false, false, use_tbs_index_alt); nof_prb, nof_re, cell.dl_cqi, cell.max_mcs_dl, req_bytes, false, false, use_tbs_index_alt);
// If coderate > SRSLTE_MIN(max_coderate, 0.930 * Qm) we should set TBS=0. We don't because it's not correctly // If coderate > SRSLTE_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly
// handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR // handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR
if (ret.tbs_bytes < 0) { if (ret.tbs_bytes < 0) {
ret.mcs = 0; ret.mcs = 0;
@ -260,7 +260,7 @@ tbs_info cqi_to_tbs_ul(const sched_ue_cell& cell, uint32_t nof_prb, uint32_t nof
ret = compute_min_mcs_and_tbs_from_required_bytes( ret = compute_min_mcs_and_tbs_from_required_bytes(
nof_prb, nof_re, cell.ul_cqi, cell.max_mcs_ul, req_bytes, true, ulqam64_enabled, false); nof_prb, nof_re, cell.ul_cqi, cell.max_mcs_ul, req_bytes, true, ulqam64_enabled, false);
// If coderate > SRSLTE_MIN(max_coderate, 0.930 * Qm) we should set TBS=0. We don't because it's not correctly // If coderate > SRSLTE_MIN(max_coderate, 0.932 * Qm) we should set TBS=0. We don't because it's not correctly
// handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR // handled by the scheduler, but we might be scheduling undecodable codewords at very low SNR
if (ret.tbs_bytes < 0) { if (ret.tbs_bytes < 0) {
ret.mcs = 0; ret.mcs = 0;

@ -15,8 +15,6 @@
#include "srslte/adt/accumulators.h" #include "srslte/adt/accumulators.h"
#include <chrono> #include <chrono>
const uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count();
namespace srsenb { namespace srsenb {
struct run_params { struct run_params {
@ -198,7 +196,8 @@ int run_benchmark_scenario(run_params params, std::vector<run_data>& run_results
sched_args.sched_policy = params.sched_policy; sched_args.sched_policy = params.sched_policy;
sched sched_obj; sched sched_obj;
sched_obj.init(nullptr, sched_args); rrc_dummy rrc{};
sched_obj.init(&rrc, sched_args);
sched_tester tester(&sched_obj, sched_args, cell_list); sched_tester tester(&sched_obj, sched_args, cell_list);
tester.total_stats = {}; tester.total_stats = {};
@ -248,31 +247,72 @@ run_data expected_run_result(run_params params)
{ {
assert(params.cqi == 15 && "only cqi=15 supported for now"); assert(params.cqi == 15 && "only cqi=15 supported for now");
run_data ret{}; run_data ret{};
float dl_overhead = 0.9, ul_overhead = 0.75; int tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, false);
int tbs = srslte_ra_tbs_from_idx(tbs_idx, params.nof_prbs);
ret.avg_dl_throughput = tbs * 1e3; // bps
tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, true);
uint32_t nof_pusch_prbs = params.nof_prbs - (params.nof_prbs == 6 ? 2 : 4);
tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs);
ret.avg_ul_throughput = tbs * 1e3; // bps
ret.avg_dl_mcs = 27;
ret.avg_ul_mcs = 22;
switch (params.nof_prbs) { switch (params.nof_prbs) {
case 6: case 6:
ret.avg_dl_mcs = 25; ret.avg_dl_mcs = 25;
ret.avg_ul_mcs = 22; ret.avg_dl_throughput *= 0.7;
dl_overhead = 0.8; ret.avg_ul_throughput *= 0.25;
ul_overhead = 0.4; break;
case 15:
ret.avg_dl_throughput *= 0.95;
ret.avg_ul_throughput *= 0.5;
break; break;
default: default:
ret.avg_dl_mcs = 26; ret.avg_dl_throughput *= 0.97;
ret.avg_ul_mcs = 22; ret.avg_ul_throughput *= 0.5;
break;
}
return ret;
} }
int tbs_idx = srslte_ra_tbs_idx_from_mcs(ret.avg_dl_mcs, false, false); void print_benchmark_results(const std::vector<run_data>& run_results)
int tbs = srslte_ra_tbs_from_idx(tbs_idx, params.nof_prbs); {
ret.avg_dl_throughput = tbs * 1e3 * dl_overhead; // bps srslog::flush();
fmt::print("run | Nprb | cqi | sched pol | Nue | DL/UL [Mbps] | DL/UL mcs | DL/UL OH [%] | latency "
"[usec]\n");
fmt::print("---------------------------------------------------------------------------------------"
"------\n");
for (uint32_t i = 0; i < run_results.size(); ++i) {
const run_data& r = run_results[i];
tbs_idx = srslte_ra_tbs_idx_from_mcs(ret.avg_ul_mcs, false, true); int tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, false);
tbs = srslte_ra_tbs_from_idx(tbs_idx, params.nof_prbs - 2); int tbs = srslte_ra_tbs_from_idx(tbs_idx, r.params.nof_prbs);
ret.avg_ul_throughput = tbs * 1e3 * ul_overhead; // bps float dl_rate_overhead = 1.0F - r.avg_dl_throughput / (tbs * 1e3);
return ret; tbs_idx = srslte_ra_tbs_idx_from_mcs(28, false, true);
uint32_t nof_pusch_prbs = r.params.nof_prbs - (r.params.nof_prbs == 6 ? 2 : 4);
tbs = srslte_ra_tbs_from_idx(tbs_idx, nof_pusch_prbs);
float ul_rate_overhead = 1.0F - r.avg_ul_throughput / (tbs * 1e3);
fmt::print("{:>3d}{:>6d}{:>6d}{:>12}{:>6d}{:>9.2}/{:>4.2}{:>9.1f}/{:>4.1f}{:9.1f}/{:>4.1f}{:12d}\n",
i,
r.params.nof_prbs,
r.params.cqi,
r.params.sched_policy,
r.params.nof_ues,
r.avg_dl_throughput / 1e6,
r.avg_ul_throughput / 1e6,
r.avg_dl_mcs,
r.avg_ul_mcs,
dl_rate_overhead * 100,
ul_rate_overhead * 100,
r.avg_latency.count());
}
} }
int run_rate_test() int run_rate_test()
{ {
fmt::print("\n====== Scheduler Rate Test ======\n\n");
run_params_range run_param_list{}; run_params_range run_param_list{};
srslog::basic_logger& mac_logger = srslog::fetch_basic_logger("MAC"); srslog::basic_logger& mac_logger = srslog::fetch_basic_logger("MAC");
@ -285,12 +325,12 @@ int run_rate_test()
for (size_t r = 0; r < nof_runs; ++r) { for (size_t r = 0; r < nof_runs; ++r) {
run_params runparams = run_param_list.get_params(r); run_params runparams = run_param_list.get_params(r);
mac_logger.info("\n### New run {} ###\n", r); mac_logger.info("\n=== New run {} ===\n", r);
TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSLTE_SUCCESS); TESTASSERT(run_benchmark_scenario(runparams, run_results) == SRSLTE_SUCCESS);
} }
const std::array<float, 6> expected_dl_rate_Mbps{2.5, 8.8, 15, 31, 47, 64}; print_benchmark_results(run_results);
const std::array<float, 6> expected_ul_rate_Mbps{0.1, 1.8, 4, 8.3, 13, 19};
bool success = true; bool success = true;
for (auto& run : run_results) { for (auto& run : run_results) {
run_data expected = expected_run_result(run.params); run_data expected = expected_run_result(run.params);
@ -322,27 +362,6 @@ int run_rate_test()
return success ? SRSLTE_SUCCESS : SRSLTE_ERROR; return success ? SRSLTE_SUCCESS : SRSLTE_ERROR;
} }
void print_benchmark_results(const std::vector<run_data>& run_results)
{
srslog::flush();
fmt::print("run | Nprb | cqi | sched pol | Nue | DL [Mbps] | UL [Mbps] | DL mcs | UL mcs | latency [usec]\n");
fmt::print("---------------------------------------------------------------------------------------------\n");
for (uint32_t i = 0; i < run_results.size(); ++i) {
const run_data& r = run_results[i];
fmt::print("{:>3d}{:>6d}{:>6d}{:>12}{:>6d}{:12.2}{:12.2}{:9.1f}{:9.1f}{:12d}\n",
i,
r.params.nof_prbs,
r.params.cqi,
r.params.sched_policy,
r.params.nof_ues,
r.avg_dl_throughput / 1e6,
r.avg_ul_throughput / 1e6,
r.avg_dl_mcs,
r.avg_ul_mcs,
r.avg_latency.count());
}
}
int run_benchmark() int run_benchmark()
{ {
run_params_range run_param_list{}; run_params_range run_param_list{};
@ -366,10 +385,6 @@ int run_benchmark()
int main() int main()
{ {
// Setup seed
srsenb::set_randseed(seed);
printf("This is the chosen seed: %u\n", seed);
// Setup the log spy to intercept error and warning log entries. // Setup the log spy to intercept error and warning log entries.
if (!srslog::install_custom_sink( if (!srslog::install_custom_sink(
srslte::log_sink_spy::name(), srslte::log_sink_spy::name(),

@ -317,7 +317,7 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
float coderate = srslte_coderate(tbs * 8, nof_re); float coderate = srslte_coderate(tbs * 8, nof_re);
const uint32_t Qm = 2; const uint32_t Qm = 2;
CONDERROR( CONDERROR(
coderate > 0.930f * Qm, "Max coderate was exceeded from %s DCI", dci.rnti == SRSLTE_SIRNTI ? "SIB" : "RAR"); coderate > 0.932f * Qm, "Max coderate was exceeded from %s DCI", dci.rnti == SRSLTE_SIRNTI ? "SIB" : "RAR");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
}; };

@ -54,7 +54,7 @@ bool lower_coderate(tbs_info tb, uint32_t nof_re, const tbs_test_args& args)
srslte_mod_t mod = srslte_mod_t mod =
(args.is_ul) ? srslte_ra_ul_mod_from_mcs(tb.mcs) : srslte_ra_dl_mod_from_mcs(tb.mcs, args.use_tbs_index_alt); (args.is_ul) ? srslte_ra_ul_mod_from_mcs(tb.mcs) : srslte_ra_dl_mod_from_mcs(tb.mcs, args.use_tbs_index_alt);
float Qm = std::min(args.get_max_Qm(), srslte_mod_bits_x_symbol(mod)); float Qm = std::min(args.get_max_Qm(), srslte_mod_bits_x_symbol(mod));
return coderate <= 0.930f * Qm; return coderate <= 0.932f * Qm;
} }
int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_test_args& args, tbs_info* result) int test_mcs_tbs_dl_helper(const sched_cell_params_t& cell_params, const tbs_test_args& args, tbs_info* result)

@ -49,9 +49,9 @@ inline srsenb::sched_interface::cell_cfg_t generate_default_cell_cfg(uint32_t no
cell_cfg.maxharq_msg3tx = 3; cell_cfg.maxharq_msg3tx = 3;
cell_cfg.initial_dl_cqi = 6; cell_cfg.initial_dl_cqi = 6;
cell_cfg.target_ul_sinr = -1; cell_cfg.target_ul_sinr = -1;
cell_cfg.nrb_cqi = 2; cell_cfg.nrb_cqi = 1;
cell_cfg.n1pucch_an = 12; cell_cfg.n1pucch_an = 12;
cell_cfg.delta_pucch_shift = 2; cell_cfg.delta_pucch_shift = 1;
cell_cfg.ncs_an = 0; cell_cfg.ncs_an = 0;
return cell_cfg; return cell_cfg;

@ -106,7 +106,7 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt,
srslte_mod_t mod = srslte_ra_dl_mod_from_mcs(pdsch.dci.tb[0].mcs_idx, ue_ctxt.ue_cfg.use_tbs_index_alt); srslte_mod_t mod = srslte_ra_dl_mod_from_mcs(pdsch.dci.tb[0].mcs_idx, ue_ctxt.ue_cfg.use_tbs_index_alt);
uint32_t max_Qm = ue_ctxt.ue_cfg.use_tbs_index_alt ? 8 : 6; uint32_t max_Qm = ue_ctxt.ue_cfg.use_tbs_index_alt ? 8 : 6;
uint32_t Qm = std::min(max_Qm, srslte_mod_bits_x_symbol(mod)); uint32_t Qm = std::min(max_Qm, srslte_mod_bits_x_symbol(mod));
CONDERROR(coderate > 0.930f * Qm, "Max coderate was exceeded"); CONDERROR(coderate > 0.932f * Qm, "Max coderate was exceeded");
} }
// TEST: PUCCH-ACK will not collide with SR // TEST: PUCCH-ACK will not collide with SR

Loading…
Cancel
Save