Skip to content

Commit

Permalink
Sysman : Add check on engine handle creation
Browse files Browse the repository at this point in the history
Add check whether init succeeded on handle creation.

Related-To: LOCI-3005

Signed-off-by: Bellekallu Rajkiran <[email protected]>
  • Loading branch information
bellekal authored and Compute-Runtime-Automation committed Mar 16, 2022
1 parent 878466a commit 061af9c
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 9 deletions.
8 changes: 6 additions & 2 deletions level_zero/tools/source/sysman/engine/engine.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -24,7 +24,11 @@ EngineHandleContext::~EngineHandleContext() {

void EngineHandleContext::createHandle(zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {
Engine *pEngine = new EngineImp(pOsSysman, engineType, engineInstance, subDeviceId);
handleList.push_back(pEngine);
if (pEngine->initSuccess == true) {
handleList.push_back(pEngine);
} else {
delete pEngine;
}
}

void EngineHandleContext::init() {
Expand Down
3 changes: 2 additions & 1 deletion level_zero/tools/source/sysman/engine/engine.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -28,6 +28,7 @@ class Engine : _zes_engine_handle_t {
return static_cast<Engine *>(handle);
}
inline zes_engine_handle_t toHandle() { return this; }
bool initSuccess = false;
};

struct EngineHandleContext {
Expand Down
7 changes: 5 additions & 2 deletions level_zero/tools/source/sysman/engine/engine_imp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -20,7 +20,10 @@ ze_result_t EngineImp::engineGetProperties(zes_engine_properties_t *pProperties)
}

void EngineImp::init() {
pOsEngine->getProperties(engineProperties);
if (pOsEngine->isEngineModuleSupported()) {
pOsEngine->getProperties(engineProperties);
this->initSuccess = true;
}
}

EngineImp::EngineImp(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {
Expand Down
7 changes: 7 additions & 0 deletions level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ void LinuxEngineImp::init() {
fd = pPmuInterface->pmuInterfaceOpen(I915_PMU_ENGINE_BUSY(i915EngineClass->second, engineInstance), -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
}

bool LinuxEngineImp::isEngineModuleSupported() {
if (fd < 0) {
return false;
}
return true;
}

LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId) : engineGroup(type), engineInstance(engineInstance), subDeviceId(subDeviceId) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pDrm = &pLinuxSysmanImp->getDrm();
Expand Down
3 changes: 2 additions & 1 deletion level_zero/tools/source/sysman/engine/linux/os_engine_imp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -19,6 +19,7 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableOrMovableClass {
public:
ze_result_t getActivity(zes_engine_stats_t *pStats) override;
ze_result_t getProperties(zes_engine_properties_t &properties) override;
bool isEngineModuleSupported() override;
static zes_engine_group_t getGroupFromEngineType(zes_engine_group_t type);
LinuxEngineImp() = default;
LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ void LinuxEngineImp::init() {
fd = pPmuInterface->pmuInterfaceOpen(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
}

bool LinuxEngineImp::isEngineModuleSupported() {
if (fd < 0) {
return false;
}
return true;
}

LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId) : engineGroup(type), engineInstance(engineInstance), subDeviceId(subDeviceId) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pDrm = &pLinuxSysmanImp->getDrm();
Expand Down
3 changes: 2 additions & 1 deletion level_zero/tools/source/sysman/engine/os_engine.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -21,6 +21,7 @@ class OsEngine {
public:
virtual ze_result_t getActivity(zes_engine_stats_t *pStats) = 0;
virtual ze_result_t getProperties(zes_engine_properties_t &properties) = 0;
virtual bool isEngineModuleSupported() = 0;
static OsEngine *create(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId);
static ze_result_t getNumEngineTypeAndInstances(std::set<std::pair<zes_engine_group_t, EngineInstanceSubDeviceId>> &engineGroupInstance, OsSysman *pOsSysman);
virtual ~OsEngine() = default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -57,6 +57,10 @@ ze_result_t WddmEngineImp::getProperties(zes_engine_properties_t &properties) {
return ZE_RESULT_SUCCESS;
}

bool WddmEngineImp::isEngineModuleSupported() {
return true;
}

WddmEngineImp::WddmEngineImp(OsSysman *pOsSysman, zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId) {
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
this->engineGroup = engineType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -17,6 +17,7 @@ class WddmEngineImp : public OsEngine, NEO::NonCopyableOrMovableClass {
public:
ze_result_t getActivity(zes_engine_stats_t *pStats) override;
ze_result_t getProperties(zes_engine_properties_t &properties) override;
bool isEngineModuleSupported() override;

WddmEngineImp() = default;
WddmEngineImp(OsSysman *pOsSysman, zes_engine_group_t type, uint32_t engineInstance, uint32_t subDeviceId);
Expand Down

0 comments on commit 061af9c

Please sign in to comment.