fix(sysman): handle number of vf not available case

Related-To: NEO-8554

Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
Joshua Santosh Ranjan
2023-12-27 07:18:59 +00:00
committed by Compute-Runtime-Automation
parent 72a999599f
commit 8176e13111
3 changed files with 32 additions and 6 deletions

View File

@@ -74,6 +74,7 @@ ze_result_t OsEngine::getNumEngineTypeAndInstances(std::set<std::pair<zes_engine
static ze_result_t readBusynessFromGroupFd(PmuInterface *pPmuInterface, std::pair<int64_t, int64_t> &fdPair, zes_engine_stats_t *pStats) {
uint64_t data[4] = {};
auto ret = pPmuInterface->pmuRead(static_cast<int>(fdPair.first), data, sizeof(data));
if (ret < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():pmuRead is returning value:%d and error:0x%x \n", __FUNCTION__, ret, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
@@ -168,13 +169,18 @@ void LinuxEngineImp::init() {
fd[1] = pPmuInterface->pmuInterfaceOpen(__PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(subDeviceId), static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fdList.push_back(std::make_pair(fd[0], fd[1]));
pSysfsAccess->read(pathForNumberOfVfs.data(), numberOfVfs);
auto status = pSysfsAccess->read(pathForNumberOfVfs.data(), numberOfVfs);
if (status != ZE_RESULT_SUCCESS) {
numberOfVfs = 0;
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():Reading Number Of Vfs Failed \n", __FUNCTION__);
return;
}
// +1 to include PF
for (uint64_t i = 0; i < numberOfVfs + 1; i++) {
uint64_t functionConfig = ___PRELIM_I915_PMU_FN_EVENT(config, i);
fd[0] = pPmuInterface->pmuInterfaceOpen(functionConfig, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fd[1] = pPmuInterface->pmuInterfaceOpen(__PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(subDeviceId), static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
const uint64_t busyConfig = ___PRELIM_I915_PMU_FN_EVENT(config, i);
fd[0] = pPmuInterface->pmuInterfaceOpen(busyConfig, -1, PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
const uint64_t totalConfig = ___PRELIM_I915_PMU_FN_EVENT(__PRELIM_I915_PMU_TOTAL_ACTIVE_TICKS(subDeviceId), i);
fd[1] = pPmuInterface->pmuInterfaceOpen(totalConfig, static_cast<int>(fd[0]), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
fdList.push_back(std::make_pair(fd[0], fd[1]));
}
}

View File

@@ -168,6 +168,7 @@ struct MockEngineSysfsAccess : public SysfsAccess {
bool mockReadSymLinkFailure = false;
bool mockReadSymLinkSuccess = false;
ze_result_t mockReadStatus = ZE_RESULT_SUCCESS;
uint32_t mockReadVal = 0;
ze_result_t readSymLink(const std::string file, std::string &val) override {
@@ -199,7 +200,7 @@ struct MockEngineSysfsAccess : public SysfsAccess {
ze_result_t read(const std::string file, uint32_t &val) override {
val = mockReadVal;
return ZE_RESULT_SUCCESS;
return mockReadStatus;
}
MockEngineSysfsAccess() = default;

View File

@@ -105,6 +105,7 @@ TEST_F(ZesEngineFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumEngineGr
EXPECT_EQ(zesDeviceEnumEngineGroups(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
EXPECT_EQ(count, handleComponentCount);
}
TEST_F(ZesEngineFixture, GivenValidEngineHandlesWhenCallingZesEngineGetPropertiesThenVerifyCallSucceeds) {
zes_engine_properties_t properties;
auto handles = getEngineHandles(handleComponentCount);
@@ -230,6 +231,24 @@ TEST_F(ZesEngineFixture, GivenValidEngineHandleAndDiscreteDeviceWhenCallingZesEn
}
}
TEST_F(ZesEngineFixture, GivenReadingNumberOfVfsFailWhenInitializingEnginesThenGetActivityExtReturnsError) {
auto pMemoryManagerTest = std::make_unique<MockMemoryManagerInEngineSysman>(*neoDevice->getExecutionEnvironment());
pMemoryManagerTest->localMemorySupported[0] = true;
device->getDriverHandle()->setMemoryManager(pMemoryManagerTest.get());
pSysfsAccess->mockReadStatus = ZE_RESULT_ERROR_INVALID_ARGUMENT;
pSysfsAccess->mockReadSymLinkSuccess = true;
pSysmanDeviceImp->pEngineHandleContext->handleList.clear();
pSysmanDeviceImp->pEngineHandleContext->init(deviceHandles);
auto handles = getEngineHandles(handleComponentCount);
EXPECT_EQ(handleComponentCount, handles.size());
for (auto handle : handles) {
ASSERT_NE(nullptr, handle);
uint32_t count = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesEngineGetActivityExt(handle, &count, nullptr));
}
}
TEST_F(ZesEngineFixture, GivenDiscreteDeviceWithNoVfsWhenCallingZesEngineGetActivityExtThenReturnFailure) {
auto pMemoryManagerTest = std::make_unique<MockMemoryManagerInEngineSysman>(*neoDevice->getExecutionEnvironment());
pMemoryManagerTest->localMemorySupported[0] = true;