Skip to content

Commit e66b0bc

Browse files
committed
add Level Zero memory provider
1 parent b9cf873 commit e66b0bc

File tree

14 files changed

+732
-1
lines changed

14 files changed

+732
-1
lines changed

.github/workflows/gpu.yml

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

.github/workflows/pr_push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ jobs:
9696
Proxy_lib:
9797
needs: [Build]
9898
uses: ./.github/workflows/proxy_lib.yml
99+
GPU:
100+
needs: [Build]
101+
uses: ./.github/workflows/gpu.yml

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_LIBUMF_PROVIDER_LEVEL_ZERO "Build Level Zero memory provider" OFF)
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ For development and contributions:
3131
For building tests, multithreaded benchmarks and Disjoint Pool:
3232
- C++ compiler with C++17 support
3333

34+
For Level Zero memory provider and its tests:
35+
- Level Zero headers and libraries
36+
- compatible GPU with installed driver
37+
3438
### Linux
3539

3640
Executable and binaries will be in **build/bin**
@@ -84,6 +88,7 @@ List of options provided by CMake:
8488
| - | - | - | - |
8589
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
8690
| UMF_BUILD_OS_MEMORY_PROVIDER | Build OS memory provider | ON/OFF | ON |
91+
| UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO | Build Level Zero memory provider | ON/OFF | OFF |
8792
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
8893
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
8994
| UMF_BUILD_LIBUMF_POOL_SCALABLE | Build the libumf_pool_scalable static library | ON/OFF | OFF |
@@ -123,6 +128,18 @@ A memory provider that provides memory from an operating system.
123128
4) Required packages for tests:
124129
- libnuma-dev
125130

131+
#### Level Zero memory provider (Linux-only yet)
132+
133+
A memory provider that provides memory from a graphics device.
134+
135+
##### Requirements
136+
137+
1) System with Level Zero compatible GPU
138+
2) Linux OS
139+
3) The `UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO` option turned `ON`
140+
4) Required packages:
141+
- TODO
142+
126143
### Memory pool managers
127144

128145
#### 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_LIBUMF_PROVIDER_LEVEL_ZERO)
56+
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO=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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 <level_zero/ze_api.h>
12+
13+
#include "umf/memory_provider.h"
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
/// @brief Level Zero provider settings struct
20+
typedef struct level_zero_memory_provider_params_t {
21+
ze_context_handle_t context;
22+
ze_device_handle_t device;
23+
ze_memory_type_t memory_type;
24+
ze_host_mem_alloc_desc_t host_mem_alloc_desc;
25+
ze_device_mem_alloc_desc_t device_mem_alloc_desc;
26+
} level_zero_memory_provider_params_t;
27+
28+
umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
34+
#endif /* UMF_PROVIDER_LEVEL_ZERO_H */

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ install(TARGETS umf
115115
)
116116

117117
add_subdirectory(pool)
118+
add_subdirectory(provider)
118119

119120
# TODO: enable proxy_lib on Windows
120121
if(LINUX)

src/libumf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ UMF_1.0 {
3535
umfMemoryProviderCreateFromMemspace;
3636
umfMemspaceCreateFromNumaArray;
3737
umfMemspaceDestroy;
38+
umfLevelZeroMemoryProviderOps;
3839
local:
3940
*;
4041
};

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"

src/provider/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
# libumf_provider_level_zero
6+
if(UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO)
7+
add_umf_library(NAME level_zero_provider
8+
TYPE STATIC
9+
SRCS provider_level_zero.c ${BA_SOURCES}
10+
LIBS umf_utils)
11+
target_compile_definitions(level_zero_provider PUBLIC ${PROVIDER_COMPILE_DEFINITIONS})
12+
13+
add_library(${PROJECT_NAME}::level_zero_provider ALIAS level_zero_provider)
14+
15+
add_dependencies(level_zero_provider
16+
umf)
17+
18+
target_link_libraries(level_zero_provider PRIVATE
19+
umf)
20+
21+
target_include_directories(level_zero_provider PUBLIC
22+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/umf/providers>
23+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
24+
)
25+
26+
install(TARGETS level_zero_provider
27+
EXPORT ${PROJECT_NAME}-targets
28+
)
29+
endif()

0 commit comments

Comments
 (0)