Defer Sysman Scheduler and Memory Module Initialization

With this change, init for sysman Scheduler/Memory API would
not be done during zeInit.
init and thereby Scheduler/Memory API handle creation would be done
only when user explicitly requests to enumerate handles
using zesDeviceEnumSchedulers/zesDeviceEnumMemory.

Related-To: LOCI-3127

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2022-07-13 09:59:14 +00:00
committed by Compute-Runtime-Automation
parent e58bc1ca86
commit e1748ad436
9 changed files with 20 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,6 +10,7 @@
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
#include "level_zero/tools/source/sysman/os_sysman.h"
namespace L0 {
@@ -36,6 +37,9 @@ ze_result_t MemoryHandleContext::init(std::vector<ze_device_handle_t> &deviceHan
}
ze_result_t MemoryHandleContext::memoryGet(uint32_t *pCount, zes_mem_handle_t *phMemory) {
std::call_once(initMemoryOnce, [this]() {
this->init(pOsSysman->getDeviceHandles());
});
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,7 @@
#include "level_zero/core/source/device/device.h"
#include <level_zero/zes_api.h>
#include <mutex>
#include <vector>
struct _zes_mem_handle_t {
@@ -46,6 +47,7 @@ struct MemoryHandleContext {
private:
void createHandle(ze_device_handle_t deviceHandle);
std::once_flag initMemoryOnce;
};
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,6 +8,7 @@
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/debug_helpers.h"
#include "level_zero/tools/source/sysman/os_sysman.h"
#include "level_zero/tools/source/sysman/scheduler/scheduler_imp.h"
class OsScheduler;
@@ -39,6 +40,9 @@ void SchedulerHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles
}
ze_result_t SchedulerHandleContext::schedulerGet(uint32_t *pCount, zes_sched_handle_t *phScheduler) {
std::call_once(initSchedulerOnce, [this]() {
this->init(pOsSysman->getDeviceHandles());
});
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,6 +12,7 @@
#include <level_zero/zes_api.h>
#include <map>
#include <mutex>
#include <string>
#include <vector>
@@ -51,6 +52,7 @@ struct SchedulerHandleContext : NEO::NonCopyableOrMovableClass {
private:
void createHandle(zes_engine_type_flag_t engineType, std::vector<std::string> &listOfEngines, ze_device_handle_t deviceHandle);
std::once_flag initSchedulerOnce;
};
} // namespace L0

View File

@@ -112,12 +112,6 @@ ze_result_t SysmanDeviceImp::init() {
if (pEngineHandleContext) {
pEngineHandleContext->init();
}
if (pSchedulerHandleContext) {
pSchedulerHandleContext->init(deviceHandles);
}
if (pMemoryHandleContext) {
pMemoryHandleContext->init(deviceHandles);
}
if (pGlobalOperations) {
pGlobalOperations->init();
}