Tpetra: ImportExport2_UnitTest & FixedHashTable tests fail in debug mode; Teuchos::ArrayView ctor issue
Created by: mhoemmen
@trilinos/tpetra @trilinos/teuchos @bartlettroscoe @ibaned
Some Tpetra tests have been failing in debug mode. For example, FixedHashTable's test fails. Teuchos::ArrayView
's constructor that takes a pointer and a length throws, because the length is zero but the pointer is nonnull. When I stop ArrayView
's constructor from throwing, the test passes just fine.
This is a bit of a problem, because Kokkos::View
permits a View with a zero length to have a nonnull pointer. I can see the value of the test, but it is a bit troublesome to have to do an extra test to convert from Kokkos::View
to Teuchos::ArrayView
. Furthermore, std::vector
behaves just like Kokkos::View
, in that .data()
need not return nullptr
if the vector's length is zero.
My plan was to go through Tpetra, find all instances of that constructor, and fix them. I plan to modify the relevant conversion functions in the TeuchosKokkosCompat subpackage, and only use those. However, it seems like this could lead to trouble when attempting obvious conversions from std::vector
to Teuchos::ArrayView
. Should we consider removing this debug test?
See e.g., https://github.com/trilinos/Trilinos/issues/184 .
Expectations
Conversions from zero-length std::vector
or Kokkos::View
to Teuchos::ArrayView
should not require an extra branch just to make the pointer null if the length is zero.