|
|
|
@ -17,6 +17,8 @@
|
|
|
|
|
|
|
|
|
|
namespace srsenb {
|
|
|
|
|
|
|
|
|
|
using dl_sched_t = sched_nr_interface::dl_sched_t;
|
|
|
|
|
|
|
|
|
|
srsran_coreset_t get_default_coreset()
|
|
|
|
|
{
|
|
|
|
|
srsran_coreset_t coreset{};
|
|
|
|
@ -87,37 +89,46 @@ sched_nr_interface::ue_cfg_t get_default_ue_cfg(uint32_t nof_cc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct task_job_manager {
|
|
|
|
|
std::mutex mutex;
|
|
|
|
|
std::condition_variable cond_var;
|
|
|
|
|
int tasks = 0;
|
|
|
|
|
int res_count = 0;
|
|
|
|
|
int pdsch_count = 0;
|
|
|
|
|
int max_tasks = std::numeric_limits<int>::max() / 2;
|
|
|
|
|
srslog::basic_logger& test_logger = srslog::fetch_basic_logger("TEST");
|
|
|
|
|
|
|
|
|
|
void start_task()
|
|
|
|
|
std::mutex mutex;
|
|
|
|
|
int res_count = 0;
|
|
|
|
|
int pdsch_count = 0;
|
|
|
|
|
srslog::basic_logger& test_logger = srslog::fetch_basic_logger("TEST");
|
|
|
|
|
struct slot_guard {
|
|
|
|
|
int count = 0;
|
|
|
|
|
std::condition_variable cvar;
|
|
|
|
|
};
|
|
|
|
|
srsran::bounded_vector<slot_guard, 10> slot_counter{};
|
|
|
|
|
|
|
|
|
|
explicit task_job_manager(int max_concurrent_slots = 4) : slot_counter(max_concurrent_slots) {}
|
|
|
|
|
|
|
|
|
|
void start_slot(tti_point tti, int nof_sectors)
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mutex);
|
|
|
|
|
while (tasks >= max_tasks) {
|
|
|
|
|
cond_var.wait(lock);
|
|
|
|
|
auto& sl = slot_counter[tti.to_uint() % slot_counter.size()];
|
|
|
|
|
while (sl.count > 0) {
|
|
|
|
|
sl.cvar.wait(lock);
|
|
|
|
|
}
|
|
|
|
|
tasks++;
|
|
|
|
|
sl.count = nof_sectors;
|
|
|
|
|
}
|
|
|
|
|
void finish_task(const sched_nr_interface::tti_request_t& res)
|
|
|
|
|
void finish_cc(tti_point tti, const dl_sched_t& dl_res, const sched_nr_interface::ul_sched_t& ul_res)
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mutex);
|
|
|
|
|
TESTASSERT(res.dl_res.pdschs.size() <= 1);
|
|
|
|
|
TESTASSERT(dl_res.pdcch_dl.size() <= 1);
|
|
|
|
|
res_count++;
|
|
|
|
|
pdsch_count += res.dl_res.pdschs.size();
|
|
|
|
|
if (tasks-- >= max_tasks or tasks == 0) {
|
|
|
|
|
cond_var.notify_one();
|
|
|
|
|
pdsch_count += dl_res.pdcch_dl.size();
|
|
|
|
|
auto& sl = slot_counter[tti.to_uint() % slot_counter.size()];
|
|
|
|
|
if (--sl.count == 0) {
|
|
|
|
|
sl.cvar.notify_one();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void wait_task_finish()
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(mutex);
|
|
|
|
|
while (tasks > 0) {
|
|
|
|
|
cond_var.wait(lock);
|
|
|
|
|
for (auto& sl : slot_counter) {
|
|
|
|
|
while (sl.count > 0) {
|
|
|
|
|
sl.cvar.wait(lock);
|
|
|
|
|
}
|
|
|
|
|
sl.count = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void print_results() const
|
|
|
|
@ -142,17 +153,19 @@ void sched_nr_cfg_serialized_test()
|
|
|
|
|
sched_tester.add_user(0x46, uecfg, 0);
|
|
|
|
|
|
|
|
|
|
for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) {
|
|
|
|
|
tti_point tti(nof_ttis % 10240);
|
|
|
|
|
sched_tester.slot_indication(tti);
|
|
|
|
|
tti_point tti_rx(nof_ttis % 10240);
|
|
|
|
|
tti_point tti_tx = tti_rx + TX_ENB_DELAY;
|
|
|
|
|
tasks.start_slot(tti_rx, nof_sectors);
|
|
|
|
|
sched_tester.new_slot(tti_tx);
|
|
|
|
|
for (uint32_t cc = 0; cc < cells_cfg.size(); ++cc) {
|
|
|
|
|
tasks.start_task();
|
|
|
|
|
sched_nr_interface::tti_request_t res;
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->generate_sched_result(tti, cc, res) == SRSRAN_SUCCESS);
|
|
|
|
|
sched_nr_cc_output_res_t out{tti, cc, &res.dl_res, &res.ul_res};
|
|
|
|
|
sched_nr_interface::dl_sched_t dl_res;
|
|
|
|
|
sched_nr_interface::ul_sched_t ul_res;
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->get_dl_sched(tti_tx, cc, dl_res) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->get_ul_sched(tti_tx, cc, ul_res) == SRSRAN_SUCCESS);
|
|
|
|
|
sched_nr_cc_output_res_t out{tti_tx, cc, &dl_res, &ul_res};
|
|
|
|
|
sched_tester.update(out);
|
|
|
|
|
tasks.finish_task(res);
|
|
|
|
|
TESTASSERT(not srsran_tdd_nr_is_dl(&cells_cfg[cc].tdd, 0, (tti + TX_ENB_DELAY).sf_idx()) or
|
|
|
|
|
res.dl_res.pdschs.size() == 1);
|
|
|
|
|
tasks.finish_cc(tti_rx, dl_res, ul_res);
|
|
|
|
|
TESTASSERT(not srsran_tdd_nr_is_dl(&cells_cfg[cc].tdd, 0, (tti_tx).sf_idx()) or dl_res.pdcch_dl.size() == 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -162,11 +175,12 @@ void sched_nr_cfg_serialized_test()
|
|
|
|
|
|
|
|
|
|
void sched_nr_cfg_parallel_cc_test()
|
|
|
|
|
{
|
|
|
|
|
uint32_t nof_sectors = 4;
|
|
|
|
|
uint32_t max_nof_ttis = 1000;
|
|
|
|
|
task_job_manager tasks;
|
|
|
|
|
|
|
|
|
|
sched_nr_interface::sched_cfg_t cfg;
|
|
|
|
|
std::vector<sched_nr_interface::cell_cfg_t> cells_cfg = get_default_cells_cfg(4);
|
|
|
|
|
std::vector<sched_nr_interface::cell_cfg_t> cells_cfg = get_default_cells_cfg(nof_sectors);
|
|
|
|
|
|
|
|
|
|
sched_nr_sim_base sched_tester(cfg, cells_cfg, "Parallel CC Test");
|
|
|
|
|
|
|
|
|
@ -174,16 +188,19 @@ void sched_nr_cfg_parallel_cc_test()
|
|
|
|
|
sched_tester.add_user(0x46, uecfg, 0);
|
|
|
|
|
|
|
|
|
|
for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) {
|
|
|
|
|
tti_point tti(nof_ttis % 10240);
|
|
|
|
|
sched_tester.slot_indication(tti);
|
|
|
|
|
tti_point tti_rx(nof_ttis % 10240);
|
|
|
|
|
tti_point tti_tx = tti_rx + TX_ENB_DELAY;
|
|
|
|
|
tasks.start_slot(tti_tx, nof_sectors);
|
|
|
|
|
sched_tester.new_slot(tti_tx);
|
|
|
|
|
for (uint32_t cc = 0; cc < cells_cfg.size(); ++cc) {
|
|
|
|
|
tasks.start_task();
|
|
|
|
|
srsran::get_background_workers().push_task([cc, tti, &tasks, &sched_tester]() {
|
|
|
|
|
sched_nr_interface::tti_request_t res;
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->generate_sched_result(tti, cc, res) == SRSRAN_SUCCESS);
|
|
|
|
|
sched_nr_cc_output_res_t out{tti, cc, &res.dl_res, &res.ul_res};
|
|
|
|
|
srsran::get_background_workers().push_task([cc, tti_tx, &tasks, &sched_tester]() {
|
|
|
|
|
sched_nr_interface::dl_sched_t dl_res;
|
|
|
|
|
sched_nr_interface::ul_sched_t ul_res;
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->get_dl_sched(tti_tx, cc, dl_res) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(sched_tester.get_sched()->get_ul_sched(tti_tx, cc, ul_res) == SRSRAN_SUCCESS);
|
|
|
|
|
sched_nr_cc_output_res_t out{tti_tx, cc, &dl_res, &ul_res};
|
|
|
|
|
sched_tester.update(out);
|
|
|
|
|
tasks.finish_task(res);
|
|
|
|
|
tasks.finish_cc(tti_tx, dl_res, ul_res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -191,6 +208,7 @@ void sched_nr_cfg_parallel_cc_test()
|
|
|
|
|
tasks.wait_task_finish();
|
|
|
|
|
|
|
|
|
|
tasks.print_results();
|
|
|
|
|
TESTASSERT(tasks.pdsch_count == (int)(max_nof_ttis * nof_sectors * 0.6));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sched_nr_cfg_parallel_sf_test()
|
|
|
|
@ -211,13 +229,14 @@ void sched_nr_cfg_parallel_sf_test()
|
|
|
|
|
|
|
|
|
|
for (uint32_t nof_ttis = 0; nof_ttis < max_nof_ttis; ++nof_ttis) {
|
|
|
|
|
tti_point tti(nof_ttis % 10240);
|
|
|
|
|
sched.slot_indication(tti);
|
|
|
|
|
tasks.start_slot(tti, nof_sectors);
|
|
|
|
|
for (uint32_t cc = 0; cc < cells_cfg.size(); ++cc) {
|
|
|
|
|
tasks.start_task();
|
|
|
|
|
srsran::get_background_workers().push_task([cc, &sched, tti, &tasks]() {
|
|
|
|
|
sched_nr_interface::tti_request_t res;
|
|
|
|
|
TESTASSERT(sched.generate_sched_result(tti, cc, res) == SRSRAN_SUCCESS);
|
|
|
|
|
tasks.finish_task(res);
|
|
|
|
|
sched_nr_interface::dl_sched_t dl_res;
|
|
|
|
|
sched_nr_interface::ul_sched_t ul_res;
|
|
|
|
|
TESTASSERT(sched.get_dl_sched(tti, cc, dl_res) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(sched.get_ul_sched(tti, cc, ul_res) == SRSRAN_SUCCESS);
|
|
|
|
|
tasks.finish_cc(tti, dl_res, ul_res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|