Skip to content

Commit cb18636

Browse files
committed
du: simplify optimization fnc in srs res mng
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent a11bb33 commit cb18636

File tree

4 files changed

+59
-44
lines changed

4 files changed

+59
-44
lines changed

lib/du/du_high/du_manager/ran_resource_management/du_pucch_resource_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void du_pucch_resource_manager::dealloc_resources(cell_group_config& cell_grp_cf
350350
}
351351

352352
// Disable the PUCCH configuration in this UE. This makes sure the DU will exit this function immediately when it gets
353-
// call again for the same UE (upon destructor's call).
353+
// called again for the same UE (upon destructor's call).
354354
disable_pucch_cfg(cell_grp_cfg);
355355
}
356356

lib/du/du_high/du_manager/ran_resource_management/du_srs_resource_manager.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ static std::optional<unsigned> compute_srs_bw_param(unsigned nof_ul_rbs)
5757
// are placed at the center of the band.
5858
static unsigned compute_freq_shift(unsigned c_srs, unsigned nof_ul_rbs)
5959
{
60-
// As per Section 6.4.1.4.3, the parameter \f$C_{SRS}\f$ = 0 provides the bandwidth of the SRS resources.
60+
// As per Section 6.4.1.4.3, the parameter \f$m_{SRS}\f$ = 0 is an index that, along with \f$C_{SRS}\f$, maps to the
61+
// bandwidth of the SRS resources.
6162
constexpr uint8_t b_srs_0 = 0;
6263
std::optional<srsran::srs_configuration> srs_params = srs_configuration_get(c_srs, b_srs_0);
6364
srsran_sanity_check(srs_params.has_value() and nof_ul_rbs >= srs_params.value().m_srs,
@@ -137,20 +138,22 @@ du_srs_policy_max_ul_th::du_srs_policy_max_ul_th(span<const du_cell_config> cell
137138
cell.cell_srs_res_list = generate_cell_srs_list(cell.cell_cfg);
138139

139140
const auto srs_period_slots = static_cast<unsigned>(cell.cell_cfg.srs_cfg.srs_period.value());
140-
cell.slot_resource_cnt.reserve(srs_period_slots);
141+
// Reserve the size of the vector and set the SRS counter of each offset to 0.
142+
cell.slot_resource_cnt.assign(srs_period_slots, 0U);
141143
cell.srs_res_offset_free_list.reserve(du_srs_policy_max_ul_th::cell_context::max_nof_srs_res);
144+
cell.nof_res_per_symb_interval = static_cast<unsigned>(cell.cell_cfg.srs_cfg.tx_comb) *
145+
static_cast<unsigned>(cell.cell_cfg.srs_cfg.cyclic_shift_reuse_factor) *
146+
static_cast<unsigned>(cell.cell_cfg.srs_cfg.sequence_id_reuse_factor);
142147

143148
for (unsigned offset = 0; offset != srs_period_slots; ++offset) {
144149
// We don't generate more than the maximum number of SRS resources per cell.
145150
if (cell.srs_res_offset_free_list.size() >= du_srs_policy_max_ul_th::cell_context::max_nof_srs_res) {
146151
break;
147152
}
148153

149-
unsigned offset_res_cnt = 0U;
150154
// Verify whether the offset maps to a partially- or fully-UL slot.
151155
if (cell_cfg_list_[0].tdd_ul_dl_cfg_common.has_value() and
152156
not is_ul_slot(offset, cell_cfg_list_[0].tdd_ul_dl_cfg_common.value())) {
153-
cell.slot_resource_cnt.emplace_back(0U, offset_res_cnt);
154157
continue;
155158
}
156159

@@ -164,6 +167,8 @@ du_srs_policy_max_ul_th::du_srs_policy_max_ul_th(span<const du_cell_config> cell
164167
if (is_partually_ul_slot(offset, cell_cfg_list_[0].tdd_ul_dl_cfg_common.value())) {
165168
const unsigned slot_index =
166169
offset % (NOF_SUBFRAMES_PER_FRAME * get_nof_slots_per_subframe(tdd_cfg.ref_scs));
170+
// As per Section 6.4.1.4.1, TS 38.211, the SRS resources can only be placed in the last 6 symbols of the
171+
// slot.
167172
static constexpr unsigned max_srs_symbols = 6U;
168173
const unsigned nof_ul_symbols_for_srs =
169174
std::min(srsran::get_active_tdd_ul_symbols(tdd_cfg, slot_index, cyclic_prefix::NORMAL).length(),
@@ -185,9 +190,7 @@ du_srs_policy_max_ul_th::du_srs_policy_max_ul_th(span<const du_cell_config> cell
185190
}
186191
}
187192
cell.srs_res_offset_free_list.emplace_back(res.cell_res_id, offset);
188-
++offset_res_cnt;
189193
}
190-
cell.slot_resource_cnt.emplace_back(0U, offset_res_cnt);
191194
}
192195
}
193196
}
@@ -208,8 +211,8 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
208211
return true;
209212
}
210213

211-
// The UE SRS configuration is taken from a base configuration, saved in the GNB. The details that are
212-
// UE specific will be added later on in this function.
214+
// The UE SRS configuration is taken from a base configuration, saved in the GNB. The UE specific parameters will be
215+
// added later on in this function.
213216
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.emplace(
214217
cells[cell_grp_cfg.cells[0].serv_cell_cfg.cell_index].default_srs_cfg);
215218
srs_config& ue_srs_cfg = cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.value();
@@ -222,7 +225,7 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
222225
return false;
223226
}
224227

225-
// Find the best resource ID and offset for this UE.
228+
// Find the best resource ID and offset for this UE, according to the class policy.
226229
auto srs_res_id_offset = cells[0].find_optimal_ue_srs_resource();
227230

228231
if (srs_res_id_offset == free_srs_list.end()) {
@@ -278,22 +281,23 @@ bool du_srs_policy_max_ul_th::alloc_resources(cell_group_config& cell_grp_cfg)
278281
// Remove the allocated SRS resource from the free list.
279282
free_srs_list.erase(srs_res_id_offset);
280283

281-
// Update the used_not_full slot vector.
282-
++cells[0].slot_resource_cnt[srs_offset].first;
284+
// Update the SRS resource per slot counter.
285+
++cells[0].slot_resource_cnt[srs_offset];
283286

284287
return true;
285288
}
286289

287290
std::vector<std::pair<unsigned, unsigned>>::const_iterator
288291
du_srs_policy_max_ul_th::cell_context::find_optimal_ue_srs_resource()
289292
{
290-
// The weights assigned here can be set to any value, as long as:
293+
// The weights assigned here can be set to arbitrarily value, as long as:
291294
// - symbol_weight_base is greater than 0;
292-
// - reuse_slot_discount less than symbol_weight_base;
293-
// - max_weight is > symbol_weight_base * (srs_builder_params::max_nof_symbols /
294-
// srs_builder_params::nof_symbols).
295+
// - reuse_slot_discount is less than symbol_weight_base;
296+
// - max_weight > symbol_weight_base * (srs_builder_params::max_nof_symbols / srs_builder_params::nof_symbols).
295297
static constexpr unsigned max_weight = 100U;
296298
static constexpr unsigned symbol_weight_base = 10U;
299+
// We give a discount to the symbol weight if the offset is already used but not full.
300+
static const unsigned partial_symb_interval_discount = symbol_weight_base / 2U;
297301

298302
const auto weight_function = [&](const pair_res_id_offset& srs_res) {
299303
if (cell_cfg.tdd_ul_dl_cfg_common.has_value() and
@@ -308,15 +312,16 @@ du_srs_policy_max_ul_th::cell_context::find_optimal_ue_srs_resource()
308312
return max_weight;
309313
}
310314

311-
// Give priority to the last symbols within a slot. This reduces the space used for the SRS in a slot.
315+
// Give priority to the last symbol intervals within a slot. This reduces the space used for the SRS in a slot.
312316
const unsigned symb_weight =
313317
symbol_weight_base *
314318
((NOF_OFDM_SYM_PER_SLOT_NORMAL_CP - srs_res_cfg_it->symbols.start()) / srs_res_cfg_it->symbols.length());
315319

316320
// We consider a discount if the offset is already used but not full; this way, we give an incentive
317321
// to the SRS resources not to be allocated on a new slot, to avoid taking PUSCH symbols on a new
318322
// slot.
319-
const unsigned reuse_slot_discount = offset_used_not_full(srs_res.second) ? symbol_weight_base / 2U : 0U;
323+
const unsigned reuse_slot_discount =
324+
offset_interval_used_not_full(srs_res.second) ? partial_symb_interval_discount : 0U;
320325

321326
return symb_weight - reuse_slot_discount;
322327
};
@@ -346,11 +351,11 @@ void du_srs_policy_max_ul_th::dealloc_resources(cell_group_config& cell_grp_cfg)
346351
free_srs_list.emplace_back(srs_res.id.cell_res_id, offset_to_deallocate);
347352

348353
// Update the used_not_full slot vector.
349-
srsran_assert(cells[0].slot_resource_cnt[offset_to_deallocate].first != 0, "The offset is expected to be non-zero");
350-
--cells[0].slot_resource_cnt[offset_to_deallocate].first;
354+
srsran_assert(cells[0].slot_resource_cnt[offset_to_deallocate] != 0, "The offset is expected to be non-zero");
355+
--cells[0].slot_resource_cnt[offset_to_deallocate];
351356
}
352357

353358
// Reset the SRS configuration in this UE. This makes sure the DU will exit this function immediately when it gets
354-
// call again for the same UE (upon destructor's call).
359+
// called again for the same UE (upon destructor's call).
355360
cell_grp_cfg.cells[0].serv_cell_cfg.ul_config->init_ul_bwp.srs_cfg.reset();
356361
}

lib/du/du_high/du_manager/ran_resource_management/du_srs_resource_manager.h

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ class du_srs_resource_manager
3737
};
3838

3939
/// This class implements the MAX UL throughput policy for the SRS allocation. The SRS resources are allocated with the
40-
/// objective to minimize the number of slots that contains the SRS resources; furthermore, within a given slot, the SRS
41-
/// resources are allocated to minimize the number of symbols that are used for SRS. The drawback of this policy is that
42-
/// it can increase the inter slot SRS interference among different UEs.
40+
/// objective to minimize the number of slots and symbols that contain the SRS resources, to reduce as much as possible
41+
/// the slots and symbols resources taken from the PUSCH. The drawback of this policy is that it can increase the
42+
/// inter-slot SRS interference among different UEs.
4343
class du_srs_policy_max_ul_th : public du_srs_resource_manager
4444
{
4545
public:
4646
explicit du_srs_policy_max_ul_th(span<const du_cell_config> cell_cfg_list_);
4747

48+
/// The SRS resources are allocate according to the following policy:
49+
/// - Give priority to resources that are placed on partially-UL slots, first.
50+
/// - Then, give priority to SRS resources that is placed on the symbol interval (i.e, the symbols interval used by an
51+
/// SRS resource) closest to the end of the slot.
52+
/// - If a symbol interval on a particular slot is already used and not completely full, then give priority to this
53+
/// symbol interval over any other symbol intervals on the same or on different slots.
4854
bool alloc_resources(cell_group_config& cell_grp_cfg) override;
4955

5056
void dealloc_resources(cell_group_config& cell_grp_cfg) override;
@@ -53,8 +59,6 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
5359
struct cell_context {
5460
cell_context(const du_cell_config& cfg);
5561

56-
using pair_res_id_offset = std::pair<unsigned, unsigned>;
57-
5862
// Returns the DU SRS resource with the given cell resource ID from the cell list of resources.
5963
std::vector<du_srs_resource>::const_iterator get_du_srs_res_cfg(unsigned cell_res_id)
6064
{
@@ -65,15 +69,22 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
6569
return cell_srs_res_list.cbegin() + cell_res_id;
6670
}
6771

72+
using pair_res_id_offset = std::pair<unsigned, unsigned>;
73+
6874
// Returns the best SRS resource ID and offset for this UE, according to the policy defined in this class.
6975
std::vector<pair_res_id_offset>::const_iterator find_optimal_ue_srs_resource();
7076

71-
// Check if this SRS offset has already some SRS resources allocated, but can still host more.
72-
bool offset_used_not_full(unsigned offset) const
77+
// Check if this SRS offset has already some SRS resources allocated at a given symbol interval, but can still host
78+
// more.
79+
bool offset_interval_used_not_full(unsigned offset) const
7380
{
81+
// The counter of SRS resources counts how many resources have been allocated in the current slot (offset).
82+
// If the counter is 0, then the offset is free.
83+
// If the counter is a non-zero multiple (i.e, N) of nof_res_per_symb_interval, then the symbol interval of index
84+
// N-1 has been filled completely and the next symbol interval of index N is free. In any other case, the symbol
85+
// interval N-1 is partially filled.
7486
srsran_assert(offset < slot_resource_cnt.size(), "Offset out of range");
75-
return slot_resource_cnt[offset].first != 0 and
76-
slot_resource_cnt[offset].first < slot_resource_cnt[offset].second;
87+
return slot_resource_cnt[offset] % nof_res_per_symb_interval != 0U;
7788
}
7889

7990
// Parameters that are common to all cell SRS resources.
@@ -82,8 +93,6 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
8293
unsigned freq_shift;
8394
};
8495

85-
using pair_cnt_max = std::pair<unsigned, const unsigned>;
86-
8796
// Maximum number of SRS resources that can be generated in a cell.
8897
// [Implementation-defined] We assume each UE has one and only one resource.
8998
static const unsigned max_nof_srs_res = MAX_NOF_DU_UES;
@@ -96,8 +105,9 @@ class du_srs_policy_max_ul_th : public du_srs_resource_manager
96105
std::vector<du_srs_resource> cell_srs_res_list;
97106
// List of SRS resource ID and offset that can be allocated to the cell's UEs.
98107
std::vector<pair_res_id_offset> srs_res_offset_free_list;
99-
// Counter of how many SRS resources (current counter, max_counter) that can be allocated in the same slot (offset).
100-
std::vector<pair_cnt_max> slot_resource_cnt;
108+
unsigned nof_res_per_symb_interval = 0;
109+
// Counter of how many SRS resources that are allocated per slot (offset).
110+
std::vector<unsigned> slot_resource_cnt;
101111
};
102112

103113
// Contains the resources for the different cells of the DU.

tests/unittests/du_manager/du_ran_resource_manager_test.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -830,14 +830,13 @@ static cell_config_builder_params make_cell_cfg_params(const srs_params& params)
830830

831831
static du_cell_config make_srs_base_du_cell_config(const cell_config_builder_params& params)
832832
{
833-
// This function generates a configuration which would potentially allow for very large number of SRS resources.
833+
// This function generates a configuration which would potentially allow for a very large number of SRS resources.
834834
du_cell_config du_cfg = config_helpers::make_default_du_cell_config(params);
835835
auto& srs_cfg = du_cfg.srs_cfg;
836836

837837
// Generates a random SRS configuration.
838-
srs_cfg.tx_comb = test_rgen::bernoulli(0.5) ? tx_comb_size::n2 : tx_comb_size::n4;
839-
srs_cfg.max_nof_symbols = test_rgen::uniform_int<unsigned>(1U, 6U);
840-
// The number of SRS symbols cannot exceed the number of
838+
srs_cfg.tx_comb = test_rgen::bernoulli(0.5) ? tx_comb_size::n2 : tx_comb_size::n4;
839+
srs_cfg.max_nof_symbols = test_rgen::uniform_int<unsigned>(1U, 6U);
841840
std::array<srs_nof_symbols, 3> nof_symb_values = {srs_nof_symbols::n1, srs_nof_symbols::n2, srs_nof_symbols::n4};
842841
srs_cfg.nof_symbols = nof_symb_values[test_rgen::uniform_int<unsigned>(0, nof_symb_values.size() - 1)];
843842
while (srs_cfg.nof_symbols > srs_cfg.max_nof_symbols) {
@@ -896,7 +895,7 @@ static du_cell_config make_srs_du_cell_config(const cell_config_builder_params&
896895
{
897896
auto du_cfg = make_srs_base_du_cell_config(params);
898897

899-
// For the optimality test, we to have a configuration that doesn't allow more than 1024 SRS resources.
898+
// For the optimality test, we to have a configuration that doesn't allow for more than 1024 SRS resources.
900899
if (not limit_srs_res) {
901900
return du_cfg;
902901
}
@@ -906,14 +905,14 @@ static du_cell_config make_srs_du_cell_config(const cell_config_builder_params&
906905
auto tot_num_srs_res = [&du_cfg]() {
907906
auto& tdd_cfg = du_cfg.tdd_ul_dl_cfg_common;
908907
auto& srs_cfg = du_cfg.srs_cfg;
909-
// This is the number of SRS resources per symbol interval.
908+
// This is the number of SRS resources per symbol interval. A symbol interval is an interval where the SRS resource
909+
// can be placed within a slot and its width (or length) is given by the corresponding SRS parameter \c nof_symb in
910+
// the SRS configuration.
910911
const unsigned nof_res_per_symb_interval = srs_cfg.sequence_id_reuse_factor *
911912
static_cast<unsigned>(srs_cfg.cyclic_shift_reuse_factor) *
912913
static_cast<unsigned>(srs_cfg.tx_comb);
913914

914-
// A symbol interval is an interval where the SRS resource can be placed within a slot and its width (or length) is
915-
// given by the corresponding SRS parameter \c nof_symb in the SRS configuration. This "number of symbols intervals"
916-
// counts all the symbols intervals within the SRS period.
915+
// This "number of symbols intervals" counts all the symbols intervals within the SRS period.
917916
unsigned nof_symb_intervals = 0;
918917

919918
// The number of symbols interval per slot depends on whether it's FDD or TDD.
@@ -937,6 +936,7 @@ static du_cell_config make_srs_du_cell_config(const cell_config_builder_params&
937936
}
938937
}
939938

939+
// Return the total number of SRS resources.
940940
return nof_symb_intervals * nof_res_per_symb_interval;
941941
};
942942

@@ -1046,7 +1046,7 @@ class du_srs_resource_manager_tester : public ::testing::TestWithParam<srs_param
10461046
// Helper that computes the Frequency Shift parameter (see Section 6.4.1.4.3, TS 38.211).
10471047
unsigned compute_freq_shift() const
10481048
{
1049-
// The function computes the frequency shift so that the SRS resources are placed in the center of the bandwidth.
1049+
// The function computes the frequency shift so that the SRS resources are placed in the center of the band.
10501050
unsigned c_srs = compute_c_srs();
10511051
unsigned ul_bw_nof_rbs = cell_cfg_list[0].ul_cfg_common.init_ul_bwp.generic_params.crbs.length();
10521052
const auto srs_cfg = srs_configuration_get(c_srs, 0U);

0 commit comments

Comments
 (0)