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

Add specialization for is_bitwise_comparable<cuco::pair>> #335

Closed
wants to merge 2 commits into from

Conversation

sleeepyjack
Copy link
Collaborator

This PR fixes a bug introduced with the new open_addressing_impl abstraction layer:
Tl;dr, for the packed_cas code path in cuco::experimental::static_map::insert() we need to bitwise_compare a cuco::pair. However, since cuco::pair has no unique object representation by default, it is not is_bitwise_comparable. Compilation fails with an assertion error here.

This PR adds the missing specialization for is_bitwise_comparable<cuco::pair>.

@sleeepyjack sleeepyjack added type: bug Something isn't working P0: Must have Critical feature or bug fix Needs Review Awaiting reviews before merging labels Jul 18, 2023
* @brief A pair of bitwise comparable types is also bitwise comparable
*/
template <typename First, typename Second>
struct is_bitwise_comparable<pair<First, Second>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is dangerous. If someone used a pair<char, int> as their key type, then it would be considered bitwise comparable, even though it would have padding bits.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. would adding && sizeof(pair<First, Second>) == sizeof(First)+sizeof(Second) help?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remind me where we need to perform a bitwise equality on a pair?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here: https://github.com/NVIDIA/cuCollections/blob/a2833dbfb1b7d4915d530bd6adb45092a87a3b07/include/cuco/detail/open_addressing_ref_impl.cuh#L659C5-L659C76

For a static_map, the value_type of the underlying open_addressing_impl is cuco::pair<Key, Value>.

@PointKernel
Copy link
Member

@sleeepyjack This can be closed.

The work is replaced by #356 since the root cause is that we shouldn't compare the whole slot for map key equality checks.

@PointKernel PointKernel added invalid This doesn't seem right and removed P0: Must have Critical feature or bug fix Needs Review Awaiting reviews before merging labels Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right type: bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants