Add support to retrieve process VRAM usage information.
Change-Id: I60843a99207a658022a26aa346b79f91863833cf
This commit is contained in:
+11
-1
@@ -2924,7 +2924,17 @@ rsmi_compute_process_info_by_pid_get(uint32_t pid,
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
int err = amd::smi::GetProcessInfoForPID(pid, proc);
|
||||
std::unordered_set<uint64_t> gpu_set;
|
||||
amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance();
|
||||
auto it = smi.kfd_node_map().begin();
|
||||
|
||||
while (it != smi.kfd_node_map().end()) {
|
||||
uint64_t gpu_id = it->first;
|
||||
gpu_set.insert(gpu_id);
|
||||
it++;
|
||||
}
|
||||
|
||||
int err = amd::smi::GetProcessInfoForPID(pid, proc, &gpu_set);
|
||||
|
||||
if (err) {
|
||||
return errno_to_rsmi_status(err);
|
||||
|
||||
+25
-1
@@ -384,10 +384,13 @@ int GetProcessGPUs(uint32_t pid, std::unordered_set<uint64_t> *gpu_set) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetProcessInfoForPID(uint32_t pid, rsmi_process_info_t *proc) {
|
||||
int GetProcessInfoForPID(uint32_t pid, rsmi_process_info_t *proc,
|
||||
std::unordered_set<uint64_t> *gpu_set) {
|
||||
assert(proc != nullptr);
|
||||
assert(gpu_set != nullptr);
|
||||
int err;
|
||||
std::string tmp;
|
||||
std::unordered_set<uint64_t>::iterator itr;
|
||||
|
||||
std::string proc_str_path = kKFDProcPathRoot;
|
||||
proc_str_path += "/";
|
||||
@@ -413,6 +416,27 @@ int GetProcessInfoForPID(uint32_t pid, rsmi_process_info_t *proc) {
|
||||
}
|
||||
proc->pasid = std::stoi(tmp);
|
||||
|
||||
proc->vram_usage = 0;
|
||||
|
||||
for (itr = gpu_set->begin(); itr != gpu_set->end(); itr++) {
|
||||
uint64_t gpu_id = (*itr);
|
||||
|
||||
std::string vram_str_path = proc_str_path;
|
||||
vram_str_path += "/vram_";
|
||||
vram_str_path += std::to_string(gpu_id);
|
||||
|
||||
err = ReadSysfsStr(vram_str_path, &tmp);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!is_number(tmp)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
proc->vram_usage += std::stoi(tmp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
مرجع در شماره جدید
Block a user