Skip to content

Commit c92ab7c

Browse files
fix: expose preview L0 API functions from L0 namespace
Related-To: NEO-14560 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 0bfcd97 commit c92ab7c

File tree

3 files changed

+75
-17
lines changed

3 files changed

+75
-17
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "level_zero/ze_intel_gpu.h"
11+
12+
namespace L0 {
13+
14+
ze_context_handle_t zeDriverGetDefaultContext(ze_driver_handle_t hDriver);
15+
16+
ze_result_t zeDeviceSynchronize(ze_device_handle_t hDevice);
17+
18+
ze_result_t zeCommandListAppendLaunchKernelWithParameters(
19+
ze_command_list_handle_t hCommandList,
20+
ze_kernel_handle_t hKernel,
21+
const ze_group_count_t *pGroupCounts,
22+
const void *pNext,
23+
ze_event_handle_t hSignalEvent,
24+
uint32_t numWaitEvents,
25+
ze_event_handle_t *phWaitEvents);
26+
27+
ze_result_t zeCommandListAppendLaunchKernelWithArguments(
28+
ze_command_list_handle_t hCommandList,
29+
ze_kernel_handle_t hKernel,
30+
const ze_group_count_t groupCounts,
31+
const ze_group_size_t groupSizes,
32+
void **pArguments,
33+
const void *pNext,
34+
ze_event_handle_t hSignalEvent,
35+
uint32_t numWaitEvents,
36+
ze_event_handle_t *phWaitEvents
37+
38+
);
39+
40+
ze_result_t zerGetLastErrorDescription(const char **ppString);
41+
42+
uint32_t zerTranslateDeviceHandleToIdentifier(ze_device_handle_t device);
43+
44+
ze_device_handle_t zerTranslateIdentifierToDeviceHandle(uint32_t identifier);
45+
46+
ze_context_handle_t zerGetDefaultContext();
47+
} // namespace L0

level_zero/core/source/driver/extension_function_address.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "level_zero/core/source/driver/extension_function_address.h"
99

10+
#include "level_zero/api/core/preview_api_entrypoints.h"
1011
#include "level_zero/api/extensions/public/ze_exp_ext.h"
1112
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_ext.h"
1213
#include "level_zero/driver_experimental/zex_api.h"
@@ -27,20 +28,28 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str
2728
} \
2829
}
2930

31+
#define RETURN_L0_FUNC_PTR_IF_EXIST(name) \
32+
{ \
33+
if (functionName == #name) { \
34+
void *ret = ((void *)(L0::name)); \
35+
return ret; \
36+
} \
37+
}
38+
3039
RETURN_FUNC_PTR_IF_EXIST(zexDriverImportExternalPointer);
3140
RETURN_FUNC_PTR_IF_EXIST(zexDriverReleaseImportedPointer);
3241
RETURN_FUNC_PTR_IF_EXIST(zexDriverGetHostPointerBaseAddress);
33-
RETURN_FUNC_PTR_IF_EXIST(zeDriverGetDefaultContext);
34-
RETURN_FUNC_PTR_IF_EXIST(zerGetDefaultContext);
35-
RETURN_FUNC_PTR_IF_EXIST(zerGetLastErrorDescription);
42+
RETURN_L0_FUNC_PTR_IF_EXIST(zeDriverGetDefaultContext);
43+
RETURN_L0_FUNC_PTR_IF_EXIST(zerGetDefaultContext);
44+
RETURN_L0_FUNC_PTR_IF_EXIST(zerGetLastErrorDescription);
3645

37-
RETURN_FUNC_PTR_IF_EXIST(zerTranslateDeviceHandleToIdentifier);
38-
RETURN_FUNC_PTR_IF_EXIST(zerTranslateIdentifierToDeviceHandle);
39-
RETURN_FUNC_PTR_IF_EXIST(zeDeviceSynchronize);
46+
RETURN_L0_FUNC_PTR_IF_EXIST(zerTranslateDeviceHandleToIdentifier);
47+
RETURN_L0_FUNC_PTR_IF_EXIST(zerTranslateIdentifierToDeviceHandle);
48+
RETURN_L0_FUNC_PTR_IF_EXIST(zeDeviceSynchronize);
4049
RETURN_FUNC_PTR_IF_EXIST(zeDeviceGetPriorityLevels);
4150

42-
RETURN_FUNC_PTR_IF_EXIST(zeCommandListAppendLaunchKernelWithArguments);
43-
RETURN_FUNC_PTR_IF_EXIST(zeCommandListAppendLaunchKernelWithParameters);
51+
RETURN_L0_FUNC_PTR_IF_EXIST(zeCommandListAppendLaunchKernelWithArguments);
52+
RETURN_L0_FUNC_PTR_IF_EXIST(zeCommandListAppendLaunchKernelWithParameters);
4453

4554
RETURN_FUNC_PTR_IF_EXIST(zexKernelGetBaseAddress);
4655
RETURN_FUNC_PTR_IF_EXIST(zexKernelGetArgumentSize);
@@ -146,6 +155,7 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str
146155
RETURN_FUNC_PTR_IF_EXIST(zeGraphDumpContentsExp);
147156

148157
#undef RETURN_FUNC_PTR_IF_EXIST
158+
#undef RETURN_L0_FUNC_PTR_IF_EXIST
149159

150160
return ExtensionFunctionAddressHelper::getAdditionalExtensionFunctionAddress(functionName);
151161
}

level_zero/core/test/unit_tests/sources/driver/test_driver.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "shared/test/common/mocks/ult_device_factory.h"
3333
#include "shared/test/common/test_macros/hw_test.h"
3434

35+
#include "level_zero/api/core/preview_api_entrypoints.h"
3536
#include "level_zero/core/source/builtin/builtin_functions_lib_impl.h"
3637
#include "level_zero/core/source/driver/driver_handle_imp.h"
3738
#include "level_zero/core/source/driver/driver_imp.h"
@@ -835,7 +836,7 @@ TEST(DriverTest, givenDriverWhenGetDefaultContextApiIsCalledThenProperHandleIsRe
835836
auto driverHandle = whiteboxCast(static_cast<::L0::DriverHandleImp *>(DriverHandle::create(std::move(devices), envVariables, &returnValue)));
836837
EXPECT_NE(nullptr, driverHandle);
837838

838-
auto defaultContext = zeDriverGetDefaultContext(driverHandle);
839+
auto defaultContext = ::zeDriverGetDefaultContext(driverHandle);
839840

840841
EXPECT_NE(nullptr, defaultContext);
841842

@@ -1315,16 +1316,16 @@ TEST_F(DriverExperimentalApiTest, whenRetrievingApiFunctionThenExpectProperPoint
13151316
decltype(&zexDriverImportExternalPointer) expectedImport = zexDriverImportExternalPointer;
13161317
decltype(&zexDriverReleaseImportedPointer) expectedRelease = zexDriverReleaseImportedPointer;
13171318
decltype(&zexDriverGetHostPointerBaseAddress) expectedGet = zexDriverGetHostPointerBaseAddress;
1318-
decltype(&zeDriverGetDefaultContext) expectedZeDriverGetDefaultContext = zeDriverGetDefaultContext;
1319-
decltype(&zerGetDefaultContext) expectedZerGetDefaultContext = zerGetDefaultContext;
1320-
decltype(&zerGetLastErrorDescription) expectedZerGetLastErrorDescription = zerGetLastErrorDescription;
1319+
decltype(&zeDriverGetDefaultContext) expectedZeDriverGetDefaultContext = L0::zeDriverGetDefaultContext;
1320+
decltype(&zerGetDefaultContext) expectedZerGetDefaultContext = L0::zerGetDefaultContext;
1321+
decltype(&zerGetLastErrorDescription) expectedZerGetLastErrorDescription = L0::zerGetLastErrorDescription;
13211322

1322-
decltype(&zerTranslateDeviceHandleToIdentifier) expectedZerTranslateDeviceHandleToIdentifier = zerTranslateDeviceHandleToIdentifier;
1323-
decltype(&zerTranslateIdentifierToDeviceHandle) expectedZerTranslateIdentifierToDeviceHandle = zerTranslateIdentifierToDeviceHandle;
1324-
decltype(&zeDeviceSynchronize) expectedZeDeviceSynchronize = zeDeviceSynchronize;
1323+
decltype(&zerTranslateDeviceHandleToIdentifier) expectedZerTranslateDeviceHandleToIdentifier = L0::zerTranslateDeviceHandleToIdentifier;
1324+
decltype(&zerTranslateIdentifierToDeviceHandle) expectedZerTranslateIdentifierToDeviceHandle = L0::zerTranslateIdentifierToDeviceHandle;
1325+
decltype(&zeDeviceSynchronize) expectedZeDeviceSynchronize = L0::zeDeviceSynchronize;
13251326

1326-
decltype(&zeCommandListAppendLaunchKernelWithArguments) expectedZeCommandListAppendLaunchKernelWithArguments = zeCommandListAppendLaunchKernelWithArguments;
1327-
decltype(&zeCommandListAppendLaunchKernelWithParameters) expectedZeCommandListAppendLaunchKernelWithParameters = zeCommandListAppendLaunchKernelWithParameters;
1327+
decltype(&zeCommandListAppendLaunchKernelWithArguments) expectedZeCommandListAppendLaunchKernelWithArguments = L0::zeCommandListAppendLaunchKernelWithArguments;
1328+
decltype(&zeCommandListAppendLaunchKernelWithParameters) expectedZeCommandListAppendLaunchKernelWithParameters = L0::zeCommandListAppendLaunchKernelWithParameters;
13281329

13291330
decltype(&zexKernelGetBaseAddress) expectedKernelGetBaseAddress = zexKernelGetBaseAddress;
13301331
decltype(&zeIntelGetDriverVersionString) expectedIntelGetDriverVersionString = zeIntelGetDriverVersionString;

0 commit comments

Comments
 (0)