-
Notifications
You must be signed in to change notification settings - Fork 407
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
sorting an empty view should exit early and not fail #6130
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.
What about BinSort::sort
?
yes that too, i am working on it... have not pushed yet. I was unsure whether to make a separate PR just for that. I will jsut add it here |
sort
or BinSort::sort
on an empty view should exit early and not fail
sort
or BinSort::sort
on an empty view should exit early and not failsort
or BinSort::sort
or BinSort::create_permute_vector
on an empty view should exit early and not fail
sort
or BinSort::sort
or BinSort::create_permute_vector
on an empty view should exit early and not faile88833b
to
b63d807
Compare
What did you change? |
change what? I only rebased on develop |
Why bother? Anyway too late. I plan on merging after the CI completes |
habit of keeping things updated so that no surprises come up after merging (maybe in this case does not matter, but in general does) |
So you know we test your PR merged into develop unless there is conflict in which we can't merge anyway. |
Now I know :) thanks! |
* sorting an empty view should not fail * fix binsort too * fix unused * fix test * add comment * address review comments * add fences * address comments * address comments * remove unused
sort
The current impl of
sort
does not handle nor test the special case of an empty view.Passing an empty view to sort should not fail.
Currently, the code fails because if we look here:
kokkos/algorithms/src/Kokkos_Sort.hpp
Lines 607 to 640 in 3f602b6
when
view
is empty, the reduction does not happen and soresult
contains the reduction_identity values.Since those values are not equal, the following if is not satisfied:
and the code fails because it hits this:
BinSort
For BinSort there is a similar problem here:
kokkos/algorithms/src/Kokkos_Sort.hpp
Lines 327 to 331 in 3f602b6
Comments
Note that an empty view is not a precondition violation.
Also, the std lib behaves similarly: if we try to call std::sort on an empty vector the code does not crash.
When merging, need to be careful with #6081