[SWDEV-488303] Updated CU occupancy for per-process retrieval (#243)

Change-Id: I2990597c6dd4b2e8cf3e11ce60f72049ebdd9a8c
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
This commit is contained in:
Arif, Maisam
2025-05-29 20:35:27 -05:00
committed by GitHub
parent fba62e2270
commit 0fdaebdbaa
12 changed files with 232 additions and 259 deletions
+1 -10
View File
@@ -456,7 +456,6 @@ int GetProcessInfoForPID(uint32_t pid, rsmi_process_info_t *proc,
proc->sdma_usage = 0;
proc->cu_occupancy = 0;
uint32_t cu_count = 0;
static amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance();
static std::map<uint64_t, std::shared_ptr<KFDNode>>& kfd_node_map =
smi.kfd_node_map();
@@ -510,23 +509,15 @@ int GetProcessInfoForPID(uint32_t pid, rsmi_process_info_t *proc,
}
else if(sysfs_data_errcode==0){
// Update CU usage by the process
proc->cu_occupancy += std::stoi(tmp);
// Collect count of compute units
cu_count += kfd_node_map[gpu_id]->cu_count();
proc->cu_occupancy = std::stoi(tmp);
}
else {
// Some GFX revisions do not provide cu_occupancy debugfs method
// which may cause ENOENT
proc->cu_occupancy = CU_OCCUPANCY_INVALID;
cu_count = 0;
}
}
// Adjust CU occupancy to percent.
if (cu_count > 0) {
proc->cu_occupancy = ((proc->cu_occupancy * 100) / cu_count);
}
return 0;
}