Skip to content

Commit 1fec73e

Browse files
committed
Always use relaxed allocation limits for L0 host mem
1 parent 5d093ed commit 1fec73e

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/provider/provider_level_zero.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ static void store_last_native_error(int32_t native_error) {
143143
struct ctl ze_memory_ctl_root;
144144
static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT;
145145

146-
static ze_relaxed_allocation_limits_exp_desc_t relaxed_device_allocation_desc =
147-
{.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC,
148-
.pNext = NULL,
149-
.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE};
146+
static ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc = {
147+
.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC,
148+
.pNext = NULL,
149+
.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE};
150150

151151
static ze_external_memory_export_desc_t memory_export_desc = {
152152
.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,
530530
.stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC,
531531
.pNext = NULL,
532532
.flags = 0};
533+
void *lastNext = &host_desc.pNext;
534+
535+
// add relaxed allocation desc to the pNext chain
536+
ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc_copy =
537+
relaxed_allocation_desc;
538+
*(void **)lastNext = &relaxed_allocation_desc_copy;
539+
533540
ze_result = g_ze_ops.zeMemAllocHost(ze_provider->context, &host_desc,
534541
size, alignment, resultPtr);
535542
break;
@@ -542,13 +549,12 @@ static umf_result_t ze_memory_provider_alloc_helper(void *provider, size_t size,
542549
.ordinal = ze_provider->device_ordinal};
543550
void *lastNext = &dev_desc.pNext;
544551

545-
ze_relaxed_allocation_limits_exp_desc_t
546-
relaxed_device_allocation_desc_copy =
547-
relaxed_device_allocation_desc;
552+
ze_relaxed_allocation_limits_exp_desc_t relaxed_allocation_desc_copy =
553+
relaxed_allocation_desc;
548554
if (use_relaxed_allocation(ze_provider, size)) {
549555
// add relaxed allocation desc to the pNext chain
550-
*(void **)lastNext = &relaxed_device_allocation_desc_copy;
551-
lastNext = &relaxed_device_allocation_desc_copy.pNext;
556+
*(void **)lastNext = &relaxed_allocation_desc_copy;
557+
lastNext = &relaxed_allocation_desc_copy.pNext;
552558
}
553559

554560
// 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,
573579
ze_device_mem_alloc_desc_t dev_desc = {
574580
.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC,
575581
.pNext = use_relaxed_allocation(ze_provider, size)
576-
? &relaxed_device_allocation_desc
582+
? &relaxed_allocation_desc
577583
: NULL,
578584
.flags = 0,
579585
.ordinal = ze_provider->device_ordinal};

0 commit comments

Comments
 (0)