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