Skip to content

Commit

Permalink
todo
Browse files Browse the repository at this point in the history
  • Loading branch information
bratpiorka committed Jan 29, 2025
1 parent e31c856 commit b4edc5c
Show file tree
Hide file tree
Showing 30 changed files with 321 additions and 96 deletions.
78 changes: 7 additions & 71 deletions .github/workflows/pr_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,75 +16,11 @@ permissions:
contents: read

jobs:
CodeChecks:
uses: ./.github/workflows/reusable_checks.yml
DocsBuild:
uses: ./.github/workflows/reusable_docs_build.yml
FastBuild:
name: Fast builds
needs: [CodeChecks, DocsBuild]
uses: ./.github/workflows/reusable_fast.yml
Build:
name: Basic builds
needs: [FastBuild]
uses: ./.github/workflows/reusable_basic.yml
DevDax:
needs: [FastBuild]
uses: ./.github/workflows/reusable_dax.yml
MultiNuma:
needs: [FastBuild]
uses: ./.github/workflows/reusable_multi_numa.yml
L0:
needs: [Build]
uses: ./.github/workflows/reusable_gpu.yml
Compatibility:
name: Compatibility
uses: ./.github/workflows/reusable_compatibility.yml
strategy:
matrix:
tag: ["v0.10.1"]
with:
name: "LEVEL_ZERO"
shared_lib: "['ON']"
CUDA:
needs: [Build]
uses: ./.github/workflows/reusable_gpu.yml
with:
name: "CUDA"
shared_lib: "['ON']"
Sanitizers:
needs: [FastBuild]
uses: ./.github/workflows/reusable_sanitizers.yml
QEMU:
needs: [FastBuild]
uses: ./.github/workflows/reusable_qemu.yml
with:
short_run: true
Benchmarks:
needs: [Build]
uses: ./.github/workflows/reusable_benchmarks.yml
ProxyLib:
needs: [Build]
uses: ./.github/workflows/reusable_proxy_lib.yml
Valgrind:
needs: [Build]
uses: ./.github/workflows/reusable_valgrind.yml
Coverage:
# total coverage (on upstream only)
if: github.repository == 'oneapi-src/unified-memory-framework'
needs: [Build, DevDax, L0, CUDA, MultiNuma, QEMU, ProxyLib]
uses: ./.github/workflows/reusable_coverage.yml
secrets: inherit
with:
trigger: "${{github.event_name}}"
Coverage_partial:
# partial coverage (on forks)
if: github.repository != 'oneapi-src/unified-memory-framework'
needs: [Build, QEMU, ProxyLib]
uses: ./.github/workflows/reusable_coverage.yml
CodeQL:
needs: [Build]
permissions:
contents: read
security-events: write
uses: ./.github/workflows/reusable_codeql.yml
Trivy:
needs: [Build]
permissions:
contents: read
security-events: write
uses: ./.github/workflows/reusable_trivy.yml
tag: ${{ matrix.tag }}
133 changes: 133 additions & 0 deletions .github/workflows/reusable_compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# TODO
name: Compatibility

on:
workflow_call:
inputs:
tag:
description: Check backward compatibility with this tag
type: string
default: "0.10.1"

permissions:
contents: read

jobs:
ubuntu-build:
name: Ubuntu
strategy:
matrix:
# TODO other systems?
os: ['ubuntu-22.04']
build_type: [Debug]
compiler: [{c: gcc, cxx: g++}]
shared_library: ['ON']
level_zero_provider: ['ON']
cuda_provider: ['ON']
install_tbb: ['ON']
runs-on: ${{matrix.os}}

steps:
# NOTE: we need jemalloc for older version of UMF
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev
- name: Install TBB apt package
if: matrix.install_tbb == 'ON'
run: |
sudo apt-get install -y 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 --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
echo "tag version: $VERSION"
- name: Configure "tag" UMF build
working-directory: ${{github.workspace}}/tag_version
run: >
cmake
-B ${{github.workspace}}/tag_version/build
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/tag_version/build/install"
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
-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)
# NOTE: we need jemalloc for older version of UMF
# if: startsWith(github.event.inputs.tag, '0.10.') || startsWith(github.event.inputs.tag, '0.9.')
- name: Set ptrace value for IPC test
run: sudo bash -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope"

- 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 --abbrev=0 | grep -oP '\d+\.\d+\.\d+')
echo "checked version: $VERSION"
- name: Configure latest UMF build
working-directory: ${{github.workspace}}/latest_version
run: >
cmake
-B ${{github.workspace}}/latest_version/build
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/latest_version/build/install"
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${{matrix.level_zero_provider}}
-DUMF_BUILD_CUDA_PROVIDER=${{matrix.cuda_provider}}
-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 (warnigs 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
2 changes: 1 addition & 1 deletion examples/custom_file_provider/custom_file_provider.c
Original file line number Diff line number Diff line change
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: 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

// TODO comment
// 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
7 changes: 6 additions & 1 deletion include/umf/memory_provider_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
extern "C" {
#endif

// TODO comment
// 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
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ set(UMF_SOURCES
memspaces/memspace_lowest_latency.c
memspaces/memspace_numa.c
provider/provider_cuda.c
provider/provider_deprecated.c
provider/provider_devdax_memory.c
provider/provider_file_memory.c
provider/provider_fixed_memory.c
Expand Down
4 changes: 2 additions & 2 deletions src/cpp_helpers.hpp
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions src/libumf.def
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ EXPORTS
umfTearDown
umfGetCurrentVersion
umfCloseIPCHandle
umfCoarseMemoryProviderGetStats ; deprecated
umfCoarseMemoryProviderOps ; deprecated
umfCUDAMemoryProviderOps
umfCUDAMemoryProviderParamsCreate
umfCUDAMemoryProviderParamsDestroy
Expand Down
2 changes: 2 additions & 0 deletions src/libumf.map
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ UMF_0.10 {
umfTearDown;
umfGetCurrentVersion;
umfCloseIPCHandle;
umfCoarseMemoryProviderGetStats; # deprecated
umfCoarseMemoryProviderOps; # deprecated
umfCUDAMemoryProviderOps;
umfCUDAMemoryProviderParamsCreate;
umfCUDAMemoryProviderParamsDestroy;
Expand Down
6 changes: 5 additions & 1 deletion src/memory_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}

assert(ops->version == UMF_VERSION_CURRENT);
if (ops->version != UMF_POOL_OPS_VERSION_CURRENT) {
LOG_WARN("memory pool ops version \"%d\" is different than current "
"version \"%d\"",
ops->version, UMF_POOL_OPS_VERSION_CURRENT);
}

if (!(flags & UMF_POOL_CREATE_FLAG_DISABLE_TRACKING)) {
// Wrap provider with memory tracking provider.
Expand Down
40 changes: 37 additions & 3 deletions src/memory_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <umf/memory_provider.h>

#include "base_alloc.h"
#include "base_alloc_global.h"
#include "libumf.h"
#include "memory_provider_internal.h"
#include "provider_deprecated.h"
#include "utils_assert.h"

typedef struct umf_memory_provider_t {
Expand Down Expand Up @@ -173,9 +175,41 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}

assert(ops->version == UMF_VERSION_CURRENT);

provider->ops = *ops;
if (ops->version != UMF_PROVIDER_OPS_VERSION_CURRENT) {
LOG_WARN("memory provider ops version \"%d\" is different than current "
"version \"%d\"",
ops->version, UMF_PROVIDER_OPS_VERSION_CURRENT);

// TODO move to provider_deprecated.c?
if (ops->version == UMF_MAKE_VERSION(0, 10)) {
umf_memory_provider_ops_10_0_t ops_10_0;
memcpy(&ops_10_0, ops, sizeof(ops_10_0));

provider->ops.version = UMF_PROVIDER_OPS_VERSION_CURRENT;
provider->ops.alloc = ops_10_0.alloc;
provider->ops.free = ops_10_0.ext.free; // NOTE: ops <- ops.ext
provider->ops.get_last_native_error =
ops_10_0.get_last_native_error;
provider->ops.get_recommended_page_size =
ops_10_0.get_recommended_page_size;
provider->ops.get_min_page_size = ops_10_0.get_min_page_size;
provider->ops.get_name = ops_10_0.get_name;
provider->ops.initialize = ops_10_0.initialize;
provider->ops.finalize = ops_10_0.finalize;

provider->ops.ext.purge_lazy = ops_10_0.ext.purge_lazy;
provider->ops.ext.purge_force = ops_10_0.ext.purge_force;
provider->ops.ext.allocation_merge = ops_10_0.ext.allocation_merge;
provider->ops.ext.allocation_split = ops_10_0.ext.allocation_split;

// IPC hasn't changed
assert(sizeof(umf_memory_provider_ipc_ops_t) ==
sizeof(umf_memory_provider_ipc_ops_10_0_t));
memcpy(&provider->ops.ipc, &ops_10_0.ipc, sizeof(ops_10_0.ipc));
}
} else {
provider->ops = *ops;
}

assignOpsExtDefaults(&(provider->ops));
assignOpsIpcDefaults(&(provider->ops));
Expand Down
Loading

0 comments on commit b4edc5c

Please sign in to comment.