Skip to content

Commit 15e3522

Browse files
committed
add Level Zero memory provider
1 parent f2b784a commit 15e3522

File tree

15 files changed

+458
-1
lines changed

15 files changed

+458
-1
lines changed

.github/workflows/gpu.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: GPU
2+
3+
# on: workflow_call
4+
on: [push, pull_request]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
ubuntu-build:
15+
name: Build - Ubuntu
16+
17+
strategy:
18+
matrix:
19+
os: ['ubuntu-22.04']
20+
build_type: [Release]
21+
compiler: [{c: gcc, cxx: g++}]
22+
shared_library: ['ON', 'OFF']
23+
runs-on: ${{matrix.os}}
24+
25+
steps:
26+
- name: Install apt packages
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev
30+
31+
- name: Checkout Level Zero
32+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
with:
34+
repository: oneapi-src/level-zero
35+
path: level_zero
36+
37+
- name: Build and Install Level Zero
38+
run: |
39+
cd level_zero
40+
mkdir build
41+
cd build
42+
cmake ..
43+
sudo cmake --build . --config Release --target install
44+
cd ..
45+
46+
- name: Checkout
47+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
48+
49+
- name: Configure build
50+
run: >
51+
cmake
52+
-B ${{github.workspace}}/build
53+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
54+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
55+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
56+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
57+
-DUMF_BUILD_BENCHMARKS=ON
58+
-DUMF_BUILD_TESTS=ON
59+
-DUMF_FORMAT_CODE_STYLE=ON
60+
-DUMF_DEVELOPER_MODE=ON
61+
-DUMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO=ON
62+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
63+
-DUMF_ENABLE_POOL_TRACKING=ON
64+
65+
- name: Build UMF
66+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
67+
68+
- name: Run tests
69+
working-directory: ${{github.workspace}}/build
70+
run: |
71+
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
@@ -91,3 +91,6 @@ jobs:
9191
Benchmark:
9292
needs: [Build]
9393
uses: ./.github/workflows/benchmarks.yml
94+
#GPU:
95+
# needs: [Build]
96+
# 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ List of options provided by CMake:
8484
| - | - | - | - |
8585
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
8686
| UMF_BUILD_OS_MEMORY_PROVIDER | Build OS memory provider | ON/OFF | ON |
87+
| UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO | Build Level Zero memory provider | ON/OFF | OFF |
8788
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
8889
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
8990
| UMF_BUILD_LIBUMF_POOL_SCALABLE | Build the libumf_pool_scalable static library | ON/OFF | OFF |

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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_device_mem_alloc_desc_t device_mem_alloc_desc;
24+
} level_zero_memory_provider_params_t;
25+
26+
umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);
27+
28+
#ifdef __cplusplus
29+
}
30+
#endif
31+
32+
#endif /* UMF_PROVIDER_LEVEL_ZERO_H */

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ install(TARGETS umf
103103
)
104104

105105
add_subdirectory(pool)
106+
add_subdirectory(provider)

src/libumf.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ EXPORTS
3939
umfMemoryProviderCreateFromMemspace
4040
umfMemspaceDestroy
4141
umfProxyPoolOps
42+

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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
if(UMF_BUILD_SHARED_LIBRARY)
6+
set(PROVIDER_EXTRA_SRCS ${BA_SOURCES})
7+
set(PROVIDER_COMPILE_DEFINITIONS UMF_SHARED_LIBRARY)
8+
endif()
9+
10+
# libumf_provider_level_zero
11+
if(UMF_BUILD_LIBUMF_PROVIDER_LEVEL_ZERO)
12+
add_umf_library(NAME level_zero_provider
13+
TYPE STATIC
14+
SRCS provider_level_zero.c ${PROVIDER_EXTRA_SRCS}
15+
LIBS umf_utils)
16+
target_compile_definitions(level_zero_provider PUBLIC ${PROVIDER_COMPILE_DEFINITIONS})
17+
18+
add_library(${PROJECT_NAME}::level_zero_provider ALIAS level_zero_provider)
19+
20+
add_dependencies(level_zero_provider
21+
umf)
22+
23+
target_link_libraries(level_zero_provider PRIVATE
24+
umf)
25+
26+
target_include_directories(level_zero_provider PUBLIC
27+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/umf/providers>
28+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
29+
)
30+
31+
install(TARGETS level_zero_provider
32+
EXPORT ${PROJECT_NAME}-targets
33+
)
34+
endif()

0 commit comments

Comments
 (0)