Skip to content

Commit 814d7fb

Browse files
committed
enable building L0 prov in CI on Linux
1 parent 317afb8 commit 814d7fb

File tree

13 files changed

+86
-33
lines changed

13 files changed

+86
-33
lines changed

.github/workflows/basic.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
pool_tracking: ['ON', 'OFF']
2222
shared_library: ['OFF']
2323
os_provider: ['ON']
24+
level_zero_provider: ['ON']
2425
runs-on: ubuntu-22.04
2526
container:
2627
image: intel/oneapi:latest
@@ -46,15 +47,15 @@ jobs:
4647
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
4748
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
4849
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
49-
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
50+
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
51+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
5052
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
5153
-DUMF_FORMAT_CODE_STYLE=OFF
5254
-DUMF_DEVELOPER_MODE=ON
5355
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
5456
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
5557
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
5658
-DUMF_BUILD_EXAMPLES=ON
57-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
5859
5960
- name: Build UMF
6061
run: cmake --build build -j $(nproc)
@@ -86,6 +87,7 @@ jobs:
8687
pool_tracking: ['ON', 'OFF']
8788
shared_library: ['OFF']
8889
os_provider: ['ON']
90+
level_zero_provider: ['ON']
8991
include:
9092
- os: 'ubuntu-20.04'
9193
build_type: Release
@@ -119,6 +121,13 @@ jobs:
119121
compiler: {c: gcc, cxx: g++}
120122
shared_library: 'OFF'
121123
os_provider: 'OFF'
124+
# test level_zero_provider='OFF'
125+
- os: 'ubuntu-22.04'
126+
build_type: Release
127+
compiler: {c: gcc, cxx: g++}
128+
shared_library: 'OFF'
129+
os_provider: 'ON'
130+
level_zero_provider: 'OFF'
122131
runs-on: ${{matrix.os}}
123132

124133
steps:
@@ -145,13 +154,13 @@ jobs:
145154
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
146155
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
147156
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
157+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
148158
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
149159
-DUMF_FORMAT_CODE_STYLE=OFF
150160
-DUMF_DEVELOPER_MODE=ON
151161
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
152162
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
153163
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
154-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
155164
156165
- name: Build UMF
157166
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -187,6 +196,7 @@ jobs:
187196
pool_tracking: ['ON', 'OFF']
188197
shared_library: ['OFF']
189198
os_provider: ['ON']
199+
# TODO add level zero provider
190200
include:
191201
- os: 'windows-2022'
192202
build_type: Release
@@ -268,8 +278,7 @@ jobs:
268278
-DCMAKE_BUILD_TYPE=Release
269279
-DUMF_FORMAT_CODE_STYLE=OFF
270280
-DUMF_DEVELOPER_MODE=ON
271-
-DUMF_ENABLE_POOL_TRACKING=ON
272-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
281+
-DUMF_ENABLE_POOL_TRACKING=ON
273282
274283
- name: Build UMF
275284
run: cmake --build ${{env.BUILD_DIR}} -j $(sysctl -n hw.logicalcpu)

.github/workflows/benchmarks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
sudo apt-get update
2727
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev
2828
29+
# TODO add GPU benchmarks
2930
- name: Configure build
3031
run: >
3132
cmake
@@ -40,11 +41,11 @@ jobs:
4041
-DUMF_FORMAT_CODE_STYLE=OFF
4142
-DUMF_DEVELOPER_MODE=OFF
4243
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
44+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
4345
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
4446
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4547
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
4648
-DUMF_ENABLE_POOL_TRACKING=OFF
47-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
4849
4950
- name: Build UMF
5051
run: cmake --build ${{github.workspace}}/build -j $(nproc)

.github/workflows/codeql.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ jobs:
7575
-DUMF_DEVELOPER_MODE=ON
7676
-DUMF_ENABLE_POOL_TRACKING=ON
7777
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=${{matrix.pool_scalable}}
78-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
7978
8079
- name: Build
8180
run: cmake --build ${{github.workspace}}/build --config Release -j

.github/workflows/coverity.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
-DUMF_FORMAT_CODE_STYLE=OFF
4242
-DUMF_DEVELOPER_MODE=OFF
4343
-DUMF_ENABLE_POOL_TRACKING=ON
44-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
4544
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
4645
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4746
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON

.github/workflows/gpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
3636
-DUMF_BUILD_BENCHMARKS=ON
3737
-DUMF_BUILD_TESTS=ON
38+
-DUMF_BUILD_GPU_TESTS=ON
3839
-DUMF_FORMAT_CODE_STYLE=ON
3940
-DUMF_DEVELOPER_MODE=ON
40-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
4141
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4242
-DUMF_ENABLE_POOL_TRACKING=ON
4343

.github/workflows/pr_push.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@ jobs:
2222
pool_scalable: 'OFF'
2323
disjoint: 'OFF'
2424
jemalloc: 'OFF'
25+
level_zero_provider: 'OFF' # TODO enable
2526
# pure C build (Windows)
2627
- os: windows-latest
2728
pool_scalable: 'OFF'
2829
disjoint: 'OFF'
2930
jemalloc: 'OFF'
3031
# Tests' building is off for a pure C build
3132
extra_build_options: '-DUMF_BUILD_TESTS=OFF'
33+
level_zero_provider: 'OFF' # TODO enable
3234
- os: ubuntu-latest
3335
pool_scalable: 'ON'
3436
disjoint: 'ON'
3537
jemalloc: 'ON'
3638
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3739
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_BENCHMARKS_MT=ON'
40+
level_zero_provider: 'ON'
3841
# pure C build (Linux)
3942
- os: ubuntu-latest
4043
pool_scalable: 'ON'
@@ -43,6 +46,7 @@ jobs:
4346
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
4447
# Tests' building is off for a pure C build
4548
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_TESTS=OFF'
49+
level_zero_provider: 'ON'
4650
runs-on: ${{matrix.os}}
4751

4852
steps:
@@ -81,7 +85,7 @@ jobs:
8185
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${{matrix.jemalloc}}
8286
-DUMF_BUILD_TESTS=ON
8387
-DUMF_BUILD_EXAMPLES=ON
84-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
88+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
8589
${{matrix.extra_build_options}}
8690
8791
- name: Build
@@ -111,7 +115,7 @@ jobs:
111115
-DUMF_FORMAT_CODE_STYLE=ON
112116
-DUMF_BUILD_OS_MEMORY_PROVIDER=OFF
113117
-DUMF_BUILD_TESTS=OFF
114-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
118+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
115119
116120
- name: Check clang-format
117121
run: cmake --build build --target clang-format-check

.github/workflows/proxy_lib.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4343
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
4444
-DUMF_ENABLE_POOL_TRACKING=ON
45-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
4645
4746
- name: Build UMF
4847
run: cmake --build ${{github.workspace}}/build -j $(nproc)

.github/workflows/sanitizers.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
4444
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
4545
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
46+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
4647
-DUMF_ENABLE_POOL_TRACKING=ON
4748
-DUMF_FORMAT_CODE_STYLE=OFF
4849
-DUMF_DEVELOPER_MODE=ON
@@ -53,7 +54,6 @@ jobs:
5354
-DUSE_UBSAN=${{matrix.sanitizers.ubsan}}
5455
-DUSE_TSAN=${{matrix.sanitizers.tsan}}
5556
-DUMF_BUILD_EXAMPLES=ON
56-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
5757
5858
- name: Build UMF
5959
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -89,6 +89,7 @@ jobs:
8989
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
9090
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
9191
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
92+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
9293
-DUMF_ENABLE_POOL_TRACKING=ON
9394
-DUMF_FORMAT_CODE_STYLE=OFF
9495
-DUMF_DEVELOPER_MODE=ON
@@ -99,7 +100,6 @@ jobs:
99100
-DUSE_UBSAN=${{matrix.sanitizers.ubsan}}
100101
-DUSE_TSAN=${{matrix.sanitizers.tsan}}
101102
-DUMF_BUILD_EXAMPLES=ON
102-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
103103
104104
- name: Build UMF
105105
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -146,6 +146,7 @@ jobs:
146146
run: vcpkg install
147147
shell: pwsh # Specifies PowerShell as the shell for running the script.
148148

149+
# TODO enable level zero provider
149150
- name: Configure build
150151
run: >
151152
cmake

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ option(UMF_BUILD_LIBUMF_POOL_DISJOINT "Build the libumf_pool_disjoint static lib
1313
option(UMF_BUILD_LIBUMF_POOL_JEMALLOC "Build the libumf_pool_jemalloc static library" OFF)
1414
option(UMF_BUILD_LIBUMF_POOL_SCALABLE "Build the libumf_pool_scalable static library" OFF)
1515
option(UMF_BUILD_TESTS "Build UMF tests" ON)
16+
option(UMF_BUILD_GPU_TESTS "Build UMF GPU tests" OFF)
1617
option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
1718
option(UMF_BUILD_BENCHMARKS_MT "Build UMF multithreaded benchmarks" OFF)
1819
option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ For development and contributions:
3434
For building tests, multithreaded benchmarks and Disjoint Pool:
3535
- C++ compiler with C++17 support
3636

37-
For Level Zero memory provider and its tests:
37+
For Level Zero memory provider tests:
3838
- Level Zero headers and libraries
3939
- compatible GPU with installed driver
4040

@@ -96,6 +96,7 @@ List of options provided by CMake:
9696
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
9797
| UMF_BUILD_LIBUMF_POOL_SCALABLE | Build the libumf_pool_scalable static library | ON/OFF | OFF |
9898
| UMF_BUILD_TESTS | Build UMF tests | ON/OFF | ON |
99+
| UMF_BUILD_GPU_TESTS | Build UMF GPU tests | ON/OFF | OFF |
99100
| UMF_BUILD_BENCHMARKS | Build UMF benchmarks | ON/OFF | OFF |
100101
| UMF_BUILD_EXAMPLES | Build UMF examples | ON/OFF | ON |
101102
| UMF_ENABLE_POOL_TRACKING | Build UMF with pool tracking | ON/OFF | ON |
@@ -138,9 +139,10 @@ A memory provider that provides memory from L0 device.
138139

139140
1) System with Level Zero compatible GPU
140141
2) Linux OS
141-
3) The `UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO` option turned `ON`
142-
4) Required packages:
143-
- level-zero-dev (TODO: check this)
142+
3) The `UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO` option turned `ON` (by default)
143+
4) Required for tests (Linux-only yet): `UMF_BUILD_GPU_TESTS` option turned `ON`
144+
4) Required packages for tests (Linux-only yet):
145+
- liblevel-zero-dev
144146

145147
### Memory pool managers
146148

src/CMakeLists.txt

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

55
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)
6+
7+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
8+
include(FetchContent)
9+
10+
set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
11+
set(LEVEL_ZERO_LOADER_TAG v1.16.1)
12+
13+
message(STATUS "Will fetch Level Zero Loader from ${LEVEL_ZERO_LOADER_REPO}")
14+
include(FetchContent)
15+
FetchContent_Declare(level-zero-loader
16+
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
17+
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
18+
EXCLUDE_FROM_ALL
19+
)
20+
if(MSVC)
21+
set(USE_Z7 ON)
22+
endif()
23+
24+
FetchContent_GetProperties(level-zero-loader)
25+
if(NOT level-zero-loader_POPULATED)
26+
FetchContent_Populate(level-zero-loader)
27+
endif()
28+
29+
set(LEVEL_ZERO_INCLUDE_DIRS
30+
${level-zero-loader_SOURCE_DIR}/include CACHE PATH "Path to Level Zero Headers")
31+
endif()
632

733
# set UMF_PROXY_LIB_BASED_ON_POOL to one of:
834
# - SCALABLE
@@ -75,18 +101,6 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER)
75101
endif()
76102
endif()
77103

78-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
79-
# Currently, Level Zero provider is only built for Linux
80-
# TODO add fetch content or PkgConfig/find_package for Level Zero
81-
set(UMF_SOURCES_LINUX ${UMF_SOURCES_LINUX}
82-
provider/provider_level_zero.c)
83-
84-
if(LINUX)
85-
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
86-
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
87-
endif()
88-
endif()
89-
90104
if(LINUX)
91105
set(UMF_SOURCES ${UMF_SOURCES} ${UMF_SOURCES_LINUX})
92106
elseif(WINDOWS)
@@ -129,12 +143,35 @@ else()
129143
target_sources(umf PRIVATE memory_pool_default.c)
130144
endif()
131145

146+
# Currently, Level Zero provider is only built for Linux
147+
if(LINUX AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
148+
149+
# WA for error ze_api.h:14234:20: no newline at end of file [-Werror,-Wnewline-eof]
150+
#set(CMAKE_C_FLAGS_BAK "${CMAKE_C_FLAGS}")
151+
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-newline-eof")
152+
153+
target_sources(umf PRIVATE
154+
provider/provider_level_zero.c)
155+
set_source_files_properties(provider/provider_level_zero.c
156+
PROPERTIES COMPILE_FLAGS -Wno-newline-eof)
157+
158+
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
159+
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
160+
161+
# restore original C flags
162+
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BAK}")
163+
endif()
164+
132165
add_library(${PROJECT_NAME}::umf ALIAS umf)
133166

134167
if(LIBHWLOC_INCLUDE_DIRS)
135168
target_include_directories(umf PRIVATE ${LIBHWLOC_INCLUDE_DIRS})
136169
endif()
137170

171+
if (LEVEL_ZERO_INCLUDE_DIRS)
172+
target_include_directories(umf PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS})
173+
endif()
174+
138175
target_include_directories(umf PUBLIC
139176
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
140177
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>

src/provider/provider_level_zero.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <stddef.h>
1313
#include <unistd.h>
1414

15-
#include <level_zero/ze_api.h>
15+
// Level Zero API
16+
#include <ze_api.h>
1617

1718
#include <umf.h>
1819
#include <umf/memory_provider_ops.h>
@@ -84,7 +85,7 @@ enum umf_result_t ze_memory_provider_initialize(void *params, void **provider) {
8485

8586
ze_provider->context = ze_params->level_zero_context_handle;
8687
ze_provider->device = ze_params->level_zero_device_handle;
87-
ze_provider->memory_type = ze_params->memory_type;
88+
ze_provider->memory_type = (ze_memory_type_t)ze_params->memory_type;
8889

8990
*provider = ze_provider;
9091

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER AND LINUX) # OS-specific functions are implement
139139
endif()
140140

141141
# TODO add support for Windows
142-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND LINUX)
142+
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER AND LINUX)
143143
# we have two test binaries here that use the same sources, but differ in
144144
# the way they are linked to the Level Zero (statically or at runtime using
145145
# dlopen)

0 commit comments

Comments
 (0)