From 77d5484b5c4daa691a7f78235053fb036829b1e9 Mon Sep 17 00:00:00 2001 From: Ishita Ghosh <43157456+IshitaGhosh@users.noreply.github.com> Date: Fri, 13 Nov 2020 07:51:30 -0800 Subject: [PATCH] Fix issue with reading AIE counter and GMIO metadata when PL device trace offload is enabled : CR 1083019 (#4455) --- .../profile/database/static_info_database.h | 33 +++++++++++++++- .../xdp/profile/plugin/aie/aie_plugin.cpp | 39 ++++++++----------- .../plugin/aie_trace/aie_trace_plugin.cpp | 23 +++++------ 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/src/runtime_src/xdp/profile/database/static_info_database.h b/src/runtime_src/xdp/profile/database/static_info_database.h index 0ba729c1b77..7c683946397 100644 --- a/src/runtime_src/xdp/profile/database/static_info_database.h +++ b/src/runtime_src/xdp/profile/database/static_info_database.h @@ -184,8 +184,6 @@ namespace xdp { }; struct DeviceInfo { - bool isReady; - double clockRateMHz; struct PlatformInfo platformInfo; @@ -215,6 +213,9 @@ namespace xdp { bool hasFloatingAIM = false; bool hasFloatingASM = false; + bool isReady = false; + bool isAIEcounterRead = false; + bool isGMIORead = false; uint32_t numTracePLIO = 0; @@ -294,6 +295,34 @@ namespace xdp { return deviceInfo[deviceId]->isReady; } + bool isAIECounterRead(uint64_t deviceId) + { + if(deviceInfo.find(deviceId) == deviceInfo.end()) + return false; + return deviceInfo[deviceId]->isAIEcounterRead; + } + + void setIsAIECounterRead(uint64_t deviceId, bool val) + { + if(deviceInfo.find(deviceId) == deviceInfo.end()) + return; + deviceInfo[deviceId]->isAIEcounterRead = val; + } + + void setIsGMIORead(uint64_t deviceId, bool val) + { + if(deviceInfo.find(deviceId) == deviceInfo.end()) + return; + deviceInfo[deviceId]->isGMIORead = val; + } + + bool isGMIORead(uint64_t deviceId) + { + if(deviceInfo.find(deviceId) == deviceInfo.end()) + return false; + return deviceInfo[deviceId]->isGMIORead; + } + double getClockRateMHz(uint64_t deviceId) { if(deviceInfo.find(deviceId) == deviceInfo.end()) diff --git a/src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp index 9b9c945c9e2..b2accf35915 100755 --- a/src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie/aie_plugin.cpp @@ -130,32 +130,25 @@ namespace xdp { (db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName)); } } + } #ifdef XRT_ENABLE_AIE - { - // Update the AIE specific portion of the device - std::shared_ptr device = - xrt_core::get_userpf_device(handle) ; - auto counters = xrt_core::edge::aie::get_profile_counters(device.get()); - if (xrt_core::config::get_aie_profile() && counters.empty()) { - std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available."); - xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ; - } - for (auto& counter : counters) { - (db->getStaticInfo()).addAIECounter(deviceId, - counter.id, - counter.column, - counter.row, - counter.counterNumber, - counter.startEvent, - counter.endEvent, - counter.resetEvent, - counter.clockFreqMhz, - counter.module, - counter.name) ; - } + if(!(db->getStaticInfo()).isAIECounterRead(deviceId)) { + // Update the AIE specific portion of the device + // When new xclbin is loaded, the xclbin specific datastructure is already recreated + std::shared_ptr device = xrt_core::get_userpf_device(handle); + auto counters = xrt_core::edge::aie::get_profile_counters(device.get()); + if (xrt_core::config::get_aie_profile() && counters.empty()) { + std::string msg("AIE Profile Counters are not found in AIE metadata of the given design. So, AIE Profile information will not be available."); + xrt_core::message::send(xrt_core::message::severity_level::XRT_WARNING, "XRT", msg) ; } -#endif + for (auto& counter : counters) { + (db->getStaticInfo()).addAIECounter(deviceId, counter.id, counter.column, + counter.row, counter.counterNumber, counter.startEvent, counter.endEvent, + counter.resetEvent, counter.clockFreqMhz, counter.module, counter.name); + } + (db->getStaticInfo()).setIsAIECounterRead(deviceId, true); } +#endif // Open the writer for this device struct xclDeviceInfo2 info; diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_plugin.cpp index 6e4a8c0a945..499dea03093 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_plugin.cpp @@ -99,19 +99,20 @@ namespace xdp { (db->getStaticInfo()).setDeviceName(deviceId, std::string(info.mName)); } } + } #ifdef XRT_ENABLE_AIE - { - // Update the AIE specific portion of the device - std::shared_ptr device = - xrt_core::get_userpf_device(handle) ; - if (device != nullptr) { - for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) { - (db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ; - } - } - } -#endif + if(!(db->getStaticInfo()).isGMIORead(deviceId)) { + // Update the AIE specific portion of the device + // When new xclbin is loaded, the xclbin specific datastructure is already recreated + std::shared_ptr device = xrt_core::get_userpf_device(handle) ; + if (device != nullptr) { + for (auto& gmio : xrt_core::edge::aie::get_trace_gmios(device.get())) { + (db->getStaticInfo()).addTraceGMIO(deviceId, gmio.id, gmio.shim_col, gmio.channel_number, gmio.stream_id, gmio.burst_len) ; + } + } + (db->getStaticInfo()).setIsGMIORead(deviceId, true); } +#endif uint64_t numAIETraceOutput = (db->getStaticInfo()).getNumAIETraceStream(deviceId); if(0 == numAIETraceOutput) {