-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix Dynamic memory space when configured with Umpire #1507
base: develop
Are you sure you want to change the base?
Conversation
New test uses all available memory spaces and reallocates memory between them. The test crashes because we assume memory is from Umpire even when it's Dynamic.
This fixes (1) Dynamic memory space allocation/reallocation and (2) reallocations betwen Dynamic memory space and Umpire spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might need to discuss this further since the proposed change might lead to unexpected behaviors.
@@ -506,3 +506,72 @@ TEST(core_memory_management, allocator_id_from_pointer) | |||
delete[] buf; | |||
} | |||
#endif | |||
|
|||
//------------------------------------------------------------------------------ | |||
TEST(core_memory_management, interspace_reallocation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gunney1 and I discussed this today, and he will rework this PR.
It seems that he has a user request to support malloc
allocations through Axom's memory_management API even when Axom is configured with Umpire.
I recommended that this new use case should use an allocator ID that is not valid with umpire (e.g. a negative number other than -1, which we currently use as our INVALID_ALLOCATOR_ID
).
He will also remove/rename the DYNAMIC_ALLOCATOR_ID
global variable, which was only recently added since the name is confusing and it uses a potentially valid Umpire allocator ID (0
)
meaning. I had confused dynamic with malloc. There was no allocator specifically for malloc/free. Now there is.
Summary
The main fixes check whether a pointer is from Umpire or an allocator id indicates Umpire. If the pointer is not Umpire, assume it's in the Dynamic memory space and deallcoate or reallocate accordingly. Without handling this in Axom, Umpire throws an exception when it tries to handle the external pointer.