From 9ba4d6206bd8405aaca88c679f19298a529b4ccb Mon Sep 17 00:00:00 2001 From: Rafal Rudnicki Date: Wed, 22 Jul 2026 07:32:58 +0000 Subject: [PATCH 1/2] Always use relaxed allocation limits for L0 host mem --- src/provider/provider_level_zero.c | 26 ++++++++++++++++---------- test/providers/provider_level_zero.cpp | 8 ++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/provider/provider_level_zero.c b/src/provider/provider_level_zero.c index aec65fc566..3d07bd1737 100644 --- a/src/provider/provider_level_zero.c +++ b/src/provider/provider_level_zero.c @@ -143,10 +143,10 @@ static void store_last_native_error(int32_t native_error) { struct ctl ze_memory_ctl_root; static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT; -static ze_relaxed_allocation_limits_exp_desc_t relaxed_device_allocation_desc = - {.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC, - .pNext = NULL, - .flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE}; +static ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc = { + .stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC, + .pNext = NULL, + .flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE}; static ze_external_memory_export_desc_t memory_export_desc = { .stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC, @@ -530,6 +530,13 @@ static umf_result_t ze_memory_provider_alloc_helper(void *provider, size_t size, .stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, .pNext = NULL, .flags = 0}; + void *lastNext = &host_desc.pNext; + + // add relaxed allocation desc to the pNext chain + ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc_copy = + relaxed_allocation_desc; + *(void **)lastNext = &relaxed_allocation_desc_copy; + ze_result = g_ze_ops.zeMemAllocHost(ze_provider->context, &host_desc, size, alignment, resultPtr); break; @@ -542,13 +549,12 @@ static umf_result_t ze_memory_provider_alloc_helper(void *provider, size_t size, .ordinal = ze_provider->device_ordinal}; void *lastNext = &dev_desc.pNext; - ze_relaxed_allocation_limits_exp_desc_t - relaxed_device_allocation_desc_copy = - relaxed_device_allocation_desc; + ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc_copy = + relaxed_allocation_desc; if (use_relaxed_allocation(ze_provider, size)) { // add relaxed allocation desc to the pNext chain - *(void **)lastNext = &relaxed_device_allocation_desc_copy; - lastNext = &relaxed_device_allocation_desc_copy.pNext; + *(void **)lastNext = &relaxed_allocation_desc_copy; + lastNext = &relaxed_allocation_desc_copy.pNext; } // check if the allocation should use import / export mechanism @@ -573,7 +579,7 @@ static umf_result_t ze_memory_provider_alloc_helper(void *provider, size_t size, ze_device_mem_alloc_desc_t dev_desc = { .stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC, .pNext = use_relaxed_allocation(ze_provider, size) - ? &relaxed_device_allocation_desc + ? &relaxed_allocation_desc : NULL, .flags = 0, .ordinal = ze_provider->device_ordinal}; diff --git a/test/providers/provider_level_zero.cpp b/test/providers/provider_level_zero.cpp index 1894d0aa4e..d77f715403 100644 --- a/test/providers/provider_level_zero.cpp +++ b/test/providers/provider_level_zero.cpp @@ -538,6 +538,13 @@ TEST(umfLevelZeroProviderOps, default_name_null_handle) { } TEST_P(umfLevelZeroProviderTest, allocInvalidSize) { + if (GetParam() == UMF_MEMORY_TYPE_HOST) { + // For host memory, even with relaxed limits, the allocation may + // succeed or fail depending on the system's available memory, + // so we skip this test for host memory type. + GTEST_SKIP() << "Skipping test for host memory type."; + } + umf_memory_provider_handle_t provider = nullptr; umf_result_t umf_result = umfMemoryProviderCreate( umfLevelZeroMemoryProviderOps(), params, &provider); @@ -547,6 +554,7 @@ TEST_P(umfLevelZeroProviderTest, allocInvalidSize) { void *ptr = nullptr; umf_result = umfMemoryProviderAlloc( provider, std::numeric_limits::max(), 0, &ptr); + ASSERT_EQ(umf_result, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC); const char *message; int32_t error; From 770abef36e3c342169a73162964f761454068715 Mon Sep 17 00:00:00 2001 From: Rafal Rudnicki Date: Thu, 23 Jul 2026 08:50:58 +0000 Subject: [PATCH 2/2] Update compatibility tests list in CI --- .github/workflows/reusable_compatibility.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable_compatibility.yml b/.github/workflows/reusable_compatibility.yml index f3088a2a1d..e5673f9a3b 100644 --- a/.github/workflows/reusable_compatibility.yml +++ b/.github/workflows/reusable_compatibility.yml @@ -385,16 +385,22 @@ jobs: UMF_LOG: level:warning;flush:debug;output:stderr;pid:no LD_LIBRARY_PATH: ${{github.workspace}}/latest_version/build/lib/ run: | - ctest --verbose -E "test_memoryProvider|test_disjoint_pool" + ctest --verbose -E "test_memoryProvider|test_disjoint_pool|test_provider_level_zero|test_provider_level_zero_dlopen_global|test_provider_level_zero_dlopen_local" - name: Run disabled tests individually with latest UMF libs (warnings enabled) working-directory: ${{github.workspace}}/tag_version/build env: UMF_LOG: level:warning;flush:debug;output:stderr;pid:no LD_LIBRARY_PATH: ${{github.workspace}}/latest_version/build/lib/ + MATRIX_PROVIDER: ${{matrix.provider}} run: | test/test_memoryProvider --gtest_filter="-*Trace" test/test_disjoint_pool --gtest_filter="-test.internals" + if [[ "$MATRIX_PROVIDER" == "LEVEL_ZERO" ]]; then + test/test_provider_level_zero --gtest_filter="-*allocInvalidSize/2" + test/test_provider_level_zero_dlopen_global --gtest_filter="-*allocInvalidSize/2" + test/test_provider_level_zero_dlopen_local --gtest_filter="-*allocInvalidSize/2" + fi # Browse all folders in the examples directory, build them using the # latest UMF version, and run them, excluding those in the exclude list.