Skip to content

Commit a9dbcfa

Browse files
committed
DDI extension support
- Support in the L0 Loader for https://oneapi-src.github.io/level-zero-spec/level-zero/latest/core/EXT_Driver_DDIHandles.html#ze-extension-driver-ddi-handles - To improve the speed for each call of L0 apis into the correct driver, the new support enables for the driver to allocate a header that stores that driver's ddi tables such that the Loader does not need to perform translation of handles to/from ze_object_t. - Given a driver supports the new extension, the loader will no longer create the ze_object_t and instead use the packed ddi tables in each handle_t. - The code has been refactored such that the legacy path will continue to work for the driver that has not converted over without interfering with a driver which now uses the "fast" path. - This new code path also removes the need for handle translation by the user if the drivers all support the new extension. - This new path is enabled with ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1, by default this new path is disabled. Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent 79ce2b5 commit a9dbcfa

30 files changed

Lines changed: 20819 additions & 174 deletions

.github/workflows/build-quick-static.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- env:
4343
ZEL_LIBRARY_PATH: '${{ github.workspace }}/dynamic_build/lib'
4444
working-directory: build
45-
run: ls $ZEL_LIBRARY_PATH;ZE_ENABLE_LOADER_DEBUG_TRACE=1 ctest -V
45+
run: ls $ZEL_LIBRARY_PATH;ctest -V
4646

4747
build-windows:
4848
if: github.repository_owner == 'oneapi-src'
@@ -56,7 +56,6 @@ jobs:
5656
cmake -D BUILD_L0_LOADER_TESTS=1 -D BUILD_STATIC=1 ..
5757
cmake --build . --config Release
5858
- env:
59-
ZE_ENABLE_LOADER_DEBUG_TRACE: '1'
6059
ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin/Release'
6160
working-directory: build
6261
run: ctest -C Release -V

.github/workflows/build-quick.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
..
2727
make -j$(nproc)
2828
- env:
29-
ZE_ENABLE_LOADER_DEBUG_TRACE: '1'
3029
ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/lib'
3130
working-directory: build
3231
run: ctest -V
@@ -43,7 +42,6 @@ jobs:
4342
cmake -D BUILD_L0_LOADER_TESTS=1 ..
4443
cmake --build . --config Release
4544
- env:
46-
ZE_ENABLE_LOADER_DEBUG_TRACE: '1'
4745
ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin/Release'
4846
working-directory: build
4947
run: ctest -C Release -V

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2020-2024 Intel Corporation
1+
# Copyright (C) 2020-2025 Intel Corporation
22
# SPDX-License-Identifier: MIT
33

44
cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)
@@ -13,7 +13,7 @@ if(MSVC AND (MSVC_VERSION LESS 1900))
1313
endif()
1414

1515
# This project follows semantic versioning (https://semver.org/)
16-
project(level-zero VERSION 1.22.3)
16+
project(level-zero VERSION 1.23.0)
1717

1818
include(GNUInstallDirs)
1919

PRODUCT_GUID.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.22.3
2-
b3491b8d-9942-47bf-be47-8741f9614566
1+
1.23.0
2+
146652e2-0b5a-4461-b176-800135676a46

samples/zello_world/zello_world.cpp

Lines changed: 84 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2020-2021 Intel Corporation
3+
* Copyright (C) 2020-2025 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -82,6 +82,8 @@ int main( int argc, char *argv[] )
8282
ze_device_handle_t pDevice = nullptr;
8383
uint32_t driverCount = 0;
8484
zel_tracer_handle_t tracer = nullptr;
85+
std::vector<ze_driver_handle_t> drivers;
86+
std::vector<ze_device_handle_t> devices_per_driver;
8587
if( init_ze(legacy_init, driverCount, driverTypeDesc) )
8688
{
8789

@@ -106,7 +108,6 @@ int main( int argc, char *argv[] )
106108
}
107109
}
108110

109-
std::vector<ze_driver_handle_t> drivers;
110111
if (legacy_init) {
111112
status = zeDriverGet(&driverCount, nullptr);
112113
if(status != ZE_RESULT_SUCCESS) {
@@ -129,96 +130,106 @@ int main( int argc, char *argv[] )
129130
}
130131
}
131132

132-
for( uint32_t driver = 0; driver < driverCount; ++driver )
133+
for( size_t driver = 0; driver < drivers.size(); ++driver )
133134
{
135+
std::cout << "Driver # " << driver << "\n";
134136
pDriver = drivers[driver];
135137
pDevice = findDevice( pDriver, type );
136-
if( pDevice )
137-
{
138-
break;
138+
if (pDevice) {
139+
devices_per_driver.push_back(pDevice);
140+
} else {
141+
devices_per_driver.push_back(nullptr);
139142
}
140143
}
141144
}
142145

143-
if( !pDevice )
146+
if( devices_per_driver.empty() || drivers.empty() )
144147
{
145148
std::cout << "Did NOT find matching " << to_string(type) <<" device!" << "\n";
146149
return -1;
147150
}
148151

152+
for (size_t driver_idx = 0; driver_idx < drivers.size(); ++driver_idx) {
153+
if (driver_idx >= devices_per_driver.size() || devices_per_driver[driver_idx] == nullptr) {
154+
std::cout << "No valid device found for Driver #" << driver_idx << std::endl;
155+
continue;
156+
}
157+
pDriver = drivers[driver_idx];
158+
pDevice = devices_per_driver[driver_idx];
159+
std::cout << "Executing on Driver #" << driver_idx << ", Device #" << 0 << std::endl;
160+
// Create the context
161+
ze_context_handle_t context;
162+
ze_context_desc_t context_desc = {};
163+
context_desc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC;
164+
status = zeContextCreate(pDriver, &context_desc, &context);
165+
if(status != ZE_RESULT_SUCCESS) {
166+
std::cout << "zeContextCreate Failed with return code: " << to_string(status) << std::endl;
167+
continue;
168+
}
149169

150-
// Create the context
151-
ze_context_handle_t context;
152-
ze_context_desc_t context_desc = {};
153-
context_desc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC;
154-
status = zeContextCreate(pDriver, &context_desc, &context);
155-
if(status != ZE_RESULT_SUCCESS) {
156-
std::cout << "zeContextCreate Failed with return code: " << to_string(status) << std::endl;
157-
exit(1);
158-
}
170+
// Create an immediate command list for direct submission
171+
ze_command_queue_desc_t altdesc = {};
172+
altdesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
173+
ze_command_list_handle_t command_list = {};
174+
status = zeCommandListCreateImmediate(context, pDevice, &altdesc, &command_list);
175+
if(status != ZE_RESULT_SUCCESS) {
176+
std::cout << "zeCommandListCreateImmediate Failed with return code: " << to_string(status) << std::endl;
177+
continue;
178+
}
159179

160-
// Create an immediate command list for direct submission
161-
ze_command_queue_desc_t altdesc = {};
162-
altdesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
163-
ze_command_list_handle_t command_list = {};
164-
status = zeCommandListCreateImmediate(context, pDevice, &altdesc, &command_list);
165-
if(status != ZE_RESULT_SUCCESS) {
166-
std::cout << "zeCommandListCreateImmediate Failed with return code: " << to_string(status) << std::endl;
167-
exit(1);
168-
}
180+
// Create an event to be signaled by the device
181+
ze_event_pool_desc_t ep_desc = {};
182+
ep_desc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
183+
ep_desc.count = 1;
184+
ep_desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE;
185+
ze_event_desc_t ev_desc = {};
186+
ev_desc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC;
187+
ev_desc.signal = ZE_EVENT_SCOPE_FLAG_HOST;
188+
ev_desc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
189+
ze_event_handle_t event;
190+
ze_event_pool_handle_t event_pool;
191+
192+
status = zeEventPoolCreate(context, &ep_desc, 1, &pDevice, &event_pool);
193+
if(status != ZE_RESULT_SUCCESS) {
194+
std::cout << "zeEventPoolCreate Failed with return code: " << to_string(status) << std::endl;
195+
continue;
196+
}
169197

170-
// Create an event to be signaled by the device
171-
ze_event_pool_desc_t ep_desc = {};
172-
ep_desc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
173-
ep_desc.count = 1;
174-
ep_desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE;
175-
ze_event_desc_t ev_desc = {};
176-
ev_desc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC;
177-
ev_desc.signal = ZE_EVENT_SCOPE_FLAG_HOST;
178-
ev_desc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
179-
ze_event_handle_t event;
180-
ze_event_pool_handle_t event_pool;
181-
182-
status = zeEventPoolCreate(context, &ep_desc, 1, &pDevice, &event_pool);
183-
if(status != ZE_RESULT_SUCCESS) {
184-
std::cout << "zeEventPoolCreate Failed with return code: " << to_string(status) << std::endl;
185-
exit(1);
186-
}
198+
status = zeEventCreate(event_pool, &ev_desc, &event);
199+
if(status != ZE_RESULT_SUCCESS) {
200+
std::cout << "zeEventCreate Failed with return code: " << to_string(status) << std::endl;
201+
continue;
202+
}
187203

188-
status = zeEventCreate(event_pool, &ev_desc, &event);
189-
if(status != ZE_RESULT_SUCCESS) {
190-
std::cout << "zeEventCreate Failed with return code: " << to_string(status) << std::endl;
191-
exit(1);
192-
}
204+
// signal the event from the device and wait for completion
205+
zeCommandListAppendSignalEvent(command_list, event);
206+
zeEventHostSynchronize(event, UINT64_MAX );
207+
std::cout << "Congratulations, Executing on Driver #" << driver_idx << ", Device #" << 0 << " completed execution!" << std::endl;
193208

194-
// signal the event from the device and wait for completion
195-
zeCommandListAppendSignalEvent(command_list, event);
196-
zeEventHostSynchronize(event, UINT64_MAX );
197-
std::cout << "Congratulations, the device completed execution!\n";
198-
199-
if (!zelCheckIsLoaderInTearDown())
200-
zeContextDestroy(context);
201-
if (!zelCheckIsLoaderInTearDown())
202-
zeCommandListDestroy(command_list);
203-
if (!zelCheckIsLoaderInTearDown())
204-
zeEventDestroy(event);
205-
if (!zelCheckIsLoaderInTearDown())
206-
zeEventPoolDestroy(event_pool);
207-
208-
if (tracing_enabled) {
209-
status = zelTracerDestroy(tracer);
210-
if(status != ZE_RESULT_SUCCESS) {
211-
std::cout << "zelTracerDestroy Failed with return code: " << to_string(status) << std::endl;
212-
exit(1);
209+
if (!zelCheckIsLoaderInTearDown())
210+
zeContextDestroy(context);
211+
if (!zelCheckIsLoaderInTearDown())
212+
zeCommandListDestroy(command_list);
213+
if (!zelCheckIsLoaderInTearDown())
214+
zeEventDestroy(event);
215+
if (!zelCheckIsLoaderInTearDown())
216+
zeEventPoolDestroy(event_pool);
217+
218+
if (tracing_enabled) {
219+
status = zelTracerDestroy(tracer);
220+
if(status != ZE_RESULT_SUCCESS) {
221+
std::cout << "zelTracerDestroy Failed with return code: " << to_string(status) << std::endl;
222+
exit(1);
223+
}
213224
}
214-
}
215225

216-
if (tracing_runtime_enabled) {
217-
std::cout << "Disable Tracing Layer after init" << std::endl;
218-
status = zelDisableTracingLayer();
219-
if(status != ZE_RESULT_SUCCESS) {
220-
std::cout << "zelDisableTracingLayer Failed with return code: " << to_string(status) << std::endl;
221-
exit(1);
226+
if (tracing_runtime_enabled) {
227+
std::cout << "Disable Tracing Layer after init" << std::endl;
228+
status = zelDisableTracingLayer();
229+
if(status != ZE_RESULT_SUCCESS) {
230+
std::cout << "zelDisableTracingLayer Failed with return code: " << to_string(status) << std::endl;
231+
exit(1);
232+
}
222233
}
223234
}
224235

scripts/generate_code.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (C) 2019-2021 Intel Corporation
2+
Copyright (C) 2019-2025 Intel Corporation
33
44
SPDX-License-Identifier: MIT
55
@@ -141,6 +141,23 @@ def _mako_loader_cpp(path, namespace, tags, version, specs, meta):
141141
filename = "%s.cpp"%(name)
142142
fout = os.path.join(path, filename)
143143

144+
print("Generating %s..."%fout)
145+
loc += util.makoWrite(
146+
fin, fout,
147+
name=name,
148+
ver=version,
149+
namespace=namespace,
150+
tags=tags,
151+
specs=specs,
152+
meta=meta)
153+
154+
template = "ldrddi_driver_ddi.cpp.mako"
155+
fin = os.path.join(templates_dir, template)
156+
157+
name = "%s_ldrddi_driver_ddi"%(namespace)
158+
filename = "%s.cpp"%(name)
159+
fout = os.path.join(path, filename)
160+
144161
print("Generating %s..."%fout)
145162
loc += util.makoWrite(
146163
fin, fout,

scripts/templates/helper.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (C) 2019-2021 Intel Corporation
2+
Copyright (C) 2019-2025 Intel Corporation
33
44
SPDX-License-Identifier: MIT
55
@@ -1702,6 +1702,45 @@ def get_class_function_objs(specs, cname, minVersion = 0, maxVersion = 9999):
17021702
objects.append(obj)
17031703
return sorted(objects, key=lambda obj: (float(obj.get('version',"1.0"))*10000) + int(obj.get('ordinal',"100")))
17041704

1705+
"""
1706+
Public:
1707+
returns the version of a function object
1708+
"""
1709+
def get_version(obj):
1710+
if obj_traits.is_function(obj):
1711+
ret_version = "ZE_API_VERSION_FORCE_UINT32"
1712+
version = obj.get('version')
1713+
if version == "1.0":
1714+
ret_version = "ZE_API_VERSION_1_0"
1715+
if version == "1.1":
1716+
ret_version = "ZE_API_VERSION_1_1"
1717+
if version == "1.2":
1718+
ret_version = "ZE_API_VERSION_1_2"
1719+
if version == "1.3":
1720+
ret_version = "ZE_API_VERSION_1_3"
1721+
if version == "1.4":
1722+
ret_version = "ZE_API_VERSION_1_4"
1723+
if version == "1.5":
1724+
ret_version = "ZE_API_VERSION_1_5"
1725+
if version == "1.6":
1726+
ret_version = "ZE_API_VERSION_1_6"
1727+
if version == "1.7":
1728+
ret_version = "ZE_API_VERSION_1_7"
1729+
if version == "1.8":
1730+
ret_version = "ZE_API_VERSION_1_8"
1731+
if version == "1.9":
1732+
ret_version = "ZE_API_VERSION_1_9"
1733+
if version == "1.10":
1734+
ret_version = "ZE_API_VERSION_1_10"
1735+
if version == "1.11":
1736+
ret_version = "ZE_API_VERSION_1_11"
1737+
if version == "1.12":
1738+
ret_version = "ZE_API_VERSION_1_12"
1739+
if version == "1.13":
1740+
ret_version = "ZE_API_VERSION_1_13"
1741+
assert(ret_version != "ZE_API_VERSION_FORCE_UINT32")
1742+
return ret_version
1743+
17051744
"""
17061745
Public:
17071746
returns a list of all non-experimental function objs and a list of experimental function objs for the specified class

0 commit comments

Comments
 (0)