Skip to content

Commit 69aaabe

Browse files
committed
add CUDA provider
1 parent f320b36 commit 69aaabe

27 files changed

+935
-18
lines changed

.github/workflows/basic.yml

Lines changed: 18 additions & 0 deletions
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,58 +32,67 @@ 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
- os: 'ubuntu-22.04'
3638
build_type: Release
3739
compiler: {c: clang, cxx: clang++}
3840
shared_library: 'OFF'
3941
level_zero_provider: 'ON'
42+
cuda_provider: 'ON'
4043
install_tbb: 'ON'
4144
- os: 'ubuntu-22.04'
4245
build_type: Release
4346
compiler: {c: gcc, cxx: g++}
4447
shared_library: 'ON'
4548
level_zero_provider: 'ON'
49+
cuda_provider: 'ON'
4650
install_tbb: 'ON'
4751
- os: 'ubuntu-22.04'
4852
build_type: Debug
4953
compiler: {c: gcc, cxx: g++}
5054
shared_library: 'ON'
5155
level_zero_provider: 'ON'
56+
cuda_provider: 'ON'
5257
install_tbb: 'ON'
5358
# test level_zero_provider='OFF'
5459
- os: 'ubuntu-22.04'
5560
build_type: Release
5661
compiler: {c: gcc, cxx: g++}
5762
shared_library: 'OFF'
5863
level_zero_provider: 'OFF'
64+
cuda_provider: 'OFF'
5965
install_tbb: 'ON'
6066
# test icx compiler
6167
- os: 'ubuntu-22.04'
6268
build_type: Release
6369
compiler: {c: icx, cxx: icpx}
6470
shared_library: 'ON'
6571
level_zero_provider: 'ON'
72+
cuda_provider: 'ON'
6673
install_tbb: 'ON'
6774
# test without installing TBB
6875
- os: 'ubuntu-22.04'
6976
build_type: Release
7077
compiler: {c: gcc, cxx: g++}
7178
shared_library: 'ON'
7279
level_zero_provider: 'ON'
80+
cuda_provider: 'ON'
7381
install_tbb: 'OFF'
7482
- os: 'ubuntu-22.04'
7583
build_type: Debug
7684
compiler: {c: gcc, cxx: g++}
7785
shared_library: 'ON'
7886
level_zero_provider: 'ON'
87+
cuda_provider: 'ON'
7988
install_tbb: 'ON'
8089
disable_hwloc: 'ON'
8190
- os: 'ubuntu-22.04'
8291
build_type: Release
8392
compiler: {c: gcc, cxx: g++}
8493
shared_library: 'ON'
8594
level_zero_provider: 'ON'
95+
cuda_provider: 'ON'
8696
install_tbb: 'ON'
8797
link_hwloc_statically: 'ON'
8898
runs-on: ${{matrix.os}}
@@ -133,6 +143,7 @@ jobs:
133143
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
134144
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
135145
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
146+
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
136147
-DUMF_FORMAT_CODE_STYLE=OFF
137148
-DUMF_DEVELOPER_MODE=ON
138149
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
@@ -177,23 +188,27 @@ jobs:
177188
compiler: [{c: cl, cxx: cl}]
178189
shared_library: ['ON', 'OFF']
179190
level_zero_provider: ['ON']
191+
cuda_provider: ['ON']
180192
include:
181193
- os: 'windows-2022'
182194
build_type: Release
183195
compiler: {c: clang-cl, cxx: clang-cl}
184196
shared_library: 'ON'
185197
level_zero_provider: 'ON'
198+
cuda_provider: 'ON'
186199
toolset: "-T ClangCL"
187200
- os: 'windows-2022'
188201
build_type: Release
189202
compiler: {c: cl, cxx: cl}
190203
shared_library: 'ON'
191204
level_zero_provider: 'ON'
205+
cuda_provider: 'ON'
192206
- os: 'windows-2022'
193207
build_type: Release
194208
compiler: {c: cl, cxx: cl}
195209
shared_library: 'ON'
196210
level_zero_provider: 'OFF'
211+
cuda_provider: 'OFF'
197212

198213
runs-on: ${{matrix.os}}
199214

@@ -229,6 +244,7 @@ jobs:
229244
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
230245
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
231246
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
247+
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
232248
-DUMF_TESTS_FAIL_ON_SKIP=ON
233249
234250
- name: Build UMF
@@ -287,6 +303,7 @@ jobs:
287303
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
288304
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
289305
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
306+
-DUMF_BUILD_CUDA_PROVIDER=ON
290307
-DUMF_TESTS_FAIL_ON_SKIP=ON
291308
-DUMF_LINK_HWLOC_STATICALLY=ON
292309
@@ -329,6 +346,7 @@ jobs:
329346
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
330347
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
331348
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
349+
-DUMF_BUILD_CUDA_PROVIDER=ON
332350
-DUMF_TESTS_FAIL_ON_SKIP=ON
333351
-DUMF_LINK_HWLOC_STATICALLY=ON
334352

.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: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
INSTL_DIR : "${{github.workspace}}/../install-dir"
1414

1515
jobs:
16-
gpu:
16+
gpu-L0:
1717
name: Build
1818
env:
1919
BUILD_TYPE: Release
@@ -63,6 +63,7 @@ jobs:
6363
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
6464
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
6565
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
66+
-DUMF_BUILD_CUDA_PROVIDER=OFF
6667
-DUMF_TESTS_FAIL_ON_SKIP=ON
6768
6869
- name: Configure build for Ubuntu
@@ -84,6 +85,71 @@ jobs:
8485
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
8586
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
8687
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
88+
-DUMF_BUILD_CUDA_PROVIDER=OFF
89+
-DUMF_TESTS_FAIL_ON_SKIP=ON
90+
91+
- name: Build UMF
92+
run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
93+
94+
- name: Run tests
95+
working-directory: ${{env.BUILD_DIR}}
96+
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --test-dir test
97+
98+
- name: Run examples
99+
working-directory: ${{env.BUILD_DIR}}
100+
run: ctest --output-on-failure --test-dir examples -C ${{env.BUILD_TYPE}}
101+
102+
- name: Run benchmarks
103+
working-directory: ${{env.BUILD_DIR}}
104+
run: ctest --output-on-failure --test-dir benchmark -C ${{env.BUILD_TYPE}} --exclude-regex umf-bench-multithreaded
105+
106+
gpu-CUDA:
107+
name: Build
108+
env:
109+
BUILD_TYPE: Release
110+
# run only on upstream; forks will not have the HW
111+
if: github.repository == 'oneapi-src/unified-memory-framework'
112+
strategy:
113+
matrix:
114+
shared_library: ['ON', 'OFF']
115+
# TODO add windows
116+
os: ['Ubuntu']
117+
include:
118+
- os: 'Ubuntu'
119+
compiler: {c: gcc, cxx: g++}
120+
number_of_processors: '$(nproc)'
121+
122+
runs-on: ["DSS-CUDA", "DSS-${{matrix.os}}"]
123+
steps:
124+
- name: Checkout
125+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
126+
with:
127+
fetch-depth: 0
128+
129+
- name: Get information about platform
130+
if: matrix.os == 'Ubuntu'
131+
run: .github/scripts/get_system_info.sh
132+
133+
- name: Configure build for Ubuntu
134+
if: matrix.os == 'Ubuntu'
135+
run: >
136+
cmake
137+
-B ${{env.BUILD_DIR}}
138+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
139+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
140+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
141+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
142+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
143+
-DUMF_BUILD_BENCHMARKS=ON
144+
-DUMF_BUILD_TESTS=ON
145+
-DUMF_BUILD_GPU_TESTS=ON
146+
-DUMF_BUILD_GPU_EXAMPLES=ON
147+
-DUMF_FORMAT_CODE_STYLE=OFF
148+
-DUMF_DEVELOPER_MODE=ON
149+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
150+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
151+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
152+
-DUMF_BUILD_CUDA_PROVIDER=ON
87153
-DUMF_TESTS_FAIL_ON_SKIP=ON
88154
89155
- name: Build UMF

.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
@@ -130,6 +131,7 @@ jobs:
130131
-DUMF_USE_ASAN=${{matrix.sanitizers.asan}}
131132
-DUMF_BUILD_EXAMPLES=ON
132133
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
134+
-DUMF_BUILD_CUDA_PROVIDER=OFF
133135
-DUMF_TESTS_FAIL_ON_SKIP=ON
134136
135137
- 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
@@ -399,6 +400,11 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
399400
add_optional_symbol(umfLevelZeroMemoryProviderOps)
400401
endif()
401402

403+
# Conditional configuration for CUDA provider
404+
if(UMF_BUILD_CUDA_PROVIDER)
405+
add_optional_symbol(umfCUDAMemoryProviderOps)
406+
endif()
407+
402408
if(NOT UMF_DISABLE_HWLOC)
403409
add_optional_symbol(umfOsMemoryProviderOps)
404410
endif()

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ For a quick introduction to UMF usage, please see
2121
documentation, which includes the code of the
2222
[basic example](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/basic/basic.c)
2323
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)
24+
[USM memory from the Level Zero device](https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/level_zero_shared_memory/level_zero_shared_memory.c)
2525
using the Level Zero API and UMF Level Zero memory provider.
2626

2727
## Build
@@ -101,6 +101,7 @@ List of options provided by CMake:
101101
| - | - | - | - |
102102
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
103103
| UMF_BUILD_LEVEL_ZERO_PROVIDER | Build Level Zero memory provider | ON/OFF | ON |
104+
| UMF_BUILD_CUDA_PROVIDER | Build CUDA memory provider | ON/OFF | ON |
104105
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
105106
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
106107
| UMF_BUILD_TESTS | Build UMF tests | ON/OFF | ON |
@@ -172,6 +173,22 @@ Additionally, required for tests:
172173
5) Required packages:
173174
- liblevel-zero-dev (Linux) or level-zero-sdk (Windows)
174175

176+
#### CUDA memory provider
177+
178+
A memory provider that provides memory from CUDA device.
179+
180+
##### Requirements
181+
182+
1) Linux or Windows OS
183+
2) The `UMF_BUILD_CUDA_PROVIDER` option turned `ON` (by default)
184+
185+
Additionally, required for tests:
186+
187+
3) The `UMF_BUILD_GPU_TESTS` option turned `ON`
188+
4) System with CUDA compatible GPU
189+
5) Required packages:
190+
- nvidia-cuda-dev (Linux) or cuda-sdk (Windows)
191+
175192
### Memory pool managers
176193

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

benchmark/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
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()

benchmark/ubench.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ UBENCH_EX(ipc, disjoint_pool_with_level_zero_provider) {
505505
}
506506
#endif /* (defined UMF_BUILD_LIBUMF_POOL_DISJOINT && defined UMF_BUILD_LEVEL_ZERO_PROVIDER && defined UMF_BUILD_GPU_TESTS) */
507507

508+
// TODO add IPC benchmark for CUDA
509+
508510
UBENCH_MAIN()
509511

510512
#if defined(_MSC_VER)

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ if(UMF_POOL_SCALABLE_ENABLED)
4141
endif()
4242
endif()
4343

44+
# TODO add CUDA examples
45+
4446
if(UMF_BUILD_GPU_EXAMPLES
4547
AND UMF_BUILD_LIBUMF_POOL_DISJOINT
4648
AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
47-
set(EXAMPLE_NAME umf_example_gpu_shared_memory)
49+
set(EXAMPLE_NAME umf_example_level_zero_shared_memory)
4850

4951
add_umf_executable(
5052
NAME ${EXAMPLE_NAME}
51-
SRCS gpu_shared_memory/gpu_shared_memory.c
53+
SRCS level_zero_shared_memory/level_zero_shared_memory.c
5254
LIBS disjoint_pool ze_loader umf)
5355

5456
target_include_directories(

0 commit comments

Comments
 (0)