Skip to content

Commit b6ec7a3

Browse files
authored
Merge pull request #1154 from oneapi-src/main
merge main to v0.12.x-dev
2 parents dcd7c9c + 9fb88d5 commit b6ec7a3

File tree

16 files changed

+181
-125
lines changed

16 files changed

+181
-125
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Ubuntu
1818
strategy:
1919
matrix:
20-
os: ['ubuntu-20.04', 'ubuntu-22.04']
20+
os: ['ubuntu-22.04', 'ubuntu-24.04']
2121
build_type: [Debug, Release]
2222
compiler: [{c: gcc, cxx: g++}]
2323
shared_library: ['OFF']
@@ -27,15 +27,6 @@ jobs:
2727
disable_hwloc: ['OFF']
2828
link_hwloc_statically: ['OFF']
2929
include:
30-
- os: 'ubuntu-20.04'
31-
build_type: Release
32-
compiler: {c: gcc-7, cxx: g++-7}
33-
shared_library: 'OFF'
34-
level_zero_provider: 'ON'
35-
cuda_provider: 'ON'
36-
install_tbb: 'ON'
37-
disable_hwloc: 'OFF'
38-
link_hwloc_statically: 'OFF'
3930
- os: 'ubuntu-22.04'
4031
build_type: Release
4132
compiler: {c: clang, cxx: clang++}

.github/workflows/reusable_compatibility.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ jobs:
9797
-DUMF_FORMAT_CODE_STYLE=OFF
9898
-DUMF_DEVELOPER_MODE=ON
9999
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
100-
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
101100
-DUMF_TESTS_FAIL_ON_SKIP=ON
102101
103102
- name: Build latest UMF
@@ -197,7 +196,6 @@ jobs:
197196
-DUMF_FORMAT_CODE_STYLE=OFF
198197
-DUMF_DEVELOPER_MODE=ON
199198
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
200-
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
201199
-DUMF_TESTS_FAIL_ON_SKIP=ON
202200
203201
- name: Build latest UMF

.github/workflows/reusable_fast.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
build_tests: 'ON'
4444
extra_build_options: '-DCMAKE_BUILD_TYPE=Release'
4545
simple_cmake: 'ON'
46-
# simplest CMake ubuntu-20.04
47-
- os: ubuntu-20.04
46+
# simplest CMake ubuntu-22.04
47+
- os: ubuntu-22.04
4848
build_tests: 'ON'
4949
extra_build_options: '-DCMAKE_BUILD_TYPE=Release'
5050
simple_cmake: 'ON'
@@ -69,19 +69,12 @@ jobs:
6969
run: vcpkg install
7070
shell: pwsh # Specifies PowerShell as the shell for running the script.
7171

72-
- name: Install dependencies (ubuntu-latest)
73-
if: matrix.os == 'ubuntu-latest'
72+
- name: Install dependencies
73+
if: matrix.os != 'windows-latest'
7474
run: |
7575
sudo apt-get update
7676
sudo apt-get install -y cmake libhwloc-dev libnuma-dev libtbb-dev
7777
78-
- name: Install dependencies (ubuntu-20.04)
79-
if: matrix.os == 'ubuntu-20.04'
80-
run: |
81-
sudo apt-get update
82-
sudo apt-get install -y cmake libnuma-dev libtbb-dev
83-
.github/scripts/install_hwloc.sh # install hwloc-2.3.0 instead of hwloc-2.1.0 present in the OS package
84-
8578
- name: Configure CMake
8679
if: matrix.simple_cmake == 'OFF'
8780
run: >

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ else()
283283

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

286-
if(CMAKE_GENERATOR STREQUAL "Ninja")
286+
if(CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL
287+
"Unix Makefiles")
287288
add_custom_command(
288289
COMMAND ${CMAKE_COMMAND}
289290
-DCMAKE_INSTALL_PREFIX=${hwloc_targ_BINARY_DIR} -B build
@@ -408,7 +409,7 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
408409
include(FetchContent)
409410

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

413414
message(
414415
STATUS

benchmark/benchmark.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static void multithreaded(benchmark::internal::Benchmark *benchmark) {
3535
benchmark->Threads(1);
3636
}
3737

38+
static void singlethreaded(benchmark::internal::Benchmark *benchmark) {
39+
benchmark->Threads(1);
40+
}
41+
3842
static void
3943
default_multiple_alloc_fix_size(benchmark::internal::Benchmark *benchmark) {
4044
benchmark->Args({10000, 1, 4096});
@@ -68,15 +72,17 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, proxy_pool,
6872
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, proxy_pool)
6973
->Apply(&default_multiple_alloc_fix_size)
7074
// reduce iterations, as this benchmark is slower than others
71-
->Iterations(50000);
75+
->Iterations(50000)
76+
->Apply(&singlethreaded);
7277

7378
UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, os_provider,
7479
fixed_alloc_size,
7580
provider_allocator<os_provider>);
7681
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, os_provider)
7782
->Apply(&default_multiple_alloc_fix_size)
7883
// reduce iterations, as this benchmark is slower than others
79-
->Iterations(50000);
84+
->Iterations(50000)
85+
->Apply(&singlethreaded);
8086

8187
UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark, disjoint_pool_fix,
8288
fixed_alloc_size,
@@ -89,8 +95,9 @@ UMF_BENCHMARK_TEMPLATE_DEFINE(multiple_malloc_free_benchmark,
8995
disjoint_pool_uniform, uniform_alloc_size,
9096
pool_allocator<disjoint_pool<os_provider>>);
9197
UMF_BENCHMARK_REGISTER_F(multiple_malloc_free_benchmark, disjoint_pool_uniform)
92-
->Apply(&default_multiple_alloc_uniform_size);
93-
// TODO: enable
98+
->Apply(&default_multiple_alloc_uniform_size)
99+
->Apply(&singlethreaded);
100+
// TODO: change to multithreaded
94101
//->Apply(&multithreaded);
95102

96103
#ifdef UMF_POOL_JEMALLOC_ENABLED

examples/ipc_level_zero/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif()
2424
include(FetchContent)
2525

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

2929
message(
3030
STATUS

examples/level_zero_shared_memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif()
2424
include(FetchContent)
2525

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

2929
message(
3030
STATUS

src/coarse/coarse.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,13 @@ umf_result_t coarse_free(coarse_t *coarse, void *ptr, size_t bytes) {
11701170
}
11711171

11721172
block_t *block = get_node_block(node);
1173-
assert(block->used);
1173+
if (!block->used) {
1174+
LOG_ERR("double free");
1175+
utils_mutex_unlock(&coarse->lock);
1176+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
1177+
}
11741178

11751179
if (bytes > 0 && bytes != block->size) {
1176-
// wrong size of allocation
11771180
LOG_ERR("wrong size of allocation");
11781181
utils_mutex_unlock(&coarse->lock);
11791182
return UMF_RESULT_ERROR_INVALID_ARGUMENT;

src/pool/pool_disjoint.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,10 @@ void *disjoint_pool_aligned_malloc(void *pool, size_t size, size_t alignment) {
752752
}
753753

754754
void *aligned_ptr = (void *)ALIGN_UP_SAFE((size_t)ptr, alignment);
755-
VALGRIND_DO_MEMPOOL_ALLOC(disjoint_pool, aligned_ptr, size);
756-
utils_annotate_memory_undefined(aligned_ptr, size);
755+
size_t diff = (ptrdiff_t)aligned_ptr - (ptrdiff_t)ptr;
756+
size_t real_size = bucket->size - diff;
757+
VALGRIND_DO_MEMPOOL_ALLOC(disjoint_pool, aligned_ptr, real_size);
758+
utils_annotate_memory_undefined(aligned_ptr, real_size);
757759

758760
utils_mutex_unlock(&bucket->bucket_lock);
759761

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

769771
size_t disjoint_pool_malloc_usable_size(void *pool, void *ptr) {
770-
(void)pool;
771-
(void)ptr;
772+
disjoint_pool_t *disjoint_pool = (disjoint_pool_t *)pool;
773+
if (ptr == NULL) {
774+
return 0;
775+
}
772776

773-
// Not supported
774-
return 0;
777+
// check if given pointer is allocated inside any Disjoint Pool slab
778+
slab_t *slab =
779+
(slab_t *)critnib_find_le(disjoint_pool->known_slabs, (uintptr_t)ptr);
780+
if (slab == NULL || ptr >= slab_get_end(slab)) {
781+
// memory comes directly from the provider
782+
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
783+
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
784+
if (ret != UMF_RESULT_SUCCESS) {
785+
return 0;
786+
}
787+
788+
return allocInfo.baseSize;
789+
}
790+
// Get the unaligned pointer
791+
// NOTE: the base pointer slab->mem_ptr needn't to be aligned to bucket size
792+
size_t chunk_idx =
793+
(((uintptr_t)ptr - (uintptr_t)slab->mem_ptr) / slab->bucket->size);
794+
void *unaligned_ptr =
795+
(void *)((uintptr_t)slab->mem_ptr + chunk_idx * slab->bucket->size);
796+
797+
ptrdiff_t diff = (ptrdiff_t)ptr - (ptrdiff_t)unaligned_ptr;
798+
799+
return slab->bucket->size - diff;
775800
}
776801

777802
umf_result_t disjoint_pool_free(void *pool, void *ptr) {

src/provider/provider_tracking.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,26 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
291291
tracker_alloc_info_t *lowValue = (tracker_alloc_info_t *)critnib_get(
292292
provider->hTracker->alloc_segments_map, (uintptr_t)lowPtr);
293293
if (!lowValue) {
294-
LOG_ERR("no left value");
294+
LOG_FATAL("no left value");
295295
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
296-
goto err;
296+
goto err_assert;
297297
}
298298
tracker_alloc_info_t *highValue = (tracker_alloc_info_t *)critnib_get(
299299
provider->hTracker->alloc_segments_map, (uintptr_t)highPtr);
300300
if (!highValue) {
301-
LOG_ERR("no right value");
301+
LOG_FATAL("no right value");
302302
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
303-
goto err;
303+
goto err_assert;
304304
}
305305
if (lowValue->pool != highValue->pool) {
306-
LOG_ERR("pool mismatch");
306+
LOG_FATAL("pool mismatch");
307307
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
308-
goto err;
308+
goto err_assert;
309309
}
310310
if (lowValue->size + highValue->size != totalSize) {
311-
LOG_ERR("lowValue->size + highValue->size != totalSize");
311+
LOG_FATAL("lowValue->size + highValue->size != totalSize");
312312
ret = UMF_RESULT_ERROR_INVALID_ARGUMENT;
313-
goto err;
313+
goto err_assert;
314314
}
315315

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

343343
return UMF_RESULT_SUCCESS;
344344

345-
err:
345+
err_assert:
346346
assert(0);
347347

348348
not_merged:

0 commit comments

Comments
 (0)