-
Notifications
You must be signed in to change notification settings - Fork 0
Better allocator support #2
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
base: master
Are you sure you want to change the base?
Conversation
… Umpire for SplitVectors
…stalled and found
markusbattarbee
left a comment
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.
Didn't look through tests yet, but some commentary and fix suggestions.
markusbattarbee
left a comment
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.
Bump
| } | ||
| return elements.size(); | ||
| } | ||
|
|
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.
up - what I mean is that with Allocator support, will the old versions (which do not template allocators) ever be called anymore? Or could they be safely deleted?
|
What do you think, how much work would it be to test this also with MallocMC? That would be nice to report. :) Also, in case you didn't notice, there's some merge conflicts that still need resolving. |
markusbattarbee
left a comment
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.
A few major things still, please.
| } | ||
| return elements.size(); | ||
| } | ||
|
|
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.
That's a lot of code duplication :( Couldn't you put the default allocator as the default argument to this templated function? (same thing as in split_tools.h line 104)
include/splitvector/splitvec.h
Outdated
| HOSTONLY void copyMetadata(SplitInfo* dst, split_gpuStream_t s = 0) { | ||
| SPLIT_CHECK_ERR(split_gpuMemcpyAsync(&dst->size, _size, sizeof(size_t), split_gpuMemcpyDeviceToHost, s)); | ||
| SPLIT_CHECK_ERR(split_gpuMemcpyAsync(&dst->capacity, _capacity, sizeof(size_t), split_gpuMemcpyDeviceToHost, s)); | ||
| SPLIT_CHECK_ERR(split_gpuMemcpyAsync(&dst->size, _info, sizeof(SplitInfo), split_gpuMemcpyDeviceToHost, s)); |
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.
still needs changing to point to just dst
| assert(0 && "Splitvector has a catastrophic failure trying to resize on device."); | ||
| } | ||
| if (construct) { | ||
| if constexpr (!std::is_trivially_copy_constructible_v<T> ){ |
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.
Well, in that case there needs to be some other workaround - by default, a vector of a given size has all elements set to zero. This must still hold true for SplitVector. If necessary, you can add:
if (_construct) {
for (size_t i = size(); i < newSize; ++i) {
data[i] = T();
}
}
or something similar, I guess. Ugly, but potentially needs to be done.
Or can you check somehow if the allocator has a construct method? Make an issue about it on the Umpire repo?
|
|
||
| // Allocate with Mempool | ||
| const size_t memory_for_pool = 8 * nBlocks * sizeof(uint32_t); | ||
| splitStackArena mPool(memory_for_pool, s); |
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.
🤔
…tion" This reverts commit 27789a6.
|
|
|
||
| // Allocate with Mempool | ||
| const size_t memory_for_pool = 8 * nBlocks * sizeof(uint32_t); | ||
| splitStackArena mPool(memory_for_pool, s); |
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.
IMO the allocator should be the one handling the memory pools.
| } | ||
| #if defined(__HIP__) && !defined(AMD_COHERENCE_FINE) | ||
| int device; | ||
| SPLIT_CHECK_ERR(split_gpuGetDevice(&device)); |
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.
<3
|
In general I would like to see less code duplication as that leads to potential issues in future development, having to fix things in several places, but I guess it's out of my hands now :) |
So in this PR there is some pruning in the SplitVector code to enable the use of external allocators such as Umpire. This PR enables Hashinator as well to propagate the allocators to SplitVector. A citation methods has also been added and as well as some changes to the README.
split::split_host_allocatoris not needed anymore an replace withstd::allocatorsizeof(T)is enormous this approach is not efficient, but since Hashinator and SplitVectors are meant to be used with trivial types this is rather unlikely.