Fix floating point exception in Kokkos sort

THe current version of sort in Kokkos does not check whether the array
is of size 0, and that messes up its bin calculation. If the size of the
array is less than 2, skip the sort since the order cannot change.
This commit is contained in:
Kenneth Moreland 2023-01-25 13:52:30 -07:00
parent 89245c3df5
commit 726bb09108

@ -726,6 +726,13 @@ private:
template <typename T>
VTKM_CONT static void SortImpl(vtkm::cont::ArrayHandle<T>& values, vtkm::SortLess, std::true_type)
{
// In Kokkos 3.7, we have noticed some errors when sorting with zero-length arrays (which
// should do nothing). There is no check, and the bin size computation gets messed up.
if (values.GetNumberOfValues() <= 1)
{
return;
}
vtkm::cont::Token token;
auto portal = values.PrepareForInPlace(vtkm::cont::DeviceAdapterTagKokkos{}, token);
kokkos::internal::KokkosViewExec<T> view(portal.GetArray(), portal.GetNumberOfValues());