Skip to content
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

Better allocator support #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

kstppd
Copy link
Collaborator

@kstppd kstppd commented Sep 6, 2024

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.

  • The split::split_host_allocator is not needed anymore an replace with std::allocator
  • The metadata size and capacity are now allocated by the template allocator in splitvector. This enables us to use a standardized allocators but comes with the hacky part of some extra type casting that needs to take place. In cases where sizeof(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.

@kstppd kstppd marked this pull request as ready for review September 27, 2024 07:47
Copy link

@markusbattarbee markusbattarbee left a 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.

include/hashinator/hashinator.h Outdated Show resolved Hide resolved
include/hashinator/hashinator.h Show resolved Hide resolved
include/hashinator/hashinator.h Outdated Show resolved Hide resolved
include/hashinator/hashinator.h Outdated Show resolved Hide resolved
include/hashinator/hashinator.h Show resolved Hide resolved
include/splitvector/splitvec.h Outdated Show resolved Hide resolved
include/splitvector/splitvec.h Outdated Show resolved Hide resolved
include/splitvector/splitvec.h Outdated Show resolved Hide resolved
include/splitvector/splitvec.h Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump

@@ -85,8 +95,7 @@ class Hashmap {
void preallocate_device_handles() {
#ifndef HASHINATOR_CPU_ONLY_MODE
SPLIT_CHECK_ERR(split_gpuMalloc((void**)&device_map, sizeof(Hashmap)));
device_buckets = reinterpret_cast<split::SplitVector<hash_pair<KEY_TYPE, VAL_TYPE>>*>(
reinterpret_cast<char*>(device_map) + offsetof(Hashmap, buckets));
device_buckets = &device_map->buckets;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in fact now doing the same thing and usint the arrow operator after the address in order to get an offsetof? Because if it isn't, then this would be trying to store a device-side value to the host here.

include/hashinator/hashinator.h Show resolved Hide resolved
@@ -1214,6 +1246,24 @@ class Hashmap {
}
return elements.size();
}

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?

defaults::WARPSIZE>(buckets, elements, rule, stack, max_size, s);
return elements.size();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up

return std::nullopt;
}
}
return std::nullopt;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you changed assertions to be a nullopt. How would the user catch that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user tries to access this nullopt a bad access exception will be thrown had the key not been in the map. But I really do not like this change so I take it back.

*this = SplitVector<T, Allocator>(1, std::move(val));
return;
}
// if (_data == nullptr) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this also an assert?

include/splitvector/splitvec.h Show resolved Hide resolved
include/splitvector/splitvec.h Show resolved Hide resolved
include/splitvector/splitvec.h Show resolved Hide resolved
@@ -322,8 +355,8 @@ class Hashmap {
// DeviceHasher::reset_all(buckets.data(),_mapInfo, buckets.size(), s);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting comment here: On line 326, the mallocation of a temporary buffer should surely happen with the provided allocator.

Same on line 1339 for tombstone cleaning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants