Skip to content

Commit d65d21b

Browse files
committed
Add gpu with L0 test on windows
1 parent fea2553 commit d65d21b

File tree

4 files changed

+53
-33
lines changed

4 files changed

+53
-33
lines changed

.github/workflows/gpu.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
# TODO: add support for tests on Windows
1312
gpu:
1413
name: Build
1514
# run only on upstream; forks will not have the HW
@@ -20,20 +19,33 @@ jobs:
2019
build_type: [Release]
2120
compiler: [{c: gcc, cxx: g++}]
2221
shared_library: ['ON', 'OFF']
23-
# TODO enable testing on DSS-WINDOWS
24-
runs-on: [ "DSS-LEVEL_ZERO", "DSS-UBUNTU" ]
22+
include:
23+
- os-labels: ["DSS-LEVEL_ZERO", "DSS-UBUNTU"]
24+
os: 'UBUNTU'
25+
compiler: [{c: gcc, cxx: g++}]
26+
cmake_toolchain_file: 'OFF'
27+
level_zero_provider: 'OFF'
28+
- os-labels: ["DSS-LEVEL_ZERO", "DSS-WINDOWS"]
29+
os: 'WINDOWS'
30+
compiler: [{c: cl, cxx: cl}]
31+
cmake_toolchain_file: "C:/Users/Administrator/repo/vpckg/scripts/buildsystems/vpckg.cmake"
32+
level_zero_provider: 'ON'
33+
34+
runs-on: ${{matrix.os}}
2535

2636
steps:
2737
- name: Checkout
2838
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2939

3040
- name: Get information about platform
41+
if: matrix.os == 'UBUNTU'
3142
run: .github/scripts/get_system_info.sh
3243

3344
- name: Configure build
3445
run: >
3546
cmake
3647
-B ${{github.workspace}}/build
48+
-DCMAKE_TOOLCHAIN_FILE=${{matrix.cmake_toolchain_file}}
3749
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
3850
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
3951
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
@@ -45,10 +57,18 @@ jobs:
4557
-DUMF_FORMAT_CODE_STYLE=ON
4658
-DUMF_DEVELOPER_MODE=ON
4759
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
60+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
61+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
4862
-DUMF_ENABLE_POOL_TRACKING=ON
49-
63+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
64+
5065
- name: Build UMF
51-
run: cmake --build ${{github.workspace}}/build -j $(nproc)
66+
run: |
67+
if [ "${{ matrix.os-name }}" = "WINDOWS" ]; then
68+
cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j $(nproc)
69+
else
70+
cmake --build ${{github.workspace}}/build -j $(nproc)
71+
fi
5272
5373
- name: Run tests
5474
working-directory: ${{github.workspace}}/build
@@ -57,4 +77,3 @@ jobs:
5777
- name: Run examples
5878
working-directory: ${{github.workspace}}/build
5979
run: ctest --output-on-failure --test-dir examples -C ${{matrix.build_type}}
60-

src/utils/utils_load_library.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ static inline int util_close_library(void *handle) {
4242
return (FreeLibrary((HMODULE)handle) == 0);
4343
}
4444

45-
static inline void *util_get_symbol_addr(void *handle, const char *symbol) {
45+
static inline void *util_get_symbol_addr(void *handle, const char *symbol, const char *dll_name) {
4646
if (handle == NULL) {
47-
// handle can't be null
48-
handle = GetModuleHandle("ze_loader.dll");
47+
if (dll_name == NULL) {
48+
return NULL;
49+
}
50+
handle = GetModuleHandle(dll_name);
4951
}
5052
return GetProcAddress((HMODULE)handle, symbol);
5153
}

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function(add_umf_test)
5858
NAME ${TEST_TARGET_NAME}
5959
SRCS ${ARG_SRCS}
6060
LIBS ${TEST_LIBS})
61-
61+
6262
target_link_directories(${TEST_TARGET_NAME} PRIVATE ${LIB_DIRS})
6363

6464
target_include_directories(

test/providers/provider_level_zero.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,63 +64,62 @@ struct umfLevelZeroProviderTest : umf_test::test {
6464
#if USE_DLOPEN
6565
void InitLevelZeroOps() {
6666
// Load Level Zero symbols
67-
// NOTE that we use RTLD_GLOBAL which add all loaded symbols to the
68-
// global symbol table. These symbols would be used by the Level Zero
69-
// provider later
7067
#ifdef _WIN32
71-
zeDlHandle = util_open_library("ze_loader.dll");
68+
const char *lib = "ze_loader.dll";
69+
zeDlHandle = util_open_library(lib);
7270
#else
73-
zeDlHandle = util_open_library("libze_loader.so");
71+
const char *lib = "ze_loader.so";
72+
zeDlHandle = util_open_library(lib);
7473
#endif
75-
*(void **)&libze_ops.zeInit = util_get_symbol_addr(zeDlHandle, "zeInit");
74+
*(void **)&libze_ops.zeInit = util_get_symbol_addr(zeDlHandle, "zeInit", lib);
7675
ASSERT_NE(libze_ops.zeInit, nullptr);
77-
*(void **)&libze_ops.zeDriverGet = util_get_symbol_addr(zeDlHandle, "zeDriverGet");
76+
*(void **)&libze_ops.zeDriverGet = util_get_symbol_addr(zeDlHandle, "zeDriverGet", lib);
7877
ASSERT_NE(libze_ops.zeDriverGet, nullptr);
79-
*(void **)&libze_ops.zeDeviceGet = util_get_symbol_addr(zeDlHandle, "zeDeviceGet");
78+
*(void **)&libze_ops.zeDeviceGet = util_get_symbol_addr(zeDlHandle, "zeDeviceGet", lib);
8079
ASSERT_NE(libze_ops.zeDeviceGet, nullptr);
8180
*(void **)&libze_ops.zeDeviceGetProperties =
82-
util_get_symbol_addr(zeDlHandle, "zeDeviceGetProperties");
81+
util_get_symbol_addr(zeDlHandle, "zeDeviceGetProperties", lib);
8382
ASSERT_NE(libze_ops.zeDeviceGetProperties, nullptr);
8483
*(void **)&libze_ops.zeContextCreate =
85-
util_get_symbol_addr(zeDlHandle, "zeContextCreate");
84+
util_get_symbol_addr(zeDlHandle, "zeContextCreate", lib);
8685
ASSERT_NE(libze_ops.zeContextCreate, nullptr);
8786
*(void **)&libze_ops.zeContextDestroy =
88-
util_get_symbol_addr(zeDlHandle, "zeContextDestroy");
87+
util_get_symbol_addr(zeDlHandle, "zeContextDestroy", lib);
8988
ASSERT_NE(libze_ops.zeContextDestroy, nullptr);
9089
*(void **)&libze_ops.zeCommandQueueCreate =
91-
util_get_symbol_addr(zeDlHandle, "zeCommandQueueCreate");
90+
util_get_symbol_addr(zeDlHandle, "zeCommandQueueCreate", lib);
9291
ASSERT_NE(libze_ops.zeCommandQueueCreate, nullptr);
9392
*(void **)&libze_ops.zeCommandQueueDestroy =
94-
util_get_symbol_addr(zeDlHandle, "zeCommandQueueDestroy");
93+
util_get_symbol_addr(zeDlHandle, "zeCommandQueueDestroy", lib);
9594
ASSERT_NE(libze_ops.zeCommandQueueDestroy, nullptr);
9695
*(void **)&libze_ops.zeCommandQueueExecuteCommandLists =
97-
util_get_symbol_addr(zeDlHandle, "zeCommandQueueExecuteCommandLists");
96+
util_get_symbol_addr(zeDlHandle, "zeCommandQueueExecuteCommandLists", lib);
9897
ASSERT_NE(libze_ops.zeCommandQueueExecuteCommandLists, nullptr);
9998
*(void **)&libze_ops.zeCommandQueueSynchronize =
100-
util_get_symbol_addr(zeDlHandle, "zeCommandQueueSynchronize");
99+
util_get_symbol_addr(zeDlHandle, "zeCommandQueueSynchronize", lib);
101100
ASSERT_NE(libze_ops.zeCommandQueueSynchronize, nullptr);
102101
*(void **)&libze_ops.zeCommandListCreate =
103-
util_get_symbol_addr(zeDlHandle, "zeCommandListCreate");
102+
util_get_symbol_addr(zeDlHandle, "zeCommandListCreate", lib);
104103
ASSERT_NE(libze_ops.zeCommandListCreate, nullptr);
105104
*(void **)&libze_ops.zeCommandListDestroy =
106-
util_get_symbol_addr(zeDlHandle, "zeCommandListDestroy");
105+
util_get_symbol_addr(zeDlHandle, "zeCommandListDestroy", lib);
107106
ASSERT_NE(libze_ops.zeCommandListDestroy, nullptr);
108107
*(void **)&libze_ops.zeCommandListClose =
109-
util_get_symbol_addr(zeDlHandle, "zeCommandListClose");
108+
util_get_symbol_addr(zeDlHandle, "zeCommandListClose", lib);
110109
ASSERT_NE(libze_ops.zeCommandListClose, nullptr);
111110
*(void **)&libze_ops.zeCommandListAppendMemoryCopy =
112-
util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryCopy");
111+
util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryCopy", lib);
113112
ASSERT_NE(libze_ops.zeCommandListAppendMemoryCopy, nullptr);
114113
*(void **)&libze_ops.zeCommandListAppendMemoryFill =
115-
util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryFill");
114+
util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryFill", lib);
116115
ASSERT_NE(libze_ops.zeCommandListAppendMemoryFill, nullptr);
117116
*(void **)&libze_ops.zeMemGetAllocProperties =
118-
util_get_symbol_addr(zeDlHandle, "zeMemGetAllocProperties");
117+
util_get_symbol_addr(zeDlHandle, "zeMemGetAllocProperties", lib);
119118
ASSERT_NE(libze_ops.zeMemGetAllocProperties, nullptr);
120119
*(void **)&libze_ops.zeMemAllocDevice =
121-
util_get_symbol_addr(zeDlHandle, "zeMemAllocDevice");
120+
util_get_symbol_addr(zeDlHandle, "zeMemAllocDevice", lib);
122121
ASSERT_NE(libze_ops.zeMemAllocDevice, nullptr);
123-
*(void **)&libze_ops.zeMemFree = util_get_symbol_addr(zeDlHandle, "zeMemFree");
122+
*(void **)&libze_ops.zeMemFree = util_get_symbol_addr(zeDlHandle, "zeMemFree", lib);
124123
ASSERT_NE(libze_ops.zeMemFree, nullptr);
125124
}
126125

0 commit comments

Comments
 (0)