Skip to content

Commit f73df63

Browse files
committed
Add backward compatibility workflow and tests
1 parent 660f1f4 commit f73df63

39 files changed

+708
-80
lines changed

.github/workflows/pr_push.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ jobs:
8585
contents: read
8686
security-events: write
8787
uses: ./.github/workflows/reusable_trivy.yml
88+
Compatibility:
89+
needs: [Build]
90+
uses: ./.github/workflows/reusable_compatibility.yml
91+
strategy:
92+
matrix:
93+
tag: ["v0.10.1"]
94+
with:
95+
tag: ${{matrix.tag}}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Workflow for checkig the backward compatibility of UMF.
2+
# Test the latest UMF shared library with binaries compiled using the older UMF
3+
# shared library.
4+
name: Compatibility
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
tag:
10+
description: Check backward compatibility with this tag
11+
type: string
12+
default: "v0.10.1"
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
ubuntu-build:
19+
# TODO add other OSes
20+
name: Ubuntu
21+
runs-on: 'ubuntu-22.04'
22+
23+
steps:
24+
# NOTE: we need jemalloc for older version of UMF
25+
- name: Install apt packages
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev libtbb-dev
29+
30+
- name: Checkout "tag" UMF version
31+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
32+
with:
33+
fetch-depth: 0
34+
ref: refs/tags/${{inputs.tag}}
35+
path: ${{github.workspace}}/tag_version
36+
37+
- name: Install libhwloc
38+
working-directory: ${{github.workspace}}/tag_version
39+
run: .github/scripts/install_hwloc.sh
40+
41+
- name: Get "tag" UMF version
42+
working-directory: ${{github.workspace}}/tag_version
43+
run: |
44+
VERSION=$(git describe --tags --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
45+
echo "tag version: $VERSION"
46+
47+
- name: Configure "tag" UMF build
48+
working-directory: ${{github.workspace}}/tag_version
49+
run: >
50+
cmake
51+
-B ${{github.workspace}}/tag_version/build
52+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/tag_version/build/install"
53+
-DCMAKE_BUILD_TYPE=Debug
54+
-DUMF_BUILD_SHARED_LIBRARY=ON
55+
-DCMAKE_C_COMPILER=gcc
56+
-DCMAKE_CXX_COMPILER=g++
57+
-DUMF_BUILD_TESTS=ON
58+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
59+
-DUMF_BUILD_CUDA_PROVIDER=ON
60+
-DUMF_FORMAT_CODE_STYLE=OFF
61+
-DUMF_DEVELOPER_MODE=ON
62+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
63+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
64+
-DUMF_TESTS_FAIL_ON_SKIP=ON
65+
66+
- name: Build "tag" UMF
67+
working-directory: ${{github.workspace}}/tag_version
68+
run: |
69+
cmake --build ${{github.workspace}}/tag_version/build -j $(nproc)
70+
71+
# For UMF < 0.11 set ptrace_scope
72+
- name: Set ptrace value for IPC test
73+
if: ${{ startsWith(inputs.tag, 'v0.10.') || startsWith(inputs.tag, 'v0.9.') }}
74+
run: sudo bash -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope"
75+
76+
- name: Run "tag" UMF tests
77+
working-directory: ${{github.workspace}}/tag_version/build
78+
run: |
79+
LD_LIBRARY_PATH=${{github.workspace}}/tag_version/build/lib/ ctest --output-on-failure
80+
81+
- name: Checkout latest UMF version
82+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
83+
with:
84+
fetch-depth: 0
85+
path: ${{github.workspace}}/latest_version
86+
87+
- name: Get latest UMF version
88+
working-directory: ${{github.workspace}}/latest_version
89+
run: |
90+
VERSION=$(git describe --tags --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
91+
echo "checked version: $VERSION"
92+
93+
- name: Configure latest UMF build
94+
working-directory: ${{github.workspace}}/latest_version
95+
run: >
96+
cmake
97+
-B ${{github.workspace}}/latest_version/build
98+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/latest_version/build/install"
99+
-DCMAKE_BUILD_TYPE=Debug
100+
-DUMF_BUILD_SHARED_LIBRARY=ON
101+
-DCMAKE_C_COMPILER=gcc
102+
-DCMAKE_CXX_COMPILER=g++
103+
-DUMF_BUILD_TESTS=ON
104+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
105+
-DUMF_BUILD_CUDA_PROVIDER=ON
106+
-DUMF_FORMAT_CODE_STYLE=OFF
107+
-DUMF_DEVELOPER_MODE=ON
108+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
109+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
110+
-DUMF_TESTS_FAIL_ON_SKIP=ON
111+
112+
- name: Build latest UMF
113+
working-directory: ${{github.workspace}}/latest_version
114+
run: |
115+
cmake --build ${{github.workspace}}/latest_version/build -j $(nproc)
116+
117+
# NOTE: exclude umf-provider_coarse, umf-disjointCoarseMallocPool,
118+
# umf-jemalloc_coarse_file, umf-scalable_coarse_file as they use Coarse
119+
# Provider which is not supported for UMF > 0.10.0
120+
- name: Run "tag" UMF tests with latest UMF libs (warnings enabled)
121+
working-directory: ${{github.workspace}}/tag_version/build
122+
run: >
123+
UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
124+
LD_LIBRARY_PATH=${{github.workspace}}/latest_version/build/lib/
125+
ctest --output-on-failure -E "umf-provider_coarse|umf-disjointCoarseMallocPool|umf-jemalloc_coarse_file|umf-scalable_coarse_file"

examples/custom_file_provider/custom_file_provider.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2024-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -234,7 +234,7 @@ static umf_result_t file_get_min_page_size(void *provider, void *ptr,
234234

235235
// File provider operations
236236
static umf_memory_provider_ops_t file_ops = {
237-
.version = UMF_VERSION_CURRENT,
237+
.version = UMF_PROVIDER_OPS_VERSION_CURRENT,
238238
.initialize = file_init,
239239
.finalize = file_deinit,
240240
.alloc = file_alloc,

include/umf/memory_pool.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define UMF_MEMORY_POOL_H 1
1212

1313
#include <umf/base.h>
14+
#include <umf/memory_pool_ops.h>
1415
#include <umf/memory_provider.h>
1516

1617
#ifdef __cplusplus
@@ -22,12 +23,6 @@ extern "C" {
2223
/// functions
2324
typedef struct umf_memory_pool_t *umf_memory_pool_handle_t;
2425

25-
/// @brief This structure comprises function pointers used by corresponding umfPool*
26-
/// calls. Each memory pool implementation should initialize all function
27-
/// pointers.
28-
///
29-
typedef struct umf_memory_pool_ops_t umf_memory_pool_ops_t;
30-
3126
/// @brief Supported pool creation flags
3227
typedef enum umf_pool_create_flag_t {
3328
UMF_POOL_CREATE_FLAG_NONE =

include/umf/memory_pool_ops.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717
extern "C" {
1818
#endif
1919

20+
/// @brief Version of the Memory Pool ops structure.
21+
/// NOTE: This is equal to the latest UMF version, in which the ops structure
22+
/// has been modified.
23+
#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
24+
2025
///
2126
/// @brief This structure comprises function pointers used by corresponding umfPool*
2227
/// calls. Each memory pool implementation should initialize all function
2328
/// pointers.
2429
///
25-
typedef struct umf_memory_pool_ops_t {
30+
typedef struct umf_memory_pool_ops_0_11_t {
2631
/// Version of the ops structure.
27-
/// Should be initialized using UMF_VERSION_CURRENT.
32+
/// Should be initialized using UMF_POOL_OPS_VERSION_CURRENT.
2833
uint32_t version;
2934

3035
///
@@ -120,7 +125,8 @@ typedef struct umf_memory_pool_ops_t {
120125
/// The value is undefined if the previous allocation was successful.
121126
///
122127
umf_result_t (*get_last_allocation_error)(void *pool);
123-
} umf_memory_pool_ops_t;
128+
} umf_memory_pool_ops_0_11_t;
129+
typedef umf_memory_pool_ops_0_11_t umf_memory_pool_ops_t;
124130

125131
#ifdef __cplusplus
126132
}

include/umf/memory_provider_ops.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023-2024 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -16,12 +16,17 @@
1616
extern "C" {
1717
#endif
1818

19+
/// @brief Version of the Memory Provider ops structure.
20+
/// NOTE: This is equal to the latest UMF version, in which the ops structure
21+
/// has been modified.
22+
#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
23+
1924
///
2025
/// @brief This structure comprises optional function pointers used
2126
/// by corresponding umfMemoryProvider* calls. A memory provider implementation
2227
/// can keep them NULL.
2328
///
24-
typedef struct umf_memory_provider_ext_ops_t {
29+
typedef struct umf_memory_provider_ext_ops_0_11_t {
2530
///
2631
/// @brief Discard physical pages within the virtual memory mapping associated at the given addr
2732
/// and \p size. This call is asynchronous and may delay purging the pages indefinitely.
@@ -78,13 +83,14 @@ typedef struct umf_memory_provider_ext_ops_t {
7883
umf_result_t (*allocation_split)(void *hProvider, void *ptr,
7984
size_t totalSize, size_t firstSize);
8085

81-
} umf_memory_provider_ext_ops_t;
86+
} umf_memory_provider_ext_ops_0_11_t;
87+
typedef umf_memory_provider_ext_ops_0_11_t umf_memory_provider_ext_ops_t;
8288

8389
///
8490
/// @brief This structure comprises optional IPC API. The API allows sharing of
8591
/// memory objects across different processes. A memory provider implementation can keep them NULL.
8692
///
87-
typedef struct umf_memory_provider_ipc_ops_t {
93+
typedef struct umf_memory_provider_ipc_ops_0_11_t {
8894
///
8995
/// @brief Retrieve the size of opaque data structure required to store IPC data.
9096
/// @param provider pointer to the memory provider.
@@ -134,16 +140,17 @@ typedef struct umf_memory_provider_ipc_ops_t {
134140
/// UMF_RESULT_ERROR_INVALID_ARGUMENT if invalid \p ptr is passed.
135141
/// UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.
136142
umf_result_t (*close_ipc_handle)(void *provider, void *ptr, size_t size);
137-
} umf_memory_provider_ipc_ops_t;
143+
} umf_memory_provider_ipc_ops_0_11_t;
144+
typedef umf_memory_provider_ipc_ops_0_11_t umf_memory_provider_ipc_ops_t;
138145

139146
///
140147
/// @brief This structure comprises function pointers used by corresponding
141148
/// umfMemoryProvider* calls. Each memory provider implementation should
142149
/// initialize all function pointers.
143150
///
144-
typedef struct umf_memory_provider_ops_t {
151+
typedef struct umf_memory_provider_ops_0_11_t {
145152
/// Version of the ops structure.
146-
/// Should be initialized using UMF_VERSION_CURRENT.
153+
/// Should be initialized using UMF_PROVIDER_OPS_VERSION_CURRENT.
147154
uint32_t version;
148155

149156
///
@@ -245,7 +252,8 @@ typedef struct umf_memory_provider_ops_t {
245252
/// @brief Optional IPC ops. The API allows sharing of memory objects across different processes.
246253
///
247254
umf_memory_provider_ipc_ops_t ipc;
248-
} umf_memory_provider_ops_t;
255+
} umf_memory_provider_ops_0_11_t;
256+
typedef umf_memory_provider_ops_0_11_t umf_memory_provider_ops_t;
249257

250258
#ifdef __cplusplus
251259
}

include/umf/providers/provider_devdax_memory.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -65,6 +65,10 @@ typedef enum umf_devdax_memory_provider_native_error {
6565
UMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
6666
} umf_devdax_memory_provider_native_error_t;
6767

68+
/// @cond
69+
// use 0.11 version of the ops by default
70+
#define umfDevDaxMemoryProviderOps umfDevDaxMemoryProviderOps_0_11
71+
/// @endcond
6872
umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void);
6973

7074
#ifdef __cplusplus

include/umf/providers/provider_file_memory.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -66,6 +66,10 @@ typedef enum umf_file_memory_provider_native_error {
6666
UMF_FILE_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
6767
} umf_file_memory_provider_native_error_t;
6868

69+
/// @cond
70+
// use 0.11 version of the ops by default
71+
#define umfFileMemoryProviderOps umfFileMemoryProviderOps_0_11
72+
/// @endcond
6973
umf_memory_provider_ops_t *umfFileMemoryProviderOps(void);
7074

7175
#ifdef __cplusplus

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ set(UMF_SOURCES
7676
memspaces/memspace_highest_bandwidth.c
7777
memspaces/memspace_lowest_latency.c
7878
memspaces/memspace_numa.c
79+
provider/provider_coarse_deprecated.c
7980
provider/provider_cuda.c
81+
provider/provider_deprecated.c
8082
provider/provider_devdax_memory.c
83+
provider/provider_devdax_memory_deprecated.c
8184
provider/provider_file_memory.c
85+
provider/provider_file_memory_deprecated.c
8286
provider/provider_fixed_memory.c
8387
provider/provider_level_zero.c
8488
provider/provider_os_memory.c

src/cpp_helpers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023-2024 Intel Corporation
3+
* Copyright (C) 2023-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -67,7 +67,7 @@ umf_result_t initialize(T *obj, ArgsTuple &&args) {
6767

6868
template <typename T> umf_memory_pool_ops_t poolOpsBase() {
6969
umf_memory_pool_ops_t ops{};
70-
ops.version = UMF_VERSION_CURRENT;
70+
ops.version = UMF_POOL_OPS_VERSION_CURRENT;
7171
ops.finalize = [](void *obj) { delete reinterpret_cast<T *>(obj); };
7272
UMF_ASSIGN_OP(ops, T, malloc, ((void *)nullptr));
7373
UMF_ASSIGN_OP(ops, T, calloc, ((void *)nullptr));
@@ -81,7 +81,7 @@ template <typename T> umf_memory_pool_ops_t poolOpsBase() {
8181

8282
template <typename T> constexpr umf_memory_provider_ops_t providerOpsBase() {
8383
umf_memory_provider_ops_t ops{};
84-
ops.version = UMF_VERSION_CURRENT;
84+
ops.version = UMF_PROVIDER_OPS_VERSION_CURRENT;
8585
ops.finalize = [](void *obj) { delete reinterpret_cast<T *>(obj); };
8686
UMF_ASSIGN_OP(ops, T, alloc, UMF_RESULT_ERROR_UNKNOWN);
8787
UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_ERROR_UNKNOWN);

0 commit comments

Comments
 (0)