From da7b59046b6487854360574099a00389326342aa Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Thu, 2 Mar 2023 13:24:38 -0600 Subject: [PATCH 1/2] [SWDEV-335697 + SWDEV-342812] Fix NPS & Compute tests Updates: * Fixed rsmi_dev_compute_partition_get & rsmi_dev_nps_mode_get to properly check for invalid arguments * Updated compute partition & NPS mode tests - Now properly confirms the invalid argument is seen - Spacing for multiple devices is added to better see distinction between separate device's tests (for verbose output) - Changed expect to assert calls, so errors are observed faster for test failures - Fixed multiple device testing where a variable should have been unset, but having multiple devices caused it to set - Updated multiple device testing to iterate accross all devices (previously returned, instead of continuing checking support after RSMI_STATUS_NOT_SUPPORTED detected) - Fixed a few spelling errors & verbose output Change-Id: Ieba9e5b46763c6cd880fbf27fcdf58be8ecbc683 Signed-off-by: Charis Poag [ROCm/rocm_smi_lib commit: c252ecccd1a0bc76a23675e9330c86ce24ff90f6] --- .../rocm_smi/docs/ROCm_SMI_Manual.pdf | Bin 527272 -> 527272 bytes projects/rocm-smi-lib/src/rocm_smi.cc | 8 +-- .../functional/computepartition_read_write.cc | 51 +++++++----------- .../functional/npsmode_read_write.cc | 46 ++++++++-------- 4 files changed, 49 insertions(+), 56 deletions(-) diff --git a/projects/rocm-smi-lib/rocm_smi/docs/ROCm_SMI_Manual.pdf b/projects/rocm-smi-lib/rocm_smi/docs/ROCm_SMI_Manual.pdf index 3a3ec7aa6f9428734840c6ed2459fafa04032f93..e3d19724581c408237ba25668d396c2279d7db5d 100644 GIT binary patch delta 128 zcmZ26U17y^g@zW!7N!>F7M2#)7Pc+ymrrsU8yFcH8XKD$Prq}LT?)b7{{JNV5;kW? v10xq_Qxgkw3rA;XHzOBgClgawXE$?G3u9MT0~a$p1sg(2wm-YTe#i;{v>YWN delta 128 zcmZ26U17y^g@zW!7N!>F7M2#)7Pc+ymrrsU85tOw8W(partition); + new_nps_mode = static_cast(partition); IF_VERB(STANDARD) { std::cout << std::endl; std::cout << "\t**" @@ -265,8 +270,8 @@ void TestNPSModeReadWrite::Run(void) { std::cout << "\t**" << "Current nps mode: " << current_nps_mode << std::endl; } - EXPECT_EQ(RSMI_STATUS_SUCCESS, ret); - EXPECT_STREQ(npsModeString(new_nps_mode).c_str(), current_nps_mode); + ASSERT_EQ(RSMI_STATUS_SUCCESS, ret); + ASSERT_STREQ(npsModeString(new_nps_mode).c_str(), current_nps_mode); } /* TEST RETURN TO BOOT NPS MODE SETTING */ @@ -331,8 +336,7 @@ void TestNPSModeReadWrite::Run(void) { << "\t**" << "Current nps mode: " << current_nps_mode << std::endl; } - EXPECT_EQ(RSMI_STATUS_SUCCESS, ret); - EXPECT_STREQ(npsModeString(new_nps_mode).c_str(), current_nps_mode); - + ASSERT_EQ(RSMI_STATUS_SUCCESS, ret); + ASSERT_STREQ(npsModeString(new_nps_mode).c_str(), current_nps_mode); } } From 73f8c1563ab29e9baf6af02ea18e4fcaea6f152a Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Thu, 2 Mar 2023 15:42:00 -0600 Subject: [PATCH 2/2] Filter out the GPUs not assigned to a container in showpid The process ids of other container are still visible in the sysfs file, filter it out to prevent crash. Change-Id: I665912cd09c606804186aff8cba5c24f5e58ded7 [ROCm/rocm_smi_lib commit: 710649ab660d489c2b2f4688dd80705aa1ab69bb] --- projects/rocm-smi-lib/src/rocm_smi.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/rocm-smi-lib/src/rocm_smi.cc b/projects/rocm-smi-lib/src/rocm_smi.cc index 96073462dd..44d8d907eb 100755 --- a/projects/rocm-smi-lib/src/rocm_smi.cc +++ b/projects/rocm-smi-lib/src/rocm_smi.cc @@ -3315,11 +3315,23 @@ rsmi_compute_process_gpus_get(uint32_t pid, uint32_t *dv_indices, uint32_t i = 0; amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance(); + // filter out the devices not visible to container + auto& nodes = smi.kfd_node_map(); + for (auto nit = gpu_set.begin(); nit != gpu_set.end();) { + uint64_t gpu_id_val = (*nit); + auto kfd_ite = nodes.find(gpu_id_val); + if (kfd_ite == nodes.end()) { + nit = gpu_set.erase(nit); + } else { + nit++; + } + } + if (dv_indices != nullptr) { for (auto it = gpu_set.begin(); i < *num_devices && it != gpu_set.end(); ++it, ++i) { uint64_t gpu_id_val = (*it); - dv_indices[i] = smi.kfd_node_map()[gpu_id_val]->amdgpu_dev_index(); + dv_indices[i] = nodes[gpu_id_val]->amdgpu_dev_index(); } }