(Sysman):Changes made in standby API.

Replacing normal pointers by smart pointers in standby 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-03 17:08:16 +00:00
committed by Compute-Runtime-Automation
parent 49827b7122
commit ac929eaf61
8 changed files with 25 additions and 48 deletions

View File

@@ -85,9 +85,9 @@ LinuxStandbyImp::LinuxStandbyImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uin
init();
}
OsStandby *OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
LinuxStandbyImp *pLinuxStandbyImp = new LinuxStandbyImp(pOsSysman, onSubdevice, subdeviceId);
return static_cast<OsStandby *>(pLinuxStandbyImp);
std::unique_ptr<OsStandby> OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
std::unique_ptr<LinuxStandbyImp> pLinuxStandbyImp = std::make_unique<LinuxStandbyImp>(pOsSysman, onSubdevice, subdeviceId);
return pLinuxStandbyImp;
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,6 +10,8 @@
#include "level_zero/tools/source/sysman/os_sysman.h"
#include <level_zero/zes_api.h>
#include <memory>
namespace L0 {
class OsStandby {
@@ -20,7 +22,7 @@ class OsStandby {
virtual bool isStandbySupported(void) = 0;
static OsStandby *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
static std::unique_ptr<OsStandby> create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
virtual ~OsStandby() {}
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,18 +13,11 @@
namespace L0 {
StandbyHandleContext::~StandbyHandleContext() {
for (Standby *pStandby : handleList) {
delete pStandby;
}
}
StandbyHandleContext::~StandbyHandleContext() = default;
void StandbyHandleContext::createHandle(ze_device_handle_t deviceHandle) {
Standby *pStandby = new StandbyImp(pOsSysman, deviceHandle);
std::unique_ptr<Standby> pStandby = std::make_unique<StandbyImp>(pOsSysman, deviceHandle);
if (pStandby->isStandbyEnabled == true) {
handleList.push_back(pStandby);
} else {
delete pStandby;
handleList.push_back(std::move(pStandby));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -44,7 +44,7 @@ struct StandbyHandleContext {
ze_result_t standbyGet(uint32_t *pCount, zes_standby_handle_t *phStandby);
OsSysman *pOsSysman;
std::vector<Standby *> handleList = {};
std::vector<std::unique_ptr<Standby>> handleList = {};
private:
void createHandle(ze_device_handle_t deviceHandle);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -40,8 +40,5 @@ StandbyImp::StandbyImp(OsSysman *pOsSysman, ze_device_handle_t handle) : deviceH
init();
}
StandbyImp::~StandbyImp() {
delete pOsStandby;
}
StandbyImp::~StandbyImp() {}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -24,7 +24,7 @@ class StandbyImp : public Standby, NEO::NonCopyableOrMovableClass {
StandbyImp() = default;
StandbyImp(OsSysman *pOsSysman, ze_device_handle_t handle);
~StandbyImp() override;
OsStandby *pOsStandby = nullptr;
std::unique_ptr<OsStandby> pOsStandby = nullptr;
void init();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -33,9 +33,9 @@ bool WddmStandbyImp::isStandbySupported(void) {
return false;
}
OsStandby *OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
WddmStandbyImp *pWddmStandbyImp = new WddmStandbyImp();
return static_cast<OsStandby *>(pWddmStandbyImp);
std::unique_ptr<OsStandby> OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
std::unique_ptr<WddmStandbyImp> pWddmStandbyImp = std::make_unique<WddmStandbyImp>();
return pWddmStandbyImp;
}
} // namespace L0