-
Notifications
You must be signed in to change notification settings - Fork 88
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
Make device contains
take a template key parameter
#174
Conversation
rerun tests |
Key const& k, | ||
Hash hash = Hash{}, | ||
KeyEqual key_equal = KeyEqual{}) const noexcept; | ||
__device__ std::enable_if_t<std::is_invocable_v<KeyEqual, ProbeKey, Key>, bool> contains( |
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.
__device__ std::enable_if_t<std::is_invocable_v<KeyEqual, ProbeKey, Key>, bool> contains( | |
__device__ std::enable_if_t<std::is_invocable_r_v<bool, KeyEqual, ProbeKey, Key> && std::is_invocable_r_v<bool, KeyEqual, Key, ProbeKey>, bool> contains( |
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.
The condition here is not a requirement check. It's just to differentiate CG API and non-CG API cause if we pass three template parameters to contains
, the compiler cannot know which one we are referring to. e.g. https://github.com/PointKernel/cuCollections/blob/3b0adf597ed828f3813030452fb39f9b1735c90b/tests/static_map/custom_type_test.cu#L217
This looks good to me. I will try to test and will update. |
Update: I have successfully adopted this: rapidsai/cudf#10656 (code). Thanks again for working on it. |
KeyEqual key_equal) noexcept | ||
{ | ||
static_assert(std::is_invocable_r_v<bool, KeyEqual, ProbeKey, Key>, |
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.
tbh, all these static_asserts are overkill. If someone passes in an invalid callable, it will still fail to compile, just with a different error message. This feels like a ton of complexity to maintain.
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 pointed to is_invocable
just for the purposes of documentation. I didn't intend that we need to static_assert
all of the requirements of the function.
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've removed those static_assert
as requested and updated corresponding docs.
I agree that so many asserts are painful to maintain now but the situation will be improved after the grand refactor where we only need one set of those static asserts in the base class as opposed to putting them in every involved function for all map types.
Contributes to #26
Closes #172
This PR makes the device
contains
APIs take a template key parameter. It also includesthrust::identity