From 3b0cafa47778c97e5c0c5e92237b6433f906ca0c Mon Sep 17 00:00:00 2001 From: Daniel Benusovich Date: Fri, 30 Jun 2023 10:18:50 -0700 Subject: [PATCH 1/2] VITIS-8971 Update memory report backend to prepare for MCDM changes Signed-off-by: Daniel Benusovich --- src/runtime_src/core/common/info_memory.cpp | 49 +++++++------------- src/runtime_src/core/common/query_requests.h | 11 +++-- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/runtime_src/core/common/info_memory.cpp b/src/runtime_src/core/common/info_memory.cpp index 7309f092447..fca08b08503 100644 --- a/src/runtime_src/core/common/info_memory.cpp +++ b/src/runtime_src/core/common/info_memory.cpp @@ -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); @@ -304,32 +304,15 @@ struct memory_info_collector hw_context_memories = xrt_core::device_query(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(device); - memory_topology.grp_topology = xrt_core::device_query(device); - memory_topology.statistics = xrt_core::device_query(device); - - try { - memory_topology.temperature = xrt_core::device_query(dev); - } - catch (const xq::exception&) { - //ignore if not defined. Try legacy method - } - - try { - memory_topology.xclbin_uuid = xrt_core::device_query(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(device, ""); + hw_context_mem.topology = xrt_core::device_query(device); + hw_context_mem.grp_topology = xrt_core::device_query(device); + hw_context_mem.statistics = xrt_core::device_query(device); + hw_context_mem.temperature = xrt_core::device_query_default(dev, {}); + hw_context_memories.push_back(hw_context_mem); } // validate the memory topologies for each hardware context @@ -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(device, ""); + hw_context.metadata.id = "0"; + hw_context.metadata.xclbin_uuid = xrt_core::device_query_default(device, ""); hw_context.pl_compute_units = xrt_core::device_query_default(device, {}); hw_context.ps_compute_units = xrt_core::device_query_default(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) { @@ -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)); } diff --git a/src/runtime_src/core/common/query_requests.h b/src/runtime_src/core/common/query_requests.h index 6d3c0f53bef..e9c0a26008b 100644 --- a/src/runtime_src/core/common/query_requests.h +++ b/src/runtime_src/core/common/query_requests.h @@ -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 @@ -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; }; @@ -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; From 2a8375d348048b5a5755ca3cb5c55fdd07a6ff92 Mon Sep 17 00:00:00 2001 From: Daniel Benusovich Date: Fri, 30 Jun 2023 10:56:21 -0700 Subject: [PATCH 2/2] VITIS-8971 Update aie partition report to use metadata structure Signed-off-by: Daniel Benusovich --- src/runtime_src/core/common/query_requests.h | 3 +-- src/runtime_src/core/tools/common/ReportAiePartitions.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/runtime_src/core/common/query_requests.h b/src/runtime_src/core/common/query_requests.h index e9c0a26008b..43fc36bf973 100644 --- a/src/runtime_src/core/common/query_requests.h +++ b/src/runtime_src/core/common/query_requests.h @@ -1489,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; diff --git a/src/runtime_src/core/tools/common/ReportAiePartitions.cpp b/src/runtime_src/core/tools/common/ReportAiePartitions.cpp index 8610a816d8c..e51e6a5f6f4 100644 --- a/src/runtime_src/core/tools/common/ReportAiePartitions.cpp +++ b/src/runtime_src/core/tools/common/ReportAiePartitions.cpp @@ -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);