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

Don't allow calling UnorderdMap::value_at for a set #4639

Merged

Conversation

masterleinad
Copy link
Contributor

@masterleinad masterleinad commented Dec 29, 2021

Fixes #4555.

@masterleinad masterleinad force-pushed the disallow_unorderedmap_value_at_set branch from 3ff24b4 to e4be7a0 Compare December 29, 2021 21:43
@masterleinad masterleinad marked this pull request as ready for review December 29, 2021 22:34
@@ -699,7 +725,8 @@ class UnorderedMap {
/// kernel.
KOKKOS_FORCEINLINE_FUNCTION
key_type key_at(size_type i) const {
return m_keys[i < capacity() ? i : capacity()];
KOKKOS_EXPECTS(i < capacity());
Copy link
Member

Choose a reason for hiding this comment

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

The precondition check needs to be guarded for deprecated code enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would argue that returning the last element if out-of-range was just wrong/buggy. That was more like a drive-by change. If that is debatable I'm happy to just remove it.

Copy link
Member

Choose a reason for hiding this comment

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

m_keys("UnorderedMap keys", capacity() + 1),

Copy link
Member

Choose a reason for hiding this comment

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

Not defending the current design, just pointing out that the behavior is changing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See b058e08.

value_at(size_type i) const {
return m_values[is_set ? 0 : (i < capacity() ? i : capacity())];
KOKKOS_EXPECTS(i < capacity());
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about change of behavior

@masterleinad masterleinad force-pushed the disallow_unorderedmap_value_at_set branch from b058e08 to 586e7af Compare January 3, 2022 17:51
@dalg24
Copy link
Member

dalg24 commented Jan 5, 2022

@Char-Aznable would you please review?

@Char-Aznable
Copy link
Contributor

Looks good to me! Thanks for the patch!

@crtrott crtrott merged commit fea3574 into kokkos:develop Jan 5, 2022
@masterleinad masterleinad deleted the disallow_unorderedmap_value_at_set branch January 7, 2022 19:57
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.

None yet

4 participants