Skip to content

Commit 378a616

Browse files
committed
enable building L0 provider on Windows
1 parent e521e4b commit 378a616

File tree

9 files changed

+43
-36
lines changed

9 files changed

+43
-36
lines changed

.github/workflows/basic.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,26 +214,37 @@ jobs:
214214
pool_tracking: ['ON', 'OFF']
215215
shared_library: ['OFF']
216216
os_provider: ['ON']
217-
# TODO add level zero provider
217+
level_zero_provider: ['ON']
218218
include:
219219
- os: 'windows-2022'
220220
build_type: Release
221221
compiler: {c: clang-cl, cxx: clang-cl}
222222
pool_tracking: 'ON'
223223
os_provider: 'ON'
224+
level_zero_provider: 'ON'
224225
toolset: "-T ClangCL"
225226
- os: 'windows-2022'
226227
build_type: Release
227228
compiler: {c: cl, cxx: cl}
228229
pool_tracking: 'ON'
229230
shared_library: 'ON'
230231
os_provider: 'ON'
232+
level_zero_provider: 'ON'
231233
- os: 'windows-2022'
232234
build_type: Release
233235
compiler: {c: cl, cxx: cl}
234236
pool_tracking: 'ON'
235237
shared_library: 'ON'
236238
os_provider: 'OFF'
239+
level_zero_provider: 'ON'
240+
- os: 'windows-2022'
241+
build_type: Release
242+
compiler: {c: cl, cxx: cl}
243+
pool_tracking: 'ON'
244+
shared_library: 'ON'
245+
os_provider: 'ON'
246+
level_zero_provider: 'OFF'
247+
237248
runs-on: ${{matrix.os}}
238249

239250
steps:
@@ -267,7 +278,7 @@ jobs:
267278
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
268279
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
269280
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
270-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
281+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
271282
272283
- name: Build UMF
273284
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS

.github/workflows/benchmarks.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ jobs:
1414
VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows"
1515
strategy:
1616
matrix:
17-
include:
18-
- os: ubuntu-latest
19-
level_zero_provider: 'ON'
20-
- os: windows-latest
21-
level_zero_provider: 'OFF'
22-
17+
os: ['ubuntu-latest', 'windows-latest']
2318
runs-on: ${{matrix.os}}
2419

2520
steps:
@@ -57,12 +52,12 @@ jobs:
5752
-DUMF_BUILD_TESTS=OFF
5853
-DUMF_FORMAT_CODE_STYLE=OFF
5954
-DUMF_DEVELOPER_MODE=OFF
55+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
6056
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
6157
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
6258
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
6359
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
6460
-DUMF_ENABLE_POOL_TRACKING=OFF
65-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
6661
6762
- name: Build UMF on Linux
6863
if: matrix.os == 'ubuntu-latest'

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
-DUMF_ENABLE_POOL_TRACKING=ON
7676
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
7777
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
78-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
78+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
7979
8080
- name: Build
8181
run: cmake --build ${{github.workspace}}/build --config Release -j

.github/workflows/gpu.yml

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

1111
jobs:
12-
# TODO: add support for Windows
13-
ubuntu-build:
14-
name: Build - Ubuntu
12+
# TODO: add support for tests on Windows
13+
gpu:
14+
name: Build
1515
# run only on upstream; forks will not have the HW
1616
if: github.repository == 'oneapi-src/unified-memory-framework'
1717

@@ -20,6 +20,7 @@ jobs:
2020
build_type: [Release]
2121
compiler: [{c: gcc, cxx: g++}]
2222
shared_library: ['ON', 'OFF']
23+
# TODO enable testing on DSS-WINDOWS
2324
runs-on: [ "DSS-LEVEL_ZERO", "DSS-UBUNTU" ]
2425

2526
steps:

.github/workflows/pr_push.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,21 @@ jobs:
2020
include:
2121
- os: windows-latest
2222
disjoint: 'OFF'
23-
level_zero_provider: 'OFF' # TODO enable
2423
# pure C build (Windows)
2524
- os: windows-latest
2625
disjoint: 'OFF'
2726
# Tests' building is off for a pure C build
2827
extra_build_options: '-DUMF_BUILD_TESTS=OFF'
29-
level_zero_provider: 'OFF' # TODO enable
3028
- os: ubuntu-latest
3129
disjoint: 'ON'
3230
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3331
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_BENCHMARKS_MT=ON'
34-
level_zero_provider: 'ON'
3532
# pure C build (Linux)
3633
- os: ubuntu-latest
3734
disjoint: 'OFF'
3835
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3936
# Tests' building is off for a pure C build
4037
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_TESTS=OFF'
41-
level_zero_provider: 'ON'
4238
runs-on: ${{matrix.os}}
4339

4440
steps:
@@ -77,7 +73,7 @@ jobs:
7773
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
7874
-DUMF_BUILD_TESTS=ON
7975
-DUMF_BUILD_EXAMPLES=ON
80-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
76+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
8177
${{matrix.extra_build_options}}
8278
8379
- name: Build

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ A memory provider that provides memory from L0 device.
138138

139139
##### Requirements
140140

141-
1) Linux OS
141+
1) Linux or Windows OS
142142
2) The `UMF_BUILD_LEVEL_ZERO_PROVIDER` option turned `ON` (by default)
143143

144144
Additionally, required for tests:
145-
3) The `UMF_BUILD_GPU_TESTS` option turned `ON`
146-
4) System with Level Zero compatible GPU
147-
5) Required packages:
145+
3) Linux OS
146+
4) The `UMF_BUILD_GPU_TESTS` option turned `ON`
147+
5) System with Level Zero compatible GPU
148+
6) Required packages:
148149
- liblevel-zero-dev
149150

150151
### Memory pool managers

scripts/qemu/run-build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ cd build
2323

2424
cmake .. \
2525
-DCMAKE_BUILD_TYPE=Debug \
26+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON \
2627
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON \
2728
-DUMF_ENABLE_POOL_TRACKING=ON \
2829
-DUMF_FORMAT_CODE_STYLE=OFF \
2930
-DUMF_DEVELOPER_MODE=ON \
3031
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON \
3132
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON \
3233
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON \
33-
-DUMF_BUILD_EXAMPLES=ON \
34-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
34+
-DUMF_BUILD_EXAMPLES=ON
3535

3636
make -j $(nproc)
3737

src/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,16 @@ else()
142142
target_sources(umf PRIVATE memory_pool_default.c)
143143
endif()
144144

145-
# Currently, Level Zero provider is only built for Linux
146-
if(LINUX AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
145+
# Currently, Level Zero provider is only built for Linux and Windows
146+
if((LINUX OR WINDOWS) AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
147147
target_sources(umf PRIVATE
148148
provider/provider_level_zero.c)
149149

150-
# WA for error ze_api.h:14234:20: no newline at end of file [-Werror,-Wnewline-eof]
151-
set_source_files_properties(provider/provider_level_zero.c
152-
PROPERTIES APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-newline-eof")
150+
if(LINUX)
151+
# WA for error ze_api.h:14234:20: no newline at end of file [-Werror,-Wnewline-eof]
152+
set_source_files_properties(provider/provider_level_zero.c
153+
PROPERTIES APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-newline-eof")
154+
endif()
153155

154156
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
155157
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")

src/provider/provider_level_zero.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
*/
77

88
#include <assert.h>
9-
#include <dlfcn.h>
10-
#include <pthread.h>
119
#include <stdbool.h>
1210
#include <stddef.h>
13-
#include <unistd.h>
1411

1512
// Level Zero API
1613
#include <ze_api.h>
@@ -22,6 +19,7 @@
2219
#include "base_alloc_global.h"
2320
#include "utils_common.h"
2421
#include "utils_concurrency.h"
22+
#include "utils_load_library.h"
2523
#include "utils_sanitizers.h"
2624

2725
typedef struct ze_memory_provider_t {
@@ -51,10 +49,13 @@ static bool Init_ze_global_state_failed;
5149
static void init_ze_global_state(void) {
5250
// check if Level Zero shared library is already loaded
5351
// we pass 0 as a handle to search the global symbol table
54-
*(void **)&g_ze_ops.zeMemAllocHost = dlsym(0, "zeMemAllocHost");
55-
*(void **)&g_ze_ops.zeMemAllocDevice = dlsym(0, "zeMemAllocDevice");
56-
*(void **)&g_ze_ops.zeMemAllocShared = dlsym(0, "zeMemAllocShared");
57-
*(void **)&g_ze_ops.zeMemFree = dlsym(0, "zeMemFree");
52+
*(void **)&g_ze_ops.zeMemAllocHost =
53+
util_get_symbol_addr(0, "zeMemAllocHost");
54+
*(void **)&g_ze_ops.zeMemAllocDevice =
55+
util_get_symbol_addr(0, "zeMemAllocDevice");
56+
*(void **)&g_ze_ops.zeMemAllocShared =
57+
util_get_symbol_addr(0, "zeMemAllocShared");
58+
*(void **)&g_ze_ops.zeMemFree = util_get_symbol_addr(0, "zeMemFree");
5859

5960
if (!g_ze_ops.zeMemAllocHost || !g_ze_ops.zeMemAllocDevice ||
6061
!g_ze_ops.zeMemAllocShared || !g_ze_ops.zeMemFree) {

0 commit comments

Comments
 (0)