diff --git a/CMakeLists.txt b/CMakeLists.txt index edd9c18657..2ca3de460f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,6 +271,11 @@ add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace" ON) add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace" ON) +add_boolean_option(TRACY_ENABLE OFF "Enable tracy instrumentation" ON) +if (TRACY_ENABLE) + CPMAddPackage("gh:wolfpld/tracy#v0.11.1") +endif() + set (OCP_ITTI ${OPENAIR_DIR}/common/utils/ocp_itti) add_library(ITTI ${OCP_ITTI}/intertask_interface.cpp) target_link_libraries(ITTI PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) @@ -637,6 +642,7 @@ if (cap_FOUND) target_compile_definitions(UTIL PRIVATE HAVE_LIB_CAP) endif() target_link_libraries(UTIL PUBLIC ${T_LIB} pthread LOG thread-pool utils) +target_link_libraries(UTIL PUBLIC instrumentation) set(SECURITY_SRC ${OPENAIR3_DIR}/SECU/secu_defs.c @@ -706,7 +712,7 @@ set(SCHED_SRC_NR_UE ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_uci_ue_nr.c ) add_library(SCHED_NR_UE_LIB ${SCHED_SRC_NR_UE}) -target_link_libraries(SCHED_NR_UE_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) +target_link_libraries(SCHED_NR_UE_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs UTIL) # nFAPI ################################# @@ -1144,7 +1150,7 @@ target_link_libraries(PHY_NR_NO_AVX_256 nr_phy_common nr_common) target_compile_definitions(PHY_NR_NO_AVX_256 PUBLIC USE_128BIT) add_library(PHY_NR_UE ${PHY_NR_UE_SRC}) -target_link_libraries(PHY_NR_UE PRIVATE asn1_nr_rrc_hdrs nr_phy_common nr_common) +target_link_libraries(PHY_NR_UE PRIVATE asn1_nr_rrc_hdrs nr_phy_common nr_common UTIL) add_library(PHY_RU ${PHY_SRC_RU}) target_link_libraries(PHY_RU PRIVATE asn1_lte_rrc_hdrs) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 14c4ac582a..229c93b043 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -2,3 +2,9 @@ add_subdirectory(utils) add_subdirectory(config/yaml) configure_file(oai_version.h.in oai_version.h @ONLY) + +add_library(instrumentation INTERFACE instrumentation.h) +target_include_directories(instrumentation INTERFACE .) +if (TRACY_ENABLE) + target_link_libraries(instrumentation INTERFACE Tracy::TracyClient) +endif() diff --git a/common/instrumentation.h b/common/instrumentation.h new file mode 100644 index 0000000000..6810761f69 --- /dev/null +++ b/common/instrumentation.h @@ -0,0 +1,42 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef INSTRUMENTATION_H +#define INSTRUMENTATION_H + +#ifdef TRACY_ENABLE +#include "tracy/TracyC.h" +#endif + +#ifndef TracyCZone +#define TracyCZone(...) +#endif +#ifndef TracyCZoneEnd +#define TracyCZoneEnd(...) +#endif +#ifndef TracyCFrameMark +#define TracyCFrameMark +#endif +#ifndef TracyCPlot +#define TracyCPlot(...) +#endif + +#endif diff --git a/executables/nr-ue.c b/executables/nr-ue.c index d6c3086317..a51f4b9294 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -39,6 +39,7 @@ #include "RRC/NR/MESSAGES/asn1_msg.h" #include "openair1/PHY/TOOLS/phy_scope_interface.h" #include "PHY/MODULATION/nr_modulation.h" +#include "instrumentation.h" /* * NR SLOT PROCESSING SEQUENCE @@ -480,6 +481,7 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD, bool sl_tx_action) void processSlotTX(void *arg) { + TracyCZone(ctx, true); nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; const UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; @@ -592,10 +594,12 @@ void processSlotTX(void *arg) *msgData = newslot; pushNotifiedFIFO(UE->tx_resume_ind_fifo + newslot, newElt); RU_write(rxtxD, sl_tx_action); + TracyCZoneEnd(ctx); } static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, const UE_nr_rxtx_proc_t *proc, int *tx_wait_for_dlsch, nr_phy_data_t *phy_data) { + TracyCZone(ctx, true); int sampleShift = INT_MAX; NR_DL_FRAME_PARMS *fp = &UE->frame_parms; if (UE->sl_mode == 2) @@ -677,10 +681,12 @@ static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, const UE_nr_rxtx_proc_t *proc } else ue_ta_procedures(UE, proc->nr_slot_tx, proc->frame_tx); + TracyCZoneEnd(ctx); return sampleShift; } void UE_dl_processing(void *arg) { + TracyCZone(ctx, true);; nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; @@ -688,6 +694,8 @@ void UE_dl_processing(void *arg) { if (!UE->sl_mode) pdsch_processing(UE, proc, phy_data); + + TracyCZoneEnd(ctx); } void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { @@ -951,6 +959,7 @@ void *UE_thread(void *arg) // start of normal case, the UE is in sync absolute_slot++; + TracyCFrameMark; int slot_nr = absolute_slot % nb_slot_frame; nr_rxtx_thread_data_t curMsg = {0}; diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 53c302e789..23560568cf 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -33,6 +33,7 @@ #include "T.h" #include #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h" +#include "instrumentation.h" extern openair0_config_t openair0_cfg[]; @@ -658,6 +659,7 @@ int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp, bool sidelink, uint Nid) { + TracyCZone(ctx, true); int Ns = proc->nr_slot_rx; c16_t pilot[200] __attribute__((aligned(16))); //int slot_pbch; @@ -830,6 +832,7 @@ int nr_pbch_channel_estimation(const NR_DL_FRAME_PARMS *fp, } } + TracyCZoneEnd(ctx); return(0); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 82819551e4..5dbab85f12 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -38,6 +38,7 @@ #include #include #include "openair1/PHY/NR_REFSIG/nr_refsig_common.h" +#include "instrumentation.h" //#define DEBUG_PBCH //#define DEBUG_PBCH_ENCODING @@ -365,6 +366,7 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, int rxdataFSize, const struct complex16 rxdataF[][rxdataFSize]) { + TracyCZone(ctx, true); int max_h=0; int symbol; uint8_t Lmax=frame_parms->Lmax; @@ -539,5 +541,6 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, ue->if_inst->dl_indication(&dl_indication); } + TracyCZoneEnd(ctx); return 0; } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2be6faeb9c..a3d566e707 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -75,6 +75,7 @@ fifo_dump_emos_UE emos_dump_UE; #include "UTIL/OPT/opt.h" #include "intertask_interface.h" #include "T.h" +#include "instrumentation.h" static const unsigned int gain_table[31] = {100, 112, 126, 141, 158, 178, 200, 224, 251, 282, 316, 359, 398, 447, 501, 562, 631, 708, 794, 891, 1000, 1122, @@ -378,6 +379,7 @@ static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, struct complex16 dl_ch_estimates[][estimateSz], c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { + TracyCZone(ctx, true); int ret = 0; DevAssert(ue); @@ -422,6 +424,7 @@ static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, LOG_E(PHY, "[UE %d] frame %d, nr_slot_rx %d, Error decoding PBCH!\n", ue->Mod_id, frame_rx, nr_slot_rx); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_OUT); + TracyCZoneEnd(ctx); return ret; } @@ -894,6 +897,7 @@ static bool is_ssb_index_transmitted(const PHY_VARS_NR_UE *ue, const int index) int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_data_t *phy_data) { + TracyCZone(ctx, true); int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int gNB_id = proc->gNB_id; @@ -1060,6 +1064,7 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ LOG_D(PHY, "[UE %d] Frame %d, nr_slot_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_slot_rx, dci_cnt); phy_pdcch_config->nb_search_space = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT); + TracyCZoneEnd(ctx); return sampleShift; } @@ -1154,6 +1159,7 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_phy_ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_IN); // it returns -1 in case of internal failure, or 0 in case of normal result int ret_pdsch = nr_ue_pdsch_procedures(ue, proc, dlsch, llr, rxdataF, G); + TracyCPlot("pdsch mcs", dlsch->dlsch_config.mcs); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_OUT);