Skip to content

Commit b10c6b4

Browse files
feature: add global driver dispatch as prework for DDI handles extension support
As per DDI handles extension, global ddi table pointers will be included in every L0 handle. This change is focused on initialization of the global objects and reuse of them within zeGet...ProcAddrTable functions to avoid duplication of per component ddi table definitions Related-To: NEO-13121, NEO-13917 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 6dd948a commit b10c6b4

File tree

13 files changed

+1137
-505
lines changed

13 files changed

+1137
-505
lines changed

level_zero/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ if(BUILD_WITH_L0)
208208
endif()
209209
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/source/cmdlist${BRANCH_DIR_SUFFIX})
210210
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/source/cmdlist/cmdlist_extended${BRANCH_DIR_SUFFIX})
211-
include_directories(ddi)
212211

213212
# Create our shared library/DLL
214213
configure_file(ze_intel_gpu_version.h.in ${NEO_BUILD_DIR}/ze_intel_gpu_version.h)
@@ -343,6 +342,7 @@ if(BUILD_WITH_L0)
343342
hide_subdir(api)
344343
add_subdirectory_unique(source)
345344

345+
hide_subdir(ddi)
346346
hide_subdir(experimental)
347347
hide_subdir(include)
348348
set(L0_RELEASE_LIB_NAME "${TARGET_NAME_L0}_lib")
@@ -360,6 +360,7 @@ if(BUILD_WITH_L0)
360360
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
361361
)
362362
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/api "${NEO_BUILD_DIR}/${LIB_NAME}/api")
363+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ddi "${NEO_BUILD_DIR}/${LIB_NAME}/ddi")
363364
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core/source "${NEO_BUILD_DIR}/${LIB_NAME}/core/source")
364365
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/experimental "${NEO_BUILD_DIR}/${LIB_NAME}/experimental")
365366
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/include "${NEO_BUILD_DIR}/${LIB_NAME}/include")

level_zero/api/core/ze_core_loader.cpp

Lines changed: 215 additions & 221 deletions
Large diffs are not rendered by default.

level_zero/api/sysman/ze_sysman_loader.cpp

Lines changed: 174 additions & 182 deletions
Large diffs are not rendered by default.

level_zero/api/tools/ze_tools_loader.cpp

Lines changed: 79 additions & 85 deletions
Large diffs are not rendered by default.

level_zero/core/source/global_teardown.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "level_zero/core/source/driver/driver.h"
1313
#include "level_zero/core/source/driver/driver_handle_imp.h"
14+
#include "level_zero/ddi/ze_ddi_tables.h"
1415
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
1516

1617
namespace L0 {
@@ -19,6 +20,9 @@ decltype(&zelLoaderTranslateHandle) loaderTranslateHandleFunc = nullptr;
1920
decltype(&zelSetDriverTeardown) setDriverTeardownFunc = nullptr;
2021

2122
void globalDriverSetup() {
23+
globalDriverDispatch.core.isValidFlag = true;
24+
globalDriverDispatch.tools.isValidFlag = true;
25+
globalDriverDispatch.sysman.isValidFlag = true;
2226
if (!globalDriverHandles) {
2327
globalDriverHandles = new std::vector<_ze_driver_handle_t *>;
2428
}
@@ -64,5 +68,8 @@ void globalDriverTeardown() {
6468
delete Sysman::globalSysmanDriver;
6569
Sysman::globalSysmanDriver = nullptr;
6670
}
71+
globalDriverDispatch.core.isValidFlag = false;
72+
globalDriverDispatch.tools.isValidFlag = false;
73+
globalDriverDispatch.sysman.isValidFlag = false;
6774
}
6875
} // namespace L0

level_zero/core/test/common/ult_config_listener_l0.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@
99

1010
#include "level_zero/core/source/driver/driver.h"
1111
#include "level_zero/core/source/driver/driver_handle_imp.h"
12+
#include "level_zero/ddi/ze_ddi_tables.h"
1213
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
1314

1415
void L0::UltConfigListenerL0::OnTestStart(const ::testing::TestInfo &testInfo) {
1516
BaseUltConfigListener::OnTestStart(testInfo);
16-
17+
globalDriverDispatch.core.isValidFlag = true;
18+
globalDriverDispatch.tools.isValidFlag = true;
19+
globalDriverDispatch.sysman.isValidFlag = true;
1720
globalDriverHandles->clear();
1821
}
1922

2023
void L0::UltConfigListenerL0::OnTestEnd(const ::testing::TestInfo &testInfo) {
21-
24+
globalDriverDispatch.core.isValidFlag = false;
25+
globalDriverDispatch.tools.isValidFlag = false;
26+
globalDriverDispatch.sysman.isValidFlag = false;
2227
EXPECT_TRUE(globalDriverHandles->empty());
2328
EXPECT_EQ(nullptr, L0::Sysman::globalSysmanDriver);
2429

level_zero/core/test/unit_tests/os_interface/global_teardown_tests.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "level_zero/core/source/driver/driver_handle_imp.h"
1717
#include "level_zero/core/source/driver/driver_imp.h"
1818
#include "level_zero/core/source/global_teardown.h"
19+
#include "level_zero/ddi/ze_ddi_tables.h"
1920
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
2021

2122
namespace L0 {
@@ -191,5 +192,24 @@ TEST_F(GlobalTearDownTests, givenForkedProcessWhenGlobalTearDownFunctionCalledTh
191192
delete tempDriver;
192193
}
193194

195+
TEST_F(GlobalTearDownTests, givenGlobalDriverDispatchWhenGlobalSetupAndTeardownAreCalledThenPerApiValidFlagsAreChanged) {
196+
VariableBackup<DriverDispatch> globalDispatchBackup{&globalDriverDispatch};
197+
198+
globalDriverDispatch.core.isValidFlag = false;
199+
globalDriverDispatch.tools.isValidFlag = false;
200+
globalDriverDispatch.sysman.isValidFlag = false;
201+
202+
globalDriverSetup();
203+
204+
EXPECT_TRUE(globalDriverDispatch.core.isValidFlag);
205+
EXPECT_TRUE(globalDriverDispatch.tools.isValidFlag);
206+
EXPECT_TRUE(globalDriverDispatch.sysman.isValidFlag);
207+
208+
globalDriverTeardown();
209+
210+
EXPECT_FALSE(globalDriverDispatch.core.isValidFlag);
211+
EXPECT_FALSE(globalDriverDispatch.tools.isValidFlag);
212+
EXPECT_FALSE(globalDriverDispatch.sysman.isValidFlag);
213+
}
194214
} // namespace ult
195215
} // namespace L0

level_zero/core/test/unit_tests/sources/loader/test_loader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
#include "shared/test/common/test_macros/test.h"
99

10+
#include "level_zero/ddi/ze_ddi_tables.h"
1011
#include <level_zero/ze_api.h>
1112

12-
#include "ze_ddi_tables.h"
13-
1413
namespace L0 {
1514
namespace ult {
1615

level_zero/ddi/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (C) 2025 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
target_sources(${L0_STATIC_LIB_NAME}
8+
PRIVATE
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/ze_ddi_tables.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/ze_ddi_tables.h
12+
)
13+
14+
add_subdirectories()
15+

0 commit comments

Comments
 (0)