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-8985 Refactor hw context metadata field in query requests #7610

Merged
merged 2 commits into from
Jul 4, 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
49 changes: 16 additions & 33 deletions src/runtime_src/core/common/info_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ struct memory_info_collector
const mem_data* mem,
ptree_type& pt_mem)
{
pt_mem.put("xclbin_uuid", topology.xclbin_uuid);
pt_mem.put("hw_context_slot", boost::format("%u") % topology.id);
pt_mem.put("xclbin_uuid", topology.metadata.xclbin_uuid);
pt_mem.put("hw_context_slot", boost::format("%u") % topology.metadata.id);
pt_mem.put("type", memtype2str(mem->m_type));
pt_mem.put("tag", mem->m_tag);
pt_mem.put("enabled", mem->m_used ? true : false);
Expand Down Expand Up @@ -304,32 +304,15 @@ struct memory_info_collector
hw_context_memories = xrt_core::device_query<xq::hw_context_memory_info>(device);
}
catch (const xq::exception&) {
//ignore if not defined. Try legacy method
}

// If the mem_topo is empty attempt the legacy method
if (hw_context_memories.empty()) {
xq::hw_context_memory_info::data_type memory_topology;
memory_topology.id = "0";
memory_topology.topology = xrt_core::device_query<xq::mem_topology_raw>(device);
memory_topology.grp_topology = xrt_core::device_query<xq::group_topology>(device);
memory_topology.statistics = xrt_core::device_query<xq::memstat_raw>(device);

try {
memory_topology.temperature = xrt_core::device_query<xq::temp_by_mem_topology>(dev);
}
catch (const xq::exception&) {
//ignore if not defined. Try legacy method
}

try {
memory_topology.xclbin_uuid = xrt_core::device_query<xq::xclbin_uuid>(device);
}
catch (const xq::exception&) {
// Support noop devices
}

hw_context_memories.push_back(memory_topology);
// Try legacy method
xq::hw_context_memory_info::data_type hw_context_mem;
hw_context_mem.metadata.id = "0";
hw_context_mem.metadata.xclbin_uuid = xrt_core::device_query_default<xq::xclbin_uuid>(device, "");
hw_context_mem.topology = xrt_core::device_query<xq::mem_topology_raw>(device);
hw_context_mem.grp_topology = xrt_core::device_query<xq::group_topology>(device);
hw_context_mem.statistics = xrt_core::device_query<xq::memstat_raw>(device);
hw_context_mem.temperature = xrt_core::device_query_default<xq::temp_by_mem_topology>(dev, {});
hw_context_memories.push_back(hw_context_mem);
}

// validate the memory topologies for each hardware context
Expand Down Expand Up @@ -576,13 +559,13 @@ populate_hardware_context(const xrt_core::device* device)
// Legacy Case
xq::hw_context_info::data_type hw_context;

hw_context.id = "0";
hw_context.xclbin_uuid = xrt_core::device_query_default<xq::xclbin_uuid>(device, "");
hw_context.metadata.id = "0";
hw_context.metadata.xclbin_uuid = xrt_core::device_query_default<xq::xclbin_uuid>(device, "");
hw_context.pl_compute_units = xrt_core::device_query_default<xq::kds_cu_info>(device, {});
hw_context.ps_compute_units = xrt_core::device_query_default<xq::kds_scu_info>(device, {});

// Account for devices that do not have an xclbin uuid but have compute units
if (!hw_context.xclbin_uuid.empty() || !hw_context.pl_compute_units.empty() || !hw_context.ps_compute_units.empty())
if (!hw_context.metadata.xclbin_uuid.empty() || !hw_context.pl_compute_units.empty() || !hw_context.ps_compute_units.empty())
hw_context_stats.push_back(hw_context);
}
catch (const std::exception& ex) {
Expand All @@ -592,8 +575,8 @@ populate_hardware_context(const xrt_core::device* device)

for (const auto& hw : hw_context_stats) {
ptree_type pt_hw;
pt_hw.put("id", boost::algorithm::to_upper_copy(hw.id));
pt_hw.put("xclbin_uuid", boost::algorithm::to_upper_copy(hw.xclbin_uuid));
pt_hw.put("id", boost::algorithm::to_upper_copy(hw.metadata.id));
pt_hw.put("xclbin_uuid", boost::algorithm::to_upper_copy(hw.metadata.xclbin_uuid));
pt_hw.add_child("compute_units", populate_cus(device, hw.pl_compute_units, hw.ps_compute_units));
pt.push_back(std::make_pair("", pt_hw));
}
Expand Down
14 changes: 8 additions & 6 deletions src/runtime_src/core/common/query_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ struct kds_scu_info : request
*/
struct hw_context_info : request
{
struct metadata {
std::string id;
std::string xclbin_uuid;
};

/**
* A structure to represent a single hardware context on any device type. This
* structure must contain all data that makes up a hardware context across
Expand All @@ -970,8 +975,7 @@ struct hw_context_info : request
* Versal -> populate PL and PS compute units
*/
struct data {
std::string id;
std::string xclbin_uuid;
struct metadata metadata;
kds_cu_info::result_type pl_compute_units;
kds_scu_info::result_type ps_compute_units;
};
Expand All @@ -995,8 +999,7 @@ struct hw_context_memory_info : request
* hardware context memory structure across all device types.
*/
struct data {
std::string id;
std::string xclbin_uuid;
hw_context_info::metadata metadata;
mem_topology_raw::result_type topology;
group_topology::result_type grp_topology;
memstat_raw::result_type statistics;
Expand Down Expand Up @@ -1486,8 +1489,7 @@ struct aie_partition_info : request
{
struct data
{
std::string xclbin_uuid;
uint64_t slot_id;
hw_context_info::metadata metadata;
uint64_t start_col;
uint64_t num_cols;
uint64_t usage_count;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/tools/common/ReportAiePartitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ populate_aie_partition(const xrt_core::device* device)
auto partition = pt_map.emplace(std::make_tuple(entry.start_col, entry.num_cols), boost::property_tree::ptree());

boost::property_tree::ptree pt_entry;
pt_entry.put("xclbin_uuid", entry.xclbin_uuid);
pt_entry.put("slot_id", entry.slot_id);
pt_entry.put("xclbin_uuid", entry.metadata.xclbin_uuid);
pt_entry.put("slot_id", entry.metadata.id);
pt_entry.put("usage_count", entry.usage_count);
pt_entry.put("migration_count", entry.migration_count);
pt_entry.put("device_bo_sync_count", entry.bo_sync_count);
Expand Down