diff --git a/.gitlab/ci/e2e/.env b/.gitlab/ci/e2e/.env index 45c8845504..b1609c6f3b 100644 --- a/.gitlab/ci/e2e/.env +++ b/.gitlab/ci/e2e/.env @@ -1,6 +1,6 @@ SRSGNB_REGISTRY_URI=registry.gitlab.com/softwareradiosystems/srsgnb RETINA_REGISTRY_PREFIX=registry.gitlab.com/softwareradiosystems/ci/retina -RETINA_VERSION=0.54.13 +RETINA_VERSION=0.54.16 UBUNTU_VERSION=24.04 AMARISOFT_VERSION=2023-09-08 SRSUE_VERSION=23.11 diff --git a/CMakeLists.txt b/CMakeLists.txt index 556b0fe092..65fa2eb40f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,14 +276,14 @@ if (ENABLE_FFTW) endif (ENABLE_FFTW) # MKL -if (ENABLE_MKL) +if (ENABLE_MKL AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") find_package(MKL) -endif (ENABLE_MKL) +endif (ENABLE_MKL AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") # ARMPL -if (ENABLE_ARMPL) +if (ENABLE_ARMPL AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") find_package(ARMPL) -endif (ENABLE_ARMPL) +endif (ENABLE_ARMPL AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") # Google Tests if (BUILD_TESTS) diff --git a/apps/examples/phy/radio_ssb.cpp b/apps/examples/phy/radio_ssb.cpp index 94be67e10f..7a9a507e7a 100644 --- a/apps/examples/phy/radio_ssb.cpp +++ b/apps/examples/phy/radio_ssb.cpp @@ -268,11 +268,8 @@ static const auto profiles = to_array({ }); /// Global instances. -static std::mutex stop_execution_mutex; -static std::atomic stop = {false}; -static std::unique_ptr upper_phy = nullptr; -static std::unique_ptr lower_phy_instance = nullptr; -static std::unique_ptr radio = nullptr; +static std::mutex stop_execution_mutex; +static std::atomic stop = {false}; static void stop_execution() { @@ -286,12 +283,6 @@ static void stop_execution() // Signal program to stop. stop = true; - - // Stop radio. It stops blocking the radio transmit and receive operations. The timing handler prevents the PHY from - // free running. - if (radio != nullptr) { - radio->stop(); - } } /// Function to call when the application is interrupted. @@ -474,6 +465,7 @@ lower_phy_configuration create_lower_phy_configuration(task_executor* lower_phy_metrics_notifier* metrics_notifier, lower_phy_rx_symbol_notifier* rx_symbol_notifier, lower_phy_timing_notifier* timing_notifier, + baseband_gateway& bb_gateway, srslog::basic_logger* logger) { lower_phy_configuration phy_config; @@ -485,7 +477,7 @@ lower_phy_configuration create_lower_phy_configuration(task_executor* phy_config.ta_offset = n_ta_offset::n0; phy_config.cp = cp; phy_config.dft_window_offset = 0.5F; - phy_config.bb_gateway = &radio->get_baseband_gateway(0); + phy_config.bb_gateway = &bb_gateway; phy_config.rx_symbol_notifier = rx_symbol_notifier; phy_config.timing_notifier = timing_notifier; phy_config.error_notifier = error_notifier; @@ -618,7 +610,7 @@ int main(int argc, char** argv) radio_notifier_spy notification_handler(log_level); // Create radio. - radio = factory->create(radio_config, *async_task_executor, notification_handler); + std::unique_ptr radio = factory->create(radio_config, *async_task_executor, notification_handler); srsran_assert(radio, "Failed to create radio."); // Create symbol handler. @@ -637,6 +629,7 @@ int main(int argc, char** argv) phy_rx_symbol_request_adapter phy_rx_symbol_req_adapter; // Create lower physical layer. + std::unique_ptr lower_phy_instance = nullptr; { // Prepare lower physical layer configuration. lower_phy_configuration phy_config = create_lower_phy_configuration(rx_task_executor.get(), @@ -648,6 +641,7 @@ int main(int argc, char** argv) &metrics_adapter, &rx_symbol_adapter, &timing_adapter, + radio->get_baseband_gateway(0), &logger); lower_phy_instance = create_lower_phy(phy_config); srsran_assert(lower_phy_instance, "Failed to create lower physical layer."); @@ -706,7 +700,7 @@ int main(int argc, char** argv) upper_phy_sample_config.enable_ul_processing = enable_ul_processing; upper_phy_sample_config.enable_prach_processing = enable_prach_processing; upper_phy_sample_config.data_modulation = data_mod_scheme; - upper_phy = upper_phy_ssb_example::create(upper_phy_sample_config); + std::unique_ptr upper_phy = upper_phy_ssb_example::create(upper_phy_sample_config); srsran_assert(upper_phy, "Failed to create upper physical layer."); // Connect adapters. @@ -733,6 +727,12 @@ int main(int argc, char** argv) // Stop execution. stop_execution(); + // Stop radio. It stops blocking the radio transmit and receive operations. The timing handler prevents the PHY from + // free running. + if (radio != nullptr) { + radio->stop(); + } + // Stop the timing handler. It stops blocking notifier and allows the PHY to free run. upper_phy->stop(); @@ -749,5 +749,10 @@ int main(int argc, char** argv) // Prints radio notification summary (number of overflow, underflow and other events). notification_handler.print(); + // Destroy physical layer components in the correct order. + lower_phy_instance.reset(); + upper_phy.reset(); + radio.reset(); + return 0; } diff --git a/apps/gnb/CMakeLists.txt b/apps/gnb/CMakeLists.txt index 5d16351cb4..667459979a 100644 --- a/apps/gnb/CMakeLists.txt +++ b/apps/gnb/CMakeLists.txt @@ -52,14 +52,6 @@ target_link_libraries(gnb if (DPDK_FOUND) add_definitions(-DDPDK_FOUND) target_link_libraries(gnb hal_dpdk) - if (ENABLE_PUSCH_HWACC) - add_definitions(-DENABLE_PUSCH_HWACC) - target_link_libraries(gnb srsran_hal_pusch srsran_hal_bbdev) - endif (ENABLE_PUSCH_HWACC) - if (ENABLE_PDSCH_HWACC) - add_definitions(-DENABLE_PDSCH_HWACC) - target_link_libraries(gnb srsran_hal_pdsch srsran_hal_bbdev) - endif (ENABLE_PDSCH_HWACC) endif (DPDK_FOUND) add_backward(gnb) diff --git a/apps/units/cu_up/cu_up_unit_pcap_config.h b/apps/units/cu_up/cu_up_unit_pcap_config.h index c30cc4da5d..036104db7d 100644 --- a/apps/units/cu_up/cu_up_unit_pcap_config.h +++ b/apps/units/cu_up/cu_up_unit_pcap_config.h @@ -41,8 +41,8 @@ struct cu_up_unit_pcap_config { bool enabled = false; } e1ap; struct { - std::string filename; - bool enabled = false; + std::string filename = "/tmp/cu_up_e2ap.pcap"; + bool enabled = false; } e2ap; /// When using the gNB app, there is no point in instantiating diff --git a/apps/units/flexible_du/o_du_low/CMakeLists.txt b/apps/units/flexible_du/o_du_low/CMakeLists.txt index 3c96c250ec..5471b88742 100644 --- a/apps/units/flexible_du/o_du_low/CMakeLists.txt +++ b/apps/units/flexible_du/o_du_low/CMakeLists.txt @@ -23,6 +23,7 @@ set(SOURCES du_low_config_translator.cpp du_low_config_validator.cpp du_low_config_yaml_writer.cpp + du_low_hal_factory.cpp o_du_low_unit_factory.cpp) add_library(srsran_o_du_low_unit_helpers STATIC ${SOURCES}) @@ -31,7 +32,7 @@ set(DU_LOW_UNIT_HELPERS_LIBRARIES srsran_upper_phy srsran_cpu_affinities_helper) # Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. if (DPDK_FOUND) - set_source_files_properties(${SOURCES} PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") + set_source_files_properties(du_low_hal_factory.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") list(APPEND DU_LOW_UNIT_HELPERS_LIBRARIES srsran_hal_pusch srsran_hal_pdsch srsran_hal_bbdev) diff --git a/apps/units/flexible_du/o_du_low/du_low_hal_factory.cpp b/apps/units/flexible_du/o_du_low/du_low_hal_factory.cpp new file mode 100644 index 0000000000..3fd9da8168 --- /dev/null +++ b/apps/units/flexible_du/o_du_low/du_low_hal_factory.cpp @@ -0,0 +1,113 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsRAN is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#include "du_low_hal_factory.h" +#include "srsran/ran/sch/sch_constants.h" +#ifdef DPDK_FOUND +#include "srsran/hal/dpdk/bbdev/bbdev_acc_factory.h" +#include "srsran/hal/phy/upper/channel_processors/hw_accelerator_factories.h" +#include "srsran/hal/phy/upper/channel_processors/pusch/ext_harq_buffer_context_repository_factory.h" +#include "srsran/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.h" +#endif // DPDK_FOUND + +using namespace srsran; + +#ifdef DPDK_FOUND +std::shared_ptr +srsran::init_bbdev_hwacc(const bbdev_appconfig& bbdev_app_cfg, srslog::basic_logger& logger, unsigned nof_hwacc_dus) +{ + // Initialize the bbdev-based hardware accelerator, if required. + static std::shared_ptr bbdev_accelerator = [bbdev_app_cfg, &logger, nof_hwacc_dus]() { + // Intefacing to the bbdev-based hardware-accelerator. + dpdk::bbdev_acc_configuration bbdev_config; + bbdev_config.id = bbdev_app_cfg.id; + if (bbdev_app_cfg.pdsch_enc && bbdev_app_cfg.pdsch_enc->nof_hwacc > 0) { + bbdev_config.nof_ldpc_enc_lcores = nof_hwacc_dus * bbdev_app_cfg.pdsch_enc->nof_hwacc; + } + if (bbdev_app_cfg.pusch_dec && bbdev_app_cfg.pusch_dec->nof_hwacc > 0) { + bbdev_config.nof_ldpc_dec_lcores = nof_hwacc_dus * bbdev_app_cfg.pusch_dec->nof_hwacc; + } + // If no msg_mbuf size is defined, a worst-case value will be used. + bbdev_config.msg_mbuf_size = bbdev_app_cfg.msg_mbuf_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); + // If no rm_mbuf size is defined, a worst-case value will be used. + bbdev_config.rm_mbuf_size = bbdev_app_cfg.rm_mbuf_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); + // If no number of mbufs is defined, a worst-case value will be used. + bbdev_config.nof_mbuf = bbdev_app_cfg.nof_mbuf.value_or(static_cast(pow2(log2_ceil(MAX_NOF_SEGMENTS)))); + std::shared_ptr bbdev_acc = create_bbdev_acc(bbdev_config, logger); + report_error_if_not(bbdev_acc, "Unable to open the {} hardware-accelerator.", bbdev_app_cfg.hwacc_type); + return bbdev_acc; + }(); + + return bbdev_accelerator; +} +#endif // DPDK_FOUND + +o_du_low_hal_dependencies srsran::make_du_low_hal_dependencies(const du_low_unit_config& du_low_unit_cfg, + unsigned nof_cells) +{ + o_du_low_hal_dependencies hal_dependencies; + + // Initialize hardware-accelerator (only once and if needed). +#ifdef DPDK_FOUND + if (du_low_unit_cfg.hal_config && du_low_unit_cfg.hal_config->bbdev_hwacc && + !du_low_unit_cfg.hal_config->bbdev_hwacc->hwacc_type.empty()) { + const bbdev_appconfig& bbdev_app_cfg = du_low_unit_cfg.hal_config->bbdev_hwacc.value(); + srslog::basic_logger& hwacc_logger = srslog::fetch_basic_logger("HWACC", false); + hwacc_logger.set_level(du_low_unit_cfg.loggers.hal_level); + + // Create a hardware-accelerated PDSCH encoder factory (only if needed). + if (bbdev_app_cfg.pdsch_enc && bbdev_app_cfg.pdsch_enc->nof_hwacc > 0) { + hal::bbdev_hwacc_pdsch_enc_factory_configuration hwacc_pdsch_enc_cfg; + hwacc_pdsch_enc_cfg.acc_type = bbdev_app_cfg.hwacc_type; + hwacc_pdsch_enc_cfg.bbdev_accelerator = init_bbdev_hwacc(bbdev_app_cfg, hwacc_logger, nof_cells); + hwacc_pdsch_enc_cfg.cb_mode = bbdev_app_cfg.pdsch_enc->cb_mode; + // If no maximum buffer size is defined, a worst-case value will be used. + hwacc_pdsch_enc_cfg.max_tb_size = bbdev_app_cfg.pdsch_enc->max_buffer_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); + hwacc_pdsch_enc_cfg.dedicated_queue = bbdev_app_cfg.pdsch_enc->dedicated_queue; + hal_dependencies.hw_encoder_factory = hal::create_bbdev_pdsch_enc_acc_factory(hwacc_pdsch_enc_cfg); + } + + // // Create a hardware-accelerated PUSCH decoder factory (only if needed). + if (bbdev_app_cfg.pusch_dec && bbdev_app_cfg.pusch_dec->nof_hwacc > 0) { + hal::bbdev_hwacc_pusch_dec_factory_configuration hwacc_pusch_dec_cfg; + std::shared_ptr harq_buffer_context = nullptr; + hwacc_pusch_dec_cfg.acc_type = bbdev_app_cfg.hwacc_type; + hwacc_pusch_dec_cfg.bbdev_accelerator = init_bbdev_hwacc(bbdev_app_cfg, hwacc_logger, nof_cells); + hwacc_pusch_dec_cfg.ext_softbuffer = bbdev_app_cfg.pusch_dec->ext_softbuffer; + if (hwacc_pusch_dec_cfg.ext_softbuffer) { + // Set up an external HARQ buffer context repository. + unsigned nof_cbs = bbdev_app_cfg.pusch_dec->harq_context_size.value_or(MAX_NOF_SEGMENTS); + uint64_t ext_harq_buff_size = hwacc_pusch_dec_cfg.bbdev_accelerator->get_harq_buff_size_bytes(); + harq_buffer_context = hal::create_ext_harq_buffer_context_repository(nof_cbs, ext_harq_buff_size, false); + report_error_if_not(harq_buffer_context, + "Unable to create the external HARQ buffer context for the {} hardware-accelerator.", + bbdev_app_cfg.hwacc_type); + hwacc_pusch_dec_cfg.harq_buffer_context = harq_buffer_context; + } + hwacc_pusch_dec_cfg.dedicated_queue = bbdev_app_cfg.pusch_dec->dedicated_queue; + hal_dependencies.hw_decoder_factory = hal::create_bbdev_pusch_dec_acc_factory(hwacc_pusch_dec_cfg); + } + } +#endif // DPDK_FOUND + + return hal_dependencies; +} diff --git a/apps/units/flexible_du/o_du_low/du_low_hal_factory.h b/apps/units/flexible_du/o_du_low/du_low_hal_factory.h new file mode 100644 index 0000000000..e55101a2d5 --- /dev/null +++ b/apps/units/flexible_du/o_du_low/du_low_hal_factory.h @@ -0,0 +1,58 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsRAN is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#pragma once + +#include "du_low_config.h" +#include "srsran/hal/phy/upper/channel_processors/hw_accelerator_pdsch_enc_factory.h" +#include "srsran/hal/phy/upper/channel_processors/pusch/hw_accelerator_pusch_dec_factory.h" +#include "srsran/srslog/srslog.h" + +#ifdef DPDK_FOUND +#include "srsran/hal/dpdk/bbdev/bbdev_acc.h" +#endif // DPDK_FOUND + +namespace srsran { + +/// ORAN DU low unit HAL dependencies. +struct o_du_low_hal_dependencies { + std::shared_ptr hw_encoder_factory = nullptr; + std::shared_ptr hw_decoder_factory = nullptr; +}; + +#ifdef DPDK_FOUND +/// \brief Creates and initializes a bbdev-based hardware accelerator. +/// \param[in] bbdev_app_cfg Struct containing the DU low HAL configuration. +/// \param[in] logger SRS logger. +/// \param[in] nof_hwacc_dus Number of DU-low instances to be managed by the hardware accelerator. +/// \return A pointer to the bbdev-based accelerator interface on success, nullptr otherwise. +static std::shared_ptr +init_bbdev_hwacc(const bbdev_appconfig& bbdev_app_cfg, srslog::basic_logger& logger, unsigned nof_hwacc_dus); +#endif // DPDK_FOUND + +/// \brief Initializes the HAL depencies of the DU low unit. +/// \param[out] hal_dependencies Struct containing the DU low unit dependencies. +/// \param[in] du_low_unit_cfg Struct defining the DU low configuration. +/// \param[in] nof_cells Number of cells to be handled by the HAL. +o_du_low_hal_dependencies make_du_low_hal_dependencies(const du_low_unit_config& du_low_unit_cfg, unsigned nof_cells); + +} // namespace srsran diff --git a/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.cpp b/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.cpp index 160af37cb5..b504c25d69 100644 --- a/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.cpp +++ b/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.cpp @@ -24,28 +24,28 @@ #include "apps/services/worker_manager/worker_manager.h" #include "du_low_config.h" #include "du_low_config_translator.h" +#include "du_low_hal_factory.h" #include "srsran/du/du_low/o_du_low_factory.h" #include "srsran/ran/slot_pdu_capacity_constants.h" -#ifdef DPDK_FOUND -#include "srsran/hal/dpdk/bbdev/bbdev_acc.h" -#include "srsran/hal/dpdk/bbdev/bbdev_acc_factory.h" -#include "srsran/hal/phy/upper/channel_processors/hw_accelerator_factories.h" -#include "srsran/hal/phy/upper/channel_processors/pusch/ext_harq_buffer_context_repository_factory.h" -#include "srsran/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.h" -#endif // DPDK_FOUND using namespace srsran; static void generate_dl_processor_config(downlink_processor_factory_sw_config& out_cfg, const du_low_unit_config& unit_cfg, task_executor& pdsch_codeblock_executor, - bool hwacc_pdsch_processor) + std::shared_ptr hw_encoder_factory) { out_cfg.ldpc_encoder_type = "auto"; out_cfg.crc_calculator_type = "auto"; const du_low_unit_expert_threads_config& upper_phy_threads_cfg = unit_cfg.expert_execution_cfg.threads; + // Check hardware acceleration usage. + bool hwacc_pdsch_processor = hw_encoder_factory != nullptr; + if (hwacc_pdsch_processor) { + out_cfg.hw_encoder_factory = hw_encoder_factory; + } + // Hardware-acceleration is currently supported for 'generic' PDSCH processor types only. if ((!hwacc_pdsch_processor) && ((upper_phy_threads_cfg.pdsch_processor_type == "lite") || @@ -71,80 +71,6 @@ static void generate_dl_processor_config(downlink_processor_factory_sw_config& o out_cfg.nof_concurrent_threads = upper_phy_threads_cfg.nof_dl_threads; } -hal_upper_phy_config srsran::make_du_low_hal_config_and_dependencies(const du_low_unit_config& du_low_unit_cfg, - unsigned nof_cells) -{ - // Initialize hardware-accelerator (only if needed). - hal_upper_phy_config hal_config = {}; - hal_config.hwacc_pdsch_processor = false; - hal_config.hwacc_pusch_processor = false; -#ifdef DPDK_FOUND - if (du_low_unit_cfg.hal_config && du_low_unit_cfg.hal_config->bbdev_hwacc && - !du_low_unit_cfg.hal_config->bbdev_hwacc->hwacc_type.empty()) { - const bbdev_appconfig& bbdev_app_cfg = du_low_unit_cfg.hal_config->bbdev_hwacc.value(); - srslog::basic_logger& hwacc_logger = srslog::fetch_basic_logger("HWACC", false); - hwacc_logger.set_level(du_low_unit_cfg.loggers.hal_level); - - hal::bbdev_hwacc_pdsch_enc_factory_configuration hwacc_pdsch_enc_cfg = {}; - hal::bbdev_hwacc_pusch_dec_factory_configuration hwacc_pusch_dec_cfg = {}; - std::shared_ptr harq_buffer_context = nullptr; - unsigned nof_hwacc_dus = nof_cells; - - // Intefacing to the bbdev-based hardware-accelerator. - dpdk::bbdev_acc_configuration bbdev_config; - bbdev_config.id = bbdev_app_cfg.id; - if (bbdev_app_cfg.pdsch_enc && bbdev_app_cfg.pdsch_enc->nof_hwacc > 0) { - bbdev_config.nof_ldpc_enc_lcores = nof_hwacc_dus * bbdev_app_cfg.pdsch_enc->nof_hwacc; - } - if (bbdev_app_cfg.pusch_dec && bbdev_app_cfg.pusch_dec->nof_hwacc > 0) { - bbdev_config.nof_ldpc_dec_lcores = nof_hwacc_dus * bbdev_app_cfg.pusch_dec->nof_hwacc; - } - // If no msg_mbuf size is defined, a worst-case value will be used. - bbdev_config.msg_mbuf_size = bbdev_app_cfg.msg_mbuf_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); - // If no rm_mbuf size is defined, a worst-case value will be used. - bbdev_config.rm_mbuf_size = bbdev_app_cfg.rm_mbuf_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); - // If no number of mbufs is defined, a worst-case value will be used. - bbdev_config.nof_mbuf = bbdev_app_cfg.nof_mbuf.value_or(static_cast(pow2(log2_ceil(MAX_NOF_SEGMENTS)))); - std::shared_ptr bbdev_accelerator = create_bbdev_acc(bbdev_config, hwacc_logger); - report_error_if_not(bbdev_accelerator, "Unable to open the {} hardware-accelerator.", bbdev_app_cfg.hwacc_type); - - // Configure the hardware-accelerated PDSCH encoding factory (only if needed). - if (bbdev_app_cfg.pdsch_enc && bbdev_app_cfg.pdsch_enc->nof_hwacc > 0) { - hwacc_pdsch_enc_cfg.acc_type = bbdev_app_cfg.hwacc_type; - hwacc_pdsch_enc_cfg.bbdev_accelerator = bbdev_accelerator; - hwacc_pdsch_enc_cfg.cb_mode = bbdev_app_cfg.pdsch_enc->cb_mode; - // If no maximum buffer size is defined, a worst-case value will be used. - hwacc_pdsch_enc_cfg.max_tb_size = bbdev_app_cfg.pdsch_enc->max_buffer_size.value_or(RTE_BBDEV_LDPC_E_MAX_MBUF); - hwacc_pdsch_enc_cfg.dedicated_queue = bbdev_app_cfg.pdsch_enc->dedicated_queue; - hal_config.hwacc_pdsch_processor = true; - hal_config.hwacc_pdsch_enc_cfg = hwacc_pdsch_enc_cfg; - } - - // Configure the hardware-accelerated PUSCH decoding factory (only if needed). - if (bbdev_app_cfg.pusch_dec && bbdev_app_cfg.pusch_dec->nof_hwacc > 0) { - hwacc_pusch_dec_cfg.acc_type = bbdev_app_cfg.hwacc_type; - hwacc_pusch_dec_cfg.bbdev_accelerator = bbdev_accelerator; - hwacc_pusch_dec_cfg.ext_softbuffer = bbdev_app_cfg.pusch_dec->ext_softbuffer; - if (hwacc_pusch_dec_cfg.ext_softbuffer) { - // Set up an external HARQ buffer context repository. - unsigned nof_cbs = bbdev_app_cfg.pusch_dec->harq_context_size.value_or(MAX_NOF_SEGMENTS); - uint64_t ext_harq_buff_size = bbdev_accelerator->get_harq_buff_size_bytes(); - harq_buffer_context = hal::create_ext_harq_buffer_context_repository(nof_cbs, ext_harq_buff_size, false); - report_error_if_not(harq_buffer_context, - "Unable to create the external HARQ buffer context for the {} hardware-accelerator.", - bbdev_app_cfg.hwacc_type); - hwacc_pusch_dec_cfg.harq_buffer_context = harq_buffer_context; - } - hwacc_pusch_dec_cfg.dedicated_queue = bbdev_app_cfg.pusch_dec->dedicated_queue; - hal_config.hwacc_pusch_processor = true; - hal_config.hwacc_pusch_dec_cfg = hwacc_pusch_dec_cfg; - } - } -#endif // DPDK_FOUND - - return hal_config; -} - o_du_low_unit srsran::make_o_du_low_unit(const o_du_low_unit_config& params, const o_du_low_unit_dependencies& dependencies) { @@ -154,10 +80,8 @@ o_du_low_unit srsran::make_o_du_low_unit(const o_du_low_unit_config& param generate_o_du_low_config( o_du_low_cfg, params.du_low_unit_cfg, params.du_cells, params.max_puschs_per_slot, params.du_id); - // Fill the hal config. - for (auto& cell : o_du_low_cfg.du_low_cfg.cells) { - cell.upper_phy_cfg.hal_config = params.hal_config; - } + // Fill the HAL dependencies. + o_du_low_hal_dependencies hal_dependencies = make_du_low_hal_dependencies(params.du_low_unit_cfg, params.nof_cells); // Fill the PRACH ports. o_du_low_cfg.prach_ports = params.prach_ports; @@ -169,7 +93,7 @@ o_du_low_unit srsran::make_o_du_low_unit(const o_du_low_unit_config& param generate_dl_processor_config(cell.dl_proc_cfg, params.du_low_unit_cfg, *dependencies.workers.upper_pdsch_exec[i + params.du_id], - cell.upper_phy_cfg.hal_config.hwacc_pdsch_processor); + hal_dependencies.hw_encoder_factory); upper_phy_config& upper = cell.upper_phy_cfg; upper.rg_gateway = &dependencies.rg_gateway; @@ -179,6 +103,9 @@ o_du_low_unit srsran::make_o_du_low_unit(const o_du_low_unit_config& param upper.pusch_decoder_executor = dependencies.workers.upper_pusch_decoder_exec[i + params.du_id]; upper.prach_executor = dependencies.workers.upper_prach_exec[i + params.du_id]; upper.srs_executor = dependencies.workers.upper_srs_exec[i + params.du_id]; + if (hal_dependencies.hw_decoder_factory) { + upper.hw_decoder_factory = hal_dependencies.hw_decoder_factory; + } dependencies.workers.get_du_low_dl_executors(upper.dl_executors, i + params.du_id); } diff --git a/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.h b/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.h index fdaaccaebd..f47028f739 100644 --- a/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.h +++ b/apps/units/flexible_du/o_du_low/o_du_low_unit_factory.h @@ -35,9 +35,6 @@ struct du_cell_config; struct du_low_unit_config; struct worker_manager; -hal_upper_phy_config make_du_low_hal_config_and_dependencies(const du_low_unit_config& du_low_unit_cfg, - unsigned nof_cells); - /// ORAN DU low unit. struct o_du_low_unit { std::unique_ptr o_du_lo; @@ -46,11 +43,11 @@ struct o_du_low_unit { /// ORAN DU low unit configuration. struct o_du_low_unit_config { const du_low_unit_config& du_low_unit_cfg; - const hal_upper_phy_config& hal_config; std::vector prach_ports; span du_cells; span max_puschs_per_slot; unsigned du_id; + unsigned nof_cells; }; /// ORAN DU low unit dependencies. diff --git a/apps/units/flexible_du/split_7_2/CMakeLists.txt b/apps/units/flexible_du/split_7_2/CMakeLists.txt index 116255741d..6b61f96b63 100644 --- a/apps/units/flexible_du/split_7_2/CMakeLists.txt +++ b/apps/units/flexible_du/split_7_2/CMakeLists.txt @@ -33,11 +33,6 @@ if (DU_SPLIT_7_2) add_library(srsran_flexible_du STATIC ${SOURCES}) target_include_directories(srsran_flexible_du PRIVATE ${CMAKE_SOURCE_DIR}) - # Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. - if (DPDK_FOUND) - set_source_files_properties(split_7_2_du_factory.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") - endif (DPDK_FOUND) - target_link_libraries(srsran_flexible_du srsran_pcap srsran_app_services diff --git a/apps/units/flexible_du/split_8/CMakeLists.txt b/apps/units/flexible_du/split_8/CMakeLists.txt index 7769adac35..8ddea83c5d 100644 --- a/apps/units/flexible_du/split_8/CMakeLists.txt +++ b/apps/units/flexible_du/split_8/CMakeLists.txt @@ -33,11 +33,6 @@ if (DU_SPLIT_8) add_library(srsran_flexible_du STATIC ${SOURCES}) target_include_directories(srsran_flexible_du PRIVATE ${CMAKE_SOURCE_DIR}) - # Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. - if (DPDK_FOUND) - set_source_files_properties(split_8_du_factory.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") - endif (DPDK_FOUND) - target_link_libraries(srsran_flexible_du srsran_pcap srsran_app_services diff --git a/apps/units/flexible_du/split_dynamic/CMakeLists.txt b/apps/units/flexible_du/split_dynamic/CMakeLists.txt index 4cf7eec7a6..dab029f2bf 100644 --- a/apps/units/flexible_du/split_dynamic/CMakeLists.txt +++ b/apps/units/flexible_du/split_dynamic/CMakeLists.txt @@ -30,11 +30,6 @@ set(SOURCES add_library(srsran_flexible_du STATIC ${SOURCES}) target_include_directories(srsran_flexible_du PRIVATE ${CMAKE_SOURCE_DIR}) -# Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. -if (DPDK_FOUND) - set_source_files_properties(dynamic_du_factory.cpp multicell_dynamic_du_factory.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") -endif (DPDK_FOUND) - target_link_libraries(srsran_flexible_du srsran_ru_dummy srsran_pcap diff --git a/apps/units/flexible_du/split_helpers/CMakeLists.txt b/apps/units/flexible_du/split_helpers/CMakeLists.txt index b7c2e0e1ab..7d40fb5e85 100644 --- a/apps/units/flexible_du/split_helpers/CMakeLists.txt +++ b/apps/units/flexible_du/split_helpers/CMakeLists.txt @@ -28,11 +28,6 @@ set(SOURCES add_library(srsran_flexible_du_helpers STATIC ${SOURCES}) target_include_directories(srsran_flexible_du_helpers PRIVATE ${CMAKE_SOURCE_DIR}) -# Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. -if (DPDK_FOUND) - set_source_files_properties(flexible_du_factory.cpp multicell_flexible_du_factory.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") -endif (DPDK_FOUND) - target_link_libraries(srsran_flexible_du_helpers srsran_o_du srsran_ru_dummy diff --git a/apps/units/flexible_du/split_helpers/flexible_du_factory.cpp b/apps/units/flexible_du/split_helpers/flexible_du_factory.cpp index 455105191a..7fb6854634 100644 --- a/apps/units/flexible_du/split_helpers/flexible_du_factory.cpp +++ b/apps/units/flexible_du/split_helpers/flexible_du_factory.cpp @@ -57,19 +57,15 @@ o_du_unit flexible_du_factory::create_flexible_du(const du_unit_dependencies& de max_pusch_per_slot.push_back(high.cell.pusch_cfg.max_puschs_per_slot); } - // Initialize and configure the HAL. - // :TODO: review it. It should be managed internally in the DU low. - hal_upper_phy_config du_low_hal_cfg = make_du_low_hal_config_and_dependencies(du_lo, du_cells.size()); - // Create O-DU low. std::vector du_low_units; for (unsigned i = 0, e = du_cells.size(); i != e; ++i) { o_du_low_unit_config odu_low_cfg = {du_lo, - du_low_hal_cfg, {prach_ports[i]}, span(&du_cells[i], 1), span(&max_pusch_per_slot[i], 1), - i}; + i, + nof_cells}; o_du_low_unit_dependencies odu_low_dependencies = { du_impl->get_upper_ru_dl_rg_adapter(), du_impl->get_upper_ru_ul_request_adapter(), *dependencies.workers}; diff --git a/apps/units/flexible_du/split_helpers/multicell_flexible_du_factory.cpp b/apps/units/flexible_du/split_helpers/multicell_flexible_du_factory.cpp index 7966062b16..5d0a4ac74d 100644 --- a/apps/units/flexible_du/split_helpers/multicell_flexible_du_factory.cpp +++ b/apps/units/flexible_du/split_helpers/multicell_flexible_du_factory.cpp @@ -54,12 +54,9 @@ o_du_unit multicell_flexible_du_factory::create_flexible_du(const du_unit_depend max_pusch_per_slot.push_back(high.cell.pusch_cfg.max_puschs_per_slot); } - // Initialize and configure the HAL. - // :TODO: review it. It should be managed internally in the DU low. - hal_upper_phy_config du_low_hal_cfg = make_du_low_hal_config_and_dependencies(du_lo, du_cells.size()); - static constexpr unsigned du_id = 0U; - o_du_low_unit_config odu_low_cfg = {du_lo, du_low_hal_cfg, prach_ports, du_cells, max_pusch_per_slot, du_id}; + o_du_low_unit_config odu_low_cfg = { + du_lo, prach_ports, du_cells, max_pusch_per_slot, du_id, static_cast(du_cells.size())}; o_du_low_unit_dependencies odu_low_dependencies = { du_impl->get_upper_ru_dl_rg_adapter(), du_impl->get_upper_ru_ul_request_adapter(), *dependencies.workers}; diff --git a/include/srsran/phy/upper/upper_phy_factories.h b/include/srsran/phy/upper/upper_phy_factories.h index 9ddf670331..8bbe94aec2 100644 --- a/include/srsran/phy/upper/upper_phy_factories.h +++ b/include/srsran/phy/upper/upper_phy_factories.h @@ -25,14 +25,12 @@ #include "srsran/phy/support/support_factories.h" #include "srsran/phy/upper/channel_coding/channel_coding_factories.h" #include "srsran/phy/upper/channel_processors/channel_processor_factories.h" +#include "srsran/phy/upper/channel_processors/pdsch/factories.h" +#include "srsran/phy/upper/channel_processors/pusch/factories.h" #include "srsran/phy/upper/downlink_processor.h" #include "srsran/phy/upper/rx_buffer_pool.h" #include "srsran/phy/upper/uplink_processor.h" #include "srsran/phy/upper/upper_phy.h" -#ifdef DPDK_FOUND -#include "srsran/hal/phy/upper/channel_processors/hw_accelerator_factories.h" -#include "srsran/hal/phy/upper/channel_processors/pusch/hw_accelerator_factories.h" -#endif // DPDK_FOUND #include #include @@ -182,6 +180,10 @@ struct downlink_processor_factory_sw_config { pdsch_processor; /// Number of concurrent threads processing downlink transmissions. unsigned nof_concurrent_threads; + /// \brief Optional hardware-accelerated PDSCH encoder factory. + /// + /// if the optional is not set, a software PDSCH encoder factory will be used. + std::optional> hw_encoder_factory; }; /// Creates a full software based downlink processor factory. @@ -189,28 +191,6 @@ std::shared_ptr create_downlink_processor_factory_sw(const downlink_processor_factory_sw_config& config, std::shared_ptr rg_mapper_factory); -/// \brief Downlink processor hardware-accelerated factory configuration. -struct downlink_processor_factory_hw_config { - /// \brief CRC calculator type. - /// - /// Use of there options: - /// - \c auto: let the factory select the most efficient given the CPU architecture, or - /// - \c lut: for using a look-up table CRC calculator, or - /// - \c clmul: for using a look-up table CRC calculator (x86_64 CPUs only). - std::string crc_calculator_type; -#ifdef HWACC_PDSCH_ENABLED - /// Hardware-accelerated PDSCH encoder factory configuration structure. - hal::bbdev_hwacc_pdsch_enc_factory_configuration hwacc_pdsch_enc_cfg = {}; -#endif // HWACC_PDSCH_ENABLED - /// Number of concurrent threads processing downlink transmissions. - unsigned nof_concurrent_threads; -}; - -/// Creates a full hardware-accelerated based downlink processor factory. -std::shared_ptr -create_downlink_processor_factory_hw(const downlink_processor_factory_hw_config& config, - std::shared_ptr rg_mapper_factory); - /// Describes all downlink processors in a pool. struct downlink_processor_pool_config { /// Downlink processors for a given sector and numerology. @@ -232,20 +212,6 @@ struct downlink_processor_pool_config { /// \brief Creates and returns a downlink processor pool. std::unique_ptr create_dl_processor_pool(downlink_processor_pool_config config); -/// HAL configuration parameters for the upper PHY. -struct hal_upper_phy_config { - /// Set to true for a hardware-accelerated PUSCH processor implementation. - bool hwacc_pusch_processor = false; - /// Set to true for a hardware-accelerated PDSCH processor implementation. - bool hwacc_pdsch_processor = false; -#ifdef DPDK_FOUND - /// Hardware-accelerated PUSCH decoder function configuration structure. - hal::bbdev_hwacc_pusch_dec_factory_configuration hwacc_pusch_dec_cfg = {}; - /// Hardware-accelerated PDSCH encoder factory configuration structure. - hal::bbdev_hwacc_pdsch_enc_factory_configuration hwacc_pdsch_enc_cfg = {}; -#endif // DPDK_FOUND -}; - /// Upper PHY configuration parameters used to create a new upper PHY object. struct upper_phy_config { /// \brief Logging level. @@ -348,8 +314,10 @@ struct upper_phy_config { task_executor* srs_executor; /// Received symbol request notifier. upper_phy_rx_symbol_request_notifier* rx_symbol_request_notifier; - /// HAL configuration. - hal_upper_phy_config hal_config; + /// \brief Optional hardware-accelerated PUSCH decoder factory. + /// + /// if the optional is not set, a software PUSCH decoder factory will be used. + std::optional> hw_decoder_factory; }; /// Returns true if the given upper PHY configuration is valid, otherwise false. diff --git a/lib/du/du_low/du_low_factory.cpp b/lib/du/du_low/du_low_factory.cpp index 23f1a34374..9f48c8f82a 100644 --- a/lib/du/du_low/du_low_factory.cpp +++ b/lib/du/du_low/du_low_factory.cpp @@ -41,19 +41,8 @@ static std::unique_ptr create_upper_phy(const upper_phy_config& report_fatal_error_if_not(precoding_factory, "Invalid resource grid mapper factory."); // Create downlink processor factory. - std::shared_ptr dl_proc_factory; - // Check if a hardware-accelerated PDSCH processor is requested. - if (!upper_config.hal_config.hwacc_pdsch_processor) { - dl_proc_factory = create_downlink_processor_factory_sw(dl_fact_config, rg_mapper_factory); - } else { - downlink_processor_factory_hw_config hw_cfg = {}; - hw_cfg.crc_calculator_type = upper_config.crc_calculator_type; - hw_cfg.nof_concurrent_threads = dl_fact_config.nof_concurrent_threads; -#ifdef HWACC_PDSCH_ENABLED - hw_cfg.hwacc_pdsch_enc_cfg = upper_config.hal_config.hwacc_pdsch_enc_cfg; -#endif // HWACC_PDSCH_ENABLED - dl_proc_factory = create_downlink_processor_factory_hw(hw_cfg, rg_mapper_factory); - } + std::shared_ptr dl_proc_factory = + create_downlink_processor_factory_sw(dl_fact_config, rg_mapper_factory); report_fatal_error_if_not(dl_proc_factory, "Invalid DL processor factory."); // Create resource grid factory. diff --git a/lib/phy/upper/CMakeLists.txt b/lib/phy/upper/CMakeLists.txt index 68e3a124da..7ad88b8154 100644 --- a/lib/phy/upper/CMakeLists.txt +++ b/lib/phy/upper/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries(srsran_uplink_processor srsran_channel_processors) add_library(srsran_upper_phy upper_phy_factories.cpp upper_phy_impl.cpp upper_phy_factories.cpp upper_phy_rx_symbol_handler_impl.cpp upper_phy_rx_results_notifier_wrapper.cpp upper_phy_error_handler_impl.cpp) -set(UPPER_PHY_LIBRARIES srsran_instrumentation +target_link_libraries(srsran_upper_phy srsran_instrumentation srsran_downlink_processor srsran_uplink_processor srsran_phy_support @@ -49,15 +49,6 @@ set(UPPER_PHY_LIBRARIES srsran_instrumentation srsran_transform_precoding srsran_channel_equalizer) -# Hardware acceleration for both PUSCH and PDSCH is enabled by default when using DPDK. -if (DPDK_FOUND) - set_source_files_properties(upper_phy_factories.cpp PROPERTIES COMPILE_DEFINITIONS "DPDK_FOUND; HWACC_PDSCH_ENABLED; HWACC_PUSCH_ENABLED") - list(APPEND UPPER_PHY_LIBRARIES srsran_hal_pusch - srsran_hal_pdsch - srsran_hal_bbdev) -endif (DPDK_FOUND) -target_link_libraries(srsran_upper_phy ${UPPER_PHY_LIBRARIES}) - add_library(log_likelihood_ratio log_likelihood_ratio.cpp) target_link_libraries(log_likelihood_ratio srsvec) diff --git a/lib/phy/upper/upper_phy_factories.cpp b/lib/phy/upper/upper_phy_factories.cpp index 5ca55729ab..d3e5314f36 100644 --- a/lib/phy/upper/upper_phy_factories.cpp +++ b/lib/phy/upper/upper_phy_factories.cpp @@ -418,7 +418,7 @@ static std::shared_ptr create_ul_processor_factory(con // Check if a hardware-accelerated PUSCH processor is requested. pusch_processor_factory_sw_configuration pusch_config; - if (!config.hal_config.hwacc_pusch_processor) { + if (!config.hw_decoder_factory) { pusch_decoder_factory_sw_configuration decoder_config; decoder_config.crc_factory = crc_calc_factory; decoder_config.decoder_factory = create_ldpc_decoder_factory_sw(config.ldpc_decoder_type); @@ -442,12 +442,9 @@ static std::shared_ptr create_ul_processor_factory(con decoder_config.crc_factory = crc_calc_factory; decoder_config.hw_decoder_factory = nullptr; decoder_config.nof_pusch_decoder_threads = config.nof_pusch_decoder_threads; -#ifdef HWACC_PUSCH_ENABLED - decoder_config.hw_decoder_factory = hal::create_bbdev_pusch_dec_acc_factory(config.hal_config.hwacc_pusch_dec_cfg); -#endif // HWACC_PUSCH_ENABLED - decoder_config.executor = config.pusch_decoder_executor; - report_fatal_error_if_not(decoder_config.hw_decoder_factory, "Invalid hardware-accelerated PUSCH decoder factory."); - pusch_config.decoder_factory = create_pusch_decoder_factory_hw(decoder_config); + decoder_config.hw_decoder_factory = config.hw_decoder_factory.value(); + decoder_config.executor = config.pusch_decoder_executor; + pusch_config.decoder_factory = create_pusch_decoder_factory_hw(decoder_config); } std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); @@ -734,13 +731,23 @@ srsran::create_downlink_processor_factory_sw(const downlink_processor_factory_sw create_pdcch_encoder_factory_sw(crc_calc_factory, polar_factory); report_fatal_error_if_not(pdcch_enc_factory, "Invalid PDCCH encoder factory."); - // Create channel processors encoder factories - PDSCH - pdsch_encoder_factory_sw_configuration pdsch_enc_factory_config; - pdsch_enc_factory_config.segmenter_factory = ldpc_seg_tx_factory; - pdsch_enc_factory_config.encoder_factory = ldpc_enc_factory; - pdsch_enc_factory_config.rate_matcher_factory = ldpc_rm_factory; - - std::shared_ptr pdsch_enc_factory = create_pdsch_encoder_factory_sw(pdsch_enc_factory_config); + // Create channel processors encoder factories - PDSCH. Check if hardware acceleration is requested. + std::shared_ptr pdsch_enc_factory = nullptr; + if (!config.hw_encoder_factory) { + // Create a software PDSCH encoder factory. + pdsch_encoder_factory_sw_configuration pdsch_enc_factory_config; + pdsch_enc_factory_config.segmenter_factory = ldpc_seg_tx_factory; + pdsch_enc_factory_config.encoder_factory = ldpc_enc_factory; + pdsch_enc_factory_config.rate_matcher_factory = ldpc_rm_factory; + pdsch_enc_factory = create_pdsch_encoder_factory_sw(pdsch_enc_factory_config); + } else { + // Create a hardware-accelerated PDSCH encoder factory. + pdsch_encoder_factory_hw_configuration encoder_config; + encoder_config.crc_factory = crc_calc_factory; + encoder_config.segmenter_factory = ldpc_seg_tx_factory; + encoder_config.hw_encoder_factory = config.hw_encoder_factory.value(); + pdsch_enc_factory = create_pdsch_encoder_factory_hw(encoder_config); + } report_fatal_error_if_not(pdsch_enc_factory, "Invalid PDSCH encoder factory."); // Create channel processors modulation factories - PBCH @@ -870,144 +877,6 @@ srsran::create_downlink_processor_factory_sw(const downlink_processor_factory_sw pdcch_proc_factory, pdsch_proc_factory, ssb_proc_factory, nzp_csi_rs_factory); } -std::shared_ptr -srsran::create_downlink_processor_factory_hw(const downlink_processor_factory_hw_config& config, - std::shared_ptr rg_mapper_factory) -{ - // Create channel coding factories - CRC - std::shared_ptr crc_calc_factory = - create_crc_calculator_factory_sw(config.crc_calculator_type); - report_fatal_error_if_not(crc_calc_factory, "Invalid CRC calculator factory of type {}.", config.crc_calculator_type); - - // Create channel coding factories - LDPC - std::shared_ptr ldpc_seg_tx_factory = - create_ldpc_segmenter_tx_factory_sw(crc_calc_factory); - report_fatal_error_if_not(ldpc_seg_tx_factory, "Invalid LDPC segmenter factory."); - - // Create channel coding factories - Polar - std::shared_ptr polar_factory = create_polar_factory_sw(); - report_fatal_error_if_not(polar_factory, "Invalid POLAR factory."); - - // Create sequence generators factories - PRG - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - report_fatal_error_if_not(prg_factory, "Invalid PRG factory."); - - // Create modulation mapper factory. - std::shared_ptr mod_factory = create_channel_modulation_sw_factory(); - report_fatal_error_if_not(mod_factory, "Invalid modulation factory."); - - // Create channel processors encoder factories - PBCH - std::shared_ptr pbch_enc_factory = - create_pbch_encoder_factory_sw(crc_calc_factory, prg_factory, polar_factory); - report_fatal_error_if_not(pbch_enc_factory, "Invalid PBCH encoder factory."); - - // Create channel processors encoder factories - PDCCH - std::shared_ptr pdcch_enc_factory = - create_pdcch_encoder_factory_sw(crc_calc_factory, polar_factory); - report_fatal_error_if_not(pdcch_enc_factory, "Invalid PDCCH encoder factory."); - - // Create a hardware-accelerated PDSCH encoder factory. - pdsch_encoder_factory_hw_configuration encoder_config; - encoder_config.crc_factory = crc_calc_factory; - encoder_config.segmenter_factory = ldpc_seg_tx_factory; -#ifdef HWACC_PDSCH_ENABLED - encoder_config.hw_encoder_factory = hal::create_bbdev_pdsch_enc_acc_factory(config.hwacc_pdsch_enc_cfg); -#endif // HWACC_PDSCH_ENABLED - report_fatal_error_if_not(encoder_config.hw_encoder_factory, "Invalid hardware-accelerated PDSCH encoder factory."); - std::shared_ptr pdsch_enc_factory = create_pdsch_encoder_factory_hw(encoder_config); - report_fatal_error_if_not(pdsch_enc_factory, "Invalid hardware-accelerated PDSCH encoder factory."); - - // Create channel processors modulation factories - PBCH - std::shared_ptr pbch_mod_factory = create_pbch_modulator_factory_sw(mod_factory, prg_factory); - report_fatal_error_if_not(pbch_mod_factory, "Invalid PBCH modulation factory."); - - // Create channel processors modulation factories - PDCCH - std::shared_ptr pdcch_mod_factory = - create_pdcch_modulator_factory_sw(mod_factory, prg_factory, rg_mapper_factory); - report_fatal_error_if_not(pdcch_mod_factory, "Invalid PDCCH modulation factory."); - - // Create channel processors modulation factories - PDSCH - std::shared_ptr pdsch_mod_factory = - create_pdsch_modulator_factory_sw(mod_factory, prg_factory, rg_mapper_factory); - report_fatal_error_if_not(pdsch_mod_factory, "Invalid PDSCH modulation factory."); - - // Create DMRS generators - PBCH, PSS, SSS - std::shared_ptr dmrs_pbch_proc_factory = - create_dmrs_pbch_processor_factory_sw(prg_factory); - report_fatal_error_if_not(dmrs_pbch_proc_factory, "Invalid DMRS PBCH factory."); - - std::shared_ptr pss_proc_factory = create_pss_processor_factory_sw(); - report_fatal_error_if_not(pss_proc_factory, "Invalid PSS factory."); - - std::shared_ptr sss_proc_factory = create_sss_processor_factory_sw(); - report_fatal_error_if_not(sss_proc_factory, "Invalid SSS factory."); - - // Create DMRS generators - PDCCH - std::shared_ptr dmrs_pdcch_proc_factory = - create_dmrs_pdcch_processor_factory_sw(prg_factory, rg_mapper_factory); - report_fatal_error_if_not(dmrs_pdcch_proc_factory, "Invalid DMRS PDCCH factory."); - - // Create DMRS generators - PDSCH - std::shared_ptr dmrs_pdsch_proc_factory = - create_dmrs_pdsch_processor_factory_sw(prg_factory, rg_mapper_factory); - report_fatal_error_if_not(dmrs_pdsch_proc_factory, "Invalid DMRS PDSCH factory."); - - // Create PTRS generators - PDSCH - std::shared_ptr ptrs_pdsch_gen_factory = - create_ptrs_pdsch_generator_generic_factory(prg_factory, rg_mapper_factory); - report_fatal_error_if_not(ptrs_pdsch_gen_factory, "Invalid PTRS PDSCH factory."); - - // Create channel processors - PDCCH - std::shared_ptr pdcch_proc_factory = - create_pdcch_processor_factory_sw(pdcch_enc_factory, pdcch_mod_factory, dmrs_pdcch_proc_factory); - report_fatal_error_if_not(pdcch_proc_factory, "Invalid PDCCH processor factory."); - - // Create channel processors - PDSCH - // Hardware-acceleration currently supports 'generic' PDSCH processor types only. - std::shared_ptr pdsch_proc_factory = create_pdsch_processor_factory_sw( - pdsch_enc_factory, pdsch_mod_factory, dmrs_pdsch_proc_factory, ptrs_pdsch_gen_factory); - report_fatal_error_if_not(pdsch_proc_factory, "Invalid PDSCH processor factory."); - - // Create channel processors - SSB - ssb_processor_factory_sw_configuration ssb_factory_config; - ssb_factory_config.encoder_factory = pbch_enc_factory; - ssb_factory_config.modulator_factory = pbch_mod_factory; - ssb_factory_config.dmrs_factory = dmrs_pbch_proc_factory; - ssb_factory_config.pss_factory = pss_proc_factory; - ssb_factory_config.sss_factory = sss_proc_factory; - std::shared_ptr ssb_proc_factory = create_ssb_processor_factory_sw(ssb_factory_config); - report_fatal_error_if_not(ssb_proc_factory, "Invalid SSB processor factory."); - - // Create signal generators - NZP-CSI-RS - std::shared_ptr nzp_csi_rs_factory = - create_nzp_csi_rs_generator_factory_sw(prg_factory, rg_mapper_factory); - report_fatal_error_if_not(nzp_csi_rs_factory, "Invalid NZP-CSI-RS generator factory."); - - // Wrap the downlink processor dependencies with pools to allow concurrent execution. - if (config.nof_concurrent_threads > 1) { - // If the PDSCH instance is concurrent, the number of instances is given by the PDSCH processor configuration. - unsigned max_nof_simultaneous_pdsch = config.nof_concurrent_threads; - - pdcch_proc_factory = - create_pdcch_processor_pool_factory(std::move(pdcch_proc_factory), config.nof_concurrent_threads); - report_fatal_error_if_not(pdcch_proc_factory, "Invalid PDCCH processor pool factory."); - - // The hardware-accelerated PDSCH processor pool needs to be locked. - pdsch_proc_factory = create_pdsch_processor_pool(std::move(pdsch_proc_factory), max_nof_simultaneous_pdsch); - report_fatal_error_if_not(pdsch_proc_factory, "Invalid PDSCH processor pool factory."); - - ssb_proc_factory = create_ssb_processor_pool_factory(std::move(ssb_proc_factory), config.nof_concurrent_threads); - report_fatal_error_if_not(ssb_proc_factory, "Invalid SSB processor pool factory."); - - nzp_csi_rs_factory = - create_nzp_csi_rs_generator_pool_factory(std::move(nzp_csi_rs_factory), config.nof_concurrent_threads); - report_fatal_error_if_not(nzp_csi_rs_factory, "Invalid NZP-CSI-RS generator pool factory."); - } - - return std::make_shared( - pdcch_proc_factory, pdsch_proc_factory, ssb_proc_factory, nzp_csi_rs_factory); -} - std::unique_ptr srsran::create_uplink_processor_pool(uplink_processor_pool_config config) { // Convert from pool config to pool_impl config. diff --git a/tests/benchmarks/phy/upper/channel_processors/pusch/pusch_processor_benchmark.cpp b/tests/benchmarks/phy/upper/channel_processors/pusch/pusch_processor_benchmark.cpp index ffed76f1b0..4ec886667b 100644 --- a/tests/benchmarks/phy/upper/channel_processors/pusch/pusch_processor_benchmark.cpp +++ b/tests/benchmarks/phy/upper/channel_processors/pusch/pusch_processor_benchmark.cpp @@ -511,14 +511,8 @@ create_pusch_decoder_factory(std::shared_ptr crc_calcula return create_sw_pusch_decoder_factory(crc_calculator_factory); } -static pusch_processor_factory& get_pusch_processor_factory() +static std::shared_ptr create_pusch_processor_factory() { - static std::shared_ptr pusch_proc_factory = nullptr; - - if (pusch_proc_factory) { - return *pusch_proc_factory; - } - // Create pseudo-random sequence generator. std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); TESTASSERT(prg_factory); @@ -611,7 +605,8 @@ static pusch_processor_factory& get_pusch_processor_factory() pusch_proc_factory_config.dec_nof_iterations = 2; pusch_proc_factory_config.dec_enable_early_stop = true; pusch_proc_factory_config.max_nof_concurrent_threads = nof_threads; - pusch_proc_factory = create_pusch_processor_factory_sw(pusch_proc_factory_config); + std::shared_ptr pusch_proc_factory = + create_pusch_processor_factory_sw(pusch_proc_factory_config); TESTASSERT(pusch_proc_factory); pusch_proc_factory_config.decoder_factory = @@ -631,20 +626,20 @@ static pusch_processor_factory& get_pusch_processor_factory() pusch_proc_factory = create_pusch_processor_pool(pusch_proc_pool_config); TESTASSERT(pusch_proc_factory); - return *pusch_proc_factory; + return pusch_proc_factory; } // Instantiates the PUSCH processor and validator. static std::tuple, std::unique_ptr> create_processor() { - pusch_processor_factory& pusch_proc_factory = get_pusch_processor_factory(); + std::shared_ptr pusch_proc_factory = create_pusch_processor_factory(); // Create PUSCH processor. - std::unique_ptr processor = pusch_proc_factory.create(); + std::unique_ptr processor = pusch_proc_factory->create(); TESTASSERT(processor); // Create PUSCH processor validator. - std::unique_ptr validator = pusch_proc_factory.create_validator(); + std::unique_ptr validator = pusch_proc_factory->create_validator(); TESTASSERT(validator); return std::make_tuple(std::move(processor), std::move(validator)); @@ -893,6 +888,7 @@ int main(int argc, char** argv) worker_pool->stop(); } processor.reset(); + validator.reset(); return 0; } diff --git a/tests/e2e/tests/viavi/test_declaration.yml b/tests/e2e/tests/viavi/test_declaration.yml index c19f9918e7..a04b95cf49 100644 --- a/tests/e2e/tests/viavi/test_declaration.yml +++ b/tests/e2e/tests/viavi/test_declaration.yml @@ -76,7 +76,7 @@ tests: expected_dl_bitrate: 14.0e+3 expected_ul_bitrate: 1.0e+3 expected_nof_kos: 9999999999999 - warning_as_errors: true + warning_as_errors: false - campaign_filename: *campaign_filename test_name: "1UE fading noise UDP uplink" @@ -90,7 +90,7 @@ tests: expected_dl_bitrate: 14.0e+3 expected_ul_bitrate: 1.0e+3 expected_nof_kos: 9999999999999 - warning_as_errors: true + warning_as_errors: false - campaign_filename: *campaign_filename test_name: "1UE ideal TCP downlink" @@ -132,7 +132,7 @@ tests: expected_dl_bitrate: 14.0e+3 expected_ul_bitrate: 1.0e+3 expected_nof_kos: 9999999999999 - warning_as_errors: true + warning_as_errors: false - campaign_filename: *campaign_filename test_name: "32UE fading UDP attach-detach with traffic" @@ -146,7 +146,7 @@ tests: expected_dl_bitrate: 14.0e+3 expected_ul_bitrate: 1.0e+3 expected_nof_kos: 9999999999999 - warning_as_errors: true + warning_as_errors: false - campaign_filename: *campaign_filename test_name: "32UE ideal UDP attach-detach with traffic" diff --git a/tests/unittests/phy/generic_functions/transform_precoding/transform_precoder_vectortest.cpp b/tests/unittests/phy/generic_functions/transform_precoding/transform_precoder_vectortest.cpp index e79faa9dc4..e6be3c9887 100644 --- a/tests/unittests/phy/generic_functions/transform_precoding/transform_precoder_vectortest.cpp +++ b/tests/unittests/phy/generic_functions/transform_precoding/transform_precoder_vectortest.cpp @@ -89,6 +89,8 @@ class TransformPrecodingFixture : public ::testing::TestWithParam static void TearDownTestSuite() { precoder.reset(); } + void SetUp() override { ASSERT_NE(precoder, nullptr); } + static std::unique_ptr precoder; }; diff --git a/tests/unittests/phy/upper/channel_processors/prach_detector_vectortest.cpp b/tests/unittests/phy/upper/channel_processors/prach_detector_vectortest.cpp index 83ccf16e08..5a80a3b547 100644 --- a/tests/unittests/phy/upper/channel_processors/prach_detector_vectortest.cpp +++ b/tests/unittests/phy/upper/channel_processors/prach_detector_vectortest.cpp @@ -76,37 +76,47 @@ using PrachDetectorParams = test_case_t; class PrachDetectorFixture : public ::testing::TestWithParam { protected: - std::unique_ptr detector; - std::unique_ptr validator; + static std::unique_ptr detector; + static std::unique_ptr validator; - void SetUp() override + static void SetUpTestSuite() { std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); if (!dft_factory) { dft_factory = create_dft_processor_factory_generic(); } - ASSERT_TRUE(dft_factory); + ASSERT_NE(dft_factory, nullptr); std::shared_ptr generator_factory = create_prach_generator_factory_sw(); - ASSERT_TRUE(generator_factory); + ASSERT_NE(generator_factory, nullptr); std::shared_ptr detector_factory = create_prach_detector_factory_sw(dft_factory, generator_factory); - ASSERT_TRUE(detector_factory); + ASSERT_NE(detector_factory, nullptr); -#if 0 - srslog::init(); - detector = detector_factory->create(srslog::fetch_basic_logger("PRACH"), true); -#else detector = detector_factory->create(); -#endif - ASSERT_TRUE(detector); + ASSERT_NE(detector, nullptr); validator = detector_factory->create_validator(); - ASSERT_TRUE(validator); + ASSERT_NE(validator, nullptr); + } + + static void TearDownTestSuite() + { + detector.reset(); + validator.reset(); + } + + void SetUp() override + { + ASSERT_NE(detector, nullptr); + ASSERT_NE(validator, nullptr); } }; +std::unique_ptr PrachDetectorFixture::detector = nullptr; +std::unique_ptr PrachDetectorFixture::validator = nullptr; + TEST_P(PrachDetectorFixture, FromVector) { const PrachDetectorParams& params = GetParam(); diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_demodulator_format2_test.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_demodulator_format2_test.cpp index d82b9f284f..b86246833a 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_demodulator_format2_test.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_demodulator_format2_test.cpp @@ -108,6 +108,8 @@ class PucchDemodulatorFixture : public ::testing::TestWithParam; +template <> +std::unique_ptr PucchProcessorFormat0Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorFormat0Fixture::validator = nullptr; + namespace srsran { std::ostream& operator<<(std::ostream& os, const pucch_processor::format0_configuration& config) @@ -65,113 +73,6 @@ std::ostream& operator<<(std::ostream& os, span data) namespace { -using PucchProcessorFormat0Param = test_case_t; - -class PucchProcessorFormat0Fixture : public ::testing::TestWithParam -{ -protected: - static void SetUpTestSuite() - { - if (factory) { - return; - } - - std::shared_ptr lpg_factory = create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr); - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr) << "Cannot create low PAPR sequence collection factory."; - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr) << "Cannot create PRG factory."; - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr); - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - channel_estimate::channel_estimate_dimensions channel_estimate_dimensions; - channel_estimate_dimensions.nof_tx_layers = 1; - channel_estimate_dimensions.nof_rx_ports = 4; - channel_estimate_dimensions.nof_symbols = MAX_NSYMB_PER_SLOT; - channel_estimate_dimensions.nof_prb = MAX_RB; - - factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, channel_estimate_dimensions); - ASSERT_NE(factory, nullptr); - } - - void SetUp() override - { - ASSERT_NE(factory, nullptr); - processor = factory->create(); - ASSERT_NE(processor, nullptr) << "Could not create PUCCH processor."; - validator = factory->create_validator(); - ASSERT_NE(validator, nullptr) << "Could not create PUCCH validator."; - } - - static std::shared_ptr factory; - - // PUCCH processor. - std::unique_ptr processor; - // PUCCH processor validator. - std::unique_ptr validator; -}; - -std::shared_ptr PucchProcessorFormat0Fixture::factory; - TEST_P(PucchProcessorFormat0Fixture, FromVector) { // Prepare resource grid. diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format1_vectortest.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format1_vectortest.cpp index 10478f49a5..a28e135221 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format1_vectortest.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format1_vectortest.cpp @@ -22,6 +22,7 @@ #include "pucch_detector_test_doubles.h" #include "pucch_processor_format1_test_data.h" +#include "pucch_processor_test_fixture.h" #include "srsran/phy/upper/channel_processors/channel_processor_formatters.h" #include "srsran/phy/upper/channel_processors/pucch/formatters.h" #include "srsran/ran/pucch/pucch_constants.h" @@ -30,6 +31,13 @@ using namespace srsran; +using PucchProcessorFormat1Param = test_case_t; +using PucchProcessorFormat1Fixture = PucchProcessorTestFixture; +template <> +std::unique_ptr PucchProcessorFormat1Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorFormat1Fixture::validator = nullptr; + namespace srsran { std::ostream& operator<<(std::ostream& os, const pucch_processor::format1_configuration& config) @@ -67,113 +75,6 @@ std::ostream& operator<<(std::ostream& os, span data) namespace { -using PucchProcessorFormat1Param = test_case_t; - -class PucchProcessorFormat1Fixture : public ::testing::TestWithParam -{ -protected: - static void SetUpTestSuite() - { - if (factory) { - return; - } - - std::shared_ptr lpg_factory = create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr); - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr); - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr); - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr); - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - channel_estimate::channel_estimate_dimensions channel_estimate_dimensions; - channel_estimate_dimensions.nof_tx_layers = 1; - channel_estimate_dimensions.nof_rx_ports = 4; - channel_estimate_dimensions.nof_symbols = MAX_NSYMB_PER_SLOT; - channel_estimate_dimensions.nof_prb = MAX_RB; - - factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, channel_estimate_dimensions); - ASSERT_NE(factory, nullptr); - } - - void SetUp() override - { - ASSERT_NE(factory, nullptr); - processor = factory->create(); - ASSERT_NE(processor, nullptr) << "Could not create PUCCH processor."; - validator = factory->create_validator(); - ASSERT_NE(validator, nullptr) << "Could not create PUCCH validator."; - } - - static std::shared_ptr factory; - - // PUCCH processor. - std::unique_ptr processor; - // PUCCH processor validator. - std::unique_ptr validator; -}; - -std::shared_ptr PucchProcessorFormat1Fixture::factory; - TEST_P(PucchProcessorFormat1Fixture, FromVector) { // Prepare resource grid. diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format2_vectortest.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format2_vectortest.cpp index 35ecde2292..41528c7be1 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format2_vectortest.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_format2_vectortest.cpp @@ -21,9 +21,8 @@ */ #include "pucch_processor_format2_test_data.h" -#include "srsran/phy/support/support_factories.h" +#include "pucch_processor_test_fixture.h" #include "srsran/phy/upper/channel_processors/channel_processor_formatters.h" -#include "srsran/phy/upper/channel_processors/pucch/factories.h" #include "srsran/phy/upper/channel_processors/pucch/formatters.h" #include "srsran/phy/upper/equalization/equalization_factories.h" #include "srsran/ran/pucch/pucch_constants.h" @@ -32,8 +31,6 @@ using namespace srsran; -using PucchProcessorF2Params = test_case_t; - namespace srsran { std::ostream& operator<<(std::ostream& os, test_case_t test_case) @@ -48,117 +45,12 @@ std::ostream& operator<<(std::ostream& os, test_case_t test_case) } // namespace srsran -class PucchProcessorF2Fixture : public ::testing::TestWithParam -{ -protected: - // PUCCH processor factory. - static std::shared_ptr processor_factory; - // PUCCH processor. - std::unique_ptr processor; - // PUCCH processor validator. - std::unique_ptr validator; - - static void SetUpTestSuite() - { - if (!processor_factory) { - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr) << "Cannot create pseudo-random generator factory."; - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create factories required by the PUCCH channel estimator factory. - std::shared_ptr lpg_factory = - create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr) << "Cannot create low PAPR sequence generator factory."; - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr) << "Cannot create low PAPR sequence collection factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create PUCCH detector factory. - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr) << "Cannot create PUCCH detector factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - channel_estimate::channel_estimate_dimensions channel_estimate_dimensions; - channel_estimate_dimensions.nof_tx_layers = 1; - channel_estimate_dimensions.nof_rx_ports = 4; - channel_estimate_dimensions.nof_symbols = MAX_NSYMB_PER_SLOT; - channel_estimate_dimensions.nof_prb = MAX_RB; - - // Create PUCCH processor factory. - processor_factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, channel_estimate_dimensions); - ASSERT_NE(processor_factory, nullptr) << "Cannot create PUCCH processor factory."; - } - } - - void SetUp() override - { - // Assert PUCCH Processor factory. - ASSERT_NE(processor_factory, nullptr) << "Cannot create PUCCH processor factory."; - - // Create PUCCH processor. - processor = processor_factory->create(); - ASSERT_NE(processor, nullptr) << "Cannot create PUCCH processor."; - - // Create PUCCH validator. - validator = processor_factory->create_validator(); - ASSERT_NE(validator, nullptr) << "Cannot create PUCCH validator."; - } -}; - -std::shared_ptr PucchProcessorF2Fixture::processor_factory = nullptr; +using PucchProcessorFormat2Param = test_case_t; +using PucchProcessorF2Fixture = PucchProcessorTestFixture; +template <> +std::unique_ptr PucchProcessorF2Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorF2Fixture::validator = nullptr; TEST_P(PucchProcessorF2Fixture, PucchProcessorF2VectorTest) { diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_test_fixture.h b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_test_fixture.h new file mode 100644 index 0000000000..c90d728c2b --- /dev/null +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_test_fixture.h @@ -0,0 +1,139 @@ +/* + * + * Copyright 2021-2024 Software Radio Systems Limited + * + * This file is part of srsRAN. + * + * srsRAN is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsRAN is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#pragma once + +#include "srsran/phy/upper/channel_processors/pucch/factories.h" +#include "srsran/ran/pucch/pucch_constants.h" +#include + +namespace srsran { + +template +class PucchProcessorTestFixture : public ::testing::TestWithParam +{ +public: + static constexpr channel_estimate::channel_estimate_dimensions channel_estimate_dimensions = { + .nof_prb = MAX_NOF_PRBS, + .nof_symbols = MaxNofSymbols, + .nof_rx_ports = MaxNofRxPorts, + .nof_tx_layers = pucch_constants::MAX_LAYERS, + }; + +protected: + static void SetUpTestSuite() + { + std::shared_ptr lpg_factory = create_low_papr_sequence_generator_sw_factory(); + ASSERT_NE(lpg_factory, nullptr); + + std::shared_ptr lpc_factory = + create_low_papr_sequence_collection_sw_factory(lpg_factory); + ASSERT_NE(lpc_factory, nullptr); + + std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); + ASSERT_NE(prg_factory, nullptr); + + std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); + if (!dft_factory) { + dft_factory = create_dft_processor_factory_generic(); + } + ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; + + std::shared_ptr ta_estimator_factory = + create_time_alignment_estimator_dft_factory(dft_factory); + ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; + + // Create channel estimator factory. + std::shared_ptr port_chan_estimator_factory = + create_port_channel_estimator_factory_sw(ta_estimator_factory); + ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; + + std::shared_ptr estimator_factory = + create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); + ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; + + // Create factories required by the PUCCH demodulator factory. + std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); + ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; + + std::shared_ptr detector_factory = + create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); + ASSERT_NE(detector_factory, nullptr); + + std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); + ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; + + std::shared_ptr precoding_factory = + create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); + ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; + + // Create PUCCH demodulator factory. + std::shared_ptr pucch_demod_factory = + create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); + ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; + + // Create short block detector factory. + std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); + ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; + + // Create polar decoder factory. + std::shared_ptr polar_dec_factory = create_polar_factory_sw(); + ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; + + // Create CRC calculator factory. + std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); + ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; + + // Create UCI decoder factory. + std::shared_ptr uci_dec_factory = + create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); + ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; + + std::shared_ptr factory = create_pucch_processor_factory_sw( + estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, channel_estimate_dimensions); + ASSERT_NE(factory, nullptr); + + processor = factory->create(); + ASSERT_NE(processor, nullptr) << "Could not create PUCCH processor."; + validator = factory->create_validator(); + ASSERT_NE(validator, nullptr) << "Could not create PUCCH validator."; + } + + static void TearDownTestSuite() + { + processor.reset(); + validator.reset(); + } + + void SetUp() override + { + ASSERT_NE(processor, nullptr) << "Could not create PUCCH processor."; + ASSERT_NE(validator, nullptr) << "Could not create PUCCH validator."; + } + + // PUCCH processor. + static std::unique_ptr processor; + // PUCCH processor validator. + static std::unique_ptr validator; +}; + +} // namespace srsran diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format0_test.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format0_test.cpp index 1e99719c9a..7f39d5877d 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format0_test.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format0_test.cpp @@ -21,12 +21,11 @@ */ #include "../../../support/resource_grid_test_doubles.h" +#include "pucch_processor_test_fixture.h" #include "srsran/adt/expected.h" -#include "srsran/phy/upper/channel_processors/channel_processor_factories.h" #include "srsran/phy/upper/channel_processors/channel_processor_formatters.h" #include "srsran/phy/upper/channel_processors/pucch/factories.h" #include "srsran/phy/upper/channel_processors/pucch/formatters.h" -#include "srsran/phy/upper/equalization/equalization_factories.h" #include "srsran/ran/pucch/pucch_constants.h" #include "fmt/ostream.h" #include @@ -36,8 +35,15 @@ using namespace srsran; namespace { -// Maximum channel dimensions used to construct the PUCCH processor. It is irrelevant for Format 0. -channel_estimate::channel_estimate_dimensions max_dimensions = {1, 1, 1, 1}; +// Test case parameters structure. +struct test_params { + pucch_processor::format0_configuration config; + std::string assert_message; +}; + +struct test_case_t { + std::function get_test_params; +}; // Valid PUCCH Format 0 configuration. const pucch_processor::format0_configuration base_format_0_config = { @@ -71,16 +77,6 @@ const pucch_processor::format0_configuration base_format_0_config = { {0}, }; -// Test case parameters structure. -struct test_params { - pucch_processor::format0_configuration config; - std::string assert_message; -}; - -struct test_case_t { - std::function get_test_params; -}; - std::ostream& operator<<(std::ostream& os, const test_case_t& test_case) { fmt::print(os, "{}", test_case.get_test_params().config); @@ -201,112 +197,24 @@ const std::vector pucch_processor_validator_test_data = { }, }; -class PucchProcessorFormat0Fixture : public ::testing::TestWithParam -{ -protected: - static std::unique_ptr pucch_proc; - static std::unique_ptr pucch_validator; - - static void SetUpTestSuite() - { - if (!(pucch_proc && pucch_validator)) { - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr) << "Cannot create pseudo-random generator factory."; - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create factories required by the PUCCH channel estimator factory. - std::shared_ptr lpg_factory = - create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr) << "Cannot create low PAPR sequence generator factory."; - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr) << "Cannot create low PAPR sequence collection factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create PUCCH detector factory. - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr) << "Cannot create PUCCH detector factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - // Create PUCCH processor factory. - std::shared_ptr processor_factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, max_dimensions); - ASSERT_NE(processor_factory, nullptr) << "Cannot create PUCCH processor factory."; - - // Create PUCCH processor. - pucch_proc = processor_factory->create(); - ASSERT_NE(pucch_proc, nullptr) << "Cannot create PUCCH processor."; - - // Create PUCCH processor validator. - pucch_validator = processor_factory->create_validator(); - ASSERT_NE(pucch_validator, nullptr) << "Cannot create PUCCH validator."; - } - } -}; +} // namespace -std::unique_ptr PucchProcessorFormat0Fixture::pucch_proc; -std::unique_ptr PucchProcessorFormat0Fixture::pucch_validator; +using PucchProcessorFormat0Param = test_case_t; +using PucchProcessorFormat0Fixture = PucchProcessorTestFixture; +template <> +std::unique_ptr PucchProcessorFormat0Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorFormat0Fixture::validator = nullptr; TEST_P(PucchProcessorFormat0Fixture, PucchProcessorValidatortest) { - ASSERT_NE(pucch_proc, nullptr) << "PUCCH processor not created."; - ASSERT_NE(pucch_validator, nullptr) << "PUCCH validator not created."; + ASSERT_NE(processor, nullptr) << "PUCCH processor not created."; + ASSERT_NE(validator, nullptr) << "PUCCH validator not created."; const test_case_t& param = GetParam(); // Make sure the configuration is invalid. - error_type validator_out = pucch_validator->is_valid(param.get_test_params().config); + error_type validator_out = validator->is_valid(param.get_test_params().config); ASSERT_FALSE(validator_out.has_value()) << "Validation should fail."; ASSERT_TRUE(std::regex_match(validator_out.error(), std::regex(param.get_test_params().assert_message))) << "The assertion message doesn't match the expected pattern."; @@ -316,7 +224,7 @@ TEST_P(PucchProcessorFormat0Fixture, PucchProcessorValidatortest) // Process PUCCH PDU. #ifdef ASSERTS_ENABLED - ASSERT_DEATH({ pucch_proc->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); + ASSERT_DEATH({ processor->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); #endif // ASSERTS_ENABLED } @@ -324,5 +232,3 @@ TEST_P(PucchProcessorFormat0Fixture, PucchProcessorValidatortest) INSTANTIATE_TEST_SUITE_P(PucchProcessorValidatortest, PucchProcessorFormat0Fixture, ::testing::ValuesIn(pucch_processor_validator_test_data)); - -} // namespace diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format1_test.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format1_test.cpp index 3f76d39732..bc3c308d01 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format1_test.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format1_test.cpp @@ -21,26 +21,19 @@ */ #include "../../../support/resource_grid_test_doubles.h" -#include "srsran/phy/upper/channel_processors/channel_processor_factories.h" +#include "pucch_processor_test_fixture.h" #include "srsran/phy/upper/channel_processors/channel_processor_formatters.h" #include "srsran/phy/upper/channel_processors/pucch/factories.h" #include "srsran/phy/upper/channel_processors/pucch/formatters.h" -#include "srsran/phy/upper/equalization/equalization_factories.h" #include "srsran/ran/pucch/pucch_constants.h" -#include "fmt/ostream.h" -#include "gtest/gtest.h" +#include +#include #include using namespace srsran; namespace { -// Maximum channel dimensions used to construct the PUCCH processor. -channel_estimate::channel_estimate_dimensions max_dimensions = {MAX_RB, - MAX_NSYMB_PER_SLOT - 1, - 1, - pucch_constants::MAX_LAYERS}; - /// Minimum number of symbols (including DM-RS) that NR-PUCCH Format 1 can transmit. constexpr unsigned PUCCH_FORMAT1_MIN_NSYMB = 4; @@ -91,6 +84,19 @@ std::ostream& operator<<(std::ostream& os, const test_case_t& test_case) return os; } +} // namespace + +using PucchProcessorFormat1Param = test_case_t; +using PucchProcessorFormat1Fixture = PucchProcessorTestFixture; +template <> +std::unique_ptr PucchProcessorFormat1Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorFormat1Fixture::validator = nullptr; + +// Maximum channel dimensions used to construct the PUCCH processor. +static constexpr channel_estimate::channel_estimate_dimensions max_dimensions = + PucchProcessorFormat1Fixture::channel_estimate_dimensions; + // Test cases are implemented as lambda functions that generate and return an invalid PUCCH Format 1 configuration, // along with the expected assert message. const std::vector pucch_processor_validator_test_data = { @@ -184,112 +190,15 @@ const std::vector pucch_processor_validator_test_data = { }, }; -class PucchProcessorFormat1Fixture : public ::testing::TestWithParam -{ -protected: - static std::unique_ptr pucch_proc; - static std::unique_ptr pucch_validator; - - static void SetUpTestSuite() - { - if (!(pucch_proc && pucch_validator)) { - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr) << "Cannot create pseudo-random generator factory."; - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create factories required by the PUCCH channel estimator factory. - std::shared_ptr lpg_factory = - create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr) << "Cannot create low PAPR sequence generator factory."; - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr) << "Cannot create low PAPR sequence collection factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create PUCCH detector factory. - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr) << "Cannot create PUCCH detector factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - // Create PUCCH processor factory. - std::shared_ptr processor_factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, max_dimensions); - ASSERT_NE(processor_factory, nullptr) << "Cannot create PUCCH processor factory."; - - // Create PUCCH processor. - pucch_proc = processor_factory->create(); - ASSERT_NE(pucch_proc, nullptr) << "Cannot create PUCCH processor."; - - // Create PUCCH processor validator. - pucch_validator = processor_factory->create_validator(); - ASSERT_NE(pucch_validator, nullptr) << "Cannot create PUCCH validator."; - } - } -}; - -std::unique_ptr PucchProcessorFormat1Fixture::pucch_proc; -std::unique_ptr PucchProcessorFormat1Fixture::pucch_validator; - TEST_P(PucchProcessorFormat1Fixture, PucchProcessorValidatortest) { - ASSERT_NE(pucch_proc, nullptr) << "PUCCH processor not created."; - ASSERT_NE(pucch_validator, nullptr) << "PUCCH validator not created."; + ASSERT_NE(processor, nullptr) << "PUCCH processor not created."; + ASSERT_NE(validator, nullptr) << "PUCCH validator not created."; const test_case_t& param = GetParam(); // Make sure the configuration is invalid. - error_type validator_out = pucch_validator->is_valid(param.get_test_params().config); + error_type validator_out = validator->is_valid(param.get_test_params().config); ASSERT_FALSE(validator_out.has_value()) << "Validation should fail."; ASSERT_TRUE(std::regex_match(validator_out.error(), std::regex(param.get_test_params().assert_message))) << "The assertion message doesn't match the expected pattern."; @@ -299,7 +208,7 @@ TEST_P(PucchProcessorFormat1Fixture, PucchProcessorValidatortest) // Process PUCCH PDU. #ifdef ASSERTS_ENABLED - ASSERT_DEATH({ pucch_proc->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); + ASSERT_DEATH({ processor->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); #endif // ASSERTS_ENABLED } @@ -307,5 +216,3 @@ TEST_P(PucchProcessorFormat1Fixture, PucchProcessorValidatortest) INSTANTIATE_TEST_SUITE_P(PucchProcessorValidatortest, PucchProcessorFormat1Fixture, ::testing::ValuesIn(pucch_processor_validator_test_data)); - -} // namespace diff --git a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format2_test.cpp b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format2_test.cpp index 2da68f8f5b..1941eceaf3 100644 --- a/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format2_test.cpp +++ b/tests/unittests/phy/upper/channel_processors/pucch/pucch_processor_validator_format2_test.cpp @@ -21,26 +21,19 @@ */ #include "../../../support/resource_grid_test_doubles.h" -#include "srsran/phy/upper/channel_processors/channel_processor_factories.h" +#include "pucch_processor_test_fixture.h" #include "srsran/phy/upper/channel_processors/channel_processor_formatters.h" #include "srsran/phy/upper/channel_processors/pucch/factories.h" #include "srsran/phy/upper/channel_processors/pucch/formatters.h" -#include "srsran/phy/upper/equalization/equalization_factories.h" #include "srsran/ran/pucch/pucch_constants.h" -#include "fmt/ostream.h" -#include "gtest/gtest.h" +#include +#include #include using namespace srsran; namespace { -// Maximum channel dimensions used to construct the PUCCH processor. -channel_estimate::channel_estimate_dimensions max_dimensions = {MAX_RB, - MAX_NSYMB_PER_SLOT - 1, - 1, - pucch_constants::MAX_LAYERS}; - // Maximum number of UCI payload bits supported by the current PUCCH Format 2 implementation. constexpr unsigned PUCCH_F2_IMPL_MAX_NBITS = 1706; @@ -99,9 +92,22 @@ std::ostream& operator<<(std::ostream& os, const test_case_t& test_case) return os; } +} // namespace + +using PucchProcessorFormat2Param = test_case_t; +using PucchProcessorFormat2Fixture = PucchProcessorTestFixture; +template <> +std::unique_ptr PucchProcessorFormat2Fixture::processor = nullptr; +template <> +std::unique_ptr PucchProcessorFormat2Fixture::validator = nullptr; + +// Maximum channel dimensions used to construct the PUCCH processor. +static constexpr channel_estimate::channel_estimate_dimensions max_dimensions = + PucchProcessorFormat2Fixture::channel_estimate_dimensions; + // Test cases are implemented as lambda functions that generate and return an invalid PUCCH Format 2 configuration, // along with the expected assert message. -const std::vector pucch_processor_validator_test_data = { +const std::vector processoressor_validator_test_data = { { [] { test_params entry = {}; @@ -231,118 +237,15 @@ const std::vector pucch_processor_validator_test_data = { }, }}; -class PucchProcessorFormat2Fixture : public ::testing::TestWithParam -{ -protected: - static std::unique_ptr pucch_proc; - static std::unique_ptr pucch_validator; - - static void SetUpTestSuite() - { - if (!(pucch_proc && pucch_validator)) { - // Create factories required by the PUCCH demodulator factory. - std::shared_ptr equalizer_factory = create_channel_equalizer_generic_factory(); - ASSERT_NE(equalizer_factory, nullptr) << "Cannot create equalizer factory."; - - std::shared_ptr demod_factory = create_channel_modulation_sw_factory(); - ASSERT_NE(demod_factory, nullptr) << "Cannot create channel modulation factory."; - - std::shared_ptr prg_factory = create_pseudo_random_generator_sw_factory(); - ASSERT_NE(prg_factory, nullptr) << "Cannot create pseudo-random generator factory."; - - std::shared_ptr dft_factory = create_dft_processor_factory_fftw_slow(); - if (!dft_factory) { - dft_factory = create_dft_processor_factory_generic(); - } - ASSERT_NE(dft_factory, nullptr) << "Cannot create DFT factory."; - - std::shared_ptr precoding_factory = - create_dft_transform_precoder_factory(dft_factory, pucch_constants::FORMAT3_MAX_NPRB + 1); - ASSERT_NE(precoding_factory, nullptr) << "Cannot create transform precoder factory"; - - // Create PUCCH demodulator factory. - std::shared_ptr pucch_demod_factory = - create_pucch_demodulator_factory_sw(equalizer_factory, demod_factory, prg_factory, precoding_factory); - ASSERT_NE(pucch_demod_factory, nullptr) << "Cannot create PUCCH demodulator factory."; - - // Create factories required by the PUCCH channel estimator factory. - std::shared_ptr lpg_factory = - create_low_papr_sequence_generator_sw_factory(); - ASSERT_NE(lpg_factory, nullptr) << "Cannot create low PAPR sequence generator factory."; - - std::shared_ptr lpc_factory = - create_low_papr_sequence_collection_sw_factory(lpg_factory); - ASSERT_NE(lpc_factory, nullptr) << "Cannot create low PAPR sequence collection factory."; - - std::shared_ptr ta_estimator_factory = - create_time_alignment_estimator_dft_factory(dft_factory); - ASSERT_NE(ta_estimator_factory, nullptr) << "Cannot create TA estimator factory."; - - // Create channel estimator factory. - std::shared_ptr port_chan_estimator_factory = - create_port_channel_estimator_factory_sw(ta_estimator_factory); - ASSERT_NE(port_chan_estimator_factory, nullptr) << "Cannot create port channel estimator factory."; - - std::shared_ptr estimator_factory = - create_dmrs_pucch_estimator_factory_sw(prg_factory, lpc_factory, lpg_factory, port_chan_estimator_factory); - ASSERT_NE(estimator_factory, nullptr) << "Cannot create DM-RS PUCCH estimator factory."; - - // Create PUCCH detector factory. - std::shared_ptr detector_factory = - create_pucch_detector_factory_sw(lpc_factory, prg_factory, equalizer_factory); - ASSERT_NE(detector_factory, nullptr) << "Cannot create PUCCH detector factory."; - - // Create short block detector factory. - std::shared_ptr short_block_det_factory = create_short_block_detector_factory_sw(); - ASSERT_NE(short_block_det_factory, nullptr) << "Cannot create short block detector factory."; - - // Create polar decoder factory. - std::shared_ptr polar_dec_factory = create_polar_factory_sw(); - ASSERT_NE(polar_dec_factory, nullptr) << "Invalid polar decoder factory."; - - // Create CRC calculator factory. - std::shared_ptr crc_calc_factory = create_crc_calculator_factory_sw("auto"); - ASSERT_NE(crc_calc_factory, nullptr) << "Invalid CRC calculator factory."; - - // Create UCI decoder factory. - std::shared_ptr uci_dec_factory = - create_uci_decoder_factory_generic(short_block_det_factory, polar_dec_factory, crc_calc_factory); - ASSERT_NE(uci_dec_factory, nullptr) << "Cannot create UCI decoder factory."; - - // Create PUCCH processor factory. - std::shared_ptr processor_factory = create_pucch_processor_factory_sw( - estimator_factory, detector_factory, pucch_demod_factory, uci_dec_factory, max_dimensions); - ASSERT_NE(processor_factory, nullptr) << "Cannot create PUCCH processor factory."; - - // Create PUCCH processor. - pucch_proc = processor_factory->create(); - ASSERT_NE(pucch_proc, nullptr) << "Cannot create PUCCH processor."; - - // Create PUCCH processor validator. - pucch_validator = processor_factory->create_validator(); - ASSERT_NE(pucch_validator, nullptr) << "Cannot create PUCCH validator."; - } - } - - static void TearDownTestSuite() - { - pucch_validator.reset(); - pucch_proc.reset(); - } -}; - -std::unique_ptr PucchProcessorFormat2Fixture::pucch_proc; -std::unique_ptr PucchProcessorFormat2Fixture::pucch_validator; - TEST_P(PucchProcessorFormat2Fixture, PucchProcessorValidatortest) { - ASSERT_NE(pucch_proc, nullptr) << "PUCCH processor not created."; - ASSERT_NE(pucch_validator, nullptr) << "PUCCH validator not created."; + ASSERT_NE(processor, nullptr) << "PUCCH processor not created."; + ASSERT_NE(validator, nullptr) << "PUCCH validator not created."; const test_case_t& param = GetParam(); // Make sure the configuration is invalid. - error_type validator_out = pucch_validator->is_valid(param.get_test_params().config); + error_type validator_out = validator->is_valid(param.get_test_params().config); ASSERT_FALSE(validator_out.has_value()) << "Validation should fail."; ASSERT_TRUE(std::regex_match(validator_out.error(), std::regex(param.get_test_params().assert_message))) << "The assertion message doesn't match the expected pattern."; @@ -352,13 +255,11 @@ TEST_P(PucchProcessorFormat2Fixture, PucchProcessorValidatortest) // Process PUCCH PDU. #ifdef ASSERTS_ENABLED - ASSERT_DEATH({ pucch_proc->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); + ASSERT_DEATH({ processor->process(grid, param.get_test_params().config); }, param.get_test_params().assert_message); #endif // ASSERTS_ENABLED } // Creates test suite that combines all possible parameters. INSTANTIATE_TEST_SUITE_P(PucchProcessorValidatortest, PucchProcessorFormat2Fixture, - ::testing::ValuesIn(pucch_processor_validator_test_data)); - -} // namespace + ::testing::ValuesIn(processoressor_validator_test_data)); diff --git a/tests/unittests/phy/upper/channel_processors/pusch/pusch_demodulator_vectortest.cpp b/tests/unittests/phy/upper/channel_processors/pusch/pusch_demodulator_vectortest.cpp index 18dea2a19a..25661a9aba 100644 --- a/tests/unittests/phy/upper/channel_processors/pusch/pusch_demodulator_vectortest.cpp +++ b/tests/unittests/phy/upper/channel_processors/pusch/pusch_demodulator_vectortest.cpp @@ -128,8 +128,6 @@ class PuschDemodulatorFixture : public ::testing::TestWithParam // Prepare descrambled codeword data. codeword = test_case.codeword.read(); } - - ~PuschDemodulatorFixture() = default; }; TEST_P(PuschDemodulatorFixture, PuschDemodulatorUnittest)