From 5b9866660815131cc16d9d532ffc32605bc36fd8 Mon Sep 17 00:00:00 2001 From: Manoj Takasi Date: Mon, 6 Jan 2025 11:26:52 +0000 Subject: [PATCH] Modified aie_core_info_sysfs sturcture to get the core status when using the hw_ctx flow Signed-off-by: Manoj Takasi --- src/runtime_src/core/common/info_aie.cpp | 6 ++-- .../core/edge/user/device_linux.cpp | 32 ++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/runtime_src/core/common/info_aie.cpp b/src/runtime_src/core/common/info_aie.cpp index e1593e5ef0..b0caa69aa0 100644 --- a/src/runtime_src/core/common/info_aie.cpp +++ b/src/runtime_src/core/common/info_aie.cpp @@ -707,7 +707,7 @@ is_duplicate_core(const boost::property_tree::ptree& tile_array, boost::property void populate_buffer_only_cores(const boost::property_tree::ptree& pt, const boost::property_tree::ptree& core_info, int gr_id, - boost::property_tree::ptree& tile_array) + boost::property_tree::ptree& tile_array, int start_col) { const boost::property_tree::ptree empty_pt; @@ -719,7 +719,7 @@ populate_buffer_only_cores(const boost::property_tree::ptree& pt, auto dma_row_it = g_node.second.get_child("dma_rows", empty_pt).begin(); for (const auto& node : g_node.second.get_child("dma_columns", empty_pt)) { boost::property_tree::ptree tile; - tile.put("column", node.second.data()); + tile.put("column", (std::stoul(node.second.data()) + start_col)); tile.put("row", dma_row_it->second.data()); if (dma_row_it != g_node.second.end()) dma_row_it++; @@ -872,7 +872,7 @@ populate_aie_from_metadata(const xrt_core::device* device, boost::property_tree: tile_array.push_back({"", tile}); } - populate_buffer_only_cores(pt_aie, core_info, gr_id, tile_array); + populate_buffer_only_cores(pt_aie, core_info, gr_id, tile_array, start_col); boost::property_tree::ptree plkernel_array; // Get the name of the kernls available for this graph diff --git a/src/runtime_src/core/edge/user/device_linux.cpp b/src/runtime_src/core/edge/user/device_linux.cpp index ce371ad81f..f257002aa5 100644 --- a/src/runtime_src/core/edge/user/device_linux.cpp +++ b/src/runtime_src/core/edge/user/device_linux.cpp @@ -15,9 +15,11 @@ #include "core/edge/user/aie/aie_buffer_object.h" #endif #include "core/edge/user/aie/profile_object.h" +#include #include #include #include +#include #include #include @@ -216,14 +218,28 @@ struct aie_core_info_sysfs { boost::property_tree::ptree ptarray; aie_metadata_info aie_meta = get_aie_metadata_info(device); - const std::string aiepart = std::to_string(aie_meta.shim_row) + "_" + std::to_string(aie_meta.num_cols); - const aie_sys_parser asp(aiepart); - - /* Loop each all aie core tiles and collect core, dma, events, errors, locks status. */ - for (int i = 0; i < aie_meta.num_cols; ++i) - for (int j = 0; j < (aie_meta.num_rows-1); ++j) - ptarray.push_back(std::make_pair(std::to_string(i) + "_" + std::to_string(j), - asp.aie_sys_read(i,(j + aie_meta.core_row)))); + std::string base_path = "/sys/class/aie/"; + std::regex pattern(R"(aiepart_(\d+)_(\d+))"); + int start_col=0, num_col=0; + for (const auto& entry : std::filesystem::directory_iterator(base_path)) { + if (entry.is_directory()) { + std::string dir_name = entry.path().filename().string(); + std::smatch matches; + if (std::regex_match(dir_name, matches, pattern)) { + start_col = std::stoi(matches[1].str()); + num_col = std::stoi(matches[2].str()); + + const std::string aiepart = std::to_string(start_col) + "_" + std::to_string(num_col); + const aie_sys_parser asp(aiepart); + + /* Loop each all aie core tiles and collect core, dma, events, errors, locks status. */ + for (int i = start_col; i < (start_col + num_col); ++i) + for (int j = 0; j < (aie_meta.num_rows-1); ++j) + ptarray.push_back(std::make_pair(std::to_string(i) + "_" + std::to_string(j), + asp.aie_sys_read(i,(j + aie_meta.core_row)))); + } + } + } boost::property_tree::ptree pt; pt.add_child("aie_core",ptarray);