mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
Defer Sysman PCI, Global operations and Events Module Initialization
With this change, init for sysman PCI, Global operations and Events API would not be done during zeInit. init and thereby PCI, Global operations and Events API handle creation would be done implicitly only when user explicitly calls any APIs. Related-To: LOCI-3127 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9f36b20423
commit
cf55a92b79
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,13 +12,19 @@
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t EventsImp::eventRegister(zes_event_type_flags_t events) {
|
||||
initEvents();
|
||||
return pOsEvents->eventRegister(events);
|
||||
}
|
||||
|
||||
bool EventsImp::eventListen(zes_event_type_flags_t &pEvent, uint64_t timeout) {
|
||||
initEvents();
|
||||
return pOsEvents->eventListen(pEvent, timeout);
|
||||
}
|
||||
|
||||
void EventsImp::initEvents() {
|
||||
std::call_once(initEventsOnce, [this]() {
|
||||
this->init();
|
||||
});
|
||||
}
|
||||
void EventsImp::init() {
|
||||
pOsEvents = OsEvents::create(pOsSysman);
|
||||
UNRECOVERABLE_IF(nullptr == pOsEvents);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "events.h"
|
||||
#include "os_events.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class EventsImp : public Events, NEO::NonCopyableOrMovableClass {
|
||||
@@ -26,6 +28,8 @@ class EventsImp : public Events, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
private:
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
std::once_flag initEventsOnce;
|
||||
void initEvents();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,6 +15,7 @@
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t GlobalOperationsImp::processesGetState(uint32_t *pCount, zes_process_state_t *pProcesses) {
|
||||
initGlobalOperations();
|
||||
std::vector<zes_process_state_t> pProcessList;
|
||||
ze_result_t result = pOsGlobalOperations->scanProcessesState(pProcessList);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
@@ -39,6 +40,7 @@ ze_result_t GlobalOperationsImp::processesGetState(uint32_t *pCount, zes_process
|
||||
}
|
||||
|
||||
ze_result_t GlobalOperationsImp::deviceGetProperties(zes_device_properties_t *pProperties) {
|
||||
initGlobalOperations();
|
||||
Device *device = pOsGlobalOperations->getDevice();
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
device->getProperties(&deviceProperties);
|
||||
@@ -51,10 +53,12 @@ ze_result_t GlobalOperationsImp::deviceGetProperties(zes_device_properties_t *pP
|
||||
}
|
||||
|
||||
ze_result_t GlobalOperationsImp::reset(ze_bool_t force) {
|
||||
initGlobalOperations();
|
||||
return pOsGlobalOperations->reset(force);
|
||||
}
|
||||
|
||||
ze_result_t GlobalOperationsImp::deviceGetState(zes_device_state_t *pState) {
|
||||
initGlobalOperations();
|
||||
return pOsGlobalOperations->deviceGetState(pState);
|
||||
}
|
||||
|
||||
@@ -70,7 +74,11 @@ void GlobalOperationsImp::init() {
|
||||
pOsGlobalOperations->getBoardNumber(sysmanProperties.boardNumber);
|
||||
pOsGlobalOperations->getSerialNumber(sysmanProperties.serialNumber);
|
||||
}
|
||||
|
||||
void GlobalOperationsImp::initGlobalOperations() {
|
||||
std::call_once(initGlobalOpOnce, [this]() {
|
||||
this->init();
|
||||
});
|
||||
}
|
||||
GlobalOperationsImp::~GlobalOperationsImp() {
|
||||
if (nullptr != pOsGlobalOperations) {
|
||||
delete pOsGlobalOperations;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "global_operations.h"
|
||||
#include "os_global_operations.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
@@ -33,6 +34,8 @@ class GlobalOperationsImp : public GlobalOperations, NEO::NonCopyableOrMovableCl
|
||||
private:
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
zes_device_properties_t sysmanProperties = {};
|
||||
std::once_flag initGlobalOpOnce;
|
||||
void initGlobalOperations();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -83,11 +83,13 @@ int32_t convertLinkSpeedToPciGen(double speed) {
|
||||
}
|
||||
|
||||
ze_result_t PciImp::pciStaticProperties(zes_pci_properties_t *pProperties) {
|
||||
initPci();
|
||||
*pProperties = pciProperties;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t PciImp::pciGetInitializedBars(uint32_t *pCount, zes_pci_bar_properties_t *pProperties) {
|
||||
initPci();
|
||||
uint32_t pciBarPropertiesSize = static_cast<uint32_t>(pciBarProperties.size());
|
||||
uint32_t numToCopy = std::min(*pCount, pciBarPropertiesSize);
|
||||
if (0 == *pCount || *pCount > pciBarPropertiesSize) {
|
||||
@@ -118,6 +120,7 @@ ze_result_t PciImp::pciGetInitializedBars(uint32_t *pCount, zes_pci_bar_properti
|
||||
}
|
||||
|
||||
ze_result_t PciImp::pciGetState(zes_pci_state_t *pState) {
|
||||
initPci();
|
||||
return pOsPci->getState(pState);
|
||||
}
|
||||
|
||||
@@ -140,7 +143,11 @@ void PciImp::pciGetStaticFields() {
|
||||
pciProperties.maxSpeed.gen = convertLinkSpeedToPciGen(maxLinkSpeed);
|
||||
pOsPci->initializeBarProperties(pciBarProperties);
|
||||
}
|
||||
|
||||
void PciImp::initPci() {
|
||||
std::call_once(initPciOnce, [this]() {
|
||||
this->init();
|
||||
});
|
||||
}
|
||||
void PciImp::init() {
|
||||
if (pOsPci == nullptr) {
|
||||
pOsPci = OsPci::create(pOsSysman);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "os_pci.h"
|
||||
#include "pci.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
@@ -37,6 +38,8 @@ class PciImp : public Pci, NEO::NonCopyableOrMovableClass {
|
||||
bool resizableBarSupported = false;
|
||||
zes_pci_properties_t pciProperties = {};
|
||||
std::vector<zes_pci_bar_properties_t *> pciBarProperties = {};
|
||||
std::once_flag initPciOnce;
|
||||
void initPci();
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -97,9 +97,6 @@ ze_result_t SysmanDeviceImp::init() {
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
if (pPci) {
|
||||
pPci->init();
|
||||
}
|
||||
if (pEngineHandleContext) {
|
||||
pEngineHandleContext->init();
|
||||
}
|
||||
@@ -109,12 +106,6 @@ ze_result_t SysmanDeviceImp::init() {
|
||||
if (pMemoryHandleContext) {
|
||||
pMemoryHandleContext->init(deviceHandles);
|
||||
}
|
||||
if (pGlobalOperations) {
|
||||
pGlobalOperations->init();
|
||||
}
|
||||
if (pEvents) {
|
||||
pEvents->init();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -50,8 +50,6 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
ON_CALL(*pSysfsAccess.get(), readSymLink(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<EventsSysfsAccess>::getValStringSymLinkSuccess));
|
||||
|
||||
pEventsImp->init();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
@@ -133,7 +133,6 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
expectedModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo());
|
||||
pGlobalOperationsImp->init();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -155,6 +154,10 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
void initGlobalOps() {
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
}
|
||||
};
|
||||
class SysmanGlobalOperationsIntegratedFixture : public SysmanGlobalOperationsFixture {
|
||||
void SetUp() override {
|
||||
@@ -195,7 +198,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
test = srcVersion;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValSrcFile));
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -207,7 +209,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -218,7 +219,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -229,7 +229,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -240,7 +239,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getFalseValString));
|
||||
neoDevice->deviceInfo.vendorId = 1806; // Unknown Vendor id
|
||||
pGlobalOperationsImp->init();
|
||||
zes_device_properties_t properties;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -252,7 +250,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS));
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
@@ -331,8 +328,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInfor
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenFailureIsReturnedEvenwithFaultyClient) {
|
||||
initGlobalOps();
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDirPidEntires));
|
||||
@@ -405,7 +402,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsNotWedgedWhenCallingGetDevice
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueWhenCallingResetThenSuccessIsReturned) {
|
||||
pGlobalOperationsImp->init();
|
||||
initGlobalOps();
|
||||
static_cast<PublicLinuxGlobalOperationsImp *>(pGlobalOperationsImp->pOsGlobalOperations)->pLinuxSysmanImp = pMockGlobalOpsLinuxSysmanImp.get();
|
||||
static_cast<PublicLinuxGlobalOperationsImp *>(pGlobalOperationsImp->pOsGlobalOperations)->pLinuxSysmanImp->pDevice = pLinuxSysmanImp->getDeviceHandle();
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
@@ -415,7 +412,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueWhenCallingResetThenSuccessI
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenPermissionDeniedWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
|
||||
|
||||
pSysfsAccess->isRootSet = false;
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, result);
|
||||
}
|
||||
@@ -426,7 +422,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingReset
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
@@ -445,7 +440,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
// Check that reset closed the device
|
||||
@@ -466,7 +460,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenForceTrueAndDeviceInUseWhen
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -485,7 +478,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -504,7 +496,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
VariableBackup<UltHwConfig> backup{&ultHwConfig};
|
||||
ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult = false;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
@@ -525,7 +516,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -536,7 +526,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingReset
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
@@ -552,7 +541,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenLi
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
ON_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
@@ -571,7 +559,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pFsAccess.get(), write(mockFunctionResetPath, std::string("1")))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -589,7 +576,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), unbindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -610,13 +596,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessWontDieWhenCallingResetThenZeResultErrorHandleObjectInUseErrorIsReturned) {
|
||||
|
||||
initGlobalOps();
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -633,7 +617,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessWontDieWhenCallingRe
|
||||
.Times(0);
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.Times(0);
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
@@ -656,7 +639,6 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -679,5 +661,11 @@ TEST(SysmanGlobalOperationsTest, GivenNotExisitingPciPathWhenPrepareDeviceEnviro
|
||||
EXPECT_FALSE(DeviceFactory::prepareDeviceEnvironment(*device3->getExecutionEnvironment(), pciPath3, 0u));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleWhenCallingDeviceGetStateThenSuccessResultIsReturned) {
|
||||
zes_device_state_t deviceState;
|
||||
ze_result_t result = zesDeviceGetState(device, &deviceState);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -43,7 +43,6 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pGlobalOperationsImp = static_cast<L0::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
pGlobalOperationsImp->init();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -66,14 +65,12 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
init(true);
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetThenSuccessIsReturned) {
|
||||
init(false);
|
||||
pGlobalOperationsImp->init();
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,6 @@ TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetProperties
|
||||
zes_pci_properties_t properties;
|
||||
ON_CALL(*pSysfsAccess.get(), readSymLink(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PciSysfsAccess>::getValStringSymLinkEmpty));
|
||||
pPciImp->init();
|
||||
|
||||
ze_result_t result = zesDevicePciGetProperties(device, &properties);
|
||||
|
||||
@@ -697,6 +696,10 @@ TEST_F(ZesPciFixture, WhenConvertingLinkSpeedFromGigatransfersPerSecondToBytesPe
|
||||
EXPECT_EQ(speedPci25, static_cast<int64_t>(PciLinkSpeeds::Pci2_5GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen1Gen2));
|
||||
EXPECT_EQ(0, convertPcieSpeedFromGTsToBs(0.0));
|
||||
}
|
||||
TEST_F(SysmanDeviceFixture, GivenValidSysmanHandleWhenCallingzesSysmanPciGetStateThenVerifyzetSysmanPciGetStatsCallReturnNotSupported) {
|
||||
zes_pci_state_t state;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetState(device, &state));
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user