Skip to content

Commit 3ecbe58

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

39 files changed

+822
-80
lines changed

.github/workflows/pr_push.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@ 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}}
96+
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
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+
name: Ubuntu
20+
runs-on: 'ubuntu-22.04'
21+
22+
steps:
23+
# NOTE: we need jemalloc for older version of UMF
24+
- name: Install apt packages
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev libtbb-dev
28+
29+
- name: Checkout "tag" UMF version
30+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31+
with:
32+
fetch-depth: 0
33+
ref: refs/tags/${{inputs.tag}}
34+
path: ${{github.workspace}}/tag_version
35+
36+
- name: Install libhwloc
37+
working-directory: ${{github.workspace}}/tag_version
38+
run: .github/scripts/install_hwloc.sh
39+
40+
- name: Get "tag" UMF version
41+
working-directory: ${{github.workspace}}/tag_version
42+
run: |
43+
VERSION=$(git describe --tags --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
44+
echo "tag version: $VERSION"
45+
46+
- name: Configure "tag" UMF build
47+
working-directory: ${{github.workspace}}/tag_version
48+
run: >
49+
cmake
50+
-B ${{github.workspace}}/tag_version/build
51+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/tag_version/build/install"
52+
-DCMAKE_BUILD_TYPE=Debug
53+
-DUMF_BUILD_SHARED_LIBRARY=ON
54+
-DCMAKE_C_COMPILER=gcc
55+
-DCMAKE_CXX_COMPILER=g++
56+
-DUMF_BUILD_TESTS=ON
57+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
58+
-DUMF_BUILD_CUDA_PROVIDER=ON
59+
-DUMF_FORMAT_CODE_STYLE=OFF
60+
-DUMF_DEVELOPER_MODE=ON
61+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
62+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
63+
-DUMF_TESTS_FAIL_ON_SKIP=ON
64+
65+
- name: Build "tag" UMF
66+
working-directory: ${{github.workspace}}/tag_version
67+
run: |
68+
cmake --build ${{github.workspace}}/tag_version/build -j $(nproc)
69+
70+
# For UMF < 0.11 set ptrace_scope
71+
- name: Set ptrace value for IPC test
72+
if: ${{ startsWith(inputs.tag, 'v0.10.') || startsWith(inputs.tag, 'v0.9.') }}
73+
run: sudo bash -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope"
74+
75+
- name: Run "tag" UMF tests
76+
working-directory: ${{github.workspace}}/tag_version/build
77+
run: |
78+
LD_LIBRARY_PATH=${{github.workspace}}/tag_version/build/lib/ ctest --output-on-failure
79+
80+
- name: Checkout latest UMF version
81+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
82+
with:
83+
fetch-depth: 0
84+
path: ${{github.workspace}}/latest_version
85+
86+
- name: Get latest UMF version
87+
working-directory: ${{github.workspace}}/latest_version
88+
run: |
89+
VERSION=$(git describe --tags --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
90+
echo "checked version: $VERSION"
91+
92+
- name: Configure latest UMF build
93+
working-directory: ${{github.workspace}}/latest_version
94+
run: >
95+
cmake
96+
-B ${{github.workspace}}/latest_version/build
97+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/latest_version/build/install"
98+
-DCMAKE_BUILD_TYPE=Debug
99+
-DUMF_BUILD_SHARED_LIBRARY=ON
100+
-DCMAKE_C_COMPILER=gcc
101+
-DCMAKE_CXX_COMPILER=g++
102+
-DUMF_BUILD_TESTS=ON
103+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
104+
-DUMF_BUILD_CUDA_PROVIDER=ON
105+
-DUMF_FORMAT_CODE_STYLE=OFF
106+
-DUMF_DEVELOPER_MODE=ON
107+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
108+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
109+
-DUMF_TESTS_FAIL_ON_SKIP=ON
110+
111+
- name: Build latest UMF
112+
working-directory: ${{github.workspace}}/latest_version
113+
run: |
114+
cmake --build ${{github.workspace}}/latest_version/build -j $(nproc)
115+
116+
# NOTE: exclude umf-provider_coarse, umf-disjointCoarseMallocPool,
117+
# umf-jemalloc_coarse_file, umf-scalable_coarse_file as they use Coarse
118+
# Provider which is not supported for UMF > 0.10.0
119+
- name: Run "tag" UMF tests with latest UMF libs (warnings enabled)
120+
working-directory: ${{github.workspace}}/tag_version/build
121+
run: >
122+
UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
123+
LD_LIBRARY_PATH=${{github.workspace}}/latest_version/build/lib/
124+
ctest --output-on-failure -E "umf-provider_coarse|umf-disjointCoarseMallocPool|umf-jemalloc_coarse_file|umf-scalable_coarse_file"
125+
126+
windows-build:
127+
name: Windows
128+
env:
129+
VCPKG_PATH: "${{github.workspace}}/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/vcpkg/packages/jemalloc_x64-windows"
130+
runs-on: "windows-2022"
131+
132+
steps:
133+
- name: Checkout "tag" UMF version
134+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
135+
with:
136+
fetch-depth: 0
137+
ref: refs/tags/${{inputs.tag}}
138+
path: ${{github.workspace}}/tag_version
139+
140+
- name: Initialize vcpkg
141+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
142+
with:
143+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
144+
vcpkgDirectory: ${{github.workspace}}/vcpkg
145+
vcpkgJsonGlob: '**/vcpkg.json'
146+
147+
- name: Install dependencies
148+
working-directory: ${{github.workspace}}/tag_version
149+
run: vcpkg install
150+
shell: pwsh # Specifies PowerShell as the shell for running the script.
151+
152+
- name: Get "tag" UMF version
153+
working-directory: ${{github.workspace}}/tag_version
154+
run: |
155+
$version = (git describe --tags --abbrev=0 | Select-String -Pattern '\d+\.\d+\.\d+').Matches.Value
156+
echo "tag version: $VERSION"
157+
shell: pwsh
158+
159+
- name: Configure "tag" UMF build
160+
working-directory: ${{github.workspace}}/tag_version
161+
run: >
162+
cmake
163+
-B "${{github.workspace}}/tag_version/build"
164+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/tag_version/install"
165+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
166+
-DCMAKE_C_COMPILER=cl
167+
-DCMAKE_CXX_COMPILER=cl
168+
-DUMF_BUILD_SHARED_LIBRARY=ON
169+
-DUMF_BUILD_TESTS=ON
170+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
171+
-DUMF_BUILD_CUDA_PROVIDER=ON
172+
-DUMF_FORMAT_CODE_STYLE=OFF
173+
-DUMF_DEVELOPER_MODE=ON
174+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
175+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
176+
-DUMF_TESTS_FAIL_ON_SKIP=ON
177+
178+
- name: Build "tag" UMF
179+
run: cmake --build "${{github.workspace}}/tag_version/build" --config Debug -j $Env:NUMBER_OF_PROCESSORS
180+
181+
- name: Run "tag" UMF tests
182+
working-directory: "${{github.workspace}}/tag_version/build"
183+
run: ctest -C Debug --output-on-failure --test-dir test
184+
185+
- name: Checkout latest UMF version
186+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
187+
with:
188+
fetch-depth: 0
189+
path: ${{github.workspace}}/latest_version
190+
191+
# NOTE we use vcpkg setup from "tag" version
192+
- name: Get latest UMF version
193+
working-directory: ${{github.workspace}}/latest_version
194+
run: |
195+
$version = (git describe --tags --abbrev=0 | Select-String -Pattern '\d+\.\d+\.\d+').Matches.Value
196+
echo "latest version: $VERSION"
197+
shell: pwsh
198+
199+
- name: Configure latest UMF build
200+
working-directory: ${{github.workspace}}/latest_version
201+
run: >
202+
cmake
203+
-B "${{github.workspace}}/latest_version/build"
204+
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/latest_version/install"
205+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
206+
-DCMAKE_C_COMPILER=cl
207+
-DCMAKE_CXX_COMPILER=cl
208+
-DUMF_BUILD_SHARED_LIBRARY=ON
209+
-DUMF_BUILD_TESTS=ON
210+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
211+
-DUMF_BUILD_CUDA_PROVIDER=ON
212+
-DUMF_FORMAT_CODE_STYLE=OFF
213+
-DUMF_DEVELOPER_MODE=ON
214+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
215+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
216+
-DUMF_TESTS_FAIL_ON_SKIP=ON
217+
218+
- name: Build latest UMF
219+
run: cmake --build "${{github.workspace}}/latest_version/build" --config Debug -j $Env:NUMBER_OF_PROCESSORS
220+
221+
# NOTE: exclude umf-provider_coarse, umf-disjointCoarseMallocPool,
222+
# umf-jemalloc_coarse_file, umf-scalable_coarse_file as they use Coarse
223+
# NOTE2: on Windows we simply overwrite the umf.dll
224+
# Provider which is not supported for UMF > 0.10.0
225+
- name: Run "tag" UMF tests with latest UMF libs (warnings enabled)
226+
working-directory: ${{github.workspace}}/tag_version/build
227+
run: |
228+
$env:UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
229+
cp ${{github.workspace}}/latest_version/build/bin/Debug/umf.dll ${{github.workspace}}/tag_version/build/bin/Debug/umf.dll
230+
ctest -C Debug --output-on-failure --test-dir test -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
}

0 commit comments

Comments
 (0)