From 51ec26fcaedefe3aaa4128035a4139d56fe0347f Mon Sep 17 00:00:00 2001 From: Nishant Mysore Date: Wed, 20 Sep 2023 16:16:43 -0500 Subject: [PATCH] Cleanup Signed-off-by: Nishant Mysore --- src/runtime_src/core/common/api/xrt_hw_context.cpp | 2 +- src/runtime_src/core/common/xdp/CMakeLists.txt | 1 - src/runtime_src/core/common/xdp/profile.cpp | 8 +++----- .../plugin/aie_profile/aie_profile_metadata.cpp | 2 +- .../plugin/aie_profile/aie_profile_plugin.cpp | 13 +++++++------ .../profile/plugin/aie_profile/win/aie_profile.cpp | 12 +++++++++--- .../profile/plugin/aie_profile/win/aie_profile.h | 1 + .../xdp/profile/plugin/vp_base/vp_base_plugin.cpp | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/runtime_src/core/common/api/xrt_hw_context.cpp b/src/runtime_src/core/common/api/xrt_hw_context.cpp index d9aaeabe834..f2a118637dd 100644 --- a/src/runtime_src/core/common/api/xrt_hw_context.cpp +++ b/src/runtime_src/core/common/api/xrt_hw_context.cpp @@ -150,7 +150,7 @@ hw_context:: hw_context(const xrt::device& device, const xrt::uuid& xclbin_id, const xrt::hw_context::cfg_param_type& cfg_param) : detail::pimpl(std::make_shared(device.get_handle(), xclbin_id, cfg_param)) { - // xrt_core::xdp::update_device(get_handle().get()); + xrt_core::xdp::update_device(get_handle().get()); } diff --git a/src/runtime_src/core/common/xdp/CMakeLists.txt b/src/runtime_src/core/common/xdp/CMakeLists.txt index 9a329b5a367..c1746f98e78 100644 --- a/src/runtime_src/core/common/xdp/CMakeLists.txt +++ b/src/runtime_src/core/common/xdp/CMakeLists.txt @@ -7,7 +7,6 @@ add_library(core_common_xdp_profile_objects OBJECT target_include_directories(core_common_xdp_profile_objects PRIVATE ${XRT_SOURCE_DIR}/runtime_src - ${XRT_SOURCE_DIR}/runtime_src/core/common/elf ) if (XDP_MINIMAL_BUILD STREQUAL "yes") diff --git a/src/runtime_src/core/common/xdp/profile.cpp b/src/runtime_src/core/common/xdp/profile.cpp index 958777588d2..1eabab20ef1 100644 --- a/src/runtime_src/core/common/xdp/profile.cpp +++ b/src/runtime_src/core/common/xdp/profile.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2023 Advanced Micro Devices, Inc. - All rights reserved +#define XRT_CORE_COMMON_SOURCE #include "core/common/xdp/profile.h" #include "core/common/config_reader.h" @@ -21,8 +22,8 @@ namespace xrt_core::xdp::aie::profile { warning_callbacks); } - std::function update_device_cb; - std::function end_poll_cb; + std::function update_device_cb = nullptr; + std::function end_poll_cb = nullptr; void register_callbacks(void* handle) @@ -32,9 +33,6 @@ namespace xrt_core::xdp::aie::profile { #ifdef XDP_MINIMAL_BUILD update_device_cb = reinterpret_cast(xrt_core::dlsym(handle, "updateAIECtrDevice")); end_poll_cb = reinterpret_cast(xrt_core::dlsym(handle, "endAIECtrPoll")); - #else - update_device_cb = reinterpret_cast(xrt_core::dlsym(handle, "IPUConfigProfile")); - end_poll_cb = reinterpret_cast(xrt_core::dlsym(handle, "IPUReadProfile")); #endif } diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.cpp index 994b055bf5a..1a1be2653f6 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.cpp @@ -48,7 +48,7 @@ namespace xdp { } metricStrings[module_type::core].insert(metricStrings[module_type::core].end(), {"s2mm_throughputs", "mm2s_throughputs"}); metricStrings[module_type::dma].insert(metricStrings[module_type::dma].end(), {"s2mm_throughputs", "mm2s_throughputs"}); - metricStrings[module_type::shim].insert(metricStrings[module_type::shim].end(), {"s2mm_throughputs", "mm2s_throughputs", "s2mm_stalls", "mm2s_stalls"}); + metricStrings[module_type::shim].insert(metricStrings[module_type::shim].end(), {"s2mm_throughputs", "mm2s_throughputs", "s2mm_stalls0", "mm2s_stalls0", "s2mm_stalls1", "mm2s_stalls1"}); metricStrings[module_type::mem_tile].insert(metricStrings[module_type::mem_tile].end(), {"s2mm_throughputs", "mm2s_throughputs", "conflict_stats1", "conflict_stats2","conflict_stats3", "conflict_stats4"}); #else diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp index 72313c8c69c..df55dbb3a33 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_plugin.cpp @@ -171,11 +171,9 @@ namespace xdp { AIEData.threadCtrlBool = false; #else AIEData.threadCtrlBool = true; -#endif auto device_thread = std::thread(&AieProfilePlugin::pollAIECounters, this, mIndex, handleToAIEData.begin()->first); - // auto device_thread = std::thread(&AieProfileImpl::pollAIECounters, implementation.get(), mIndex, handle); AIEData.thread = std::move(device_thread); - +#endif // Open the writer for this device auto time = std::time(nullptr); @@ -216,7 +214,7 @@ namespace xdp { std::this_thread::sleep_for(std::chrono::microseconds(handleToAIEData[handle].metadata->getPollingIntervalVal())); } //Final Polling Operation - // handleToAIEData[handle].implementation->poll(index, handle); + handleToAIEData[handle].implementation->poll(index, handle); } void AieProfilePlugin::writeAll(bool /*openNewFiles*/) @@ -258,8 +256,11 @@ namespace xdp { void AieProfilePlugin::endPoll() { xrt_core::message::send(severity_level::info, "XRT", "Calling AIE Profile endPoll."); - auto& AIEData = handleToAIEData.begin()->second; - AIEData.implementation->poll(0, nullptr); + + #ifdef XDP_MINIMAL_BUILD + auto& AIEData = handleToAIEData.begin()->second; + AIEData.implementation->poll(0, nullptr); + #endif // Ask all threads to end for (auto& p : handleToAIEData) p.second.threadCtrlBool = false; diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.cpp b/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.cpp index 21f596d93b3..c5dbc4d4774 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.cpp @@ -105,9 +105,11 @@ namespace xdp { // **** Interface Tile Counters **** mShimStartEvents = { {"s2mm_throughputs", {XAIE_EVENT_GROUP_DMA_ACTIVITY_PL, XAIE_EVENT_PORT_RUNNING_0_PL}}, - {"s2mm_stalls", {XAIE_EVENT_DMA_S2MM_SEL0_MEMORY_BACKPRESSURE_MEM_TILE, XAIE_EVENT_DMA_S2MM_SEL0_STALLED_LOCK_ACQUIRE_MEM_TILE}}, + {"s2mm_stalls0", {XAIE_EVENT_DMA_S2MM_0_MEMORY_BACKPRESSURE_PL, XAIE_EVENT_DMA_S2MM_0_STALLED_LOCK_PL}}, + {"s2mm_stalls1", {XAIE_EVENT_DMA_S2MM_1_MEMORY_BACKPRESSURE_PL, XAIE_EVENT_DMA_S2MM_1_STALLED_LOCK_PL}}, + {"mm2s_stalls0", {XAIE_EVENT_DMA_MM2S_0_STREAM_BACKPRESSURE_PL, XAIE_EVENT_DMA_MM2S_0_MEMORY_STARVATION_PL}}, + {"mm2s_stalls1", {XAIE_EVENT_DMA_MM2S_1_STREAM_BACKPRESSURE_PL, XAIE_EVENT_DMA_MM2S_1_MEMORY_STARVATION_PL}}, {"mm2s_throughputs", {XAIE_EVENT_GROUP_DMA_ACTIVITY_PL, XAIE_EVENT_PORT_RUNNING_0_PL}}, - {"mm2s_stalls", {XAIE_EVENT_DMA_MM2S_SEL0_STREAM_BACKPRESSURE_MEM_TILE, XAIE_EVENT_DMA_MM2S_SEL0_MEMORY_STARVATION_MEM_TILE}}, {"packets", {XAIE_EVENT_PORT_TLAST_0_PL, XAIE_EVENT_PORT_TLAST_1_PL}} }; @@ -478,7 +480,10 @@ namespace xdp { AieProfile_WinImpl:: poll(uint32_t index, void* handle) { - std::cout << "handle; " << handle << std::endl; + if (finishedPoll) + return; + + (void)handle; double timestamp = xrt_core::time_ns() / 1.0e6; auto context = metadata->getHwContext(); @@ -533,6 +538,7 @@ namespace xdp { db->getDynamicInfo().addAIESample(index, timestamp, values); } + finishedPoll=true; free(op); } diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.h b/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.h index 4de6a97277c..31d81d2598f 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.h +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/win/aie_profile.h @@ -121,6 +121,7 @@ namespace xdp { std::size_t op_size; XAie_DevInst aieDevInst = {0}; std::vector> outputValues; + bool finishedPoll = false; }; diff --git a/src/runtime_src/xdp/profile/plugin/vp_base/vp_base_plugin.cpp b/src/runtime_src/xdp/profile/plugin/vp_base/vp_base_plugin.cpp index 48975049f9e..568a234a08d 100644 --- a/src/runtime_src/xdp/profile/plugin/vp_base/vp_base_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/vp_base/vp_base_plugin.cpp @@ -95,7 +95,7 @@ namespace xdp { { // Base functionality is just to have all writers write. Derived // classes might have to do more. - std::cout << "in writeall base class!" << std::endl; + endWrite(); }