|
16 | 16 | #include "nzp_csi_rs_generator_impl.h" |
17 | 17 | #include "nzp_csi_rs_generator_pool.h" |
18 | 18 | #include "port_channel_estimator_average_impl.h" |
| 19 | +#include "port_channel_estimator_pool.h" |
19 | 20 | #include "pss_processor_impl.h" |
20 | 21 | #include "pucch/dmrs_pucch_estimator_format2.h" |
21 | 22 | #include "pucch/dmrs_pucch_estimator_formats3_4.h" |
|
25 | 26 | #include "srsran/phy/support/support_formatters.h" |
26 | 27 | #include "srsran/phy/support/time_alignment_estimator/time_alignment_estimator_factories.h" |
27 | 28 | #include "srsran/phy/upper/signal_processors/signal_processor_formatters.h" |
| 29 | +#include <map> |
28 | 30 |
|
29 | 31 | using namespace srsran; |
30 | 32 |
|
@@ -270,6 +272,56 @@ class port_channel_estimator_factory_sw : public port_channel_estimator_factory |
270 | 272 | std::shared_ptr<time_alignment_estimator_factory> ta_estimator_factory; |
271 | 273 | }; |
272 | 274 |
|
| 275 | +class port_channel_estimator_pool_factory : public port_channel_estimator_factory |
| 276 | +{ |
| 277 | +public: |
| 278 | + port_channel_estimator_pool_factory(std::shared_ptr<port_channel_estimator_factory> factory_, |
| 279 | + unsigned nof_concurrent_threads_) : |
| 280 | + factory(std::move(factory_)), nof_concurrent_threads(nof_concurrent_threads_) |
| 281 | + { |
| 282 | + srsran_assert(factory, "Invalid port channel estimator factory."); |
| 283 | + srsran_assert(nof_concurrent_threads > 1, "Number of concurrent threads must be greater than one."); |
| 284 | + } |
| 285 | + |
| 286 | + std::unique_ptr<port_channel_estimator> |
| 287 | + create(port_channel_estimator_fd_smoothing_strategy fd_smoothing_strategy, |
| 288 | + port_channel_estimator_td_interpolation_strategy td_interpolation_strategy, |
| 289 | + bool compensate_cfo) override |
| 290 | + { |
| 291 | + auto& this_estimator_pool = estimators[{fd_smoothing_strategy, td_interpolation_strategy, compensate_cfo}]; |
| 292 | + if (!this_estimator_pool) { |
| 293 | + std::vector<std::unique_ptr<port_channel_estimator>> instances(nof_concurrent_threads); |
| 294 | + std::generate(instances.begin(), |
| 295 | + instances.end(), |
| 296 | + [this, fd_smoothing_strategy, td_interpolation_strategy, compensate_cfo]() { |
| 297 | + return factory->create(fd_smoothing_strategy, td_interpolation_strategy, compensate_cfo); |
| 298 | + }); |
| 299 | + this_estimator_pool = std::make_shared<port_channel_estimator_pool::estimator_pool>(instances); |
| 300 | + } |
| 301 | + return std::make_unique<port_channel_estimator_pool>(this_estimator_pool); |
| 302 | + } |
| 303 | + |
| 304 | +private: |
| 305 | + using estimator_config = |
| 306 | + std::tuple<port_channel_estimator_fd_smoothing_strategy, port_channel_estimator_td_interpolation_strategy, bool>; |
| 307 | + |
| 308 | + struct config_hash { |
| 309 | + size_t operator()(const estimator_config& c) const noexcept |
| 310 | + { |
| 311 | + size_t h1 = std::hash<int>{}(static_cast<int>(std::get<0>(c))); |
| 312 | + size_t h2 = std::hash<int>{}(static_cast<int>(std::get<1>(c))); |
| 313 | + size_t h3 = std::hash<bool>{}(std::get<2>(c)); |
| 314 | + |
| 315 | + return (h1 ^ (h2 << 1) ^ (h3 << 2)); |
| 316 | + } |
| 317 | + }; |
| 318 | + |
| 319 | + std::shared_ptr<port_channel_estimator_factory> factory; |
| 320 | + unsigned nof_concurrent_threads; |
| 321 | + std::unordered_map<estimator_config, std::shared_ptr<port_channel_estimator_pool::estimator_pool>, config_hash> |
| 322 | + estimators; |
| 323 | +}; |
| 324 | + |
273 | 325 | class pss_processor_factory_sw : public pss_processor_factory |
274 | 326 | { |
275 | 327 | public: |
@@ -349,6 +401,13 @@ srsran::create_port_channel_estimator_factory_sw(std::shared_ptr<time_alignment_ |
349 | 401 | return std::make_shared<port_channel_estimator_factory_sw>(std::move(ta_estimator_factory)); |
350 | 402 | } |
351 | 403 |
|
| 404 | +std::shared_ptr<port_channel_estimator_factory> |
| 405 | +srsran::create_port_channel_estimator_pool_factory(std::shared_ptr<port_channel_estimator_factory> ch_est_factory, |
| 406 | + unsigned nof_concurrent_threads) |
| 407 | +{ |
| 408 | + return std::make_shared<port_channel_estimator_pool_factory>(std::move(ch_est_factory), nof_concurrent_threads); |
| 409 | +} |
| 410 | + |
352 | 411 | std::shared_ptr<pss_processor_factory> srsran::create_pss_processor_factory_sw() |
353 | 412 | { |
354 | 413 | return std::make_shared<pss_processor_factory_sw>(); |
|
0 commit comments