Skip to content

Commit 7784378

Browse files
committed
add CUDA provider
1 parent 9f03d6b commit 7784378

30 files changed

+1455
-33
lines changed

.github/workflows/basic.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
compiler: [{c: gcc, cxx: g++}]
2323
shared_library: ['OFF']
2424
level_zero_provider: ['ON']
25+
cuda_provider: ['ON']
2526
install_tbb: ['ON']
2627
disable_hwloc: ['OFF']
2728
link_hwloc_statically: ['OFF']
@@ -31,6 +32,7 @@ jobs:
3132
compiler: {c: gcc-7, cxx: g++-7}
3233
shared_library: 'OFF'
3334
level_zero_provider: 'ON'
35+
cuda_provider: 'ON'
3436
install_tbb: 'ON'
3537
disable_hwloc: 'OFF'
3638
link_hwloc_statically: 'OFF'
@@ -39,6 +41,7 @@ jobs:
3941
compiler: {c: clang, cxx: clang++}
4042
shared_library: 'OFF'
4143
level_zero_provider: 'ON'
44+
cuda_provider: 'ON'
4245
install_tbb: 'ON'
4346
disable_hwloc: 'OFF'
4447
link_hwloc_statically: 'OFF'
@@ -47,6 +50,7 @@ jobs:
4750
compiler: {c: gcc, cxx: g++}
4851
shared_library: 'ON'
4952
level_zero_provider: 'ON'
53+
cuda_provider: 'ON'
5054
install_tbb: 'ON'
5155
disable_hwloc: 'OFF'
5256
link_hwloc_statically: 'OFF'
@@ -55,15 +59,17 @@ jobs:
5559
compiler: {c: gcc, cxx: g++}
5660
shared_library: 'ON'
5761
level_zero_provider: 'ON'
62+
cuda_provider: 'ON'
5863
install_tbb: 'ON'
5964
disable_hwloc: 'OFF'
6065
link_hwloc_statically: 'OFF'
61-
# test level_zero_provider='OFF'
66+
# test level_zero_provider='OFF' and cuda_provider='OFF'
6267
- os: 'ubuntu-22.04'
6368
build_type: Release
6469
compiler: {c: gcc, cxx: g++}
6570
shared_library: 'OFF'
6671
level_zero_provider: 'OFF'
72+
cuda_provider: 'OFF'
6773
install_tbb: 'ON'
6874
disable_hwloc: 'OFF'
6975
link_hwloc_statically: 'OFF'
@@ -73,6 +79,7 @@ jobs:
7379
compiler: {c: icx, cxx: icpx}
7480
shared_library: 'ON'
7581
level_zero_provider: 'ON'
82+
cuda_provider: 'ON'
7683
install_tbb: 'ON'
7784
disable_hwloc: 'OFF'
7885
link_hwloc_statically: 'OFF'
@@ -82,6 +89,7 @@ jobs:
8289
compiler: {c: gcc, cxx: g++}
8390
shared_library: 'ON'
8491
level_zero_provider: 'ON'
92+
cuda_provider: 'ON'
8593
install_tbb: 'OFF'
8694
disable_hwloc: 'OFF'
8795
link_hwloc_statically: 'OFF'
@@ -90,6 +98,7 @@ jobs:
9098
compiler: {c: gcc, cxx: g++}
9199
shared_library: 'ON'
92100
level_zero_provider: 'ON'
101+
cuda_provider: 'ON'
93102
install_tbb: 'ON'
94103
disable_hwloc: 'ON'
95104
link_hwloc_statically: 'OFF'
@@ -98,6 +107,7 @@ jobs:
98107
compiler: {c: gcc, cxx: g++}
99108
shared_library: 'ON'
100109
level_zero_provider: 'ON'
110+
cuda_provider: 'ON'
101111
install_tbb: 'ON'
102112
disable_hwloc: 'OFF'
103113
link_hwloc_statically: 'ON'
@@ -149,6 +159,7 @@ jobs:
149159
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
150160
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
151161
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
162+
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
152163
-DUMF_FORMAT_CODE_STYLE=OFF
153164
-DUMF_DEVELOPER_MODE=ON
154165
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
@@ -195,23 +206,27 @@ jobs:
195206
compiler: [{c: cl, cxx: cl}]
196207
shared_library: ['ON', 'OFF']
197208
level_zero_provider: ['ON']
209+
cuda_provider: ['ON']
198210
include:
199211
- os: 'windows-2022'
200212
build_type: Release
201213
compiler: {c: clang-cl, cxx: clang-cl}
202214
shared_library: 'ON'
203215
level_zero_provider: 'ON'
216+
cuda_provider: 'ON'
204217
toolset: "-T ClangCL"
205218
- os: 'windows-2022'
206219
build_type: Release
207220
compiler: {c: cl, cxx: cl}
208221
shared_library: 'ON'
209222
level_zero_provider: 'ON'
223+
cuda_provider: 'ON'
210224
- os: 'windows-2022'
211225
build_type: Release
212226
compiler: {c: cl, cxx: cl}
213227
shared_library: 'ON'
214228
level_zero_provider: 'OFF'
229+
cuda_provider: 'OFF'
215230

216231
runs-on: ${{matrix.os}}
217232

@@ -247,6 +262,7 @@ jobs:
247262
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
248263
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
249264
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
265+
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
250266
-DUMF_TESTS_FAIL_ON_SKIP=ON
251267
252268
- name: Build UMF
@@ -305,6 +321,7 @@ jobs:
305321
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
306322
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
307323
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
324+
-DUMF_BUILD_CUDA_PROVIDER=ON
308325
-DUMF_TESTS_FAIL_ON_SKIP=ON
309326
-DUMF_LINK_HWLOC_STATICALLY=ON
310327
@@ -347,6 +364,7 @@ jobs:
347364
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
348365
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
349366
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
367+
-DUMF_BUILD_CUDA_PROVIDER=ON
350368
-DUMF_TESTS_FAIL_ON_SKIP=ON
351369
-DUMF_LINK_HWLOC_STATICALLY=ON
352370

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
-DUMF_FORMAT_CODE_STYLE=OFF
6464
-DUMF_DEVELOPER_MODE=OFF
6565
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
66+
-DUMF_BUILD_CUDA_PROVIDER=ON
6667
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
6768
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
6869

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
-DUMF_DEVELOPER_MODE=ON
8585
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
8686
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
87+
-DUMF_BUILD_CUDA_PROVIDER=ON
8788
-DUMF_TESTS_FAIL_ON_SKIP=ON
8889
8990
- name: Build

.github/workflows/fast.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
-DUMF_BUILD_TESTS=${{matrix.build_tests}}
107107
-DUMF_BUILD_EXAMPLES=ON
108108
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
109+
-DUMF_BUILD_CUDA_PROVIDER=ON
109110
-DUMF_TESTS_FAIL_ON_SKIP=ON
110111
-DUMF_BUILD_SHARED_LIBRARY=ON
111112
${{matrix.extra_build_options}}

.github/workflows/gpu.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This workflow builds and tests providers using GPU memory. It requires
2-
# "level_zero" labeled self-hosted runners installed on systems with the
3-
# appropriate GPU and drivers.
2+
# appropriately labelled self-hosted runners installed on systems with the
3+
# correct GPU and drivers
4+
45
name: GPU
56

67
on: [workflow_call]
@@ -63,6 +64,7 @@ jobs:
6364
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
6465
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
6566
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
67+
-DUMF_BUILD_CUDA_PROVIDER=OFF
6668
-DUMF_TESTS_FAIL_ON_SKIP=ON
6769
6870
- name: Configure build for Ubuntu
@@ -84,9 +86,11 @@ jobs:
8486
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
8587
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
8688
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
89+
-DUMF_BUILD_CUDA_PROVIDER=OFF
8790
-DUMF_TESTS_FAIL_ON_SKIP=ON
8891
8992
- name: Build UMF
93+
if: matrix.os == 'Ubuntu'
9094
run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
9195

9296
- name: Run tests
@@ -100,3 +104,66 @@ jobs:
100104
- name: Run benchmarks
101105
working-directory: ${{env.BUILD_DIR}}
102106
run: ctest --output-on-failure --test-dir benchmark -C ${{env.BUILD_TYPE}} --exclude-regex umf-bench-multithreaded
107+
108+
gpu-CUDA:
109+
name: Build
110+
env:
111+
BUILD_TYPE: Release
112+
# run only on upstream; forks will not have the HW
113+
# if: github.repository == 'oneapi-src/unified-memory-framework'
114+
strategy:
115+
matrix:
116+
shared_library: ['ON', 'OFF']
117+
# TODO add windows
118+
os: ['Ubuntu']
119+
include:
120+
- os: 'Ubuntu'
121+
compiler: {c: gcc, cxx: g++}
122+
number_of_processors: '$(nproc)'
123+
124+
runs-on: ["DSS-CUDA", "DSS-${{matrix.os}}"]
125+
steps:
126+
- name: Checkout
127+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
128+
with:
129+
fetch-depth: 0
130+
131+
- name: Get information about platform
132+
if: matrix.os == 'Ubuntu'
133+
run: .github/scripts/get_system_info.sh
134+
135+
- name: Configure build for Ubuntu
136+
if: matrix.os == 'Ubuntu'
137+
run: >
138+
cmake -B ${{env.BUILD_DIR}}
139+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
140+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
141+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
142+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
143+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
144+
-DUMF_BUILD_BENCHMARKS=ON
145+
-DUMF_BUILD_TESTS=ON
146+
-DUMF_BUILD_GPU_TESTS=ON
147+
-DUMF_BUILD_GPU_EXAMPLES=ON
148+
-DUMF_FORMAT_CODE_STYLE=OFF
149+
-DUMF_DEVELOPER_MODE=ON
150+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
151+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
152+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
153+
-DUMF_BUILD_CUDA_PROVIDER=ON
154+
-DUMF_TESTS_FAIL_ON_SKIP=ON
155+
156+
- name: Build UMF
157+
run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
158+
159+
- name: Run tests
160+
working-directory: ${{env.BUILD_DIR}}
161+
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --test-dir test
162+
163+
- name: Run examples
164+
working-directory: ${{env.BUILD_DIR}}
165+
run: ctest --output-on-failure --test-dir examples -C ${{env.BUILD_TYPE}}
166+
167+
- name: Run benchmarks
168+
working-directory: ${{env.BUILD_DIR}}
169+
run: ctest --output-on-failure --test-dir benchmark -C ${{env.BUILD_TYPE}} --exclude-regex umf-bench-multithreaded

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
8080
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
8181
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
82+
-DUMF_BUILD_CUDA_PROVIDER=OFF
8283
-DUMF_USE_VALGRIND=1
8384
-DUMF_TESTS_FAIL_ON_SKIP=ON
8485

.github/workflows/pr_push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
-DUMF_FORMAT_CODE_STYLE=ON
3838
-DUMF_BUILD_TESTS=OFF
3939
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
40+
-DUMF_BUILD_CUDA_PROVIDER=OFF
4041
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
4142
4243
- name: Check C/C++ formatting

.github/workflows/sanitizers.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
5656
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
5757
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
58+
-DUMF_BUILD_CUDA_PROVIDER=ON
5859
-DUMF_FORMAT_CODE_STYLE=OFF
5960
-DUMF_DEVELOPER_MODE=ON
6061
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
@@ -132,6 +133,7 @@ jobs:
132133
-DUMF_USE_ASAN=${{matrix.sanitizers.asan}}
133134
-DUMF_BUILD_EXAMPLES=ON
134135
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
136+
-DUMF_BUILD_CUDA_PROVIDER=OFF
135137
-DUMF_TESTS_FAIL_ON_SKIP=ON
136138
137139
- name: Build UMF

.github/workflows/valgrind.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
3636
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
3737
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
38+
-DUMF_BUILD_CUDA_PROVIDER=OFF
3839
-DUMF_USE_VALGRIND=1
3940
-DUMF_TESTS_FAIL_ON_SKIP=ON
4041

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ find_package(PkgConfig)
3636
# Build Options
3737
option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
3838
option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON)
39+
option(UMF_BUILD_CUDA_PROVIDER "Build CUDA memory provider" ON)
3940
option(UMF_BUILD_LIBUMF_POOL_DISJOINT
4041
"Build the libumf_pool_disjoint static library" OFF)
4142
option(UMF_BUILD_LIBUMF_POOL_JEMALLOC
@@ -417,6 +418,11 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
417418
add_optional_symbol(umfLevelZeroMemoryProviderOps)
418419
endif()
419420

421+
# Conditional configuration for CUDA provider
422+
if(UMF_BUILD_CUDA_PROVIDER)
423+
add_optional_symbol(umfCUDAMemoryProviderOps)
424+
endif()
425+
420426
if(NOT UMF_DISABLE_HWLOC)
421427
add_optional_symbol(umfOsMemoryProviderOps)
422428
if(LINUX)

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ The Unified Memory Framework (UMF) is a library for constructing allocators and
1919
For a quick introduction to UMF usage, please see
2020
[examples](https://oneapi-src.github.io/unified-memory-framework/examples.html)
2121
documentation, which includes the code of the
22-
[basic example](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/basic/basic.c)
23-
and the more advanced one that allocates
24-
[USM memory from the GPU device](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/basic/gpu_shared_memory.c)
25-
using the Level Zero API and UMF Level Zero memory provider.
22+
[basic example](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/basic/basic.c).
23+
The are also more advanced that allocates USM memory from the
24+
[Level Zero device](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/level_zero_shared_memory/level_zero_shared_memory.c)
25+
using the Level Zero API and UMF Level Zero memory provider and [CUDA device](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/cuda_shared_memory/cuda_shared_memory.c)
26+
using the CUDA API and UMF CUDA memory provider.
2627

2728
## Build
2829

@@ -101,6 +102,7 @@ List of options provided by CMake:
101102
| - | - | - | - |
102103
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
103104
| UMF_BUILD_LEVEL_ZERO_PROVIDER | Build Level Zero memory provider | ON/OFF | ON |
105+
| UMF_BUILD_CUDA_PROVIDER | Build CUDA memory provider | ON/OFF | ON |
104106
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
105107
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
106108
| UMF_BUILD_TESTS | Build UMF tests | ON/OFF | ON |
@@ -188,6 +190,22 @@ with the `disable_provider_free` parameter set to true.
188190
1) Linux OS
189191
2) A character device file /dev/daxX.Y created in the OS.
190192

193+
#### CUDA memory provider
194+
195+
A memory provider that provides memory from CUDA device.
196+
197+
##### Requirements
198+
199+
1) Linux or Windows OS
200+
2) The `UMF_BUILD_CUDA_PROVIDER` option turned `ON` (by default)
201+
202+
Additionally, required for tests:
203+
204+
3) The `UMF_BUILD_GPU_TESTS` option turned `ON`
205+
4) System with CUDA compatible GPU
206+
5) Required packages:
207+
- nvidia-cuda-dev (Linux) or cuda-sdk (Windows)
208+
191209
### Memory pool managers
192210

193211
#### Proxy pool (part of libumf)

benchmark/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ function(add_umf_benchmark)
8585
target_compile_definitions(${BENCH_NAME}
8686
PRIVATE UMF_BUILD_LEVEL_ZERO_PROVIDER=1)
8787
endif()
88+
if(UMF_BUILD_CUDA_PROVIDER)
89+
target_compile_definitions(${BENCH_NAME}
90+
PRIVATE UMF_BUILD_CUDA_PROVIDER=1)
91+
endif()
8892
if(UMF_BUILD_GPU_TESTS)
8993
target_compile_definitions(${BENCH_NAME} PRIVATE UMF_BUILD_GPU_TESTS=1)
9094
endif()
@@ -103,8 +107,9 @@ endif()
103107
if(LINUX)
104108
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} m)
105109
endif()
106-
if(UMF_BUILD_GPU_TESTS)
110+
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
107111
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} ze_loader)
112+
# TODO add CUDA
108113
endif()
109114

110115
# BENCHMARKS

0 commit comments

Comments
 (0)