Skip to content

Commit f758a0d

Browse files
raffenethzhou
authored andcommitted
mpl/ze: Implement MPL_gpu_ipc_handle_is_valid
Compare the allocation id of a cached IPC handle with the user buffer in communication. The enables the IPC code to release stale handles when they are detected.
1 parent cb24fef commit f758a0d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/mpl/src/gpu/mpl_gpu_ze.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,20 @@ int MPL_gpu_ipc_handle_unmap(void *ptr)
20062006

20072007
bool MPL_gpu_ipc_handle_is_valid(MPL_gpu_ipc_mem_handle_t * handle, void *ptr)
20082008
{
2009-
return true;
2009+
ze_result_t ret;
2010+
ze_device_handle_t device = NULL;
2011+
ze_memory_allocation_properties_t ptr_attr = {
2012+
.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES,
2013+
.pNext = NULL,
2014+
.type = 0,
2015+
.id = 0,
2016+
.pageSize = 0,
2017+
};
2018+
2019+
ret = zeMemGetAllocProperties(ze_context, ptr, &ptr_attr, &device);
2020+
assert(ret == ZE_RESULT_SUCCESS);
2021+
2022+
return handle->data.mem_id == ptr_attr.id;
20102023
}
20112024

20122025
/* at finalize, to free a cache entry in ipc_cache_removal cache */

0 commit comments

Comments
 (0)