mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
[Sysman] Replace normal pointers with smart pointers (11/n)
Replacing normal pointers by smart pointers in memory module of LO sysman(zesinit). Related-To: LOCI-2810 Signed-off-by: Singh, Prasoon <prasoon.singh@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d1393e08d3
commit
afe99d7dbc
@@ -42,9 +42,9 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|||||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||||
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
|
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
||||||
return static_cast<OsMemory *>(pLinuxMemoryImp);
|
return pLinuxMemoryImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Sysman
|
} // namespace Sysman
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||||
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
|
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
||||||
return static_cast<OsMemory *>(pLinuxMemoryImp);
|
return pLinuxMemoryImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Sysman
|
} // namespace Sysman
|
||||||
|
|||||||
@@ -329,9 +329,9 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
|
|||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||||
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
|
std::unique_ptr<LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
||||||
return static_cast<OsMemory *>(pLinuxMemoryImp);
|
return pLinuxMemoryImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Sysman
|
} // namespace Sysman
|
||||||
|
|||||||
@@ -14,18 +14,12 @@
|
|||||||
namespace L0 {
|
namespace L0 {
|
||||||
namespace Sysman {
|
namespace Sysman {
|
||||||
|
|
||||||
MemoryHandleContext::~MemoryHandleContext() {
|
MemoryHandleContext::~MemoryHandleContext() = default;
|
||||||
for (Memory *pMemory : handleList) {
|
|
||||||
delete pMemory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemoryHandleContext::createHandle(bool onSubdevice, uint32_t subDeviceId) {
|
void MemoryHandleContext::createHandle(bool onSubdevice, uint32_t subDeviceId) {
|
||||||
Memory *pMemory = new MemoryImp(pOsSysman, onSubdevice, subDeviceId);
|
std::unique_ptr<Memory> pMemory = std::make_unique<MemoryImp>(pOsSysman, onSubdevice, subDeviceId);
|
||||||
if (pMemory->initSuccess == true) {
|
if (pMemory->initSuccess == true) {
|
||||||
handleList.push_back(pMemory);
|
handleList.push_back(std::move(pMemory));
|
||||||
} else {
|
|
||||||
delete pMemory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "level_zero/api/sysman/zes_handles_struct.h"
|
#include "level_zero/api/sysman/zes_handles_struct.h"
|
||||||
#include <level_zero/zes_api.h>
|
#include <level_zero/zes_api.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ struct MemoryHandleContext {
|
|||||||
ze_result_t memoryGet(uint32_t *pCount, zes_mem_handle_t *phMemory);
|
ze_result_t memoryGet(uint32_t *pCount, zes_mem_handle_t *phMemory);
|
||||||
|
|
||||||
OsSysman *pOsSysman = nullptr;
|
OsSysman *pOsSysman = nullptr;
|
||||||
std::vector<Memory *> handleList = {};
|
std::vector<std::unique_ptr<Memory>> handleList = {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createHandle(bool onSubdevice, uint32_t subDeviceId);
|
void createHandle(bool onSubdevice, uint32_t subDeviceId);
|
||||||
|
|||||||
@@ -35,11 +35,7 @@ MemoryImp::MemoryImp(OsSysman *pOsSysman, bool onSubdevice, uint32_t subDeviceId
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryImp::~MemoryImp() {
|
MemoryImp::~MemoryImp() = default;
|
||||||
if (nullptr != pOsMemory) {
|
|
||||||
delete pOsMemory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Sysman
|
} // namespace Sysman
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class MemoryImp : public Memory, NEO::NonCopyableOrMovableClass {
|
|||||||
|
|
||||||
MemoryImp() = default;
|
MemoryImp() = default;
|
||||||
void init();
|
void init();
|
||||||
OsMemory *pOsMemory = nullptr;
|
std::unique_ptr<OsMemory> pOsMemory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
zes_mem_properties_t memoryProperties = {};
|
zes_mem_properties_t memoryProperties = {};
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <level_zero/zes_api.h>
|
#include <level_zero/zes_api.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
namespace Sysman {
|
namespace Sysman {
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ class OsMemory {
|
|||||||
virtual ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0;
|
virtual ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0;
|
||||||
virtual ze_result_t getState(zes_mem_state_t *pState) = 0;
|
virtual ze_result_t getState(zes_mem_state_t *pState) = 0;
|
||||||
virtual bool isMemoryModuleSupported() = 0;
|
virtual bool isMemoryModuleSupported() = 0;
|
||||||
static OsMemory *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
static std::unique_ptr<OsMemory> create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||||
virtual ~OsMemory() {}
|
virtual ~OsMemory() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
namespace Sysman {
|
namespace Sysman {
|
||||||
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
std::unique_ptr<OsMemory> OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||||
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp(pOsSysman, onSubdevice, subdeviceId);
|
std::unique_ptr<WddmMemoryImp> pWddmMemoryImp = std::make_unique<WddmMemoryImp>(pOsSysman, onSubdevice, subdeviceId);
|
||||||
return static_cast<OsMemory *>(pWddmMemoryImp);
|
return pWddmMemoryImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Sysman
|
} // namespace Sysman
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DebugManager.flags.EnableLocalMemory.set(1);
|
DebugManager.flags.EnableLocalMemory.set(1);
|
||||||
SysmanDeviceFixture::SetUp();
|
SysmanDeviceFixture::SetUp();
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
device = pSysmanDeviceImp;
|
device = pSysmanDeviceImp;
|
||||||
@@ -36,9 +33,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
void setLocalSupportedAndReinit(bool supported) {
|
void setLocalSupportedAndReinit(bool supported) {
|
||||||
|
|
||||||
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
||||||
@@ -136,11 +130,10 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropert
|
|||||||
zes_mem_properties_t properties = {};
|
zes_mem_properties_t properties = {};
|
||||||
ze_bool_t isSubdevice = pLinuxSysmanImp->getSubDeviceCount() == 0 ? false : true;
|
ze_bool_t isSubdevice = pLinuxSysmanImp->getSubDeviceCount() == 0 ? false : true;
|
||||||
auto subDeviceId = std::max(0u, pLinuxSysmanImp->getSubDeviceCount() - 1);
|
auto subDeviceId = std::max(0u, pLinuxSysmanImp->getSubDeviceCount() - 1);
|
||||||
L0::Sysman::LinuxMemoryImp *pLinuxMemoryImp = new L0::Sysman::LinuxMemoryImp(pOsSysman, isSubdevice, subDeviceId);
|
std::unique_ptr<L0::Sysman::LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<L0::Sysman::LinuxMemoryImp>(pOsSysman, isSubdevice, subDeviceId);
|
||||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
||||||
EXPECT_EQ(properties.subdeviceId, subDeviceId);
|
EXPECT_EQ(properties.subdeviceId, subDeviceId);
|
||||||
EXPECT_EQ(properties.onSubdevice, isSubdevice);
|
EXPECT_EQ(properties.onSubdevice, isSubdevice);
|
||||||
delete pLinuxMemoryImp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||||
osInterface->setDriverModel(std::make_unique<MockMemoryNeoDrm>(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment())));
|
osInterface->setDriverModel(std::make_unique<MockMemoryNeoDrm>(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment())));
|
||||||
|
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
getMemoryHandles(0);
|
getMemoryHandles(0);
|
||||||
}
|
}
|
||||||
@@ -43,9 +39,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
|
|
||||||
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
||||||
|
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
||||||
}
|
}
|
||||||
@@ -202,11 +195,10 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingMemoryPropert
|
|||||||
zes_mem_properties_t properties = {};
|
zes_mem_properties_t properties = {};
|
||||||
ze_bool_t isSubdevice = pLinuxSysmanImp->getSubDeviceCount() == 0 ? false : true;
|
ze_bool_t isSubdevice = pLinuxSysmanImp->getSubDeviceCount() == 0 ? false : true;
|
||||||
auto subDeviceId = std::max(0u, pLinuxSysmanImp->getSubDeviceCount() - 1);
|
auto subDeviceId = std::max(0u, pLinuxSysmanImp->getSubDeviceCount() - 1);
|
||||||
L0::Sysman::LinuxMemoryImp *pLinuxMemoryImp = new L0::Sysman::LinuxMemoryImp(pOsSysman, isSubdevice, subDeviceId);
|
std::unique_ptr<L0::Sysman::LinuxMemoryImp> pLinuxMemoryImp = std::make_unique<L0::Sysman::LinuxMemoryImp>(pOsSysman, isSubdevice, subDeviceId);
|
||||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
||||||
EXPECT_EQ(properties.subdeviceId, subDeviceId);
|
EXPECT_EQ(properties.subdeviceId, subDeviceId);
|
||||||
EXPECT_EQ(properties.onSubdevice, isSubdevice);
|
EXPECT_EQ(properties.onSubdevice, isSubdevice);
|
||||||
delete pLinuxMemoryImp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||||
pDrm->setMemoryType(INTEL_HWCONFIG_MEMORY_TYPE_HBM2e);
|
pDrm->setMemoryType(INTEL_HWCONFIG_MEMORY_TYPE_HBM2e);
|
||||||
pDrm->ioctlHelper = static_cast<std::unique_ptr<NEO::IoctlHelper>>(std::make_unique<IoctlHelperPrelim20>(*pDrm));
|
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();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject;
|
pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject;
|
||||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||||
@@ -86,10 +84,6 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
|||||||
void setLocalSupportedAndReinit(bool supported) {
|
void setLocalSupportedAndReinit(bool supported) {
|
||||||
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
||||||
|
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
||||||
}
|
}
|
||||||
@@ -758,10 +752,6 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
|
|||||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||||
osInterface->setDriverModel(std::unique_ptr<MockMemoryNeoDrm>(pDrm));
|
osInterface->setDriverModel(std::unique_ptr<MockMemoryNeoDrm>(pDrm));
|
||||||
|
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
device = pSysmanDeviceImp;
|
device = pSysmanDeviceImp;
|
||||||
getMemoryHandles(0);
|
getMemoryHandles(0);
|
||||||
@@ -775,10 +765,6 @@ class SysmanMultiDeviceMemoryFixture : public SysmanMultiDeviceFixture {
|
|||||||
void setLocalSupportedAndReinit(bool supported) {
|
void setLocalSupportedAndReinit(bool supported) {
|
||||||
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
DebugManager.flags.EnableLocalMemory.set(supported == true ? 1 : 0);
|
||||||
|
|
||||||
for (auto handle : pSysmanDeviceImp->pMemoryHandleContext->handleList) {
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
pSysmanDeviceImp->pMemoryHandleContext->handleList.clear();
|
||||||
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
pSysmanDeviceImp->pMemoryHandleContext->init(pOsSysman->getSubDeviceCount());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user