8000 Add backward compatibility workflow and tests (ver 2) by bratpiorka · Pull Request #1087 · oneapi-src/unified-memory-framework · GitHub
[go: up one dir, main page]

Skip to content
8000

Add backward compatibility workflow and tests (ver 2) #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 8000 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Before checking all the boxes please mark the PR as draft.
- [ ] All newly added source files have a license
- [ ] All newly added source files are referenced in CMake files
- [ ] Logger (with debug/info/... messages) is used
- [ ] All API changes are reflected in docs and def/map files, and are tested
8 changes: 8 additions & 0 deletions .github/workflows/pr_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ jobs:
contents: read
security-events: write
uses: ./.github/workflows/reusable_trivy.yml
Compatibility:
needs: [Build]
uses: ./.github/workflows/reusable_compatibility.yml
strategy:
matrix:
tag: ["v0.11.0-dev1"]
with:
tag: ${{matrix.tag}}
211 changes: 211 additions & 0 deletions .github/workflows/reusable_compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# Workflow for checkig the backward compatibility of UMF.
# Test the latest UMF shared library with binaries compiled using the older UMF
# shared library.
name: Compatibility

on:
workflow_call:
inputs:
tag:
description: Check backward compatibility with this tag
type: string
default: "v0.11.0-dev1"

permissions:
contents: read

jobs:
ubuntu-build:
name: Ubuntu
runs-on: 'ubuntu-22.04'

steps:
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libnuma-dev libtbb-dev

- name: Checkout "tag" UMF version
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
ref: refs/tags/${{inputs.tag}}
path: ${{github.workspace}}/tag_version

- name: Install libhwloc
working-directory: ${{github.workspace}}/tag_version
run: .github/scripts/install_hwloc.sh

- name: Get "tag" UMF version
working-directory: ${{github.workspace}}/tag_version
run: |
VERSION=$(git describe --tags)
echo "tag version: $VERSION"

- name: Configure "tag" UMF build
working-directory: ${{github.workspace}}/tag_version
run: >
cmake
-B ${{github.workspace}}/tag_version/build
-DCMAKE_BUILD_TYPE=Debug
-DUMF_BUILD_SHARED_LIBRARY=ON
-DCMAKE_C_COMPILER=gcc
-DCMAKE_CXX_COMPILER=g++
-DUMF_BUILD_TESTS=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON

- name: Build "tag" UMF
working-directory: ${{github.workspace}}/tag_version
run: |
cmake --build ${{github.workspace}}/tag_version/build -j $(nproc)

- name: Run "tag" UMF tests
working-directory: ${{github.workspace}}/tag_version/build
run: |
LD_LIBRARY_PATH=${{github.workspace}}/tag_version/build/lib/ ctest --output-on-failure

- name: Checkout latest UMF version
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
path: ${{github.workspace}}/latest_version

- name: Get latest UMF version
working-directory: ${{github.workspace}}/latest_version
run: |
VERSION=$(git describe --tags)
echo "checked version: $VERSION"

- name: Configure latest UMF build
working-directory: ${{github.workspace}}/latest_version
run: >
cmake
-B ${{github.workspace}}/latest_version/build
-DCMAKE_BUILD_TYPE=Debug
-DUMF_BUILD_SHARED_LIBRARY=ON
-DCMAKE_C_COMPILER=gcc
-DCMAKE_CXX_COMPILER=g++
-DUMF_BUILD_TESTS=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON

- name: Build latest UMF
working-directory: ${{github.workspace}}/latest_version
run: |
cmake --build ${{github.workspace}}/latest_version/build -j $(nproc)

- name: Run "tag" UMF tests with latest UMF libs (warnings enabled)
working-directory: ${{github.workspace}}/tag_version/build
run: >
UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
LD_LIBRARY_PATH=${{github.workspace}}/latest_version/build/lib/
ctest --output-on-failure

windows-build:
name: Windows
env:
VCPKG_PATH: "${{github.workspace}}/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/vcpkg/packages/jemalloc_x64-windows"
runs-on: "windows-2022"

steps:
- name: Checkout "tag" UMF version
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
ref: refs/tags/${{inputs.tag}}
path: ${{github.workspace}}/tag_version

- name: Initialize vcpkg
uses: lukka/run-vcpkg@5e0c A93C ab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
with:
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
vcpkgDirectory: ${{github.workspace}}/vcpkg
vcpkgJsonGlob: '**/vcpkg.json'

- name: Install dependencies
working-directory: ${{github.workspace}}/tag_version
run: vcpkg install
shell: pwsh # Specifies PowerShell as the shell for running the script.

- name: Get "tag" UMF version
working-directory: ${{github.workspace}}/tag_version
run: |
$version = (git describe --tags)
echo "tag version: $VERSION"

- name: Configure "tag" UMF build
working-directory: ${{github.workspace}}/tag_version
run: >
cmake
-B "${{github.workspace}}/tag_version/build"
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DCMAKE_C_COMPILER=cl
-DCMAKE_CXX_COMPILER=cl
-DUMF_BUILD_SHARED_LIBRARY=ON
-DUMF_BUILD_TESTS=ON
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON

- name: Build "tag" UMF
run: cmake --build "${{github.workspace}}/tag_version/build" --config Debug -j $Env:NUMBER_OF_PROCESSORS

- name: Run "tag" UMF tests
working-directory: "${{github.workspace}}/tag_version/build"
run: ctest -C Debug --output-on-failure --test-dir test

- name: Checkout latest UMF version
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
path: ${{github.workspace}}/latest_version

# NOTE we use vcpkg setup from "tag" version
- name: Get latest UMF version
working-directory: ${{github.workspace}}/latest_version
run: |
$version = (git describe --tags)
echo "latest version: $VERSION"

- name: Configure latest UMF build
working-directory: ${{github.workspace}}/latest_version
run: >
cmake
-B "${{github.workspace}}/latest_version/build"
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DCMAKE_C_COMPILER=cl
-DCMAKE_CXX_COMPILER=cl
-DUMF_BUILD_SHARED_LIBRARY=ON
-DUMF_BUILD_TESTS=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON

- name: Build latest UMF
run: cmake --build "${{github.workspace}}/latest_version/build" --config Debug -j $Env:NUMBER_OF_PROCESSORS

- name: Run "tag" UMF tests with latest UMF libs (warnings enabled)
working-directory: ${{github.workspace}}/tag_version/build
run: |
$env:UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
cp ${{github.workspace}}/latest_version/build/bin/Debug/umf.dll ${{github.workspace}}/tag_version/build/bin/Debug/umf.dll
ctest -C Debug --output-on-failure --test-dir test
1 change: 1 addition & 0 deletions RELEASE_STEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Do changes for a release:
- Add an entry to ChangeLog, remember to change the day of the week in the release date
- For major and minor (prior 1.0.0) releases mention API and ABI compatibility with the previous release
- For major and minor releases, update `UMF_VERSION_CURRENT` in `include/umf/base.h` (the API version)
- For changes in ops structures, update corresponding UMF_*_OPS_VERSION_CURRENT
- For major and minor (prior 1.0.0) releases update ABI version in `.map` and `.def` files
- These files are defined for all public libraries (`libumf` and `proxy_lib`, at the moment)
- Commit these changes and tag the release:
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_file_provider/custom_file_provider.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -234,7 +234,7 @@ static umf_result_t file_get_min_page_size(void *provider, void *ptr,

// File provider operations
static umf_memory_provider_ops_t file_ops = {
.version = UMF_VERSION_CURRENT,
.version = UMF_PROVIDER_OPS_VERSION_CURRENT,
.initialize = file_init,
.finalize = file_deinit,
.alloc = file_alloc,
Expand Down
7 changes: 1 addition & 6 deletions include/umf/memory_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define UMF_MEMORY_POOL_H 1

#include <umf/base.h>
#include <umf/memory_pool_ops.h>
#include <umf/memory_provider.h>

#ifdef __cplusplus
Expand All @@ -22,12 +23,6 @@ extern "C" {
/// functions
typedef struct umf_memory_pool_t *umf_memory_pool_handle_t;

/// @brief This structure comprises function pointers used by corresponding umfPool*
/// calls. Each memory pool implementation should initialize all function
/// pointers.
///
typedef struct umf_memory_pool_ops_t umf_memory_pool_ops_t;

/// @brief Supported pool creation flags
typedef enum umf_pool_create_flag_t {
UMF_POOL_CREATE_FLAG_NONE =
Expand Down
7 changes: 6 additions & 1 deletion include/umf/memory_pool_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@
extern "C" {
#endif

/// @brief Version of the Memory Pool ops structure.
/// NOTE: This is equal to the latest UMF version, in which the ops structure
/// has been modified.
#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)

///
/// @brief This structure comprises function pointers used by corresponding umfPool*
/// calls. Each memory pool implementation should initialize all function
/// pointers.
///
typedef struct umf_memory_pool_ops_t {
/// Version of the ops structure.
/// Should be initialized using UMF_VERSION_CURRENT.
/// Should be initialized using UMF_POOL_OPS_VERSION_CURRENT.
uint32_t version;

///
Expand Down
9 changes: 7 additions & 2 deletions include/umf/memory_provider_ops.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -16,6 +16,11 @@
extern "C" {
#endif

/// @brief Version of the Memory Provider ops structure.
/// NOTE: This is equal to the latest UMF version, in which the ops structure
/// has been modified.
#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)

///
/// @brief This structure comprises optional function pointers used
/// by corresponding umfMemoryProvider* calls. A memory provider implementation
Expand Down Expand Up @@ -143,7 +148,7 @@ typedef struct umf_memory_provider_ipc_ops_t {
///
typedef struct umf_memory_provider_ops_t {
/// Version of the ops structure.
/// Should be initialized using UMF_VERSION_CURRENT.
/// Should be initialized using UMF_PROVIDER_OPS_VERSION_CURRENT.
uint32_t version;

///
Expand Down
6 changes: 3 additions & 3 deletions src/cpp_helpers.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand Down Expand Up @@ -67,7 +67,7 @@ umf_result_t initialize(T *obj, ArgsTuple &&args) {

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

template <typename T> constexpr umf_memory_provider_ops_t providerOpsBase() {
umf_memory_provider_ops_t ops{};
ops.version = UMF_VERSION_CURRENT;
ops.version = UMF_PROVIDER_OPS_VERSION_CURRENT;
ops.finalize = [](void *obj) { delete reinterpret_cast<T *>(obj); };
UMF_ASSIGN_OP(ops, T, alloc, UMF_RESULT_ERROR_UNKNOWN);
UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_ERROR_UNKNOWN);
Expand Down
7 changes: 4 additions & 3 deletions src/ipc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -15,6 +15,7 @@
#include "base_alloc_global.h"
#include "ipc_internal.h"
#include "memory_pool_internal.h"
#include "memory_provider_internal.h"
#include "provider/provider_tracking.h"
#include "utils_common.h"
#include "utils_log.h"
Expand Down Expand Up @@ -123,14 +124,14 @@ umf_result_t umfOpenIPCHandle(umf_ipc_handler_handle_t hIPCHandler,
umf_ipc_handle_t umfIPCHandle, void **ptr) {

// IPC handler is an instance of tracking memory provider
if (*(uint32_t *)hIPCHandler != UMF_VERSION_CURRENT) {
umf_memory_provider_handle_t hProvider = hIPCHandler;
if (hProvider->ops.version != UMF_PROVIDER_OPS_VERSION_CURRENT) {
// It is a temporary hack to verify that user passes correct IPC handler,
// not a pool handle, as it was required in previous version.
LOG_ERR("Invalid IPC handler.");
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

umf_memory_provider_handle_t hProvider = hIPCHandler;
void *base = NULL;

umf_result_t ret = umfMemoryProviderOpenIPCHandle(
Expand Down
Loading
Loading
0