lanl / spiner

Performance portable routines for generic, tabulated, multi-dimensional data
https://lanl.github.io/spiner
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

fix getondevice #75

Closed Yurlungur closed 1 year ago

Yurlungur commented 1 year ago

PR Summary

Even with only host context, it turns out Kokkos::Malloc and Kokkos::Free are not just the standard malloc and free. What this means is that if you build Spiner with Kokkos backend but no device, it's still dangerous to mix PORTABLE_MALLOC with free. This was causing a segfault in this particular edge case. Now fixed.

In the long term, to catch such things, we should probably add a Kokkos serial build to the Spiner CI. I didn't bother for now though.

PR Checklist

dholladay00 commented 1 year ago

The kokkos malloc behavior will be both platform and compiler dependent as well.

dholladay00 commented 1 year ago

If we match each portable malloc with a portable free wouldn't that be the best way to resolve?

Yurlungur commented 1 year ago

If we match each portable malloc with a portable free wouldn't that be the best way to resolve?

That is what this fix does. The error was that by setting AllocationStatus to allocated host, it was matching a portable malloc with a free, where it should have been a portable free.

Yurlungur commented 1 year ago

Tests pass on re-git. Pulling the trigger.