From 323703c2f3fbfa7da33f75b8dab41c62357d7327 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 12 Jul 2021 09:52:47 +0100 Subject: [PATCH] sched,nr: measure latency of sched nr in test --- srsenb/hdr/stack/mac/nr/sched_nr_interface.h | 3 +- srsenb/src/stack/mac/nr/sched_nr_bwp.cc | 2 +- srsenb/test/mac/nr/sched_nr_test.cc | 31 +++++++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_interface.h b/srsenb/hdr/stack/mac/nr/sched_nr_interface.h index 23b1093cb..a32dd5832 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_interface.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_interface.h @@ -58,7 +58,8 @@ public: }; struct cell_cfg_t { - srsran_tdd_config_nr_t tdd = {}; + srsran_carrier_nr_t carrier = {}; + srsran_tdd_config_nr_t tdd = {}; srsran::bounded_vector bwps{1}; // idx0 for BWP-common }; diff --git a/srsenb/src/stack/mac/nr/sched_nr_bwp.cc b/srsenb/src/stack/mac/nr/sched_nr_bwp.cc index 223d05294..1e9a4b38f 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_bwp.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_bwp.cc @@ -29,7 +29,7 @@ ra_sched::allocate_pending_rar(bwp_slot_allocator& slot_grid, const pending_rar_ for (nof_grants_alloc = rar.msg3_grant.size(); nof_grants_alloc > 0; nof_grants_alloc--) { ret = alloc_result::invalid_coderate; uint32_t start_prb_idx = 0; - for (uint32_t nprb = 1; nprb < bwp_cfg->N_rbg and ret == alloc_result::invalid_coderate; ++nprb) { + for (uint32_t nprb = 1; nprb < bwp_cfg->cfg.rb_width and ret == alloc_result::invalid_coderate; ++nprb) { prb_interval interv = find_empty_interval_of_length(prbs, nprb, start_prb_idx); start_prb_idx = interv.stop(); if (interv.length() == nprb) { diff --git a/srsenb/test/mac/nr/sched_nr_test.cc b/srsenb/test/mac/nr/sched_nr_test.cc index ceef7b10b..c3d058131 100644 --- a/srsenb/test/mac/nr/sched_nr_test.cc +++ b/srsenb/test/mac/nr/sched_nr_test.cc @@ -15,6 +15,7 @@ #include "srsran/common/phy_cfg_nr_default.h" #include "srsran/common/test_common.h" #include "srsran/common/thread_pool.h" +#include namespace srsenb { @@ -39,18 +40,13 @@ sched_nr_interface::cell_cfg_t get_default_cell_cfg() { sched_nr_interface::cell_cfg_t cell_cfg{}; - cell_cfg.tdd.pattern1.period_ms = 10; - cell_cfg.tdd.pattern1.nof_dl_slots = 6; - cell_cfg.tdd.pattern1.nof_dl_symbols = 0; - cell_cfg.tdd.pattern1.nof_ul_slots = 4; - cell_cfg.tdd.pattern1.nof_ul_symbols = 0; - - // Disable pattern 2 - cell_cfg.tdd.pattern2.period_ms = 0; + cell_cfg.carrier = default_phy_cfg.carrier; + cell_cfg.tdd = default_phy_cfg.tdd; cell_cfg.bwps.resize(1); - cell_cfg.bwps[0].pdcch = default_phy_cfg.pdcch; - cell_cfg.bwps[0].pdsch = default_phy_cfg.pdsch; + cell_cfg.bwps[0].pdcch = default_phy_cfg.pdcch; + cell_cfg.bwps[0].pdsch = default_phy_cfg.pdsch; + cell_cfg.bwps[0].rb_width = default_phy_cfg.carrier.nof_prb; cell_cfg.bwps[0].pdcch.coreset_present[0] = true; cell_cfg.bwps[0].pdcch.coreset[0] = get_default_coreset0(); @@ -158,6 +154,7 @@ void sched_nr_cfg_serialized_test() sched_tester.add_user(0x46, uecfg, 0); + auto tp1 = std::chrono::steady_clock::now(); for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) { tti_point tti_rx(nof_ttis % 10240); tti_point tti_tx = tti_rx + TX_ENB_DELAY; @@ -174,9 +171,13 @@ void sched_nr_cfg_serialized_test() TESTASSERT(not srsran_tdd_nr_is_dl(&cells_cfg[cc].tdd, 0, (tti_tx).sf_idx()) or dl_res.pdcch_dl.size() == 1); } } + auto tp2 = std::chrono::steady_clock::now(); tasks.print_results(); TESTASSERT(tasks.pdsch_count == (int)(max_nof_ttis * nof_sectors * 0.6)); + + uint32_t microsecs = std::chrono::duration_cast(tp2 - tp1).count(); + printf("Total time taken per slot: %f\n", microsecs / (float)max_nof_ttis); } void sched_nr_cfg_parallel_cc_test() @@ -193,6 +194,7 @@ void sched_nr_cfg_parallel_cc_test() sched_nr_interface::ue_cfg_t uecfg = get_default_ue_cfg(cells_cfg.size()); sched_tester.add_user(0x46, uecfg, 0); + auto tp1 = std::chrono::steady_clock::now(); for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) { tti_point tti_rx(nof_ttis % 10240); tti_point tti_tx = tti_rx + TX_ENB_DELAY; @@ -210,11 +212,15 @@ void sched_nr_cfg_parallel_cc_test() }); } } + auto tp2 = std::chrono::steady_clock::now(); tasks.wait_task_finish(); tasks.print_results(); TESTASSERT(tasks.pdsch_count == (int)(max_nof_ttis * nof_sectors * 0.6)); + + uint32_t microsecs = std::chrono::duration_cast(tp2 - tp1).count(); + printf("Total time taken per slot [usec]: %f\n", microsecs / (float)max_nof_ttis); } void sched_nr_cfg_parallel_sf_test() @@ -233,6 +239,7 @@ void sched_nr_cfg_parallel_sf_test() sched_nr_interface::ue_cfg_t uecfg = get_default_ue_cfg(cells_cfg.size()); sched.ue_cfg(0x46, uecfg); + auto tp1 = std::chrono::steady_clock::now(); for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) { tti_point tti(nof_ttis % 10240); tasks.start_slot(tti, nof_sectors); @@ -246,10 +253,14 @@ void sched_nr_cfg_parallel_sf_test() }); } } + auto tp2 = std::chrono::steady_clock::now(); tasks.wait_task_finish(); tasks.print_results(); + + uint32_t microsecs = std::chrono::duration_cast(tp2 - tp1).count(); + printf("Total time taken per slot [usec]: %f\n", microsecs / (float)max_nof_ttis); } } // namespace srsenb