Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fd27836
Bump L0 loader to v1.20.2
lukaszstolarczuk Feb 20, 2025
ab731c0
Fix Windows Unix Makefiles generator builds
PatKamin Feb 24, 2025
8fecb89
Merge pull request #1117 from lukaszstolarczuk/bump-l0-loader
lukaszstolarczuk Feb 25, 2025
249c364
implement malloc_usable_size and enable pool tests for disjoint
pbalcer Feb 24, 2025
6b2e8f6
Merge pull request #1130 from PatKamin/fix-hwloc-make-build
lukaszstolarczuk Feb 25, 2025
bf593a0
Bump breathe
dependabot[bot] Feb 25, 2025
08d137c
Merge pull request #1137 from oneapi-src/dependabot/pip/third_party/p…
lukaszstolarczuk Feb 26, 2025
c9134a4
Use LOG_FATAL() in case of critical errors
ldorau Feb 26, 2025
5d67494
Merge pull request #1132 from pbalcer/malloc-usable-size-disjoint-pool
bratpiorka Feb 26, 2025
113f3e0
Merge pull request #1139 from ldorau/Use_LOG_FATAL_in_case_of_critica…
lukaszstolarczuk Feb 26, 2025
258c6f2
explicitly declare single threaded benchmark
lplewa Feb 26, 2025
2d19a61
remove deprecated cmake flag from compat workflow
bratpiorka Feb 26, 2025
1c9c7a1
Merge pull request #1140 from lplewa/single_thread
bratpiorka Feb 26, 2025
4c70f6c
Merge pull request #1141 from bratpiorka/rrudnick_compat_cleanup
vinser52 Feb 26, 2025
c2e758e
coarse: error out on double free instead of assert
ldorau Mar 1, 2025
eae8d63
Merge pull request #1148 from ldorau/coarse_error_out_on_double_free_…
ldorau Mar 3, 2025
d97349f
[CI] Disable legacy GHA Image - Ubuntu 20.04
KFilipek Mar 4, 2025
9fb88d5
Merge pull request #1152 from KFilipek/disable_2004
bratpiorka Mar 4, 2025
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
11 changes: 1 addition & 10 deletions .github/workflows/reusable_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Ubuntu
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04']
os: ['ubuntu-22.04', 'ubuntu-24.04']
build_type: [Debug, Release]
compiler: [{c: gcc, cxx: g++}]
shared_library: ['OFF']
Expand All @@ -27,15 +27,6 @@ jobs:
disable_hwloc: ['OFF']
link_hwloc_statically: ['OFF']
include:
- os: 'ubuntu-20.04'
build_type: Release
compiler: {c: gcc-7, cxx: g++-7}
shared_library: 'OFF'
level_zero_provider: 'ON'
cuda_provider: 'ON'
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: clang, cxx: clang++}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/reusable_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
-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
Expand Down Expand Up @@ -197,7 +196,6 @@ jobs:
-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
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/reusable_fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
build_tests: 'ON'
extra_build_options: '-DCMAKE_BUILD_TYPE=Release'
simple_cmake: 'ON'
# simplest CMake ubuntu-20.04
- os: ubuntu-20.04
# simplest CMake ubuntu-22.04
- os: ubuntu-22.04
build_tests: 'ON'
extra_build_options: '-DCMAKE_BUILD_TYPE=Release'
simple_cmake: 'ON'
Expand All @@ -69,19 +69,12 @@ jobs:
run: vcpkg install
shell: pwsh # Specifies PowerShell as the shell for running the script.

- name: Install dependencies (ubuntu-latest)
if: matrix.os == 'ubuntu-latest'
- name: Install dependencies
if: matrix.os != 'windows-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libtbb-dev

- name: Install dependencies (ubuntu-20.04)
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y cmake libnuma-dev libtbb-dev
.github/scripts/install_hwloc.sh # install hwloc-2.3.0 instead of hwloc-2.1.0 present in the OS package

- name: Configure CMake
if: matrix.simple_cmake == 'OFF'
run: >
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ else()

message(STATUS "hwloc CMAKE_GENERATOR: ${CMAKE_GENERATOR}")

if(CMAKE_GENERATOR STREQUAL "Ninja")
if(CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL
"Unix Makefiles")
add_custom_command(
COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${hwloc_targ_BINARY_DIR} -B build
Expand Down Expand Up @@ -408,7 +409,7 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
include(FetchContent)

set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.19.2)
set(LEVEL_ZERO_LOADER_TAG v1.20.2)

message(
STATUS
Expand Down
15 changes: 11 additions & 4 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ static void multithreaded(benchmark::internal::Benchmark *benchmark) {
benchmark->Threads(1);
}

static void singlethreaded(benchmark::internal::Benchmark *benchmark) {
benchmark->Threads(1);
}

static void
default_multiple_alloc_fix_size(benchmark::internal::Benchmark *benchmark) {
benchmark->Args({10000, 1, 4096});
Expand Down Expand Up @@ -68,15 +72,17 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, proxy_pool,
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, proxy_pool)
->Apply(&default_multiple_alloc_fix_size)
// reduce iterations, as this benchmark is slower than others
->Iterations(50000);
->Iterations(50000)
->Apply(&singlethreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, os_provider,
fixed_alloc_size,
provider_allocator<os_provider>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, os_provider)
->Apply(&default_multiple_alloc_fix_size)
// reduce iterations, as this benchmark is slower than others
->Iterations(50000);
->Iterations(50000)
->Apply(&singlethreaded);

UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, disjoint_pool_fix,
fixed_alloc_size,
Expand All @@ -89,8 +95,9 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
disjoint_pool_uniform, uniform_alloc_size,
pool_allocator<disjoint_pool<os_provider>>);
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_uniform)
->Apply(&default_multiple_alloc_uniform_size);
// TODO: enable
->Apply(&default_multiple_alloc_uniform_size)
->Apply(&singlethreaded);
// TODO: change to multithreaded
//->Apply(&multithreaded);

#ifdef UMF_POOL_JEMALLOC_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion examples/ipc_level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()
include(FetchContent)

set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.19.2)
set(LEVEL_ZERO_LOADER_TAG v1.20.2)

message(
STATUS
Expand Down
2 changes: 1 addition & 1 deletion examples/level_zero_shared_memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()
include(FetchContent)

set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.19.2)
set(LEVEL_ZERO_LOADER_TAG v1.20.2)

message(
STATUS
Expand Down
7 changes: 5 additions & 2 deletions src/coarse/coarse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,13 @@ umf_result_t coarse_free(coarse_t *coarse, void *ptr, size_t bytes) {
}

block_t *block = get_node_block(node);
assert(block->used);
if (!block->used) {
LOG_ERR("double free");
utils_mutex_unlock(&coarse->lock);
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

if (bytes > 0 && bytes != block->size) {
// wrong size of allocation
LOG_ERR("wrong size of allocation");
utils_mutex_unlock(&coarse->lock);
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
Expand Down
37 changes: 31 additions & 6 deletions src/pool/pool_disjoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,10 @@ void *disjoint_pool_aligned_malloc(void *pool, size_t size, size_t alignment) {
}

void *aligned_ptr = (void *)ALIGN_UP_SAFE((size_t)ptr, alignment);
VALGRIND_DO_MEMPOOL_ALLOC(disjoint_pool, aligned_ptr, size);
utils_annotate_memory_undefined(aligned_ptr, size);
size_t diff = (ptrdiff_t)aligned_ptr - (ptrdiff_t)ptr;
size_t real_size = bucket->size - diff;
VALGRIND_DO_MEMPOOL_ALLOC(disjoint_pool, aligned_ptr, real_size);
utils_annotate_memory_undefined(aligned_ptr, real_size);

utils_mutex_unlock(&bucket->bucket_lock);

Expand All @@ -767,11 +769,34 @@ void *disjoint_pool_aligned_malloc(void *pool, size_t size, size_t alignment) {
}

size_t disjoint_pool_malloc_usable_size(void *pool, void *ptr) {
(void)pool;
(void)ptr;
disjoint_pool_t *disjoint_pool = (disjoint_pool_t *)pool;
if (ptr == NULL) {
return 0;
}

// Not supported
return 0;
// check if given pointer is allocated inside any Disjoint Pool slab
slab_t *slab =
(slab_t *)critnib_find_le(disjoint_pool->known_slabs, (uintptr_t)ptr);
if (slab == NULL || ptr >= slab_get_end(slab)) {
// memory comes directly from the provider
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
if (ret != UMF_RESULT_SUCCESS) {
return 0;
}

return allocInfo.baseSize;
}
// Get the unaligned pointer
// NOTE: the base pointer slab->mem_ptr needn't to be aligned to bucket size
size_t chunk_idx =
(((uintptr_t)ptr - (uintptr_t)slab->mem_ptr) / slab->bucket->size);
void *unaligned_ptr =
(void *)((uintptr_t)slab->mem_ptr + chunk_idx * slab->bucket->size);

ptrdiff_t diff = (ptrdiff_t)ptr - (ptrdiff_t)unaligned_ptr;

return slab->bucket->size - diff;
}

umf_result_t disjoint_pool_free(void *pool, void *ptr) {
Expand Down
18 changes: 9 additions & 9 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,26 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
tracker_alloc_info_t *lowValue = (tracker_alloc_info_t *)critnib_get(
provider->hTracker->alloc_segments_map, (uintptr_t)lowPtr);
if (!lowValue) {
LOG_ERR("no left value");
LOG_FATAL("no left value");
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
goto err;
goto err_assert;
}
tracker_alloc_info_t *highValue = (tracker_alloc_info_t *)critnib_get(
provider->hTracker->alloc_segments_map, (uintptr_t)highPtr);
if (!highValue) {
LOG_ERR("no right value");
LOG_FATAL("no right value");
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
goto err;
goto err_assert;
}
if (lowValue->pool != highValue->pool) {
LOG_ERR("pool mismatch");
LOG_FATAL("pool mismatch");
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
goto err;
goto err_assert;
}
if (lowValue->size + highValue->size != totalSize) {
LOG_ERR("lowValue->size + highValue->size != totalSize");
LOG_FATAL("lowValue->size + highValue->size != totalSize");
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
goto err;
goto err_assert;
}

ret = umfMemoryProviderAllocationMerge(provider->hUpstream, lowPtr, highPtr,
Expand Down Expand Up @@ -342,7 +342,7 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,

return UMF_RESULT_SUCCESS;

err:
err_assert:
assert(0);

not_merged:
Expand Down
14 changes: 14 additions & 0 deletions test/coarse_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_provider) {
ASSERT_EQ(coarse_get_stats(ch).alloc_size, alloc_size);
ASSERT_EQ(coarse_get_stats(ch).num_all_blocks, 1);

// test double free
umf_result = coarse_free(ch, ptr, 2 * MB);
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
ASSERT_EQ(coarse_get_stats(ch).used_size, 0);
ASSERT_EQ(coarse_get_stats(ch).alloc_size, alloc_size);
ASSERT_EQ(coarse_get_stats(ch).num_all_blocks, 1);

coarse_delete(ch);
umfMemoryProviderDestroy(malloc_memory_provider);
}
Expand Down Expand Up @@ -202,6 +209,13 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_fixed_memory) {
ASSERT_EQ(coarse_get_stats(ch).alloc_size, buff_size);
ASSERT_EQ(coarse_get_stats(ch).num_all_blocks, 1);

// test double free
umf_result = coarse_free(ch, ptr, 2 * MB);
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
ASSERT_EQ(coarse_get_stats(ch).used_size, 0);
ASSERT_EQ(coarse_get_stats(ch).alloc_size, buff_size);
ASSERT_EQ(coarse_get_stats(ch).num_all_blocks, 1);

coarse_delete(ch);
}

Expand Down
46 changes: 45 additions & 1 deletion test/common/pool.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 All @@ -19,6 +19,7 @@

#include <umf/base.h>
#include <umf/memory_provider.h>
#include <umf/pools/pool_disjoint.h>

#include "base.hpp"
#include "cpp_helpers.hpp"
Expand Down Expand Up @@ -150,6 +151,49 @@ struct malloc_pool : public pool_base_t {
umf_memory_pool_ops_t MALLOC_POOL_OPS =
umf::poolMakeCOps<umf_test::malloc_pool, void>();

static constexpr size_t DEFAULT_DISJOINT_SLAB_MIN_SIZE = 4096;
static constexpr size_t DEFAULT_DISJOINT_MAX_POOLABLE_SIZE = 4096;
static constexpr size_t DEFAULT_DISJOINT_CAPACITY = 4;
static constexpr size_t DEFAULT_DISJOINT_MIN_BUCKET_SIZE = 64;

inline void *defaultDisjointPoolConfig() {
umf_disjoint_pool_params_handle_t config = nullptr;
umf_result_t res = umfDisjointPoolParamsCreate(&config);
if (res != UMF_RESULT_SUCCESS) {
throw std::runtime_error("Failed to create pool params");
}
res = umfDisjointPoolParamsSetSlabMinSize(config,
DEFAULT_DISJOINT_SLAB_MIN_SIZE);
if (res != UMF_RESULT_SUCCESS) {
umfDisjointPoolParamsDestroy(config);
throw std::runtime_error("Failed to set slab min size");
}
res = umfDisjointPoolParamsSetMaxPoolableSize(
config, DEFAULT_DISJOINT_MAX_POOLABLE_SIZE);
if (res != UMF_RESULT_SUCCESS) {
umfDisjointPoolParamsDestroy(config);
throw std::runtime_error("Failed to set max poolable size");
}
res = umfDisjointPoolParamsSetCapacity(config, DEFAULT_DISJOINT_CAPACITY);
if (res != UMF_RESULT_SUCCESS) {
umfDisjointPoolParamsDestroy(config);
throw std::runtime_error("Failed to set capacity");
}
res = umfDisjointPoolParamsSetMinBucketSize(
config, DEFAULT_DISJOINT_MIN_BUCKET_SIZE);
if (res != UMF_RESULT_SUCCESS) {
umfDisjointPoolParamsDestroy(config);
throw std::runtime_error("Failed to set min bucket size");
}

return config;
}

inline umf_result_t defaultDisjointPoolConfigDestroy(void *config) {
return umfDisjointPoolParamsDestroy(
static_cast<umf_disjoint_pool_params_handle_t>(config));
}

} // namespace umf_test

#endif /* UMF_TEST_POOL_HPP */
15 changes: 9 additions & 6 deletions test/memoryPoolAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "test_helpers.h"

#include <umf/memory_provider.h>
#include <umf/pools/pool_disjoint.h>
#include <umf/pools/pool_proxy.h>

#ifdef UMF_PROXY_LIB_ENABLED
Expand Down Expand Up @@ -295,12 +296,14 @@ TEST_F(tagTest, SetAndGetInvalidPool) {

INSTANTIATE_TEST_SUITE_P(
mallocPoolTest, umfPoolTest,
::testing::Values(poolCreateExtParams{&MALLOC_POOL_OPS, nullptr, nullptr,
&UMF_NULL_PROVIDER_OPS, nullptr,
nullptr},
poolCreateExtParams{umfProxyPoolOps(), nullptr, nullptr,
&BA_GLOBAL_PROVIDER_OPS, nullptr,
nullptr}));
::testing::Values(
poolCreateExtParams{&MALLOC_POOL_OPS, nullptr, nullptr,
&UMF_NULL_PROVIDER_OPS, nullptr, nullptr},
poolCreateExtParams{umfProxyPoolOps(), nullptr, nullptr,
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr},
poolCreateExtParams{umfDisjointPoolOps(), defaultDisjointPoolConfig,
defaultDisjointPoolConfigDestroy,
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr}));

INSTANTIATE_TEST_SUITE_P(mallocMultiPoolTest, umfMultiPoolTest,
::testing::Values(poolCreateExtParams{
Expand Down
Loading
Loading