-
Notifications
You must be signed in to change notification settings - Fork 436
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
Support for C++ standard algorithms #4315
Support for C++ standard algorithms #4315
Conversation
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.
Only got through the first could of headers (up to Kokkos_ModifyingOperations.hpp) so far.
|
||
// swap | ||
template <class T> | ||
KOKKOS_INLINE_FUNCTION void swap(T& a, T& b) noexcept { |
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.
Note: this noexcept
specification differs from the one in the standard. At a minimum we should document that.
C++20 changes how swap is found. Users are no longer required to specialized std::swap; rather, they just have to put a non-member function in the same namespace as their type. Should we support that kind of lookup here?
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 added that to be consistent with std syntax - i have to read more about this.
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.
Because we need operations that cannot fail as building blocks, noexcept
really matters for the following operations (as far as optimizations made in the standard library):
Move construction
Move assignment
Swap
For swap
, noexcept
is conditional based on the noexcept
-ness of the underlying move operations until C++17, then uses the is_nothrow_swappable
trait (with the change in how swap
is called as I described in the note above).
Also, there is a subtle difference between noexcept
and not throwing. noexcept
has semantics: an exception will not escape a function marked noexcept
; rather, if one is about to escape, std::terminate
is called. In the above, I'm specifically talking about functions marked noexcept
.
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 am always unsure on this stuff. but we may just want to remove this. In particular the requirement for std::terminate if one tries to escape is kinda shitty, since it actually requires inserting a try/catch by the compiler or?
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.
Apart from critically examining #4315 (comment), SortingOperations
, MinMaxElementOperations
and PartitioningOperations
look good to me.
algorithms/src/std_algorithms/Kokkos_MinMaxElementOperations.hpp
Outdated
Show resolved
Hide resolved
algorithms/src/std_algorithms/Kokkos_PartitioningOperations.hpp
Outdated
Show resolved
Hide resolved
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.
Looks OK to me.
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.
Looks good to me!
- fix comparison between signed and unsigned integers in tests - fix return type in std::count implementation
checked the comments and it looks like its addressed
Add support for C++ standard algorithms
This adds support for C++ standard algorithms from categories A and B.
Note: replaces PR #4108.
Fixes #4075
Fixes #4076