-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom 'tags' to the memory pool #687
Comments
I agree with the problem statement, but we need to discuss API design (as I mentioned in the previous issue). |
I partially agree with @vinser52 - in the first case we could use either use (not existing yet) API to query memory properties or just use umfPoolByPtr() to get the pool - the type of memory is provided by the user during the pool creation. So the real problem here is to optimize the 2nd problem - get the UR pool from the UMF pool and this "tag" mechanism should help. |
That's true but there is no way to get this information back from the pool. You can call |
That's true but there is no way to get this information back from the pool. You can call Also, the application can use some 'cutom' memory type. For example, Unified Runtime has a concept of SharedReadOnly (read only on the device) memory - is this something that we want to define in UMF? |
My main point was that we need to design the proper API. The problem is clear. As a next step, I am going to capture the use cases we have so far. After that we can brainstorm on the right API. In the example you provided the required information is already somehow stored inside UMF structures (pool or provider) for example |
Agree that we could have a brainstorm about querying properties, but tags could be really useful to get e.g. UR or other user defined objects associated with UMF pools and this API is really simple - I think we could implement this |
Sure, I'm fine with having different APIs to solve 1. and 2. In this issue I just proposed |
Ahh, ok, I am not against But here are my questions/feedback:
|
|
Another question what if tag is tried to be assigned multiple time to the same pool. E.g. one client creates pool and assign tag and than another client get the poo via |
That's why I think passing the tag in create would be a bit better but for the |
With the Regarding thread-safety, it is not clear to me why we cannot support it? |
Well, that's true. User should be responsible for freeing it. It may very well be the case that 'tag' is just a magic value (i.e. uint64_t id casted to void* in which case no freeing is necessary). There's no reason we cannot support it, I was just saying that I don't see a use case for it right now. If we do, then the |
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'):
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
Implementation details
Store provided tag in the pool structure.
Meta
The text was updated successfully, but these errors were encountered: