Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VITIS-8548-XRT support to improve AIE status reporting #7619

Merged
merged 4 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 95 additions & 23 deletions src/runtime_src/core/common/info_aie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,80 @@ addnodelist(const std::string& search_str, const std::string& node_str,
output_pt.add_child(node_str, pt_array);
}

void
populate_bd_info(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd,
std::vector<std::string>& bd_info) {
try {
boost::property_tree::ptree bd_info_array;
const boost::property_tree::ptree& bd_node = input_pt.get_child("bd");

for (const auto& [ key, value_tree ] : bd_node) {
if (value_tree.size() != bd_info.size()) return;
boost::property_tree::ptree bd_info_entry;
bd_info_entry.put("bd_num", key);

boost::property_tree::ptree bd_details_array;
int i = 0;
for (const auto& value : value_tree) {
const std::string val = value.second.data();
boost::property_tree::ptree bd_details_entry;
bd_details_entry.put("name", bd_info[i]);
bd_details_entry.put("value", val);
bd_details_array.push_back(std::make_pair("", bd_details_entry));
i++;
}

bd_info_entry.add_child("bd_details", bd_details_array);
bd_info_array.push_back(std::make_pair("", bd_info_entry));
}
pt_bd.add_child("bd_info", bd_info_array);
}
catch (const std::exception& ex) {
pt_bd.put("error_msg", ex.what());
return;
}
}

// This function extract BD information for core tiles of 1st generation aie architecture
void
populate_core_bd_info_aie(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd){
static std::vector<std::string> bd_info{"base_address_a", "base_address_b", "length","lock_id", "lock_acq_val_a", "lock_acq_enable_a", "lock_acq_val_enable_a", "lock_rel_val_a", "lock_rel_enable_a", "lock_rel_val_enable_a", "lock_id_b", "lock_acq_val_b", "lock_acq_enable_b", "lock_acq_val_enable_b", "lock_rel_val_b", "lock_rel_enable_b", "lock_rel_val_enable_b", "pkt_enable", "pkt_id", "pkt_type", "valid_bd", "use_next_bd", "next_bd_id", "A_B_buffer_select", "current_pointer", "double_buffer_enable", "interleave_enable", "interleave_count", "fifo_mode", "x_increment", "x_wrap", "x_offset", "y_increment", "y_wrap", "y_offset"};

return populate_bd_info(input_pt, pt_bd, bd_info);
}

// This function extract BD information for shim tiles of 1st generation aie architecture
void
populate_shim_bd_info_aie(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd){
static std::vector<std::string> bd_info{"base_address", "length", "lock_id", "lock_acq_val", "lock_acq_enable", "lock_acq_val_enable", "lock_rel_val", "lock_rel_enable", "lock_rel_val_enable","pkt_enable", "pkt_id", "pkt_type", "valid_bd", "use_next_bd", "next_bd_id", "smid", "cache", "qos", "secure_access", "burst_length"};

return populate_bd_info(input_pt, pt_bd, bd_info);
}

// This function extract BD information for core tiles of 2nd generation aie architecture
void
populate_core_bd_info_aieml(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd){
static std::vector<std::string> bd_info{"base_address", "length", "lock_id", "lock_acq_val", "lock_acq_enable", "lock_rel_id", "lock_rel_val", "pkt_enable", "pkt_id", "pkt_type", "valid_bd", "use_next_bd", "next_bd_id", "tlast_suppress", "out_of_order_bd_id", "compression_enable", "iteration_current", "iteration_step_size", "iteration_wrap", "d0_stepsize", "d0_wrap", "d1_stepsize", "d1_wrap", "d2_stepsize"};

return populate_bd_info(input_pt, pt_bd, bd_info);
}

// This function extract BD information for shim tiles of 2nd generation aie architecture
void
populate_shim_bd_info_aieml(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd){
static std::vector<std::string> bd_info{"base_address", "length", "lock_id", "lock_acq_val", "lock_acq_enable", "lock_rel_id", "lock_rel_val", "pkt_enable", "pkt_id", "pkt_type", "valid_bd", "use_next_bd", "next_bd_id", "tlast_suppress", "out_of_order_bd_id", "compression_enable", "iteration_current", "iteration_stepsize", "iteration_wrap", "d0_stepsize", "d0_wrap", "d1_stepsize", "d1_wrap", "d2_stepsize", "smid", "cache", "qos", "secure_access", "burst_length"};

return populate_bd_info(input_pt, pt_bd, bd_info);
}

// This function extract BD information for mem tiles of 2nd generation aie architecture
void
populate_mem_bd_info_aieml(const boost::property_tree::ptree& input_pt, boost::property_tree::ptree& pt_bd){
static std::vector<std::string> bd_info{"base_address", "length", "lock_id", "lock_acq_val", "lock_acq_enable", "lock_rel_id", "lock_rel_val", "pkt_enable", "pkt_id", "pkt_type", "valid_bd", "use_next_bd", "next_bd_id", "tlast_suppress", "out_of_order_bd_id", "compression_enable", "iteration_current", "iteration_stepsize", "iteration_wrap", "d0_stepsize", "d0_wrap", "d0_before", "d0_after", "d1_stepsize", "d1_wrap", "d1_before", "d1_after", "d2_stepsize", "d2_wrap", "d2_before", "d2_after", "d3_stepsize"};

return populate_bd_info(input_pt, pt_bd, bd_info);
}

// This function extract DMA information for both AIE core and tiles
static void
populate_aie_dma(const boost::property_tree::ptree& pt, boost::property_tree::ptree& pt_dma)
Expand Down Expand Up @@ -272,19 +346,8 @@ populate_aie_shim(const xrt_core::device *device, const std::string& desc)
}
catch (const qr::no_such_key&) {
// Not Edge device
}
catch (const std::exception& ex) {
pt.put("error_msg", ex.what());
return pt;
}

try {
// On Pcie platforms use driver calls to get AIE Shim info
pt_shim = asd_parser::get_formated_tiles_info(device, asd_parser::aie_tile_type::shim);
}
catch (const xrt_core::query::no_such_key&) {
// Not Pcie device
}
catch (const std::exception& ex) {
pt.put("error_msg", ex.what());
return pt;
Expand All @@ -299,6 +362,8 @@ populate_aie_shim(const xrt_core::device *device, const std::string& desc)
try {
boost::property_tree::ptree tile_array;

auto hw_gen = pt_shim.get<uint8_t>("hw_gen");

// Populate the shim information such as dma, lock, error, events
// for each tiles.
for (const auto& as: pt_shim.get_child("aie_shim")) {
Expand Down Expand Up @@ -326,6 +391,13 @@ populate_aie_shim(const xrt_core::device *device, const std::string& desc)
if (oshim.find("event") != oshim.not_found())
addnodelist("event", "events", oshim, ishim);

if (oshim.find("bd") != oshim.not_found()){
if (hw_gen == 1)
populate_shim_bd_info_aie(oshim, ishim);
else
populate_shim_bd_info_aieml(oshim, ishim);
}

tile_array.push_back({"tile" + std::to_string(col), ishim});
}

Expand Down Expand Up @@ -356,19 +428,8 @@ populate_aie_mem(const xrt_core::device* device, const std::string& desc)
}
catch (const xrt_core::query::no_such_key&) {
// Not Edge device
}
catch (const std::exception& ex) {
pt.put("error_msg", ex.what());
return pt;
}

try {
// On Pcie platforms use driver calls to get AIE mem info
pt_mem = asd_parser::get_formated_tiles_info(device, asd_parser::aie_tile_type::mem);
}
catch (const xrt_core::query::no_such_key&) {
// Not Pcie device
}
catch (const std::exception& ex) {
pt.put("error_msg", ex.what());
return pt;
Expand Down Expand Up @@ -410,6 +471,9 @@ populate_aie_mem(const xrt_core::device* device, const std::string& desc)
if (imem.find("event") != imem.not_found())
addnodelist("event", "events", imem, omem);

if (imem.find("bd") != imem.not_found())
populate_mem_bd_info_aieml(imem, omem);

tile_array.push_back({"tile" + std::to_string(col), omem});
}

Expand Down Expand Up @@ -532,7 +596,8 @@ populate_aie_core(const boost::property_tree::ptree& pt_core, boost::property_tr
try {
boost::property_tree::ptree pt;
boost::property_tree::ptree empty_pt;

auto hw_gen = pt_core.get<uint8_t>("hw_gen");

auto row = tile.get<int>("row");
auto col = tile.get<int>("column");
pt = pt_core.get_child("aie_core." + std::to_string(col) + "_" + std::to_string(row));
Expand Down Expand Up @@ -571,6 +636,13 @@ populate_aie_core(const boost::property_tree::ptree& pt_core, boost::property_tr
if (pt.find("event") != pt.not_found())
addnodelist("event", "events", pt, tile);

// Add BD information to the tiles
if (pt.find("bd") != pt.not_found()){
if (hw_gen == 1)
populate_core_bd_info_aie(pt, tile);
else
populate_core_bd_info_aieml(pt, tile);
}
}
catch (const std::exception& ex) {
tile.put("error_msg", (boost::format("%s %s") % ex.what() % "found in the AIE core"));
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/edge/user/aie_sys_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ aie_sys_parser::addrecursive(const int col, const int row, const std::string& ta
boost::property_tree::ptree
aie_sys_parser::aie_sys_read(const int col, const int row)
{
const static std::vector<std::string> tags{"core","dma","lock","errors","event"};
const static std::vector<std::string> tags{"core","dma","lock","errors","event","bd"};
std::vector<std::string> data;
boost::property_tree::ptree pt;
for(auto& tag:tags) {
Expand Down
11 changes: 8 additions & 3 deletions src/runtime_src/core/edge/user/device_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct aie_metadata_info{
uint32_t core_row;
uint32_t mem_row;
uint32_t num_mem_row;
uint8_t hw_gen;
};

// Function to get aie max rows and cols by parsing aie_metadata sysfs node
Expand Down Expand Up @@ -195,7 +196,7 @@ get_aie_metadata_info(const xrt_core::device* device)
aie_meta.mem_row = pt.get<uint32_t>("aie_metadata.driver_config.mem_row_start");
aie_meta.num_mem_row = pt.get<uint32_t>("aie_metadata.driver_config.mem_num_rows");
}

aie_meta.hw_gen = pt.get<uint8_t>("aie_metadata.driver_config.hw_gen");
return aie_meta;
}

Expand All @@ -217,9 +218,9 @@ struct aie_core_info_sysfs

boost::property_tree::ptree pt;
pt.add_child("aie_core",ptarray);
pt.put("hw_gen",std::to_string(aie_meta.hw_gen));
std::ostringstream oss;
boost::property_tree::write_json(oss, pt);

std::string inifile_text = oss.str();
return inifile_text;
}
Expand All @@ -238,11 +239,13 @@ struct aie_shim_info_sysfs

/* Loop all shim tiles and collect all dma, events, errors, locks status */
for (int i=0; i < aie_meta.num_cols; ++i) {
ptarray.push_back(std::make_pair("", aie_sys_parser::get_parser(aiepart)->aie_sys_read(i, aie_meta.shim_row)));
ptarray.push_back(std::make_pair(std::to_string(i) + "_" + std::to_string(aie_meta.shim_row),
aie_sys_parser::get_parser(aiepart)->aie_sys_read(i, aie_meta.shim_row)));
}

boost::property_tree::ptree pt;
pt.add_child("aie_shim",ptarray);
pt.put("hw_gen",std::to_string(aie_meta.hw_gen));
std::ostringstream oss;
boost::property_tree::write_json(oss, pt);
std::string inifile_text = oss.str();
Expand All @@ -261,6 +264,8 @@ struct aie_mem_info_sysfs
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);

ptarray.put("hw_gen",std::to_string(aie_meta.hw_gen));

/* Loop all mem tiles and collect all dma, events, errors, locks status */
for (int i = 0; i < aie_meta.num_cols; ++i)
for (int j = 0; j < (aie_meta.num_mem_row-1); ++j)
Expand Down
10 changes: 10 additions & 0 deletions src/runtime_src/core/tools/common/ReportAie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ writeReport(const xrt_core::device* /*_pDevice*/,
}
_output << std::endl;
}

if (tile.second.find("bd_info") != tile.second.not_found()) {
_output << boost::format(" %s:\n") % "BDs";
for (const auto& bd_info : tile.second.get_child("bd_info")) {
_output << fmt8("%s") % "bd_num: " % bd_info.second.get<std::string>("bd_num");
for (const auto& bd_detail : bd_info.second.get_child("bd_details"))
_output<< fmt8("%s") % bd_detail.second.get<std::string>("name") % bd_detail.second.get<std::string>("value");
_output << std::endl;
}
}
}

const boost::property_tree::ptree& pl_kernel = graph.get_child("pl_kernel");
Expand Down
11 changes: 11 additions & 0 deletions src/runtime_src/core/tools/common/ReportAieMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ writeReport(const xrt_core::device* /*_pDevice*/,
_output << boost::format("Tile[%2d]\n") % curr_tile;
_output << fmt4("%d") % "Column" % tile.second.get<int>("column");
_output << fmt4("%d") % "Row" % tile.second.get<int>("row");

if (tile.second.find("dma") != tile.second.not_found()) {
_output << boost::format(" %s:\n") % "DMA";

Expand Down Expand Up @@ -149,6 +150,16 @@ writeReport(const xrt_core::device* /*_pDevice*/,
}
_output << std::endl;
}

if (tile.second.find("bd_info") != tile.second.not_found()) {
_output << boost::format(" %s:\n") % "BDs";
for (const auto& bd_info : tile.second.get_child("bd_info")) {
_output << fmt8("%s") % "bd_num: " % bd_info.second.get<std::string>("bd_num");
for (const auto& bd_detail : bd_info.second.get_child("bd_details"))
_output<< fmt8("%s") % bd_detail.second.get<std::string>("name") % bd_detail.second.get<std::string>("value");
_output << std::endl;
}
}
}
_output << std::endl;
}
Expand Down
12 changes: 11 additions & 1 deletion src/runtime_src/core/tools/common/ReportAieShim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ populate_aie_shim(const xrt_core::device * _pDevice, const std::string& desc)
std::stringstream ss;
ss << device.get_info<xrt::info::device::aie_shim>();
boost::property_tree::read_json(ss, pt_shim);

return pt_shim;
}

Expand Down Expand Up @@ -97,6 +96,7 @@ ReportAieShim::writeReport( const xrt_core::device* /*_pDevice*/,
_output << boost::format("Tile[%2d]\n") % curr_tile;
_output << fmt4("%d") % "Column" % tile.second.get<int>("column");
_output << fmt4("%d") % "Row" % tile.second.get<int>("row");

if(tile.second.find("dma") != tile.second.not_found()) {
_output << boost::format(" %s:\n") % "DMA";

Expand Down Expand Up @@ -160,6 +160,16 @@ ReportAieShim::writeReport( const xrt_core::device* /*_pDevice*/,
}
_output << std::endl;
}

if (tile.second.find("bd_info") != tile.second.not_found()) {
_output << boost::format(" %s:\n") % "BDs";
for (const auto& bd_info : tile.second.get_child("bd_info")) {
_output << fmt8("%s") % "bd_num: " % bd_info.second.get<std::string>("bd_num");
for (const auto& bd_detail : bd_info.second.get_child("bd_details"))
_output<< fmt8("%s") % bd_detail.second.get<std::string>("name") % bd_detail.second.get<std::string>("value");
_output << std::endl;
}
}
}
} catch(std::exception const& e) {
_output << e.what() << std::endl;
Expand Down