Skip to content

Commit 8717302

Browse files
authored
Merge pull request #671 from ldorau/Add_devdax_memory_provider
Add devdax memory provider
2 parents 2e4ca6f + 7654d79 commit 8717302

23 files changed

+1362
-6
lines changed

.github/workflows/devdax.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow builds and tests the devdax memory provider.
2+
# It requires a DAX device (e.g. /dev/dax0.0) configured in the OS.
3+
# This DAX device should be specified using UMF_TESTS_DEVDAX_PATH and UMF_TESTS_DEVDAX_SIZE
4+
# CI environment variables.
5+
6+
name: DevDax
7+
8+
on: [workflow_call]
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
UMF_TESTS_DEVDAX_PATH : "/dev/dax0.0"
15+
UMF_TESTS_DEVDAX_SIZE : 1054867456
16+
BUILD_DIR : "${{github.workspace}}/build"
17+
INSTL_DIR : "${{github.workspace}}/../install-dir"
18+
19+
jobs:
20+
devdax:
21+
name: Build
22+
# run only on upstream; forks may not have a DAX device
23+
if: github.repository == 'oneapi-src/unified-memory-framework'
24+
strategy:
25+
matrix:
26+
build_type: [Debug, Release]
27+
shared_library: ['ON', 'OFF']
28+
29+
runs-on: ["DSS-DEVDAX", "DSS-Ubuntu"]
30+
steps:
31+
- name: Check if the devdax exists
32+
run: |
33+
ndctl list -N --device-dax
34+
ls -al ${{env.UMF_TESTS_DEVDAX_PATH}}
35+
36+
- name: Checkout
37+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Configure build
42+
run: >
43+
cmake
44+
-B ${{env.BUILD_DIR}}
45+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
46+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
47+
-DCMAKE_C_COMPILER=gcc
48+
-DCMAKE_CXX_COMPILER=g++
49+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
50+
-DUMF_BUILD_BENCHMARKS=OFF
51+
-DUMF_BUILD_TESTS=ON
52+
-DUMF_BUILD_GPU_TESTS=OFF
53+
-DUMF_BUILD_GPU_EXAMPLES=OFF
54+
-DUMF_FORMAT_CODE_STYLE=OFF
55+
-DUMF_DEVELOPER_MODE=ON
56+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
57+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
58+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
59+
-DUMF_TESTS_FAIL_ON_SKIP=ON
60+
61+
- name: Build UMF
62+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $(nproc)
63+
64+
- name: Run only devdax tests
65+
working-directory: ${{env.BUILD_DIR}}
66+
run: ctest -C ${{matrix.build_type}} -R devdax -V

.github/workflows/pr_push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ jobs:
8585
name: Basic builds
8686
needs: [FastBuild]
8787
uses: ./.github/workflows/basic.yml
88+
DevDax:
89+
needs: [FastBuild]
90+
uses: ./.github/workflows/devdax.yml
8891
Sanitizers:
8992
needs: [FastBuild]
9093
uses: ./.github/workflows/sanitizers.yml

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ endif()
419419

420420
if(NOT UMF_DISABLE_HWLOC)
421421
add_optional_symbol(umfOsMemoryProviderOps)
422+
if(LINUX)
423+
add_optional_symbol(umfDevDaxMemoryProviderOps)
424+
endif()
422425
endif()
423426

424427
add_subdirectory(src)

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ Additionally, required for tests:
172172
5) Required packages:
173173
- liblevel-zero-dev (Linux) or level-zero-sdk (Windows)
174174

175+
#### DevDax memory provider (Linux only)
176+
177+
A memory provider that provides memory from a device DAX (a character device file /dev/daxX.Y).
178+
It can be used when large memory mappings are needed.
179+
180+
The DevDax memory provider does not support the free operation
181+
(`umfMemoryProviderFree()` always returns `UMF_RESULT_ERROR_NOT_SUPPORTED`),
182+
so it should be used with a pool manager that will take over
183+
the managing of the provided memory - for example the jemalloc pool
184+
with the `disable_provider_free` parameter set to true.
185+
186+
##### Requirements
187+
188+
1) Linux OS
189+
2) A character device file /dev/daxX.Y created in the OS.
190+
175191
### Memory pool managers
176192

177193
#### Proxy pool (part of libumf)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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_DEVDAX_MEMORY_PROVIDER_H
9+
#define UMF_DEVDAX_MEMORY_PROVIDER_H
10+
11+
#include <umf/providers/provider_os_memory.h>
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
/// @cond
18+
#define UMF_DEVDAX_RESULTS_START_FROM 2000
19+
/// @endcond
20+
21+
/// @brief Memory provider settings struct
22+
typedef struct umf_devdax_memory_provider_params_t {
23+
/// path of the device DAX
24+
char *path;
25+
/// size of the device DAX in bytes
26+
size_t size;
27+
/// combination of 'umf_mem_protection_flags_t' flags
28+
unsigned protection;
29+
} umf_devdax_memory_provider_params_t;
30+
31+
/// @brief Devdax Memory Provider operation results
32+
typedef enum umf_devdax_memory_provider_native_error {
33+
UMF_DEVDAX_RESULT_SUCCESS = UMF_DEVDAX_RESULTS_START_FROM, ///< Success
34+
UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED, ///< Memory allocation failed
35+
UMF_DEVDAX_RESULT_ERROR_ADDRESS_NOT_ALIGNED, ///< Allocated address is not aligned
36+
UMF_DEVDAX_RESULT_ERROR_FREE_FAILED, ///< Memory deallocation failed
37+
UMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
38+
} umf_devdax_memory_provider_native_error_t;
39+
40+
umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void);
41+
42+
/// @brief Create default params for the devdax memory provider
43+
static inline umf_devdax_memory_provider_params_t
44+
umfDevDaxMemoryProviderParamsDefault(char *path, size_t size) {
45+
umf_devdax_memory_provider_params_t params = {
46+
path, /* path of the device DAX */
47+
size, /* size of the device DAX in bytes */
48+
UMF_PROTECTION_READ | UMF_PROTECTION_WRITE, /* protection */
49+
};
50+
51+
return params;
52+
}
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif /* UMF_DEVDAX_MEMORY_PROVIDER_H */

scripts/docs_config/api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ A memory provider that provides memory from L0 device.
9696
.. doxygenfile:: provider_level_zero.h
9797
:sections: define enum typedef func var
9898

99+
DevDax Memory Provider
100+
------------------------------------------
101+
102+
A memory provider that provides memory from a device DAX (a character device file /dev/daxX.Y).
103+
104+
.. doxygenfile:: provider_devdax_memory.h
105+
:sections: define enum typedef func var
106+
99107
Memspace
100108
==========================================
101109

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ set(UMF_SOURCES_MACOSX libumf_linux.c)
101101
set(UMF_SOURCES_WINDOWS libumf_windows.c)
102102

103103
set(UMF_SOURCES_COMMON_LINUX_MACOSX
104+
provider/provider_devdax_memory.c
104105
provider/provider_os_memory.c
105106
provider/provider_os_memory_posix.c
106107
memtargets/memtarget_numa.c

0 commit comments

Comments
 (0)