Skip to content

Commit

Permalink
Merge 'trilinos/Trilinos:develop' (eff2948) into 'tcad-charon/Trilino…
Browse files Browse the repository at this point in the history
…s:develop' (e6cf0b1).

* trilinos-develop:
  Make zoltan2 UVM free (trilinos#9384)
  • Loading branch information
Charonops Jenkins Pipeline committed Jul 20, 2021
2 parents e6cf0b1 + eff2948 commit da16835
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ set (Anasazi_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (Domi_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (Kokkos_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (KokkosKernels_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (MueLu_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (NOX_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (ROL_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
set (Sacado_ENABLE_TESTS OFF CACHE BOOL "Turn off tests for non-UVM build")
Expand Down
12 changes: 6 additions & 6 deletions packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ namespace MueLu {
}

ArrayRCP<const SC> nullspaceRCP, nullspaceImpRCP;
ArrayView<const SC> nullspace, nullspaceImp;
nullspaceRCP = Nullspace->getData(0);
nullspace = nullspaceRCP();
nullspaceImpRCP = NullspaceImp->getData(0);
nullspaceImp = nullspaceImpRCP();

RCP<CrsMatrixWrap> Acrs = rcp_dynamic_cast<CrsMatrixWrap>(A);

TEUCHOS_TEST_FOR_EXCEPTION(Acrs.is_null(), Exceptions::RuntimeError,
Expand All @@ -202,6 +196,12 @@ namespace MueLu {
SC normalization = Nullspace->getVector(0)->norm2();
normalization = Teuchos::ScalarTraits<Scalar>::one()/(normalization*normalization);

ArrayView<const SC> nullspace, nullspaceImp;
nullspaceRCP = Nullspace->getData(0);
nullspace = nullspaceRCP();
nullspaceImpRCP = NullspaceImp->getData(0);
nullspaceImp = nullspaceImpRCP();

// form nullspace * nullspace^T
for (size_t i = 0; i < N; i++) {
newRowPointers[i] = i*M;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ inline std::string tolower(const std::string & str) {
std::vector<std::set<LocalOrdinal>> seedSets(spaceDim+1);

int numCells = elementToNodeMap.extent(0);
auto elementToNodeMap_host = Kokkos::create_mirror_view(elementToNodeMap);
Kokkos::deep_copy(elementToNodeMap_host,elementToNodeMap);
for (int cellOrdinal=0; cellOrdinal<numCells; cellOrdinal++)
{
for (int d=0; d<=spaceDim; d++)
Expand All @@ -155,7 +157,7 @@ inline std::string tolower(const std::string & str) {
for (int basisOrdinalOrdinal=0; basisOrdinalOrdinal<dofCount; basisOrdinalOrdinal++)
{
int basisOrdinal = basis->getDofOrdinal(d,subcord,basisOrdinalOrdinal);
int colLID = elementToNodeMap(cellOrdinal,basisOrdinal);
int colLID = elementToNodeMap_host(cellOrdinal,basisOrdinal);
if (colLID != Teuchos::OrdinalTraits<LO>::invalid())
{
GlobalOrdinal colGID = columnMap.getGlobalElement(colLID);
Expand Down Expand Up @@ -293,24 +295,27 @@ void GenerateLoNodeInHiViaGIDs(const std::vector<std::vector<size_t> > & candida
size_t lo_nperel = candidates.size();
Kokkos::resize(lo_elemToHiRepresentativeNode,numElem, lo_nperel);


auto lo_elemToHiRepresentativeNode_host = Kokkos::create_mirror_view(lo_elemToHiRepresentativeNode);
auto hi_elemToNode_host = Kokkos::create_mirror_view(hi_elemToNode);
Kokkos::deep_copy(hi_elemToNode_host, hi_elemToNode);
for(size_t i=0; i<numElem; i++)
for(size_t j=0; j<lo_nperel; j++) {
if(candidates[j].size() == 1)
lo_elemToHiRepresentativeNode(i,j) = hi_elemToNode(i,candidates[j][0]);
lo_elemToHiRepresentativeNode_host(i,j) = hi_elemToNode_host(i,candidates[j][0]);
else {
// First we get the GIDs for each candidate
std::vector<GO> GID(candidates[j].size());
for(size_t k=0; k<(size_t)candidates[j].size(); k++)
GID[k] = hi_columnMap->getGlobalElement(hi_elemToNode(i,candidates[j][k]));
GID[k] = hi_columnMap->getGlobalElement(hi_elemToNode_host(i,candidates[j][k]));

// Find the one with smallest GID
size_t which = std::distance(GID.begin(),std::min_element(GID.begin(),GID.end()));

// Record this
lo_elemToHiRepresentativeNode(i,j) = hi_elemToNode(i,candidates[j][which]);
lo_elemToHiRepresentativeNode_host(i,j) = hi_elemToNode_host(i,candidates[j][which]);
}
}
Kokkos::deep_copy(lo_elemToHiRepresentativeNode, lo_elemToHiRepresentativeNode_host);
}

/*********************************************************************************************************/
Expand Down Expand Up @@ -340,10 +345,12 @@ void BuildLoElemToNodeViaRepresentatives(const LOFieldContainer & hi_elemToNode,
Kokkos::resize(lo_elemToNode,numElem, lo_nperel);

// Start by flagginc the representative nodes
auto lo_elemToHiRepresentativeNode_host = Kokkos::create_mirror_view(lo_elemToHiRepresentativeNode);
Kokkos::deep_copy(lo_elemToHiRepresentativeNode_host, lo_elemToHiRepresentativeNode);
std::vector<bool> is_low_order(hi_numNodes,false);
for(size_t i=0; i<numElem; i++)
for(size_t j=0; j<lo_nperel; j++) {
LO id = lo_elemToHiRepresentativeNode(i,j);
LO id = lo_elemToHiRepresentativeNode_host(i,j);
is_low_order[id] = true; // This can overwrite and that is OK.
}

Expand All @@ -367,9 +374,10 @@ void BuildLoElemToNodeViaRepresentatives(const LOFieldContainer & hi_elemToNode,
}

// Translate lo_elemToNode to a lo local index
auto lo_elemToNode_host = Kokkos::create_mirror_view(lo_elemToNode);
for(size_t i=0; i<numElem; i++)
for(size_t j=0; j<lo_nperel; j++)
lo_elemToNode(i,j) = hi_to_lo_map[lo_elemToHiRepresentativeNode(i,j)];
lo_elemToNode_host(i,j) = hi_to_lo_map[lo_elemToHiRepresentativeNode_host(i,j)];


// Check for the [E|T]petra column map ordering property, namely LIDs for owned nodes should all appear first.
Expand All @@ -381,6 +389,7 @@ void BuildLoElemToNodeViaRepresentatives(const LOFieldContainer & hi_elemToNode,

if(!map_ordering_test_passed)
throw std::runtime_error("MueLu::MueLuIntrepid::BuildLoElemToNodeViaRepresentatives failed map ordering test");
Kokkos::deep_copy(lo_elemToNode, lo_elemToNode_host);

}

Expand Down Expand Up @@ -418,16 +427,19 @@ void BuildLoElemToNode(const LOFieldContainer & hi_elemToNode,

// Build lo_elemToNode (in the hi local index ordering) and flag owned ones
std::vector<bool> is_low_order(hi_numNodes,false);
auto hi_elemToNode_host = Kokkos::create_mirror_view(hi_elemToNode);
Kokkos::deep_copy(hi_elemToNode_host, hi_elemToNode);
auto lo_elemToNode_host = Kokkos::create_mirror_view(lo_elemToNode);
for(size_t i=0; i<numElem; i++)
for(size_t j=0; j<lo_nperel; j++) {
LO lid = hi_elemToNode(i,lo_node_in_hi[j]);
LO lid = hi_elemToNode_host(i,lo_node_in_hi[j]);

// Remove Dirichlet
if(hi_isDirichlet[lid])
lo_elemToNode(i,j) = LOINVALID;
lo_elemToNode_host(i,j) = LOINVALID;
else {
lo_elemToNode(i,j) = lid;
is_low_order[hi_elemToNode(i,lo_node_in_hi[j])] = true; // This can overwrite and that is OK.
lo_elemToNode_host(i,j) = lid;
is_low_order[hi_elemToNode_host(i,lo_node_in_hi[j])] = true; // This can overwrite and that is OK.
}
}

Expand All @@ -453,9 +465,10 @@ void BuildLoElemToNode(const LOFieldContainer & hi_elemToNode,
// Translate lo_elemToNode to a lo local index
for(size_t i=0; i<numElem; i++)
for(size_t j=0; j<lo_nperel; j++) {
if(lo_elemToNode(i,j) != LOINVALID)
lo_elemToNode(i,j) = hi_to_lo_map[lo_elemToNode(i,j)];
if(lo_elemToNode_host(i,j) != LOINVALID)
lo_elemToNode_host(i,j) = hi_to_lo_map[lo_elemToNode_host(i,j)];
}
Kokkos::deep_copy(lo_elemToNode, lo_elemToNode_host);

// Check for the [E|T]petra column map ordering property, namely LIDs for owned nodes should all appear first.
// Since we're injecting from the higher-order mesh, it should be true, but we should add an error check & throw in case.
Expand Down Expand Up @@ -556,15 +569,17 @@ void GenerateRepresentativeBasisNodes(const Basis & basis, const SCFieldContaine
#endif

representative_node_candidates.resize(numFieldsLo);
auto LoValues_host = Kokkos::create_mirror_view(LoValues);
Kokkos::deep_copy(LoValues_host, LoValues);
for(size_t i=0; i<numFieldsLo; i++) {
// 1st pass: find the max value
typename Teuchos::ScalarTraits<SC>::magnitudeType vmax = Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<SC>::magnitudeType>::zero();
for(size_t j=0; j<numFieldsHi; j++)
vmax = std::max(vmax,Teuchos::ScalarTraits<SC>::magnitude(LoValues(i,j)));
vmax = std::max(vmax,Teuchos::ScalarTraits<SC>::magnitude(LoValues_host(i,j)));

// 2nd pass: Find all values w/i threshhold of target
for(size_t j=0; j<numFieldsHi; j++) {
if(Teuchos::ScalarTraits<SC>::magnitude(vmax - LoValues(i,j)) < threshold*vmax)
if(Teuchos::ScalarTraits<SC>::magnitude(vmax - LoValues_host(i,j)) < threshold*vmax)
representative_node_candidates[i].push_back(j);
}
}
Expand Down Expand Up @@ -603,7 +618,8 @@ void IntrepidPCoarsenFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Generat
LocalOrdinal LOINVALID = Teuchos::OrdinalTraits<LocalOrdinal>::invalid();
FC LoValues_at_HiDofs("LoValues_at_HiDofs",numFieldsLo,numFieldsHi);
lo_basis.getValues(LoValues_at_HiDofs, hi_DofCoords, Intrepid2::OPERATOR_VALUE);

auto LoValues_at_HiDofs_host = Kokkos::create_mirror_view(LoValues_at_HiDofs);
Kokkos::deep_copy(LoValues_at_HiDofs_host, LoValues_at_HiDofs);
Kokkos::fence(); // for kernel in getValues

typedef typename Teuchos::ScalarTraits<SC>::halfPrecision SClo;
Expand All @@ -619,18 +635,20 @@ void IntrepidPCoarsenFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Generat
std::vector<bool> touched(hi_map->getNodeNumElements(),false);
Teuchos::Array<GO> col_gid(1);
Teuchos::Array<SC> val(1);
auto hi_elemToNode_host = Kokkos::create_mirror_view(hi_elemToNode);
Kokkos::deep_copy(hi_elemToNode_host, hi_elemToNode);
for(size_t i=0; i<Nelem; i++) {
for(size_t j=0; j<numFieldsHi; j++) {
LO row_lid = hi_elemToNode(i,j);
LO row_lid = hi_elemToNode_host(i,j);
GO row_gid = hi_map->getGlobalElement(row_lid);
if(hi_nodeIsOwned[row_lid] && !touched[row_lid]) {
for(size_t k=0; k<numFieldsLo; k++) {
// Get the local id in P1's column map
LO col_lid = hi_to_lo_map[hi_elemToNode(i,lo_node_in_hi[k])];
LO col_lid = hi_to_lo_map[hi_elemToNode_host(i,lo_node_in_hi[k])];
if(col_lid==LOINVALID) continue;

col_gid[0] = {lo_colMap->getGlobalElement(col_lid)};
val[0] = LoValues_at_HiDofs(k,j);
val[0] = LoValues_at_HiDofs_host(k,j);

// Skip near-zeros
if(Teuchos::ScalarTraits<SC>::magnitude(val[0]) >= effective_zero)
Expand Down Expand Up @@ -661,7 +679,12 @@ void IntrepidPCoarsenFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Generat
size_t numFieldsLo = lo_basis.getCardinality();
FC LoValues_at_HiDofs("LoValues_at_HiDofs",numFieldsLo,numFieldsHi);
lo_basis.getValues(LoValues_at_HiDofs, hi_DofCoords, Intrepid2::OPERATOR_VALUE);

auto LoValues_at_HiDofs_host = Kokkos::create_mirror_view(LoValues_at_HiDofs);
auto hi_elemToNode_host = Kokkos::create_mirror_view(hi_elemToNode);
auto lo_elemToHiRepresentativeNode_host = Kokkos::create_mirror_view(lo_elemToHiRepresentativeNode);
Kokkos::deep_copy(LoValues_at_HiDofs_host, LoValues_at_HiDofs);
Kokkos::deep_copy(hi_elemToNode_host, hi_elemToNode);
Kokkos::deep_copy(lo_elemToHiRepresentativeNode_host, lo_elemToHiRepresentativeNode);
Kokkos::fence(); // for kernel in getValues

typedef typename Teuchos::ScalarTraits<SC>::halfPrecision SClo;
Expand All @@ -679,14 +702,14 @@ void IntrepidPCoarsenFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Generat
Teuchos::Array<SC> val(1);
for(size_t i=0; i<Nelem; i++) {
for(size_t j=0; j<numFieldsHi; j++) {
LO row_lid = hi_elemToNode(i,j);
LO row_lid = hi_elemToNode_host(i,j);
GO row_gid = hi_map->getGlobalElement(row_lid);
if(hi_nodeIsOwned[row_lid] && !touched[row_lid]) {
for(size_t k=0; k<numFieldsLo; k++) {
// Get the local id in P1's column map
LO col_lid = hi_to_lo_map[lo_elemToHiRepresentativeNode(i,k)];
LO col_lid = hi_to_lo_map[lo_elemToHiRepresentativeNode_host(i,k)];
col_gid[0] = {lo_colMap->getGlobalElement(col_lid)};
val[0] = LoValues_at_HiDofs(k,j);
val[0] = LoValues_at_HiDofs_host(k,j);

// Skip near-zeros
if(Teuchos::ScalarTraits<SC>::magnitude(val[0]) >= effective_zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ namespace MueLu {
Teuchos::ArrayRCP<Scalar> diagA = Utilities::GetMatrixDiagonal(*A);
RCP<Matrix> DinvADinvAP0 = Xpetra::MatrixMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Multiply(*A, false, *DinvAP0, false, GetOStream(Statistics2), doFillComplete, optimizeStorage);
Utilities::MyOldScaleMatrix(*DinvADinvAP0, diagA, true, doFillComplete, optimizeStorage); //scale matrix with reciprocal of diag
diagA = Teuchos::ArrayRCP<Scalar>();

Numerator = VectorFactory::Build(DinvADinvAP0->getColMap(), true);
Denominator = VectorFactory::Build(DinvADinvAP0->getColMap(), true);
Expand Down Expand Up @@ -438,6 +439,7 @@ namespace MueLu {
InnerProd_local[lindices[i]] += lvals[i]*lvals[i];
}
}
InnerProd_local = Teuchos::ArrayRCP< Scalar >();

// exporter: overlapping map to nonoverlapping map (target map is unique)
Teuchos::RCP<const Export> exporter =
Expand Down Expand Up @@ -562,7 +564,7 @@ namespace MueLu {
(*temp_array)[(*NewLeftLocal)[lindices_left[i] ] ] = 0.0;
}
}

InnerProd_local = Teuchos::ArrayRCP< Scalar >();
// exporter: overlapping map to nonoverlapping map (target map is unique)
Teuchos::RCP<const Export> exporter =
ExportFactory::Build(right->getColMap(), right->getDomainMap()); // TODO: change left to right?
Expand Down
Loading

0 comments on commit da16835

Please sign in to comment.