393 typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinate_type;
394 typedef Xpetra::MultiVectorFactory<coordinate_type, LO, GO, NO> RealValuedMultiVectorFactory;
395 const ParameterList& pL = GetParameterList();
396 std::string nspName =
"Nullspace";
397 if (pL.isParameter(
"Nullspace name")) nspName = pL.get<std::string>(
"Nullspace name");
399 auto A = Get<RCP<Matrix>>(fineLevel,
"A");
400 auto aggregates = Get<RCP<Aggregates>>(fineLevel,
"Aggregates");
401 auto amalgInfo = Get<RCP<AmalgamationInfo>>(fineLevel,
"UnAmalgamationInfo");
402 auto fineNullspace = Get<RCP<MultiVector>>(fineLevel, nspName);
403 auto coarseMap = Get<RCP<const Map>>(fineLevel,
"CoarseMap");
404 RCP<RealValuedMultiVector> fineCoords;
405 if (bTransferCoordinates_) {
406 fineCoords = Get<RCP<RealValuedMultiVector>>(fineLevel,
"Coordinates");
409 RCP<Matrix> Ptentative;
412 if (aggregates->GetNumGlobalAggregatesComputeIfNeeded() == 0) {
413 Ptentative = Teuchos::null;
414 Set(coarseLevel,
"P", Ptentative);
417 RCP<MultiVector> coarseNullspace;
418 RCP<RealValuedMultiVector> coarseCoords;
420 if (bTransferCoordinates_) {
421 RCP<const Map> coarseCoordMap;
424 if (rcp_dynamic_cast<const StridedMap>(coarseMap) != Teuchos::null)
425 blkSize = rcp_dynamic_cast<const StridedMap>(coarseMap)->getFixedBlockSize();
430 coarseCoordMap = coarseMap;
436 coarseCoords = RealValuedMultiVectorFactory::Build(coarseCoordMap, fineCoords->getNumVectors(),
false);
439 auto uniqueMap = fineCoords->getMap();
440 RCP<RealValuedMultiVector> ghostedCoords = fineCoords;
441 if (aggregates->AggregatesCrossProcessors()) {
442 auto nonUniqueMap = aggregates->GetMap();
443 auto importer = ImportFactory::Build(uniqueMap, nonUniqueMap);
445 ghostedCoords = RealValuedMultiVectorFactory::Build(nonUniqueMap, fineCoords->getNumVectors(),
false);
446 ghostedCoords->doImport(*fineCoords, *importer, Xpetra::INSERT);
451 auto aggGraph = aggregates->GetGraph();
452 auto numAggs = aggGraph.numRows();
454 auto fineCoordsView = fineCoords->getLocalViewDevice(Tpetra::Access::ReadOnly);
455 auto coarseCoordsView = coarseCoords->getLocalViewDevice(Tpetra::Access::OverwriteAll);
461 const auto dim = fineCoords->getNumVectors();
463 typename AppendTrait<
decltype(fineCoordsView), Kokkos::RandomAccess>::type fineCoordsRandomView = fineCoordsView;
464 for (
size_t j = 0; j < dim; j++) {
465 Kokkos::parallel_for(
466 "MueLu::TentativeP::BuildCoords", Kokkos::RangePolicy<local_ordinal_type, execution_space>(0, numAggs),
467 KOKKOS_LAMBDA(
const LO i) {
471 auto aggregate = aggGraph.rowConst(i);
473 coordinate_type sum = 0.0;
474 for (
size_t colID = 0; colID < static_cast<size_t>(aggregate.length); colID++)
475 sum += fineCoordsRandomView(aggregate(colID), j);
477 coarseCoordsView(i, j) = sum / aggregate.length;
483 if (!aggregates->AggregatesCrossProcessors()) {
484 if (Xpetra::Helpers<SC, LO, GO, NO>::isTpetraBlockCrs(A)) {
485 BuildPuncoupledBlockCrs(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace,
488 BuildPuncoupled(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace, coarseLevel.
GetLevelID());
491 BuildPcoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace);
501 if (A->IsView(
"stridedMaps") ==
true)
502 Ptentative->CreateView(
"stridedMaps", A->getRowMap(
"stridedMaps"), coarseMap);
504 if (bTransferCoordinates_) {
505 Set(coarseLevel,
"Coordinates", coarseCoords);
510 RCP<const Teuchos::Comm<int>> nodeComm = Get<RCP<const Teuchos::Comm<int>>>(fineLevel,
"Node Comm");
511 Set<RCP<const Teuchos::Comm<int>>>(coarseLevel,
"Node Comm", nodeComm);
514 Set(coarseLevel,
"Nullspace", coarseNullspace);
515 Set(coarseLevel,
"P", Ptentative);
517 if (pL.get<
bool>(
"sa: keep tentative prolongator")) {
523 RCP<ParameterList> params = rcp(
new ParameterList());
524 params->set(
"printLoadBalancingInfo",
true);
532 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
533 RCP<const Map> coarseMap, RCP<Matrix>& Ptentative,
534 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
535 auto rowMap = A->getRowMap();
536 auto colMap = A->getColMap();
538 const size_t numRows = rowMap->getLocalNumElements();
539 const size_t NSDim = fineNullspace->getNumVectors();
541 typedef KokkosKernels::ArithTraits<SC> ATS;
542 using impl_SC =
typename ATS::val_type;
543 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
544 const impl_SC zero = impl_ATS::zero(), one = impl_ATS::one();
546 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
551 aggGraph = aggregates->GetGraph();
553 auto aggRows = aggGraph.row_map;
554 auto aggCols = aggGraph.entries;
562 goodMap = isGoodMap(*rowMap, *colMap);
566 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
567 "(i.e. \"matching\" row and column maps)");
576 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
578 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
579 GO globalOffset = amalgInfo->GlobalOffset();
582 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
583 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
584 const size_t numAggregates = aggregates->GetNumAggregates();
586 int myPID = aggregates->GetMap()->getComm()->getRank();
591 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
592 AggSizeType aggDofSizes;
594 if (stridedBlockSize == 1) {
598 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
600 auto sizesConst = aggregates->ComputeAggregateSizes();
601 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), sizesConst);
607 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
609 auto nodeMap = aggregates->GetMap()->getLocalMap();
610 auto dofMap = colMap->getLocalMap();
612 Kokkos::parallel_for(
613 "MueLu:TentativePF:Build:compute_agg_sizes",
range_type(0, numAggregates),
614 KOKKOS_LAMBDA(
const LO agg) {
615 auto aggRowView = aggGraph.rowConst(agg);
618 for (LO colID = 0; colID < aggRowView.length; colID++) {
619 GO nodeGID = nodeMap.getGlobalElement(aggRowView(colID));
621 for (LO k = 0; k < stridedBlockSize; k++) {
622 GO dofGID = (nodeGID - indexBase) * fullBlockSize + k + indexBase + globalOffset + stridingOffset;
624 if (dofMap.getLocalElement(dofGID) != INVALID)
628 aggDofSizes(agg + 1) = size;
635 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
636 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
640 Kokkos::parallel_scan(
641 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
642 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
643 update += aggDofSizes(i);
645 aggDofSizes(i) = update;
650 Kokkos::View<LO*, DeviceType>
agg2RowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"agg2row_map_LO"), numRows);
654 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
655 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
657 Kokkos::parallel_for(
658 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
659 KOKKOS_LAMBDA(
const LO lnode) {
660 if (procWinner(lnode, 0) == myPID) {
662 auto aggID = vertex2AggId(lnode, 0);
664 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
668 for (LO k = 0; k < stridedBlockSize; k++)
669 agg2RowMapLO(offset + k) = lnode * stridedBlockSize + k;
676 coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim,
true);
679 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
680 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
684 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
685 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
686 typedef typename local_matrix_type::index_type::non_const_type cols_type;
687 typedef typename local_matrix_type::values_type::non_const_type vals_type;
690 typedef Kokkos::View<int[10], DeviceType> status_type;
691 status_type status(
"status");
696 const ParameterList& pL = GetParameterList();
697 const bool&
doQRStep = pL.get<
bool>(
"tentative: calculate qr");
699 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
701 GetOStream(
Warnings0) <<
"TentativePFactor : for nontrivial nullspace, this may degrade performance" << std::endl;
704 size_t nnzEstimate = numRows * NSDim;
705 rows_type
rowsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_rows"), numRows + 1);
706 cols_type
colsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_cols"), nnzEstimate);
707 vals_type
valsAux(
"Ptent_aux_vals", nnzEstimate);
708 rows_type
rows(
"Ptent_rows", numRows + 1);
715 Kokkos::parallel_for(
716 "MueLu:TentativePF:BuildPuncoupled:for1",
range_type(0, numRows + 1),
717 KOKKOS_LAMBDA(
const LO row) {
720 Kokkos::parallel_for(
721 "MueLu:TentativePF:BuildUncoupled:for2",
range_type(0, nnzEstimate),
722 KOKKOS_LAMBDA(
const LO j) {
739 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
742 Kokkos::parallel_for(
743 "MueLu:TentativePF:BuildUncoupled:main_loop", policy,
744 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
745 auto agg = thread.league_rank();
753 auto norm = impl_ATS::magnitude(zero);
758 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
760 norm += dnorm * dnorm;
774 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
778 rows(localRow + 1) = 1;
784 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
785 Kokkos::deep_copy(statusHost, status);
786 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
788 std::ostringstream oss;
789 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
791 case 0: oss <<
"!goodMap is not implemented";
break;
792 case 1: oss <<
"fine level NS part has a zero column";
break;
798 Kokkos::parallel_for(
799 "MueLu:TentativePF:BuildUncoupled:main_loop_noqr", policy,
800 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
801 auto agg = thread.league_rank();
810 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
814 rows(localRow + 1) = 1;
821 Kokkos::parallel_reduce(
822 "MueLu:TentativeP:CountNNZ",
range_type(0, numRows + 1),
823 KOKKOS_LAMBDA(
const LO i,
size_t& nnz_count) {
824 nnz_count +=
rows(i);
842 Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
844 decltype(aggDofSizes ),
decltype(maxAggSize),
decltype(
agg2RowMapLO),
849 using shared_matrix = LocalQrFunctorType::shared_matrix;
851 int n = fineNSRandom.extent(1);
852 int size = shared_matrix::shmem_size(m, n) +
853 shared_matrix::shmem_size(m, m);
855 if (size < policy.scratch_size_max((
int)0))
857 else if (size < policy.scratch_size_max((
int)1))
860 throw Exceptions::RuntimeError(
"Neither L0 scratch memory (max size " + std::to_string(policy.scratch_size_max((
int)0)) +
861 "), nor L1 scratch memory (max size " + std::to_string(policy.scratch_size_max((
int)1)) +
862 ") is large enough for requested allocation of size " + std::to_string(size));
863 policy.set_scratch_size(
scratchLevel, Kokkos::PerTeam(size));
868 Kokkos::parallel_reduce(
"MueLu:TentativePF:BuildUncoupled:main_qr_loop", policy, localQRFunctor, nnz);
871 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
872 Kokkos::deep_copy(statusHost, status);
873 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
875 std::ostringstream oss;
876 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
878 case 0: oss <<
"!goodMap is not implemented";
break;
879 case 1: oss <<
"fine level NS part has a zero column";
break;
892 if (nnz != nnzEstimate) {
897 Kokkos::parallel_scan(
898 "MueLu:TentativePF:Build:compress_rows",
range_type(0, numRows + 1),
899 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
909 cols = cols_type(
"Ptent_cols", nnz);
910 vals = vals_type(
"Ptent_vals", nnz);
915 Kokkos::parallel_for(
916 "MueLu:TentativePF:Build:compress_cols_vals",
range_type(0, numRows),
917 KOKKOS_LAMBDA(
const LO i) {
918 LO rowStart =
rows(i);
923 cols(rowStart + lnnz) =
colsAux(j);
924 vals(rowStart + lnnz) =
valsAux(j);
936 GetOStream(
Runtime1) <<
"TentativePFactory : aggregates do not cross process boundaries" << std::endl;
942 local_matrix_type lclMatrix = local_matrix_type(
"A", numRows, coarseMap->getLocalNumElements(), nnz, vals,
rows, cols);
945 RCP<ParameterList> FCparams;
946 if (pL.isSublist(
"matrixmatrix: kernel params"))
947 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
949 FCparams = rcp(
new ParameterList);
952 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
953 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") +
toString(levelID));
955 auto PtentCrs = CrsMatrixFactory::Build(lclMatrix, rowMap, coarseMap, coarseMap, A->getDomainMap());
956 Ptentative = rcp(
new CrsMatrixWrap(PtentCrs));
963 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
964 RCP<const Map> coarsePointMap, RCP<Matrix>& Ptentative,
965 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
975 RCP<const Map> rowMap = A->getRowMap();
976 RCP<const Map> rangeMap = A->getRangeMap();
977 RCP<const Map> colMap = A->getColMap();
979 const size_t numFineBlockRows = rowMap->getLocalNumElements();
983 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
985 typedef KokkosKernels::ArithTraits<SC> ATS;
986 using impl_SC =
typename ATS::val_type;
987 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
988 const impl_SC one = impl_ATS::one();
991 const size_t NSDim = fineNullspace->getNumVectors();
992 auto aggSizes = aggregates->ComputeAggregateSizes();
997 aggGraph = aggregates->GetGraph();
999 auto aggRows = aggGraph.row_map;
1000 auto aggCols = aggGraph.entries;
1006 const size_t numCoarseBlockRows = coarsePointMap->getLocalNumElements() / NSDim;
1007 RCP<const Map> coarseBlockMap = MapFactory::Build(coarsePointMap->lib(),
1008 Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(),
1010 coarsePointMap->getIndexBase(),
1011 coarsePointMap->getComm());
1013 const ParameterList& pL = GetParameterList();
1023 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
1024 "(i.e. \"matching\" row and column maps)");
1033 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
1035 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
1039 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1040 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1041 const size_t numAggregates = aggregates->GetNumAggregates();
1043 int myPID = aggregates->GetMap()->getComm()->getRank();
1048 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
1049 AggSizeType aggDofSizes;
1055 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
1057 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), aggSizes);
1063 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
1064 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
1068 Kokkos::parallel_scan(
1069 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
1070 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
1071 update += aggDofSizes(i);
1073 aggDofSizes(i) = update;
1078 Kokkos::View<LO*, DeviceType> aggToRowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"aggtorow_map_LO"), numFineBlockRows);
1082 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
1083 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
1085 Kokkos::parallel_for(
1086 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
1087 KOKKOS_LAMBDA(
const LO lnode) {
1088 if (procWinner(lnode, 0) == myPID) {
1090 auto aggID = vertex2AggId(lnode, 0);
1092 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
1096 for (LO k = 0; k < stridedBlockSize; k++)
1097 aggToRowMapLO(offset + k) = lnode * stridedBlockSize + k;
1104 coarseNullspace = MultiVectorFactory::Build(coarsePointMap, NSDim,
true);
1107 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
1108 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
1110 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
1111 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
1112 typedef typename local_matrix_type::index_type::non_const_type cols_type;
1116 typedef Kokkos::View<int[10], DeviceType> status_type;
1117 status_type status(
"status");
1123 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
1129 rows_type ia(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1130 cols_type ja(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), numFineBlockRows);
1132 Kokkos::parallel_for(
1133 "MueLu:TentativePF:BlockCrs:graph_init",
range_type(0, numFineBlockRows),
1134 KOKKOS_LAMBDA(
const LO j) {
1138 if (j == (LO)numFineBlockRows - 1)
1139 ia[numFineBlockRows] = numFineBlockRows;
1143 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
1144 Kokkos::parallel_for(
1145 "MueLu:TentativePF:BlockCrs:fillGraph", policy,
1146 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1147 auto agg = thread.league_rank();
1148 Xpetra::global_size_t offset = agg;
1153 for (LO j = 0; j < aggSize; j++) {
1155 const LO localRow = aggToRowMapLO[aggDofSizes[agg] + j];
1156 const size_t rowStart = ia[localRow];
1157 ja[rowStart] = offset;
1167 rows_type i_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1169 Kokkos::parallel_scan(
1170 "MueLu:TentativePF:BlockCrs:compress_rows",
range_type(0, numFineBlockRows),
1171 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
1174 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1175 if (ja[j] != INVALID)
1177 if (
final && i == (LO)numFineBlockRows - 1)
1178 i_temp[numFineBlockRows] = upd;
1182 cols_type j_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), nnz);
1184 Kokkos::parallel_for(
1185 "MueLu:TentativePF:BlockCrs:compress_cols",
range_type(0, numFineBlockRows),
1186 KOKKOS_LAMBDA(
const LO i) {
1187 size_t rowStart = i_temp[i];
1189 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1190 if (ja[j] != INVALID) {
1191 j_temp[rowStart + lnnz] = ja[j];
1200 RCP<CrsGraph> BlockGraph = CrsGraphFactory::Build(rowMap, coarseBlockMap, ia, ja);
1204 RCP<ParameterList> FCparams;
1205 if (pL.isSublist(
"matrixmatrix: kernel params"))
1206 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
1208 FCparams = rcp(
new ParameterList);
1210 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
1211 std::string levelIDs =
toString(levelID);
1212 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") + levelIDs);
1213 RCP<const Export> dummy_e;
1214 RCP<const Import> dummy_i;
1215 BlockGraph->expertStaticFillComplete(coarseBlockMap, rowMap, dummy_i, dummy_e, FCparams);
1225 RCP<Xpetra::CrsMatrix<SC, LO, GO, NO>> P_xpetra = Xpetra::CrsMatrixFactory<SC, LO, GO, NO>::BuildBlock(BlockGraph, coarsePointMap, rangeMap, NSDim);
1226 RCP<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>> P_tpetra = rcp_dynamic_cast<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>>(P_xpetra);
1227 if (P_tpetra.is_null())
throw std::runtime_error(
"BuildPUncoupled: Matrix factory did not return a Tpetra::BlockCrsMatrix");
1228 RCP<CrsMatrixWrap> P_wrap = rcp(
new CrsMatrixWrap(P_xpetra));
1230 auto values = P_tpetra->getTpetra_BlockCrsMatrix()->getValuesDeviceNonConst();
1231 const LO stride = NSDim * NSDim;
1233 Kokkos::parallel_for(
1234 "MueLu:TentativePF:BlockCrs:main_loop_noqr", policy,
1235 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1236 auto agg = thread.league_rank();
1240 Xpetra::global_size_t offset = agg * NSDim;
1243 for (LO j = 0; j < aggSize; j++) {
1244 LO localBlockRow = aggToRowMapLO(
aggRows(agg) + j);
1245 LO rowStart = localBlockRow * stride;
1246 for (LO r = 0; r < (LO)NSDim; r++) {
1247 LO localPointRow = localBlockRow * NSDim + r;
1248 for (LO c = 0; c < (LO)NSDim; c++) {
1249 values[rowStart + r * NSDim + c] = fineNSRandom(localPointRow, c);
1255 for (LO j = 0; j < (LO)NSDim; j++)
1259 Ptentative = P_wrap;