-
Notifications
You must be signed in to change notification settings - Fork 17
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
Release function for parsec_object_t #724
Comments
We have two proposals:
Here is another proposal:
|
All these approaches have a common issue, making impossible to properly release an object at the end of the execution (when it is really supposed to be freed). We could imagine convoluted solutions, but nothing clean and straightforward. At this point the cleanest approach would be #726 with an extra flag to the destructor. RETAIN/RELEASE could be used during the lifetime of the object (including when we expect it to be saved into some memory management structure), and DESTRUCT will be used to unconditionally release the object at any moment. This approach would solve the free problem but will break the existing relationship between CONSTRUCT/DESTRUCT and NEW/RETAIN/RELEASE as DESTRUCT is now required to be called on a NEW recycled object. Unfortunately, this does not solve the issue because DESTRUCT does not free the object. So back to square 1. |
No, releasing the memory is not an issue. If I tell you that I will handle the release of the object I will handle the release of the object. Not PaRSEC's business what I do with it. If I take it from a mempool I will put it back there and release the memory of the mempool at the end of the run. If the object is part of another object (like the GPU task in TTG) then I don't have to do anything, and we can still use #726 is not good because it leaves objects in some undefined state and it causes a huge API break. I realize that #728 suffers from the same problem. #729 is the cleanest solution as it does not break any existing code (apart from the ABI break of the |
Correctly releasing the memory is an issue because calling free on your object does not clean all the inherited classes. If you think of a simple, one-level, inheritance of a base object class then you are correct, but that's not a real solution. There is no undefined state in #726. If you are referring to the magic value, it is easy to just move its reset in the same branch as the free, and the object is always in a defined state. #729 has the same issue, in addition to only solving half of the problem (the release part but without taking care of the symmetry with the allocation). |
The object will be freed once all destructors have been called. No issue here.
Allocation is not a problem. PaRSEC itself will never allocate a user-defined object. We're only concerned about application-provided objects here and the application will not use |
Some more thoughts:
Today, we talked about the issue @abouteiller had in #623 (IIRC) that some objects are allocated dynamically while others are allocated on the stack. Maybe the right way is to add a callback to the Also, we should not call free on any object unless it has been allocated by |
Description
With #694 the GPU task structure becomes a proper PaRSEC object and carefully avoid calling
PARSEC_OBJ_RELEASE
on it to avoid freeing it explicitly and instead add a callback to free it. The regular task structure is already an object but we don't really utilize the object management macros because we want to utilize free lists, so we have a dedicated callback for its release. Data copies have to be heap allocated because they are freed so we cannot use free lists for them.Describe the solution you'd like
Instead of calling
free
inPARSEC_OBJ_RELEASE
we should unify the above approaches and add a release callback to theparsec_object_t
that allows the entity allocating it to determine the way it should be freed. Then we canPARSEC_OBJ_RELEASE
the object and the object will go back where it came from, e.g., a free-list. This avoids the careful dance we do withparsec_task_t
andparsec_gpu_task_t
and would allow the use of free lists forparsec_data_copy_t
.Describe alternatives you've considered
The current approach of type-specific deallocators is fragile and does not cover all objects that could benefit from non-standard allocation methods.
The text was updated successfully, but these errors were encountered: