diff --git a/build/petalinux.build b/build/petalinux.build index 1ab8c62e60e..633cc5adda3 100644 --- a/build/petalinux.build +++ b/build/petalinux.build @@ -1,3 +1,4 @@ # When updating Petalinux build please file a SH ticket to retain the build # https://jira.xilinx.com/secure/CreateIssue!default.jspa -PETALINUX="/proj/petalinux/2024.1/petalinux-v2024.1_11011506/tool/petalinux-v2024.1-final" +#PETALINUX="/proj/petalinux/2024.1/petalinux-v2024.1_11011506/tool/petalinux-v2024.1-final" +PETALINUX="/proj/petalinux/2024.1/petalinux-v2024.1_11291502/tool/petalinux-v2024.1-final/" diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp index 51646c7b061..8246912ab32 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.cpp @@ -190,22 +190,13 @@ namespace xdp::aie { std::string graphName = graph.second.get("name"); graphs.push_back(graphName); } + xrt_core::message::send(severity_level::warning, "XRT", "metadataReader->getValidGraphs(): " ); + for(auto name : graphs) { + xrt_core::message::send(severity_level::warning, "XRT", "\t " + name ); + } return graphs; } - /**************************************************************************** - * Read AIE metadata from axlf section - ***************************************************************************/ - std::unique_ptr - readAIEMetadata(const char* data, size_t size, pt::ptree& aie_project) - { - std::stringstream aie_stream; - aie_stream.write(data,size); - pt::read_json(aie_stream, aie_project); - - return determineFileType(aie_project); - } - /**************************************************************************** * Read AIE metadata from file ***************************************************************************/ diff --git a/src/runtime_src/xdp/profile/database/static_info/aie_util.h b/src/runtime_src/xdp/profile/database/static_info/aie_util.h index 26738c516d0..cc8a011a80a 100755 --- a/src/runtime_src/xdp/profile/database/static_info/aie_util.h +++ b/src/runtime_src/xdp/profile/database/static_info/aie_util.h @@ -37,12 +37,9 @@ namespace xdp::aie { void throwIfError(bool err, const char* msg); - // A function to read the JSON from an axlf section inside the xclbin and - // return the type of the file - XDP_CORE_EXPORT - std::unique_ptr - readAIEMetadata(const char* data, size_t size, - boost::property_tree::ptree& aie_project); + XDP_CORE_EXPORT + std::unique_ptr + determineFileType(boost::property_tree::ptree& aie_project); // A function to read the JSON from a file on disk and return the type of // the file diff --git a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp index bb378c641ab..ee66fe5178a 100644 --- a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp +++ b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.cpp @@ -32,23 +32,26 @@ AIEControlConfigFiletype::AIEControlConfigFiletype(boost::property_tree::ptree& : BaseFiletypeImpl(aie_project) {} std::string -AIEControlConfigFiletype::getMessage(std::string secName) +AIEControlConfigFiletype::getMessage(std::string secName) const { return "Ignoring AIE metadata section " + secName + " since not found."; } driver_config -AIEControlConfigFiletype::getDriverConfig() { +AIEControlConfigFiletype::getDriverConfig() const +{ return xdp::aie::getDriverConfig(aie_meta, "aie_metadata.driver_config"); } int -AIEControlConfigFiletype::getHardwareGeneration() { +AIEControlConfigFiletype::getHardwareGeneration() const +{ return xdp::aie::getHardwareGeneration(aie_meta, "aie_metadata.driver_config.hw_gen"); } aiecompiler_options -AIEControlConfigFiletype::getAIECompilerOptions() { +AIEControlConfigFiletype::getAIECompilerOptions() const +{ aiecompiler_options aiecompiler_options; aiecompiler_options.broadcast_enable_core = aie_meta.get("aie_metadata.aiecompiler_options.broadcast_enable_core", false); @@ -60,17 +63,19 @@ AIEControlConfigFiletype::getAIECompilerOptions() { } uint8_t -AIEControlConfigFiletype::getAIETileRowOffset() { +AIEControlConfigFiletype::getAIETileRowOffset() const { return xdp::aie::getAIETileRowOffset(aie_meta, "aie_metadata.driver_config.aie_tile_row_start"); } std::vector -AIEControlConfigFiletype::getValidGraphs() { +AIEControlConfigFiletype::getValidGraphs() const +{ return xdp::aie::getValidGraphs(aie_meta, "aie_metadata.graphs"); } std::vector -AIEControlConfigFiletype::getValidPorts() { +AIEControlConfigFiletype::getValidPorts() const +{ auto ios = getAllIOs(); if (ios.empty()) { xrt_core::message::send(severity_level::info, "XRT", "No valid ports found."); @@ -90,7 +95,8 @@ AIEControlConfigFiletype::getValidPorts() { } std::vector -AIEControlConfigFiletype::getValidKernels() { +AIEControlConfigFiletype::getValidKernels() const +{ std::vector kernels; // Grab all kernel to tile mappings @@ -99,6 +105,7 @@ AIEControlConfigFiletype::getValidKernels() { xrt_core::message::send(severity_level::info, "XRT", getMessage("TileMapping.AIEKernelToTileMapping")); return {}; } + xrt_core::message::send(severity_level::info, "XRT", "metadataReader found key: TileMapping.AIEKernelToTileMapping"); for (auto const &mapping : kernelToTileMapping.get()) { std::vector names; @@ -107,16 +114,22 @@ AIEControlConfigFiletype::getValidKernels() { std::unique_copy(names.begin(), names.end(), std::back_inserter(kernels)); } + xrt_core::message::send(severity_level::warning, "XRT", "metadataReader->getValidKernels(): " ); + for(auto name : kernels) { + xrt_core::message::send(severity_level::warning, "XRT", "\t " + name ); + } + return kernels; } std::unordered_map -AIEControlConfigFiletype::getTraceGMIOs(){ +AIEControlConfigFiletype::getTraceGMIOs() const +{ return getChildGMIOs("aie_metadata.TraceGMIOs"); } std::unordered_map -AIEControlConfigFiletype::getPLIOs() +AIEControlConfigFiletype::getPLIOs() const { auto pliosMetadata = aie_meta.get_child_optional("aie_metadata.PLIOs"); if (!pliosMetadata) { @@ -146,13 +159,13 @@ AIEControlConfigFiletype::getPLIOs() } std::unordered_map -AIEControlConfigFiletype::getGMIOs() +AIEControlConfigFiletype::getGMIOs() const { return getChildGMIOs("aie_metadata.GMIOs"); } std::unordered_map -AIEControlConfigFiletype::getAllIOs() +AIEControlConfigFiletype::getAllIOs() const { auto ios = getPLIOs(); auto gmios = getGMIOs(); @@ -161,7 +174,7 @@ AIEControlConfigFiletype::getAllIOs() } std::unordered_map -AIEControlConfigFiletype::getChildGMIOs( const std::string& childStr) +AIEControlConfigFiletype::getChildGMIOs( const std::string& childStr) const { auto gmiosMetadata = aie_meta.get_child_optional(childStr); if (!gmiosMetadata) { @@ -205,7 +218,7 @@ AIEControlConfigFiletype::getInterfaceTiles(const std::string& graphName, int16_t channelId, bool useColumn, uint8_t minCol, - uint8_t maxCol) + uint8_t maxCol) const { std::vector tiles; @@ -274,7 +287,7 @@ AIEControlConfigFiletype::getInterfaceTiles(const std::string& graphName, std::vector AIEControlConfigFiletype::getMemoryTiles(const std::string& graph_name, - const std::string& buffer_name) + const std::string& buffer_name) const { if (getHardwareGeneration() == 1) return {}; @@ -316,7 +329,7 @@ AIEControlConfigFiletype::getMemoryTiles(const std::string& graph_name, // Find all AIE tiles in a graph that use the core (kernel_name = all) std::vector -AIEControlConfigFiletype::getAIETiles(const std::string& graph_name) +AIEControlConfigFiletype::getAIETiles(const std::string& graph_name) const { auto graphsMetadata = aie_meta.get_child_optional("aie_metadata.graphs"); if (!graphsMetadata) { @@ -374,7 +387,7 @@ AIEControlConfigFiletype::getAIETiles(const std::string& graph_name) // Find all AIE tiles in a graph that use core and/or memories (kernel_name = all) std::vector -AIEControlConfigFiletype::getAllAIETiles(const std::string& graph_name) +AIEControlConfigFiletype::getAllAIETiles(const std::string& graph_name) const { std::vector tiles; tiles = getEventTiles(graph_name, module_type::core); @@ -385,7 +398,7 @@ AIEControlConfigFiletype::getAllAIETiles(const std::string& graph_name) std::vector AIEControlConfigFiletype::getEventTiles(const std::string& graph_name, - module_type type) + module_type type) const { if ((type == module_type::shim) || (type == module_type::mem_tile)) return {}; @@ -431,7 +444,7 @@ AIEControlConfigFiletype::getEventTiles(const std::string& graph_name, std::vector AIEControlConfigFiletype::getTiles(const std::string& graph_name, module_type type, - const std::string& kernel_name) + const std::string& kernel_name) const { if (type == module_type::mem_tile) return getMemoryTiles(graph_name, kernel_name); @@ -470,4 +483,13 @@ AIEControlConfigFiletype::getTiles(const std::string& graph_name, } return tiles; } + +void +AIEControlConfigFiletype::dumpAieMeta(std::string plugin_name) const +{ + std::string filename = "debug_" + plugin_name + "_aie_control.json"; + boost::property_tree::json_parser::write_json(filename, aie_meta); + xrt_core::message::send(severity_level::info, "XRT", "AIE_Meta as JSON file saved successfully."); +} + } diff --git a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.h b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.h index dd2b3a8575e..9568ad9e4cd 100644 --- a/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.h +++ b/src/runtime_src/xdp/profile/database/static_info/filetypes/aie_control_config_filetype.h @@ -31,38 +31,38 @@ class AIEControlConfigFiletype : public xdp::aie::BaseFiletypeImpl { ~AIEControlConfigFiletype() = default; driver_config - getDriverConfig() override; + getDriverConfig() const override; - int getHardwareGeneration() override; + int getHardwareGeneration() const override; aiecompiler_options - getAIECompilerOptions() override; + getAIECompilerOptions() const override; - uint8_t getAIETileRowOffset() override; + uint8_t getAIETileRowOffset() const override; std::vector - getValidGraphs() override; + getValidGraphs() const override; std::vector - getValidPorts() override; + getValidPorts() const override; std::vector - getValidKernels() override; + getValidKernels() const override; std::unordered_map - getTraceGMIOs(); + getTraceGMIOs() const; std::unordered_map - getAllIOs(); + getAllIOs() const; std::unordered_map - getPLIOs(); + getPLIOs() const; std::unordered_map - getChildGMIOs(const std::string& childStr); + getChildGMIOs(const std::string& childStr) const; std::unordered_map - getGMIOs(); + getGMIOs() const; std::vector getInterfaceTiles(const std::string& graphName, @@ -71,29 +71,32 @@ class AIEControlConfigFiletype : public xdp::aie::BaseFiletypeImpl { int16_t channelId = -1, bool useColumn = false, uint8_t minCol = 0, - uint8_t maxCol = 0) override; + uint8_t maxCol = 0) const override; std::vector getMemoryTiles(const std::string& graphName, - const std::string& bufferName = "all") override; + const std::string& bufferName = "all") const override; std::vector - getAIETiles(const std::string& graphName) override; + getAIETiles(const std::string& graphName) const override; std::vector - getAllAIETiles(const std::string& graphName) override; + getAllAIETiles(const std::string& graphName) const override; std::vector getEventTiles(const std::string& graph_name, - module_type type) override; + module_type type) const override; std::vector getTiles(const std::string& graph_name, module_type type, - const std::string& kernel_name = "all") override; + const std::string& kernel_name = "all") const override; + + void + dumpAieMeta(std::string plugin_name) const override; private: - std::string getMessage(std::string secName); + std::string getMessage(std::string secName) const; }; diff --git a/src/runtime_src/xdp/profile/database/static_info/filetypes/base_filetype_impl.h b/src/runtime_src/xdp/profile/database/static_info/filetypes/base_filetype_impl.h index e074b9eed5c..c2a6f7830a2 100644 --- a/src/runtime_src/xdp/profile/database/static_info/filetypes/base_filetype_impl.h +++ b/src/runtime_src/xdp/profile/database/static_info/filetypes/base_filetype_impl.h @@ -18,6 +18,7 @@ #define BASE_FILETYPE_DOT_H #include +#include #include "xdp/profile/database/static_info/aie_constructs.h" namespace xdp::aie { @@ -33,26 +34,26 @@ class BaseFiletypeImpl { // Top level interface used for both file type formats virtual driver_config - getDriverConfig() = 0; + getDriverConfig() const = 0; - virtual int getHardwareGeneration() = 0; + virtual int getHardwareGeneration() const = 0; virtual aiecompiler_options - getAIECompilerOptions() = 0; + getAIECompilerOptions() const = 0; - virtual uint8_t getAIETileRowOffset() = 0; + virtual uint8_t getAIETileRowOffset() const = 0; virtual std::vector - getValidGraphs() = 0; + getValidGraphs() const = 0; virtual std::vector - getValidPorts() = 0; + getValidPorts() const = 0; virtual std::vector - getValidKernels() = 0; + getValidKernels() const = 0; virtual std::unordered_map - getTraceGMIOs() = 0; + getTraceGMIOs() const = 0; virtual std::vector @@ -62,27 +63,30 @@ class BaseFiletypeImpl { int16_t channelId = -1, bool useColumn = false, uint8_t minCol = 0, - uint8_t maxCol = 0) = 0; + uint8_t maxCol = 0) const = 0; virtual std::vector getMemoryTiles(const std::string& graphName, - const std::string& bufferName) = 0; + const std::string& bufferName) const = 0; virtual std::vector - getAIETiles(const std::string& graphName) = 0; + getAIETiles(const std::string& graphName) const = 0; virtual std::vector - getAllAIETiles(const std::string& graphName) = 0; + getAllAIETiles(const std::string& graphName) const = 0; virtual std::vector getEventTiles(const std::string& graph_name, - module_type type) = 0; + module_type type) const = 0; virtual std::vector getTiles(const std::string& graph_name, module_type type, - const std::string& kernel_name) = 0; + const std::string& kernel_name) const = 0; + + virtual void + dumpAieMeta(std::string plugin_name) const = 0; }; } diff --git a/src/runtime_src/xdp/profile/database/static_info_database.cpp b/src/runtime_src/xdp/profile/database/static_info_database.cpp index a3735117872..2d13f9a16fa 100644 --- a/src/runtime_src/xdp/profile/database/static_info_database.cpp +++ b/src/runtime_src/xdp/profile/database/static_info_database.cpp @@ -2000,7 +2000,8 @@ namespace xdp { XclbinInfo* currentXclbin = new XclbinInfo() ; currentXclbin->uuid = xrtXclbin.get_uuid(); currentXclbin->pl.clockRatePLMHz = findClockRate(xrtXclbin) ; - + + readAIEMetadata(xrtXclbin); setDeviceNameFromXclbin(deviceId, xrtXclbin); setAIEGeneration(deviceId, xrtXclbin); @@ -2056,25 +2057,59 @@ namespace xdp { return; } } - - void VPStaticDatabase::setAIEGeneration(uint64_t deviceId, xrt::xclbin xrtXclbin) { - std::lock_guard lock(deviceLock) ; - if (deviceInfo.find(deviceId) == deviceInfo.end()) - return; + void VPStaticDatabase::readAIEMetadata(xrt::xclbin xrtXclbin) + { + #ifdef XDP_CLIENT_BUILD + metadataReader = aie::readAIEMetadata("aie_control_config.json", aie_meta); + xrt_core::message::send(xrt_core::message::severity_level::debug, "XRT", "AIE metadata read successfully!"); + return ; + #endif auto data = xrt_core::xclbin_int::get_axlf_section(xrtXclbin, AIE_METADATA); - if (!data.first || !data.second) + if (!data.first || !data.second) { return; - - boost::property_tree::ptree aie_meta; + } std::stringstream aie_stream; aie_stream.write(data.first, data.second); - boost::property_tree::read_json(aie_stream, aie_meta); - try { - auto hwGen = aie_meta.get_child("aie_metadata.driver_config.hw_gen").get_value(); + boost::property_tree::read_json(aie_stream, mAieMeta); + } catch (const std::exception& e) { + std::string msg("Error: invalid AIE_METADATA json detected: "); + msg += e.what(); + xrt_core::message::send(xrt_core::message::severity_level::info, "XRT", msg); + } + + if (mAieMeta.empty()) + return; + + metadataReader = xdp::aie::determineFileType(mAieMeta); + xrt_core::message::send(xrt_core::message::severity_level::debug, "XRT", "AIE metadata read successfully!"); + } + + bool VPStaticDatabase::metadataReaderValid() + { + return metadataReader != nullptr ; + } + + const xdp::aie::BaseFiletypeImpl* + VPStaticDatabase::getAIEmetadataReader() const + { + xrt_core::message::send(xrt_core::message::severity_level::info, "XRT", "AIE metadataReader requested"); + return metadataReader.get(); + } + + void VPStaticDatabase::setAIEGeneration(uint64_t deviceId, xrt::xclbin xrtXclbin) { + std::lock_guard lock(deviceLock) ; + if (deviceInfo.find(deviceId) == deviceInfo.end()) + return; + + if (mAieMeta.empty()) + return; + + try { + auto hwGen = mAieMeta.get_child("aie_metadata.driver_config.hw_gen").get_value(); deviceInfo[deviceId]->setAIEGeneration(hwGen); } catch(...) { return; @@ -2091,18 +2126,11 @@ namespace xdp { if (!xclbin) return; - auto data = xrt_core::xclbin_int::get_axlf_section(xrtXclbin, AIE_METADATA); - if (!data.first || !data.second) - return; - - boost::property_tree::ptree aie_meta; - - std::stringstream aie_stream; - aie_stream.write(data.first, data.second); - boost::property_tree::read_json(aie_stream,aie_meta); + if (mAieMeta.empty()) + return; try { - auto dev_node = aie_meta.get_child("aie_metadata.DeviceData"); + auto dev_node = mAieMeta.get_child("aie_metadata.DeviceData"); xclbin->aie.clockRateAIEMHz = dev_node.get("AIEFrequency"); } catch(...) { return; 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 07dc87ba45c..7481091e9a1 100644 --- a/src/runtime_src/xdp/profile/database/static_info_database.h +++ b/src/runtime_src/xdp/profile/database/static_info_database.h @@ -28,6 +28,8 @@ #include "core/common/system.h" #include "core/common/device.h" +#include "xdp/profile/database/static_info/aie_util.h" +#include "xdp/profile/database/static_info/filetypes/base_filetype_impl.h" #include "xdp/config.h" @@ -107,6 +109,8 @@ namespace xdp { void* aieDevInst = nullptr ; // XAie_DevInst void* aieDevice = nullptr ; // xaiefal::XAieDev std::function deallocateAieDevice = nullptr ; + boost::property_tree::ptree mAieMeta; // stores AIE_METADATA + std::unique_ptr metadataReader = nullptr; bool resetDeviceInfo(uint64_t deviceId, const std::shared_ptr& device); @@ -337,6 +341,9 @@ namespace xdp { XDP_CORE_EXPORT void* getAieDevice(std::function allocate, std::function deallocate, void* devHandle) ; + XDP_CORE_EXPORT void readAIEMetadata(xrt::xclbin xrtXclbin); + XDP_CORE_EXPORT bool metadataReaderValid(); + XDP_CORE_EXPORT const aie::BaseFiletypeImpl* getAIEmetadataReader() const; // ************************************************************************ // ***** Functions for information from a specific xclbin on a device ***** diff --git a/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.cpp index 39341492c9b..d8f185d3d5f 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.cpp @@ -61,10 +61,8 @@ namespace xdp { if (!xrt_core::config::get_aie_debug()) return; - try { - pt::read_json("aie_control_config.json", aie_meta); - filetype = aie::readAIEMetadata("aie_control_config.json", aie_meta); - } catch (...) { + metadataReader = (db->getStaticInfo()).getAIEmetadataReader(); + if (!metadataReader) { std::stringstream msg; msg << "The file aie_control_config.json is required in the same directory as the host executable to run AIE Debug."; xrt_core::message::send(severity_level::warning, "XRT", msg.str()); @@ -105,9 +103,9 @@ namespace xdp { std::vector tiles; if (type == module_type::shim) { - tiles = filetype->getInterfaceTiles("all", "all", "", -1); + tiles = metadataReader->getInterfaceTiles("all", "all", "", -1); } else { - tiles = filetype->getTiles("all", type, "all"); + tiles = metadataReader->getTiles("all", type, "all"); } if (tiles.empty()) { @@ -309,7 +307,7 @@ namespace xdp { AieDebugPlugin:: getAIEConfigMetadata() { - return filetype->getDriverConfig(); + return metadataReader->getDriverConfig(); } } // end namespace xdp diff --git a/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.h b/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.h index 087e31220e1..9802121882a 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.h +++ b/src/runtime_src/xdp/profile/plugin/aie_debug/aie_debug_plugin.h @@ -48,8 +48,7 @@ namespace xdp { std::unique_ptr transactionHandler; uint8_t* txn_ptr; XAie_DevInst aieDevInst = {0}; - boost::property_tree::ptree aie_meta; - std::unique_ptr filetype; + const aie::BaseFiletypeImpl* metadataReader = nullptr; aie_profile_op_t* op; std::size_t op_size; 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 9375b8ee702..3e45f760d78 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 @@ -30,7 +30,7 @@ #include "xdp/profile/plugin/vp_base/vp_base_plugin.h" namespace xdp { - using severity_level = xrt_core::message::severity_level; + // using severity_level = xrt_core::message::severity_level; namespace pt = boost::property_tree; AieProfileMetadata::AieProfileMetadata(uint64_t deviceID, void* handle) : @@ -39,21 +39,16 @@ namespace xdp { { xrt_core::message::send(severity_level::info, "XRT", "Parsing AIE Profile Metadata."); + VPDatabase* db = VPDatabase::Instance(); - #ifdef XDP_CLIENT_BUILD - metadataReader = aie::readAIEMetadata("aie_control_config.json", aie_meta); - #else - auto device = xrt_core::get_userpf_device(handle); - auto data = device->get_axlf_section(AIE_METADATA); - - metadataReader = aie::readAIEMetadata(data.first, data.second, aie_meta); - #endif - - if (metadataReader == nullptr) { + metadataReader = (db->getStaticInfo()).getAIEmetadataReader(); + if (!metadataReader) { xrt_core::message::send(severity_level::error, "XRT", "Error parsing AIE Profiling Metadata."); return; } + std::string name = "aie_profile_start"; + metadataReader->dumpAieMeta(name); // Verify settings from xrt.ini checkSettings(); @@ -64,7 +59,6 @@ namespace xdp { // Setup Config Metrics // Get AIE clock frequency - VPDatabase* db = VPDatabase::Instance(); clockFreqMhz = (db->getStaticInfo()).getClockRateMHz(deviceID, false); // Tile-based metrics settings @@ -845,5 +839,5 @@ namespace xdp { { return metadataReader->getDriverConfig(); } - + } // namespace xdp diff --git a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.h b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.h index 46f65957b79..02062fd9944 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.h +++ b/src/runtime_src/xdp/profile/plugin/aie_profile/aie_profile_metadata.h @@ -22,6 +22,7 @@ #include #include "core/common/device.h" +#include "core/common/message.h" #include "core/include/xrt/xrt_hw_context.h" #include "xdp/config.h" #include "xdp/profile/database/static_info/aie_constructs.h" @@ -31,6 +32,7 @@ namespace xdp { +using severity_level = xrt_core::message::severity_level; constexpr unsigned int NUM_CORE_COUNTERS = 4; constexpr unsigned int NUM_MEMORY_COUNTERS = 2; constexpr unsigned int NUM_SHIM_COUNTERS = 2; @@ -91,8 +93,7 @@ class AieProfileMetadata { std::vector> configMetrics; std::map configChannel0; std::map configChannel1; - boost::property_tree::ptree aie_meta; - std::unique_ptr metadataReader; + const aie::BaseFiletypeImpl* metadataReader = nullptr; public: AieProfileMetadata(uint64_t deviceID, void* handle); @@ -123,8 +124,16 @@ class AieProfileMetadata { int getNumCountersMod(const int module){ return numCountersMod[module]; } module_type getModuleType(const int module) { return moduleTypes[module]; } - uint8_t getAIETileRowOffset() { return metadataReader->getAIETileRowOffset();} - int getHardwareGen() { return metadataReader->getHardwareGeneration();} + uint8_t getAIETileRowOffset() const { + auto offset = metadataReader->getAIETileRowOffset(); + xrt_core::message::send(severity_level::warning, "XRT", std::to_string(offset)); + return offset; + } + int getHardwareGen() { + auto hwGen = metadataReader->getHardwareGeneration(); + xrt_core::message::send(severity_level::warning, "XRT", std::to_string(hwGen)); + return hwGen; + } double getClockFreqMhz() {return clockFreqMhz;} int getNumModules() {return NUM_MODULES;} diff --git a/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.cpp b/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.cpp index 4f3f1922567..373a0721ac0 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.cpp @@ -104,9 +104,9 @@ namespace xdp { { // Capture all tiles across all graphs // Note: in the future, we could support user-defined tile sets - auto graphs = filetype->getValidGraphs(); + auto graphs = metadataReader->getValidGraphs(); for (auto& graph : graphs) { - mGraphCoreTilesMap[graph] = filetype->getEventTiles(graph, module_type::core); + mGraphCoreTilesMap[graph] = metadataReader->getEventTiles(graph, module_type::core); } // Report tiles (debug only) @@ -186,8 +186,8 @@ namespace xdp { // AIE core register offsets constexpr uint64_t AIE_OFFSET_CORE_STATUS = 0x32004; - auto offset = filetype->getAIETileRowOffset(); - auto hwGen = filetype->getHardwareGeneration(); + auto offset = metadataReader->getAIETileRowOffset(); + auto hwGen = metadataReader->getHardwareGeneration(); // This mask check for following states // ECC_Scrubbing_Stall @@ -412,10 +412,13 @@ namespace xdp { } // Grab AIE metadata - auto device = xrt_core::get_userpf_device(handle); - auto data = device->get_axlf_section(AIE_METADATA); - filetype = aie::readAIEMetadata(data.first, data.second, mAieMeta); - auto hwGen = filetype->getHardwareGeneration(); + metadataReader = (db->getStaticInfo()).getAIEmetadataReader(); + if (!metadataReader) { + xrt_core::message::send(severity_level::error, + "XRT", "Error parsing AIE Profiling Metadata."); + return; + } + auto hwGen = metadataReader->getHardwareGeneration(); // Update list of tiles to debug getTilesForStatus(); diff --git a/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.h b/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.h index e9042bf6e83..9c6325db2e8 100755 --- a/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.h +++ b/src/runtime_src/xdp/profile/plugin/aie_status/aie_status_plugin.h @@ -62,8 +62,7 @@ namespace xdp { private: static bool live; uint32_t mPollingInterval; - boost::property_tree::ptree mAieMeta; - std::unique_ptr filetype; + const aie::BaseFiletypeImpl* metadataReader = nullptr; std::shared_ptr mXrtCoreDevice; // Thread control flags for each device handle diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.cpp b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.cpp index c91e1deef84..38b5b55ef6a 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.cpp +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.cpp @@ -71,21 +71,13 @@ namespace xdp { xrt_core::message::send(severity_level::warning, "XRT", AIE_TRACE_DUMP_INTERVAL_WARN_MSG); } - #ifdef XDP_CLIENT_BUILD - - metadataReader = aie::readAIEMetadata("aie_control_config.json", aie_meta); - - #else - - auto device = xrt_core::get_userpf_device(handle); - auto data = device->get_axlf_section(AIE_METADATA); - - metadataReader = aie::readAIEMetadata(data.first, data.second, aie_meta); - - #endif - - if (metadataReader == nullptr) + metadataReader = (VPDatabase::Instance()->getStaticInfo()).getAIEmetadataReader(); + if (!metadataReader) { + std::stringstream msg; + msg << "metadataReader reader couldn't be created."; + xrt_core::message::send(severity_level::error, "XRT", msg.str()); return; + } // Catch when compile-time trace is specified (e.g., --event-trace=functions) auto compilerOptions = metadataReader->getAIECompilerOptions(); @@ -937,10 +929,29 @@ namespace xdp { } } + int AieTraceMetadata::getHardwareGen() { + if ((VPDatabase::Instance()->getStaticInfo()).metadataReaderValid()) + return metadataReader->getHardwareGeneration(); + return 0; + } + + uint8_t AieTraceMetadata::getRowOffset() { + if ((VPDatabase::Instance()->getStaticInfo()).metadataReaderValid()) + return metadataReader->getAIETileRowOffset(); + return 0; + } + + std::unordered_map + AieTraceMetadata::get_trace_gmios() { + if ((VPDatabase::Instance()->getStaticInfo()).metadataReaderValid()) + return metadataReader->getTraceGMIOs(); + return {}; + } + aie::driver_config AieTraceMetadata::getAIEConfigMetadata() { - if (metadataReader) + if ((VPDatabase::Instance()->getStaticInfo()).metadataReaderValid()) return metadataReader->getDriverConfig(); return {}; } diff --git a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.h b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.h index b1d354c5c84..a419b73f9d4 100644 --- a/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.h +++ b/src/runtime_src/xdp/profile/plugin/aie_trace/aie_trace_metadata.h @@ -49,24 +49,13 @@ class AieTraceMetadata { module_type type); void getConfigMetricsForInterfaceTiles(const std::vector& metricsSettings, const std::vector graphMetricsSettings); - + xdp::aie::driver_config getAIEConfigMetadata(); + int getHardwareGen(); + uint8_t getRowOffset(); + std::unordered_map get_trace_gmios(); + public: - int getHardwareGen() { - if (metadataReader) - return metadataReader->getHardwareGeneration(); - return 0; - } - uint8_t getRowOffset() { - if (metadataReader) - return metadataReader->getAIETileRowOffset(); - return 0; - } - std::unordered_map - get_trace_gmios() { - if (metadataReader) - return metadataReader->getTraceGMIOs(); - return {}; - } + std::string getMetricString(uint8_t index) { if (index < metricSets[module_type::core].size()) return metricSets[module_type::core][index]; @@ -74,9 +63,6 @@ class AieTraceMetadata { return metricSets[module_type::core][0]; } - xdp::aie::driver_config getAIEConfigMetadata(); - - bool getUseDelay(){return useDelay;} bool getUseUserControl(){return useUserControl;} bool getUseGraphIterator(){return useGraphIterator;} @@ -130,11 +116,10 @@ class AieTraceMetadata { std::string counterScheme; std::string metricSet; - boost::property_tree::ptree aie_meta; - std::unique_ptr metadataReader; std::map configMetrics; std::map configChannel0; std::map configChannel1; + const aie::BaseFiletypeImpl* metadataReader = nullptr; std::map defaultSets { { module_type::core, "functions"},