Skip to content

Commit

Permalink
Modified aie_core_info_sysfs sturcture to get the core status when us…
Browse files Browse the repository at this point in the history
…ing the hw_ctx flow

Signed-off-by: Manoj Takasi <mtakasi@amd.com>
  • Loading branch information
Manoj Takasi committed Jan 6, 2025
1 parent acc1449 commit 5b98666
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/runtime_src/core/common/info_aie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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++;
Expand Down Expand Up @@ -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
Expand Down
32 changes: 24 additions & 8 deletions src/runtime_src/core/edge/user/device_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#include "core/edge/user/aie/aie_buffer_object.h"
#endif
#include "core/edge/user/aie/profile_object.h"
#include <filesystem>
#include <map>
#include <memory>
#include <poll.h>
#include <regex>
#include <string>

#include <fcntl.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5b98666

Please sign in to comment.