SWDEV-430619 - fix Unit_hipDeviceGetUuid_From_RocmInfo test
Ignore the iGPU when iterating rocminfo and correct the bounds check when matching results with HIP API. Also do not compare bytes directly, use string to do a string compare as it can go out of bounds. Disabling this test on windows till I get hold of a working windows machine. Change-Id: Icf811e0310776567afecea92e1d54e8438b39235
Этот коммит содержится в:
коммит произвёл
Jatin Jaikishan Chaudhary
родитель
4305328f37
Коммит
af3ac29c40
@@ -179,8 +179,6 @@
|
||||
"Unit_hipMemSetAccess_MultiProc",
|
||||
"Unit_hipMemSetAccess_negative",
|
||||
"Unit_hipMemUnmap_negative",
|
||||
"=== SWDEV-432556,SWDEV-434211:Below test randomly failing in stress test ===",
|
||||
"Unit_hipDeviceGetUuid_From_RocmInfo",
|
||||
"=== SWDEV-434171: Below tests took long time to complete in stress test on 17/11/23 ===",
|
||||
"Unit_Warp_Shfl_Positive_Basic - int",
|
||||
"Unit_Warp_Shfl_Positive_Basic - unsigned int",
|
||||
|
||||
@@ -37,6 +37,7 @@ if(UNIX)
|
||||
endif()
|
||||
|
||||
set_source_files_properties(hipGetDeviceCount.cc PROPERTIES COMPILE_FLAGS -std=c++17)
|
||||
set_source_files_properties(hipDeviceGetUuid.cc PROPERTIES COMPILE_FLAGS -std=c++17)
|
||||
|
||||
add_executable(getDeviceCount EXCLUDE_FROM_ALL getDeviceCount_exe.cc)
|
||||
|
||||
|
||||
@@ -18,13 +18,14 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <string.h>
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @addtogroup hipDeviceGetUuid hipDeviceGetUuid
|
||||
@@ -112,17 +113,14 @@ TEST_CASE("Unit_hipDeviceGetUuid_Negative") {
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipDeviceGetUuid_From_RocmInfo") {
|
||||
int deviceCount = 0;
|
||||
hipDevice_t device;
|
||||
hipUUID uuid{0};
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCount));
|
||||
assert(deviceCount > 0);
|
||||
|
||||
FILE *fpipe;
|
||||
FILE* fpipe;
|
||||
char command[COMMAND_LEN] = "";
|
||||
const char *rocmInfo = "rocminfo";
|
||||
const char* rocmInfo = "rocminfo";
|
||||
|
||||
snprintf(command, COMMAND_LEN, "%s", rocmInfo);
|
||||
strncat(command, " | grep -i Uuid:", COMMAND_LEN);
|
||||
@@ -134,25 +132,36 @@ TEST_CASE("Unit_hipDeviceGetUuid_From_RocmInfo") {
|
||||
}
|
||||
char command_op[BUFFER_LEN];
|
||||
int j = 0;
|
||||
std::vector<std::string> output(deviceCount); //NOLINT
|
||||
std::map<int, std::vector<char>> uuid_map;
|
||||
while (fgets(command_op, BUFFER_LEN, fpipe)) {
|
||||
std::string rocminfo_line(command_op);
|
||||
if ((std::string::npos != rocminfo_line.find("CPU-"))) {
|
||||
if (std::string::npos != rocminfo_line.find("CPU-")) {
|
||||
continue;
|
||||
} else if ((std::string::npos != rocminfo_line.find("GPU-"))) {
|
||||
output[j] = rocminfo_line.substr(31, 16);
|
||||
} else if (auto loc = rocminfo_line.find("GPU-"); loc != std::string::npos) {
|
||||
if (std::string::npos ==
|
||||
rocminfo_line.find("GPU-XX")) { // Only make an entry if the device is not an iGPU
|
||||
std::vector<char> t_uuid(16, 0);
|
||||
std::memcpy(t_uuid.data(), &rocminfo_line[loc + 4], 16);
|
||||
uuid_map[j] = t_uuid;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
for (int dev = 0; dev < deviceCount; dev++) {
|
||||
|
||||
for (const auto& i : uuid_map) {
|
||||
if (i.second.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
auto dev = i.first;
|
||||
HIP_CHECK(hipSetDevice(dev));
|
||||
hipDevice_t device;
|
||||
HIP_CHECK(hipDeviceGet(&device, dev));
|
||||
HIP_CHECK(hipDeviceGetUuid(&uuid, device));
|
||||
REQUIRE(output[dev] == uuid.bytes);
|
||||
hipUUID d_uuid{0};
|
||||
HIP_CHECK(hipDeviceGetUuid(&d_uuid, device));
|
||||
REQUIRE(memcmp(d_uuid.bytes, i.second.data(), 16) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
@@ -178,7 +187,8 @@ TEST_CASE("Unit_hipDeviceGetUuid_VerifyUuidFrm_hipGetDeviceProperties") {
|
||||
HIP_CHECK(hipDeviceGet(&device, dev));
|
||||
HIP_CHECK(hipDeviceGetUuid(&uuid, device));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, dev));
|
||||
REQUIRE(strcmp(prop.uuid.bytes, uuid.bytes) == 0);
|
||||
REQUIRE(memcmp(uuid.bytes, prop.uuid.bytes, 16) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Ссылка в новой задаче
Block a user