Skip to content
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
8 changes: 7 additions & 1 deletion .github/workflows/reusable_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 16 additions & 10 deletions src/provider/provider_level_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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};
Expand Down
8 changes: 8 additions & 0 deletions test/providers/provider_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -547,6 +554,7 @@ TEST_P(umfLevelZeroProviderTest, allocInvalidSize) {
void *ptr = nullptr;
umf_result = umfMemoryProviderAlloc(
provider, std::numeric_limits<size_t>::max(), 0, &ptr);

ASSERT_EQ(umf_result, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC);
const char *message;
int32_t error;
Expand Down
Loading