Tpetra: (numProcs == 1 && nonlocals_.size() > 0) with incorrect base
Created by: nschloe
The following code
#include <Teuchos_DefaultComm.hpp>
#include <Tpetra_CrsMatrix.hpp>
int main ( int argc, char *argv[] )
{
Teuchos::GlobalMPISession session(&argc, &argv, NULL);
auto comm = Teuchos::DefaultComm<int>::getComm();
const int numGlobal = 8;
auto map = Teuchos::rcp(new Tpetra::Map<int>(numGlobal, 0, comm));
std::vector<Teuchos::Tuple<int,4>> tuples =
{
Teuchos::tuple(2, 3, 4, 5),
Teuchos::tuple(4, 5, 6, 7),
Teuchos::tuple(2, 3, 6, 7),
Teuchos::tuple(2, 3, 8, 9),
Teuchos::tuple(4, 5, 8, 9)
};
// build graph
auto graph = Teuchos::rcp(new Tpetra::CrsGraph<int, int>(map, map, 0));
for (size_t k = 0; k < tuples.size(); k++) {
for (int i = 0; i < 4; i++) {
graph->insertGlobalIndices(tuples[k][i], tuples[k]);
}
}
graph->fillComplete();
// fill matrix
auto A = Teuchos::rcp(new Tpetra::CrsMatrix<double,int,int>(graph));
A->setAllToScalar(0.0);
auto vals = Teuchos::tuple(1.0, 1.1, 1.2, 1.3);
for (size_t k = 0; k < tuples.size(); k++) {
for (int i = 0; i < 4; i++) {
A->sumIntoGlobalValues(tuples[k][i], tuples[k], vals);
}
}
A->fillComplete();
return EXIT_SUCCESS;
}
errors out at the very last fillComplete
with
terminate called after throwing an instance of 'std::runtime_error'
what(): /build/trilinos-xMfrMq/trilinos-12.5~20151207030212/packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp:3596:
Throw number = 2
Throw test that evaluated to true: (numProcs == 1 && nonlocals_.size() > 0)
Tpetra::CrsMatrix<double, int, int, Kokkos::Compat::KokkosDeviceWrapperNode<Kokkos::Serial, Kokkos::HostSpace>, false>::fillComplete: cannot have nonlocal entries on a serial run. An invalid entry (i.e., with row index not in the row Map) must have been submitted to the CrsMatrix.
A fix is to manually go through the tuples
list, find out the lowest entry, and put that into Tpetra::Map
instead of 0
. Perhaps this value is something that Tpetra can fill in for me.