update <pid> case for zetSysmanProcessesGetState

Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
Mayank Raghuwanshi 2020-11-20 17:16:23 +05:30 committed by Compute-Runtime-Automation
parent 9183a9b638
commit 29254cb683
3 changed files with 37 additions and 7 deletions

View File

@ -278,6 +278,16 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
std::string realClientPidPath = clientsDir + "/" + clientId + "/" + "pid";
uint64_t pid;
result = pSysfsAccess->read(realClientPidPath, pid);
if (ZE_RESULT_SUCCESS != result) {
std::string bPidString;
result = pSysfsAccess->read(realClientPidPath, bPidString);
if (result == ZE_RESULT_SUCCESS) {
size_t start = bPidString.find("<");
size_t end = bPidString.find(">");
std::string bPid = bPidString.substr(start + 1, end - start - 1);
pid = std::stoull(bPid, nullptr, 10);
}
}
if (ZE_RESULT_SUCCESS != result) {
if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) {
continue;

View File

@ -28,11 +28,15 @@ const std::string clientsDir("clients");
constexpr uint64_t pid1 = 1711u;
constexpr uint64_t pid2 = 1722u;
constexpr uint64_t pid3 = 1723u;
constexpr uint64_t pid4 = 1733u;
const std::string bPid4 = "<1733>";
constexpr uint64_t engineTimeSpent = 123456u;
const std::string clientId1("4");
const std::string clientId2("5");
const std::string clientId3("6");
const std::string clientId4("7");
const std::string clientId5("8");
const std::string clientId6("10");
const std::string engine0("0");
const std::string engine1("1");
const std::string engine2("2");
@ -66,6 +70,8 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
val = "0x3ea5";
} else if (file.compare(vendorFile) == 0) {
val = "0x8086";
} else if (file.compare("clients/8/pid") == 0) {
val = bPid4;
} else {
return ZE_RESULT_ERROR_NOT_AVAILABLE;
}
@ -80,21 +86,25 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
} else if (file.compare("clients/7/pid") == 0) {
val = pid3;
} else if ((file.compare("clients/4/busy/0") == 0) || (file.compare("clients/4/busy/3") == 0) ||
(file.compare("clients/5/busy/1") == 0) || (file.compare("clients/6/busy/0") == 0)) {
(file.compare("clients/5/busy/1") == 0) || (file.compare("clients/6/busy/0") == 0) ||
(file.compare("clients/8/busy/1") == 0) || (file.compare("clients/8/busy/0") == 0)) {
val = engineTimeSpent;
} else if ((file.compare("clients/4/busy/1") == 0) || (file.compare("clients/4/busy/2") == 0) ||
(file.compare("clients/5/busy/0") == 0) || (file.compare("clients/5/busy/2") == 0) ||
(file.compare("clients/7/busy/0") == 0) || (file.compare("clients/7/busy/2") == 0) ||
(file.compare("clients/5/busy/3") == 0) || (file.compare("clients/6/busy/1") == 0) ||
(file.compare("clients/6/busy/2") == 0) || (file.compare("clients/6/busy/3") == 0)) {
(file.compare("clients/6/busy/2") == 0) || (file.compare("clients/6/busy/3") == 0) ||
(file.compare("clients/8/busy/2") == 0) || (file.compare("clients/8/busy/3") == 0)) {
val = 0;
} else if ((file.compare("clients/4/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/5/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/6/total_device_memory_buffer_objects/created_bytes") == 0)) {
(file.compare("clients/6/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/8/total_device_memory_buffer_objects/created_bytes") == 0)) {
val = 1024;
} else if ((file.compare("clients/4/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/5/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/6/total_device_memory_buffer_objects/imported_bytes") == 0)) {
(file.compare("clients/6/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/8/total_device_memory_buffer_objects/imported_bytes") == 0)) {
val = 512;
} else if (file.compare("clients/7/total_device_memory_buffer_objects/created_bytes") == 0) {
return ZE_RESULT_ERROR_UNKNOWN;
@ -112,8 +122,10 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
list.push_back(clientId2);
list.push_back(clientId3);
list.push_back(clientId4);
list.push_back(clientId5);
list.push_back(clientId6);
} else if ((path.compare("clients/4/busy") == 0) || (path.compare("clients/5/busy") == 0) ||
(path.compare("clients/6/busy") == 0) || (path.compare("clients/7/busy") == 0)) {
(path.compare("clients/6/busy") == 0) || (path.compare("clients/7/busy") == 0) || (path.compare("clients/8/busy") == 0)) {
list.push_back(engine0);
list.push_back(engine1);
list.push_back(engine2);
@ -129,8 +141,9 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
list.push_back(clientId1);
list.push_back(clientId2);
list.push_back(clientId3);
list.push_back(clientId5);
} else if ((path.compare("clients/4/busy") == 0) || (path.compare("clients/5/busy") == 0) ||
(path.compare("clients/6/busy") == 0)) {
(path.compare("clients/6/busy") == 0) || (path.compare("clients/8/busy") == 0)) {
list.push_back(engine0);
list.push_back(engine1);
list.push_back(engine2);

View File

@ -16,8 +16,10 @@ namespace ult {
constexpr uint64_t memSize1 = 2048;
constexpr uint64_t memSize2 = 1024;
constexpr uint64_t memSize4 = 1024;
constexpr uint64_t sharedMemSize1 = 1024;
constexpr uint64_t sharedMemSize2 = 512;
constexpr uint64_t sharedMemSize4 = 512;
// In mock function getValUnsignedLong, we have set the engines used as 0, 3 and 1.
// Hence, expecting 28 as engine field because 28 in binary would be 00011100
// This indicates bit number 2, 3 and 4 are set, thus this indicates, this process
@ -27,7 +29,8 @@ constexpr int64_t engines1 = 28u;
// 4 in binary 0100, as 2nd bit is set, hence it indicates, process used ZES_ENGINE_TYPE_FLAG_3D
// Corresponding i915 mapped value in mocked getValUnsignedLong() is 0.
constexpr int64_t engines2 = 4u;
constexpr uint32_t totalProcessStates = 2u; // Two process States for two pids
constexpr int64_t engines4 = 20u;
constexpr uint32_t totalProcessStates = 3u; // Three process States for three pids
const std::string expectedModelName("0x3ea5");
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
protected:
@ -155,6 +158,10 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInfor
EXPECT_EQ(processes[1].engines, engines2);
EXPECT_EQ(processes[1].memSize, memSize2);
EXPECT_EQ(processes[1].sharedSize, sharedMemSize2);
EXPECT_EQ(processes[2].processId, pid4);
EXPECT_EQ(processes[2].engines, engines4);
EXPECT_EQ(processes[2].memSize, memSize4);
EXPECT_EQ(processes[2].sharedSize, sharedMemSize4);
}
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingFaultyClientFileThenFailureIsReturned) {