Skip to content

Commit d6d0291

Browse files
Merge pull request #297 from bratpiorka/rrudnick_L0_fetch
enable building L0 prov in CI on Linux
2 parents 0b9cabe + 930e42f commit d6d0291

File tree

13 files changed

+99
-34
lines changed

13 files changed

+99
-34
lines changed

.github/workflows/basic.yml

Lines changed: 25 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,39 +86,60 @@ 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
9293
compiler: {c: gcc-7, cxx: g++-7}
9394
shared_library: 'OFF'
9495
os_provider: 'ON'
96+
pool_tracking: 'ON'
97+
level_zero_provider: 'ON'
9598
- os: 'ubuntu-22.04'
9699
build_type: Release
97100
compiler: {c: clang, cxx: clang++}
98101
shared_library: 'OFF'
99102
os_provider: 'ON'
103+
pool_tracking: 'ON'
104+
level_zero_provider: 'ON'
100105
- os: 'ubuntu-22.04'
101106
build_type: Release
102107
compiler: {c: gcc, cxx: g++}
103108
shared_library: 'ON'
104109
os_provider: 'ON'
110+
pool_tracking: 'ON'
111+
level_zero_provider: 'ON'
105112
- os: 'ubuntu-22.04'
106113
build_type: Debug
107114
compiler: {c: gcc, cxx: g++}
108115
shared_library: 'ON'
109116
os_provider: 'ON'
117+
pool_tracking: 'ON'
118+
level_zero_provider: 'ON'
110119
# test os_provider='OFF' with shared_library='ON'
111120
- os: 'ubuntu-22.04'
112121
build_type: Release
113122
compiler: {c: gcc, cxx: g++}
114123
shared_library: 'ON'
115124
os_provider: 'OFF'
125+
pool_tracking: 'ON'
126+
level_zero_provider: 'ON'
116127
# test os_provider='OFF' with shared_library='OFF'
117128
- os: 'ubuntu-22.04'
118129
build_type: Release
119130
compiler: {c: gcc, cxx: g++}
120131
shared_library: 'OFF'
121132
os_provider: 'OFF'
133+
pool_tracking: 'ON'
134+
level_zero_provider: 'ON'
135+
# test level_zero_provider='OFF'
136+
- os: 'ubuntu-22.04'
137+
build_type: Release
138+
compiler: {c: gcc, cxx: g++}
139+
shared_library: 'OFF'
140+
os_provider: 'ON'
141+
pool_tracking: 'ON'
142+
level_zero_provider: 'OFF'
122143
runs-on: ${{matrix.os}}
123144

124145
steps:
@@ -134,7 +155,6 @@ jobs:
134155
if: matrix.compiler.cxx == 'g++-7'
135156
run: sudo apt-get install -y ${{matrix.compiler.cxx}}
136157

137-
# TODO enable building Level Zero provider in all workflows
138158
- name: Configure build
139159
run: >
140160
cmake
@@ -145,13 +165,13 @@ jobs:
145165
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
146166
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
147167
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
168+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
148169
-DUMF_ENABLE_POOL_TRACKING=${{matrix.pool_tracking}}
149170
-DUMF_FORMAT_CODE_STYLE=OFF
150171
-DUMF_DEVELOPER_MODE=ON
151172
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
152173
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
153174
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
154-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
155175
156176
- name: Build UMF
157177
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -187,6 +207,7 @@ jobs:
187207
pool_tracking: ['ON', 'OFF']
188208
shared_library: ['OFF']
189209
os_provider: ['ON']
210+
# TODO add level zero provider
190211
include:
191212
- os: 'windows-2022'
192213
build_type: Release

.github/workflows/benchmarks.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ 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-
os: ['ubuntu-latest', 'windows-latest']
17+
include:
18+
- os: ubuntu-latest
19+
level_zero_provider: 'ON'
20+
- os: windows-latest
21+
level_zero_provider: 'OFF'
22+
1823
runs-on: ${{matrix.os}}
1924

2025
steps:
@@ -57,7 +62,7 @@ jobs:
5762
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
5863
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
5964
-DUMF_ENABLE_POOL_TRACKING=OFF
60-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
65+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
6166
6267
- name: Build UMF on Linux
6368
if: matrix.os == 'ubuntu-latest'

.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
@@ -20,21 +20,25 @@ jobs:
2020
include:
2121
- os: windows-latest
2222
disjoint: 'OFF'
23+
level_zero_provider: 'OFF' # TODO enable
2324
# pure C build (Windows)
2425
- os: windows-latest
2526
disjoint: 'OFF'
2627
# Tests' building is off for a pure C build
2728
extra_build_options: '-DUMF_BUILD_TESTS=OFF'
29+
level_zero_provider: 'OFF' # TODO enable
2830
- os: ubuntu-latest
2931
disjoint: 'ON'
3032
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3133
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_BENCHMARKS_MT=ON'
34+
level_zero_provider: 'ON'
3235
# pure C build (Linux)
3336
- os: ubuntu-latest
3437
disjoint: 'OFF'
3538
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
3639
# Tests' building is off for a pure C build
3740
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_TESTS=OFF'
41+
level_zero_provider: 'ON'
3842
runs-on: ${{matrix.os}}
3943

4044
steps:
@@ -73,7 +77,7 @@ jobs:
7377
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
7478
-DUMF_BUILD_TESTS=ON
7579
-DUMF_BUILD_EXAMPLES=ON
76-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
80+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
7781
${{matrix.extra_build_options}}
7882
7983
- 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: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
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+
FetchContent_Declare(level-zero-loader
14+
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
15+
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
16+
EXCLUDE_FROM_ALL
17+
)
18+
19+
FetchContent_GetProperties(level-zero-loader)
20+
if(NOT level-zero-loader_POPULATED)
21+
FetchContent_Populate(level-zero-loader)
22+
endif()
23+
24+
set(LEVEL_ZERO_INCLUDE_DIRS ${level-zero-loader_SOURCE_DIR}/include
25+
CACHE PATH "Path to Level Zero Headers")
26+
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
27+
endif()
628

729
# set UMF_PROXY_LIB_BASED_ON_POOL to one of:
830
# - SCALABLE
@@ -76,16 +98,6 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER)
7698
endif()
7799
endif()
78100

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-
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
86-
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
87-
endif()
88-
89101
if(LINUX)
90102
set(UMF_SOURCES ${UMF_SOURCES} ${UMF_SOURCES_LINUX})
91103
elseif(WINDOWS)
@@ -130,12 +142,29 @@ else()
130142
target_sources(umf PRIVATE memory_pool_default.c)
131143
endif()
132144

145+
# Currently, Level Zero provider is only built for Linux
146+
if(LINUX AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
147+
target_sources(umf PRIVATE
148+
provider/provider_level_zero.c)
149+
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")
153+
154+
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
155+
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
156+
endif()
157+
133158
add_library(${PROJECT_NAME}::umf ALIAS umf)
134159

135160
if(LIBHWLOC_INCLUDE_DIRS)
136161
target_include_directories(umf PRIVATE ${LIBHWLOC_INCLUDE_DIRS})
137162
endif()
138163

164+
if (LEVEL_ZERO_INCLUDE_DIRS)
165+
target_include_directories(umf PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS})
166+
endif()
167+
139168
target_include_directories(umf PUBLIC
140169
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
141170
$<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

0 commit comments

Comments
 (0)