Skip to content

Commit 0d83bd0

Browse files
authored
Merge pull request #237 from bratpiorka/rrudnick_ze_provider
add Level Zero memory provider
2 parents ab8f1f5 + ba84ef3 commit 0d83bd0

19 files changed

+818
-2
lines changed

.github/workflows/basic.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
5555
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
5656
-DUMF_BUILD_EXAMPLES=ON
57+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
5758
5859
- name: Build UMF
5960
run: cmake --build build -j $(nproc)
@@ -133,6 +134,7 @@ jobs:
133134
if: matrix.compiler.cxx == 'g++-7'
134135
run: sudo apt-get install -y ${{matrix.compiler.cxx}}
135136

137+
# TODO enable building Level Zero provider in all workflows
136138
- name: Configure build
137139
run: >
138140
cmake
@@ -149,6 +151,7 @@ jobs:
149151
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
150152
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
151153
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
154+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
152155
153156
- name: Build UMF
154157
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -221,6 +224,7 @@ jobs:
221224
-DUMF_DEVELOPER_MODE=ON
222225
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
223226
-DUMF_BUILD_OS_MEMORY_PROVIDER=${{matrix.os_provider}}
227+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
224228
225229
- name: Build UMF
226230
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
@@ -250,7 +254,8 @@ jobs:
250254
-DCMAKE_BUILD_TYPE=Release
251255
-DUMF_FORMAT_CODE_STYLE=OFF
252256
-DUMF_DEVELOPER_MODE=ON
253-
-DUMF_ENABLE_POOL_TRACKING=ON
257+
-DUMF_ENABLE_POOL_TRACKING=ON
258+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
254259
255260
- name: Build UMF
256261
run: cmake --build ${{env.BUILD_DIR}} -j $(sysctl -n hw.logicalcpu)

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4444
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
4545
-DUMF_ENABLE_POOL_TRACKING=OFF
46+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
4647
4748
- name: Build UMF
4849
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
@@ -59,6 +59,7 @@ jobs:
5959
-DUMF_DEVELOPER_MODE=ON
6060
-DUMF_ENABLE_POOL_TRACKING=ON
6161
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=${{matrix.pool_scalable}}
62+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
6263
6364
- name: Build
6465
run: cmake --build ${{github.workspace}}/build --config Release -j

.github/workflows/gpu.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# 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.
4+
name: GPU
5+
6+
on: [workflow_call]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
# TODO: add support for Windows
13+
ubuntu-build:
14+
name: Build - Ubuntu
15+
16+
strategy:
17+
matrix:
18+
os: ['ubuntu-22.04']
19+
build_type: [Release]
20+
compiler: [{c: gcc, cxx: g++}]
21+
shared_library: ['ON', 'OFF']
22+
runs-on: level_zero
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
27+
28+
- name: Configure build
29+
run: >
30+
cmake
31+
-B ${{github.workspace}}/build
32+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
33+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
34+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
35+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
36+
-DUMF_BUILD_BENCHMARKS=ON
37+
-DUMF_BUILD_TESTS=ON
38+
-DUMF_FORMAT_CODE_STYLE=ON
39+
-DUMF_DEVELOPER_MODE=ON
40+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
41+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
42+
-DUMF_ENABLE_POOL_TRACKING=ON
43+
44+
- name: Build UMF
45+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
46+
47+
- name: Run tests
48+
working-directory: ${{github.workspace}}/build
49+
run: ctest --output-on-failure --test-dir test

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
4040
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4141
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
42+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
4243
4344
- name: Build
4445
run: cmake --build ${{github.workspace}}/build --config Debug -j$(nproc)

.github/workflows/pr_push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${{matrix.jemalloc}}
6666
-DUMF_BUILD_TESTS=ON
6767
-DUMF_BUILD_EXAMPLES=ON
68+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
6869
${{matrix.extra_build_options}}
6970
7071
- name: Build
@@ -94,6 +95,7 @@ jobs:
9495
-DUMF_FORMAT_CODE_STYLE=ON
9596
-DUMF_BUILD_OS_MEMORY_PROVIDER=OFF
9697
-DUMF_BUILD_TESTS=OFF
98+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
9799
98100
- name: Check clang-format
99101
run: cmake --build build --target clang-format-check
@@ -113,3 +115,6 @@ jobs:
113115
ProxyLib:
114116
needs: [Build]
115117
uses: ./.github/workflows/proxy_lib.yml
118+
GPU:
119+
needs: [Build]
120+
uses: ./.github/workflows/gpu.yml

.github/workflows/proxy_lib.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ 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
4546
4647
- name: Build UMF
4748
run: cmake --build ${{github.workspace}}/build -j $(nproc)

.github/workflows/sanitizers.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
-DUSE_UBSAN=${{matrix.sanitizers.ubsan}}
5454
-DUSE_TSAN=${{matrix.sanitizers.tsan}}
5555
-DUMF_BUILD_EXAMPLES=ON
56+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
5657
5758
- name: Build UMF
5859
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -98,6 +99,7 @@ jobs:
9899
-DUSE_UBSAN=${{matrix.sanitizers.ubsan}}
99100
-DUSE_TSAN=${{matrix.sanitizers.tsan}}
100101
-DUMF_BUILD_EXAMPLES=ON
102+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
101103
102104
- name: Build UMF
103105
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -145,6 +147,7 @@ jobs:
145147
-DUSE_ASAN=${{matrix.sanitizers.asan}}
146148
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
147149
-DUMF_BUILD_EXAMPLES=ON
150+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
148151
149152
- name: Build UMF
150153
run: cmake --build ${{env.BUILD_DIR}} --config Debug -j $Env:NUMBER_OF_PROCESSORS

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ project(unified-memory-framework VERSION 0.1.0 LANGUAGES C)
88
# Build Options
99
option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
1010
option(UMF_BUILD_OS_MEMORY_PROVIDER "Build OS memory provider" ON)
11+
option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON)
1112
option(UMF_BUILD_LIBUMF_POOL_DISJOINT "Build the libumf_pool_disjoint static library" OFF)
1213
option(UMF_BUILD_LIBUMF_POOL_JEMALLOC "Build the libumf_pool_jemalloc static library" OFF)
1314
option(UMF_BUILD_LIBUMF_POOL_SCALABLE "Build the libumf_pool_scalable static library" OFF)

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![SpellCheck](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/spellcheck.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/spellcheck.yml)
66
[![GitHubPages](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/docs.yml)
77
[![Benchmarks](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/benchmarks.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/benchmarks.yml)
8+
[![GPU](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/gpu.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/gpu.yml)
89
[![Nightly](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/nightly.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/nightly.yml)
910
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/unified-memory-framework/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/unified-memory-framework)
1011
[![Coverity](https://scan.coverity.com/projects/29761/badge.svg?flat=0)](https://scan.coverity.com/projects/oneapi-src-unified-memory-framework)
@@ -32,6 +33,10 @@ For development and contributions:
3233
For building tests, multithreaded benchmarks and Disjoint Pool:
3334
- C++ compiler with C++17 support
3435

36+
For Level Zero memory provider and its tests:
37+
- Level Zero headers and libraries
38+
- compatible GPU with installed driver
39+
3540
### Linux
3641

3742
Executable and binaries will be in **build/bin**
@@ -85,6 +90,7 @@ List of options provided by CMake:
8590
| - | - | - | - |
8691
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
8792
| UMF_BUILD_OS_MEMORY_PROVIDER | Build OS memory provider | ON/OFF | ON |
93+
| UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO | Build Level Zero memory provider | ON/OFF | OFF |
8894
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
8995
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
9096
| UMF_BUILD_LIBUMF_POOL_SCALABLE | Build the libumf_pool_scalable static library | ON/OFF | OFF |
@@ -124,6 +130,18 @@ A memory provider that provides memory from an operating system.
124130
4) Required packages for tests:
125131
- libnuma-dev
126132

133+
#### Level Zero memory provider (Linux-only yet)
134+
135+
A memory provider that provides memory from L0 device.
136+
137+
##### Requirements
138+
139+
1) System with Level Zero compatible GPU
140+
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)
144+
127145
### Memory pool managers
128146

129147
#### proxy_pool (part of libumf)

benchmark/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ if (UMF_BUILD_OS_MEMORY_PROVIDER)
5252
endif()
5353
endif()
5454

55+
if (UMF_BUILD_OS_MEMORY_PROVIDER)
56+
target_compile_definitions(ubench PRIVATE UMF_BUILD_OS_MEMORY_PROVIDER=1)
57+
endif()
58+
5559
if (UMF_BUILD_LIBUMF_POOL_DISJOINT)
5660
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_DISJOINT=1)
5761

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2024 Intel Corporation
3+
*
4+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#ifndef UMF_PROVIDER_LEVEL_ZERO_H
9+
#define UMF_PROVIDER_LEVEL_ZERO_H
10+
11+
#include "umf/memory_provider.h"
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
/// @brief USM memory allocation type
18+
typedef enum umf_usm_memory_type_t {
19+
UMF_MEMORY_TYPE_UNKNOWN = 0,
20+
UMF_MEMORY_TYPE_HOST,
21+
UMF_MEMORY_TYPE_DEVICE,
22+
UMF_MEMORY_TYPE_SHARED,
23+
} umf_usm_memory_type_t;
24+
25+
/// @brief Level Zero Memory Provider settings struct
26+
typedef struct level_zero_memory_provider_params_t {
27+
void *level_zero_context_handle;
28+
void *level_zero_device_handle;
29+
umf_usm_memory_type_t memory_type;
30+
uint32_t level_zero_host_mem_alloc_flags;
31+
uint32_t level_zero_device_mem_alloc_flags;
32+
uint32_t level_zero_device_local_mem_ordinal;
33+
} level_zero_memory_provider_params_t;
34+
35+
umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);
36+
37+
#ifdef __cplusplus
38+
}
39+
#endif
40+
41+
#endif /* UMF_PROVIDER_LEVEL_ZERO_H */

src/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER)
7777
endif()
7878
endif()
7979

80+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
81+
# Currently, Level Zero provider is only built for Linux
82+
# TODO add fetch content or PkgConfig/find_package for Level Zero
83+
set(UMF_SOURCES_LINUX ${UMF_SOURCES_LINUX}
84+
provider/provider_level_zero.c)
85+
86+
if(LINUX)
87+
set(UMF_COMPILE_DEFINITIONS ${UMF_COMPILE_DEFINITIONS}
88+
"UMF_BUILD_LEVEL_ZERO_PROVIDER=1")
89+
endif()
90+
endif()
91+
8092
if(LINUX)
8193
set(UMF_SOURCES ${UMF_SOURCES} ${UMF_SOURCES_LINUX})
8294
elseif(WINDOWS)

src/libumf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ UMF_1.0 {
66
global:
77
umfFree;
88
umfGetLastFailedMemoryProvider;
9+
umfLevelZeroMemoryProviderOps;
910
umfMemoryProviderAlloc;
1011
umfMemoryProviderAllocationMerge;
1112
umfMemoryProviderAllocationSplit;

src/pool/pool_scalable.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <stdbool.h>
1414
#include <stdint.h>
1515
#include <stdio.h>
16-
#include <stdlib.h>
1716
#include <string.h>
1817

1918
#include "umf/pools/pool_scalable.h"

0 commit comments

Comments
 (0)