mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
refactor: Adding support for extending L0 context object
Related-To: NEO-13406 Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f852e2d8f0
commit
bd721b225e
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2023-2024 Intel Corporation
|
||||
# Copyright (C) 2023-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -13,4 +13,7 @@ target_sources(${L0_STATIC_LIB_NAME}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/context_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/context_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/context_ext.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace L0 {
|
||||
struct DriverHandle;
|
||||
struct Image;
|
||||
|
||||
class ContextExt;
|
||||
|
||||
struct Context : _ze_context_handle_t {
|
||||
inline static ze_memory_type_t parseUSMType(InternalMemoryType memoryType) {
|
||||
switch (memoryType) {
|
||||
@@ -178,6 +180,8 @@ struct Context : _ze_context_handle_t {
|
||||
|
||||
static Context *fromHandle(ze_context_handle_t handle) { return static_cast<Context *>(handle); }
|
||||
inline ze_context_handle_t toHandle() { return this; }
|
||||
|
||||
virtual ContextExt *getContextExt() = 0;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
21
level_zero/core/source/context/context_ext.cpp
Normal file
21
level_zero/core/source/context/context_ext.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class ContextExt;
|
||||
struct DriverHandle;
|
||||
|
||||
ContextExt *createContextExt(DriverHandle *driverHandle) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void destroyContextExt(ContextExt *ctxExt) {
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -61,6 +61,11 @@ DriverHandle *ContextImp::getDriverHandle() {
|
||||
|
||||
ContextImp::ContextImp(DriverHandle *driverHandle) {
|
||||
this->driverHandle = static_cast<DriverHandleImp *>(driverHandle);
|
||||
this->contextExt = createContextExt(driverHandle);
|
||||
}
|
||||
|
||||
ContextImp::~ContextImp() {
|
||||
destroyContextExt(this->contextExt);
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -22,9 +22,12 @@ struct DriverHandleImp;
|
||||
struct Device;
|
||||
struct IpcCounterBasedEventData;
|
||||
|
||||
ContextExt *createContextExt(DriverHandle *driverHandle);
|
||||
void destroyContextExt(ContextExt *ctxExt);
|
||||
|
||||
struct ContextImp : Context {
|
||||
ContextImp(DriverHandle *driverHandle);
|
||||
~ContextImp() override = default;
|
||||
~ContextImp() override;
|
||||
ze_result_t destroy() override;
|
||||
ze_result_t getStatus() override;
|
||||
DriverHandle *getDriverHandle() override;
|
||||
@@ -187,6 +190,10 @@ struct ContextImp : Context {
|
||||
unsigned int elementSizeInBytes,
|
||||
size_t *rowPitch) override;
|
||||
|
||||
ContextExt *getContextExt() override {
|
||||
return contextExt;
|
||||
}
|
||||
|
||||
protected:
|
||||
ze_result_t getIpcMemHandlesImpl(const void *ptr, uint32_t *numIpcHandles, ze_ipc_mem_handle_t *pIpcHandles);
|
||||
void setIPCHandleData(NEO::GraphicsAllocation *graphicsAllocation, uint64_t handle, IpcMemoryData &ipcData, uint64_t ptrAddress, uint8_t type);
|
||||
@@ -197,6 +204,7 @@ struct ContextImp : Context {
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
DriverHandleImp *driverHandle = nullptr;
|
||||
uint32_t numDevices = 0;
|
||||
ContextExt *contextExt = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user