-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Add custom 'tags' to the memory pool
Rationale
In UR, there are a few use-cases that we can optimize by allowing the user to associated a 'tag' with the memory pool (and to later, query the 'tag'):
- Calls to zeMemGetAllocProperties (quite expensive) in L0 adapter: https://github.com/oneapi-src/unified-runtime/blob/main/source/adapters/level_zero/memory.cpp#L51
- Quite convoluted logic for finding ur_usm_pool_handle_t for a given ptr: https://github.com/oneapi-src/unified-runtime/blob/d61cf6680c7f620bd5092e2bb22524106fbdef63/source/adapters/level_zero/usm.cpp#L637
Description
Add one extra void *tag
argument to umfPoolCreate and allow querying it later. Tag can point to a user-provided structure that user is responsible for freeing.
In UR we can create a custom structure struct pool_tag { ur_memory_type type; ur_usm_pool_handle_t urPool; }
and store a pointer to that structure as a tag for each umf pool. This will make calls to zeMemGetAllocProperties unnecessary and logic for finding ur_usm_pool_handle_t will be just ((pool_tag *) umfPoolGetTag(umfPoolByPtr(ptr)))-> urPool
API Changes
umf_result_t umfPoolCreate(const umf_memory_pool_ops_t *ops,
umf_memory_provider_handle_t provider, void *params,
void *tag, // <- NEW PARAMETER
umf_pool_create_flags_t flags,
umf_memory_pool_handle_t *hPool);
void *umfPoolGetTag(umf_memory_pool_handle_t hPool);
Implementation details
Store provided tag in the pool structure.
Meta
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request