mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
Cleanup Sysman initialization
Change-Id: Idc1e13e1b1fd3928674d5f199665054dbab27a9b Signed-off-by: Matias A. Cabral <matias.a.cabral@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
766011ba87
commit
237e2fe61f
@@ -647,8 +647,10 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
|
||||
device->getSourceLevelDebugger()
|
||||
->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0);
|
||||
}
|
||||
|
||||
if (static_cast<DriverHandleImp *>(driverHandle)->enableSysman) {
|
||||
device->setSysmanHandle(L0::SysmanDeviceHandleContext::init(device->toHandle()));
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ void DriverImp::initialize(ze_result_t *result) {
|
||||
envReader.getSetting("ZET_ENABLE_METRICS", false);
|
||||
envVariables.pin =
|
||||
envReader.getSetting("ZET_ENABLE_PROGRAM_INSTRUMENTATION", false);
|
||||
envVariables.sysman =
|
||||
envReader.getSetting("ZES_ENABLE_SYSMAN", false);
|
||||
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
UNRECOVERABLE_IF(nullptr == executionEnvironment);
|
||||
|
||||
@@ -253,6 +253,7 @@ DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> dev
|
||||
|
||||
driverHandle->affinityMaskString = envVariables.affinityMask;
|
||||
driverHandle->enableProgramDebugging = envVariables.programDebugging;
|
||||
driverHandle->enableSysman = envVariables.sysman;
|
||||
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -71,6 +71,7 @@ struct DriverHandleImp : public DriverHandle {
|
||||
// Environment Variables
|
||||
std::string affinityMaskString = "";
|
||||
bool enableProgramDebugging = false;
|
||||
bool enableSysman = false;
|
||||
};
|
||||
|
||||
extern struct DriverHandleImp *GlobalDriver;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct L0EnvVariables {
|
||||
bool programDebugging;
|
||||
bool metrics;
|
||||
bool pin;
|
||||
bool sysman;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -16,23 +16,15 @@
|
||||
|
||||
namespace L0 {
|
||||
|
||||
SysmanDevice *SysmanDeviceHandleContext::init(ze_device_handle_t device) {
|
||||
auto isSysmanEnabled = getenv("ZES_ENABLE_SYSMAN");
|
||||
if ((isSysmanEnabled == nullptr) || (device == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto isSysmanEnabledAsInt = atoi(isSysmanEnabled);
|
||||
if (isSysmanEnabledAsInt == 1) {
|
||||
SysmanDeviceImp *sysman = new SysmanDeviceImp(device);
|
||||
UNRECOVERABLE_IF(!sysman);
|
||||
sysman->init();
|
||||
return sysman;
|
||||
}
|
||||
return nullptr;
|
||||
SysmanDevice *SysmanDeviceHandleContext::init(ze_device_handle_t coreDevice) {
|
||||
SysmanDeviceImp *sysmanDevice = new SysmanDeviceImp(coreDevice);
|
||||
UNRECOVERABLE_IF(!sysmanDevice);
|
||||
sysmanDevice->init();
|
||||
return sysmanDevice;
|
||||
}
|
||||
|
||||
void DeviceImp::setSysmanHandle(SysmanDevice *pSysman) {
|
||||
pSysmanDevice = pSysman;
|
||||
void DeviceImp::setSysmanHandle(SysmanDevice *pSysmanDev) {
|
||||
pSysmanDevice = pSysmanDev;
|
||||
}
|
||||
|
||||
SysmanDevice *DeviceImp::getSysmanHandle() {
|
||||
|
||||
@@ -19,27 +19,14 @@ TEST_F(MockDeviceSysmanGetTest, GivenValidSysmanHandleSetInDeviceStructWhenGetTh
|
||||
EXPECT_EQ(sysman, device->getSysmanHandle());
|
||||
}
|
||||
|
||||
TEST_F(MockDeviceSysmanGetTest, GivenNULLDeviceHandleWhenCreatingSymanHandleThenNullSysmanHandleIsReturned) {
|
||||
ze_device_handle_t handle = nullptr;
|
||||
setenv("ZES_ENABLE_SYSMAN", "1", 1);
|
||||
EXPECT_EQ(nullptr, L0::SysmanDeviceHandleContext::init(handle));
|
||||
unsetenv("ZES_ENABLE_SYSMAN");
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenSysmanEnvironmentSetWhenEnumertatingSysmanHandlesThenValidSysmanHandleReceived) {
|
||||
zes_device_handle_t hSysman = device->toHandle();
|
||||
TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleInSysmanInitThenValidSysmanHandleReceived) {
|
||||
ze_device_handle_t hSysman = device->toHandle();
|
||||
auto pSysmanDevice = L0::SysmanDeviceHandleContext::init(hSysman);
|
||||
EXPECT_NE(pSysmanDevice, nullptr);
|
||||
delete pSysmanDevice;
|
||||
pSysmanDevice = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenSysmanEnvironmentNotSetWhenEnumertatingSysmanHandlesThenNullSysmanHandleReceived) {
|
||||
zes_device_handle_t hSysman = device->toHandle();
|
||||
unsetenv("ZES_ENABLE_SYSMAN");
|
||||
EXPECT_EQ(L0::SysmanDeviceHandleContext::init(hSysman), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenSetValidDrmHandleForDeviceWhenDoingOsSysmanDeviceInitThenSameDrmHandleIsRetrieved) {
|
||||
EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().get()->getDrm());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user