Defer Sysman Standby Module Initialization

With this change, init for sysman Standby API would not be done during zeInit.
Rather init and thereby Standby API handle creation would be done only
when user explicitly requests to enumerate handles
using zesDeviceEnumStandbyDomains.

Related-To: LOCI-3127

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2022-07-11 10:29:19 +00:00
committed by Compute-Runtime-Automation
parent e1748ad436
commit aadf424476
4 changed files with 13 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -36,6 +36,9 @@ ze_result_t StandbyHandleContext::init(std::vector<ze_device_handle_t> &deviceHa
}
ze_result_t StandbyHandleContext::standbyGet(uint32_t *pCount, zes_standby_handle_t *phStandby) {
std::call_once(initStandbyOnce, [this]() {
this->init(pOsSysman->getDeviceHandles());
});
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {

View File

@@ -9,6 +9,7 @@
#include "level_zero/core/source/device/device.h"
#include <level_zero/zes_api.h>
#include <mutex>
#include <vector>
struct _zes_standby_handle_t {
@@ -47,6 +48,7 @@ struct StandbyHandleContext {
private:
void createHandle(ze_device_handle_t deviceHandle);
std::once_flag initStandbyOnce;
};
} // namespace L0

View File

@@ -106,9 +106,6 @@ ze_result_t SysmanDeviceImp::init() {
if (pPci) {
pPci->init();
}
if (pStandbyHandleContext) {
pStandbyHandleContext->init(deviceHandles);
}
if (pEngineHandleContext) {
pEngineHandleContext->init();
}

View File

@@ -51,7 +51,6 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
deviceHandles.resize(subDeviceCount, nullptr);
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
}
pSysmanDeviceImp->pStandbyHandleContext->init(deviceHandles);
}
void TearDown() override {
if (!sysmanUltsEnable) {
@@ -68,6 +67,13 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
}
};
TEST_F(ZesStandbyFixture, GivenStandbyModeFilesNotAvailableWhenCallingEnumerateThenSuccessResultAndZeroCountIsReturned) {
uint32_t count = 0;
ptestSysfsAccess->isStandbyModeFileAvailable = false;
ze_result_t result = zesDeviceEnumStandbyDomains(device, &count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 0u);
}
TEST_F(ZesStandbyFixture, GivenComponentCountZeroWhenCallingzesStandbyGetThenNonZeroCountIsReturnedAndVerifyzesStandbyGetCallSucceeds) {
std::vector<zes_standby_handle_t> standbyHandle = {};
uint32_t count = 0;
@@ -326,7 +332,6 @@ class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
deviceHandles.resize(subDeviceCount, nullptr);
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
}
pSysmanDeviceImp->pStandbyHandleContext->init(deviceHandles);
}
void TearDown() override {
if (!sysmanUltsEnable) {