Skip to content

Commit fe3e8c1

Browse files
committed
enable building L0 prov in CI on Linux
1 parent 91a3a74 commit fe3e8c1

File tree

13 files changed

+85
-35
lines changed

13 files changed

+85
-35
lines changed

.github/workflows/basic.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ jobs:
4646
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
4747
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
4848
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
49-
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
49+
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
50+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
5051
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
5152
-DUMF_FORMAT_CODE_STYLE=OFF
5253
-DUMF_DEVELOPER_MODE=ON
5354
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
5455
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
5556
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
5657
-DUMF_BUILD_EXAMPLES=ON
57-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
5858
5959
- name: Build UMF
6060
run: cmake --build build -j $(nproc)
@@ -86,6 +86,7 @@ jobs:
8686
pool_tracking: ['ON', 'OFF']
8787
shared_library: ['OFF']
8888
os_provider: ['ON']
89+
level_zero_provider: ['ON']
8990
include:
9091
- os: 'ubuntu-20.04'
9192
build_type: Release
@@ -119,6 +120,13 @@ jobs:
119120
compiler: {c: gcc, cxx: g++}
120121
shared_library: 'OFF'
121122
os_provider: 'OFF'
123+
# test level_zero_provider='OFF'
124+
- os: 'ubuntu-22.04'
125+
build_type: Release
126+
compiler: {c: gcc, cxx: g++}
127+
shared_library: 'OFF'
128+
os_provider: 'ON'
129+
level_zero_provider: 'OFF'
122130
runs-on: ${{matrix.os}}
123131

124132
steps:
@@ -134,7 +142,6 @@ jobs:
134142
if: matrix.compiler.cxx == 'g++-7'
135143
run: sudo apt-get install -y ${{matrix.compiler.cxx}}
136144

137-
# TODO enable building Level Zero provider in all workflows
138145
- name: Configure build
139146
run: >
140147
cmake
@@ -145,13 +152,13 @@ jobs:
145152
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
146153
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
147154
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
155+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
148156
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
149157
-DUMF_FORMAT_CODE_STYLE=OFF
150158
-DUMF_DEVELOPER_MODE=ON
151159
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
152160
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
153161
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
154-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
155162
156163
- name: Build UMF
157164
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -187,6 +194,7 @@ jobs:
187194
pool_tracking: ['ON', 'OFF']
188195
shared_library: ['OFF']
189196
os_provider: ['ON']
197+
# TODO add level zero provider
190198
include:
191199
- os: 'windows-2022'
192200
build_type: Release

.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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
- name: Install pip packages
6464
run: python3 -m pip install -r third_party/requirements.txt
6565

66+
# TODO enable Level Zero provider
6667
- name: Configure CMake
6768
run: >
6869
cmake

.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
@@ -37,9 +37,9 @@ jobs:
3737
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
3838
-DUMF_BUILD_BENCHMARKS=ON
3939
-DUMF_BUILD_TESTS=ON
40+
-DUMF_BUILD_GPU_TESTS=ON
4041
-DUMF_FORMAT_CODE_STYLE=ON
4142
-DUMF_DEVELOPER_MODE=ON
42-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
4343
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4444
-DUMF_ENABLE_POOL_TRACKING=ON
4545

.github/workflows/pr_push.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ jobs:
2121
- os: windows-latest
2222
disjoint: 'OFF'
2323
jemalloc: 'OFF'
24+
level_zero_provider: 'OFF' # TODO enable
2425
# pure C build (Windows)
2526
- os: windows-latest
2627
disjoint: 'OFF'
2728
jemalloc: 'OFF'
2829
# Tests' building is off for a pure C build
2930
extra_build_options: '-DUMF_BUILD_TESTS=OFF'
31+
level_zero_provider: 'OFF' # TODO enable
3032
- os: ubuntu-latest
3133
disjoint: 'ON'
3234
jemalloc: 'ON'
3335
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3436
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_BENCHMARKS_MT=ON'
37+
level_zero_provider: 'ON'
3538
# pure C build (Linux)
3639
- os: ubuntu-latest
3740
disjoint: 'OFF'
3841
jemalloc: 'ON'
3942
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
4043
# Tests' building is off for a pure C build
4144
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_TESTS=OFF'
45+
level_zero_provider: 'ON'
4246
runs-on: ${{matrix.os}}
4347

4448
steps:
@@ -77,7 +81,7 @@ jobs:
7781
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${{matrix.jemalloc}}
7882
-DUMF_BUILD_TESTS=ON
7983
-DUMF_BUILD_EXAMPLES=ON
80-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
84+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
8185
${{matrix.extra_build_options}}
8286
8387
- name: Build

.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: 11 additions & 7 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

@@ -91,11 +91,12 @@ List of options provided by CMake:
9191
| - | - | - | - |
9292
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
9393
| UMF_BUILD_OS_MEMORY_PROVIDER | Build OS memory provider | ON/OFF | ON |
94-
| UMF_BUILD_LEVEL_ZERO_PROVIDER | Build Level Zero memory provider | ON/OFF | OFF |
94+
| UMF_BUILD_LEVEL_ZERO_PROVIDER | Build Level Zero memory provider | ON/OFF | ON |
9595
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
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 |
@@ -137,11 +138,14 @@ A memory provider that provides memory from L0 device.
137138

138139
##### Requirements
139140

140-
1) System with Level Zero compatible GPU
141-
2) Linux OS
142-
3) The `UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO` option turned `ON`
143-
4) Required packages:
144-
- level-zero-dev (TODO: check this)
141+
1) Linux OS
142+
2) The `UMF_BUILD_LEVEL_ZERO_PROVIDER` option turned `ON` (by default)
143+
144+
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:
148+
- liblevel-zero-dev
145149

146150
### Memory pool managers
147151

src/CMakeLists.txt

Lines changed: 43 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
@@ -76,18 +102,6 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER)
76102
endif()
77103
endif()
78104

79-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
80-
# Currently, Level Zero provider is only built for Linux
81-
# TODO add fetch content or PkgConfig/find_package for Level Zero
82-
set(UMF_SOURCES_LINUX ${UMF_SOURCES_LINUX}
83-
provider/provider_level_zero.c)
84-
85-
if(LINUX)
86-
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
87-
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
88-
endif()
89-
endif()
90-
91105
if(LINUX)
92106
set(UMF_SOURCES ${UMF_SOURCES} ${UMF_SOURCES_LINUX})
93107
elseif(WINDOWS)
@@ -132,12 +146,29 @@ else()
132146
target_sources(umf PRIVATE memory_pool_default.c)
133147
endif()
134148

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

137164
if(LIBHWLOC_INCLUDE_DIRS)
138165
target_include_directories(umf PRIVATE ${LIBHWLOC_INCLUDE_DIRS})
139166
endif()
140167

168+
if (LEVEL_ZERO_INCLUDE_DIRS)
169+
target_include_directories(umf PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS})
170+
endif()
171+
141172
target_include_directories(umf PUBLIC
142173
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
143174
$<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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER AND LINUX) # OS-specific functions are implement
152152
endif()
153153

154154
# TODO add support for Windows
155-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND LINUX)
156-
# we have two test binaries here that use the same sources, but differ in
157-
# the way they are linked to the Level Zero (statically or at runtime using
155+
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER AND LINUX)
156+
# we have two test binaries here that use the same sources, but differ in
157+
# the way they are linked to the Level Zero (statically or at runtime using
158158
# dlopen)
159159
add_umf_test(NAME provider_level_zero
160160
SRCS providers/provider_level_zero.cpp

0 commit comments

Comments
 (0)