[Sysman] Replace normal pointers with smart pointers (7/n)

Replacing normal pointers by smart pointers in memory  module of L0 sysman.

Related-To: LOCI-2810

Signed-off-by: Singh, Prasoon <prasoon.singh@intel.com>
This commit is contained in:
Singh, Prasoon
2023-03-29 07:03:39 +00:00
committed by Compute-Runtime-Automation
parent 7a03c78b0d
commit 4475e2228d
13 changed files with 30 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -31,10 +31,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
pMemoryManager->localMemorySupported[0] = false;
device->getDriverHandle()->setMemoryManager(pMemoryManager);
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -64,10 +60,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
void setLocalSupportedAndReinit(bool supported) {
pMemoryManager->localMemorySupported[0] = supported;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -176,11 +168,10 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropert
ze_device_properties_t deviceProperties = {};
ze_bool_t isSubDevice = deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE;
Device::fromHandle(device)->getProperties(&deviceProperties);
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, isSubDevice, deviceProperties.subdeviceId);
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, isSubDevice, deviceProperties.subdeviceId);
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
EXPECT_EQ(properties.subdeviceId, deviceProperties.subdeviceId);
EXPECT_EQ(properties.onSubdevice, isSubDevice);
delete pLinuxMemoryImp;
}
} // namespace ult

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -40,10 +40,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
pLinuxSysmanImp->pDrm = pDrm;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -78,10 +74,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
void setLocalSupportedAndReinit(bool supported) {
pMemoryManager->localMemorySupported[0] = supported;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -252,11 +244,10 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropert
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
ze_bool_t isSubDevice = deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE;
Device::fromHandle(device)->getProperties(&deviceProperties);
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, isSubDevice, deviceProperties.subdeviceId);
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, isSubDevice, deviceProperties.subdeviceId);
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
EXPECT_EQ(properties.subdeviceId, deviceProperties.subdeviceId);
EXPECT_EQ(properties.onSubdevice, isSubDevice);
delete pLinuxMemoryImp;
}
} // namespace ult

View File

@@ -62,9 +62,7 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
pDrm->setMemoryType(INTEL_HWCONFIG_MEMORY_TYPE_HBM2e);
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20>(*pDrm));
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
// We received a device handle. Check for subdevices in this device
@@ -115,10 +113,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
void setLocalSupportedAndReinit(bool supported) {
pMemoryManager->localMemorySupported[0] = supported;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -812,10 +806,6 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
pLinuxSysmanImp->pDrm = pDrm;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
// We received a device handle. Check for subdevices in this device
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
@@ -849,10 +839,6 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
void setLocalSupportedAndReinit(bool supported) {
pMemoryManager->localMemorySupported[0] = supported;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;

View File

@@ -32,10 +32,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
pOriginalKmdSysManager = pWddmSysmanImp->pKmdSysManager;
pWddmSysmanImp->pKmdSysManager = pKmdSysManager.get();
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;
@@ -61,10 +57,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
void setLocalSupportedAndReinit(bool supported) {
pMemoryManager->localMemorySupported[0] = supported;
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
uint32_t subDeviceCount = 0;
std::vector<ze_device_handle_t> deviceHandles;