Tpetra: Consolidate Node creation code in unit tests to avoid multiple Kokkos initialization & finalization cycles
Created by: mhoemmen
@trilinos/tpetra
Tpetra's current Node implementation initializes Kokkos automatically for users, if it has not yet been initialized. It uses a per-Node-class reference count to decide when to finalize Kokkos. However, Kokkos forbids multiple initialization / finalization cycles in the same run.
This works fine when applications or tests only have one Node instance. Tpetra has Node creation functions (defaultArgNode and getNode) that keep a Node instance around to avoid this problem. The issue comes up with Tpetra unit tests that, multiple times per run, create Node instances directly (without using the aforementioned creation functions), then destroy them. The reference count then goes to zero at the end of each test, so each test calls Kokkos::finalize.
To start fixing this, the best thing to do is not to create Nodes directly in tests. Instead, let Tpetra create the Node. Ideally, don't create or handle Node instances at all. This will make it easier for us to fix this issue inside Tpetra.