391 typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinate_type;
392 typedef Xpetra::MultiVectorFactory<coordinate_type, LO, GO, NO> RealValuedMultiVectorFactory;
393 const ParameterList& pL = GetParameterList();
394 std::string nspName =
"Nullspace";
395 if (pL.isParameter(
"Nullspace name")) nspName = pL.get<std::string>(
"Nullspace name");
397 auto A = Get<RCP<Matrix>>(fineLevel,
"A");
398 auto aggregates = Get<RCP<Aggregates>>(fineLevel,
"Aggregates");
399 auto amalgInfo = Get<RCP<AmalgamationInfo>>(fineLevel,
"UnAmalgamationInfo");
400 auto fineNullspace = Get<RCP<MultiVector>>(fineLevel, nspName);
401 auto coarseMap = Get<RCP<const Map>>(fineLevel,
"CoarseMap");
402 RCP<RealValuedMultiVector> fineCoords;
403 if (bTransferCoordinates_) {
404 fineCoords = Get<RCP<RealValuedMultiVector>>(fineLevel,
"Coordinates");
407 RCP<Matrix> Ptentative;
410 if (aggregates->GetNumGlobalAggregatesComputeIfNeeded() == 0) {
411 Ptentative = Teuchos::null;
412 Set(coarseLevel,
"P", Ptentative);
415 RCP<MultiVector> coarseNullspace;
416 RCP<RealValuedMultiVector> coarseCoords;
418 if (bTransferCoordinates_) {
419 RCP<const Map> coarseCoordMap;
422 if (rcp_dynamic_cast<const StridedMap>(coarseMap) != Teuchos::null)
423 blkSize = rcp_dynamic_cast<const StridedMap>(coarseMap)->getFixedBlockSize();
428 coarseCoordMap = coarseMap;
434 coarseCoords = RealValuedMultiVectorFactory::Build(coarseCoordMap, fineCoords->getNumVectors(),
false);
437 auto uniqueMap = fineCoords->getMap();
438 RCP<RealValuedMultiVector> ghostedCoords = fineCoords;
439 if (aggregates->AggregatesCrossProcessors()) {
440 auto nonUniqueMap = aggregates->GetMap();
441 auto importer = ImportFactory::Build(uniqueMap, nonUniqueMap);
443 ghostedCoords = RealValuedMultiVectorFactory::Build(nonUniqueMap, fineCoords->getNumVectors(),
false);
444 ghostedCoords->doImport(*fineCoords, *importer, Xpetra::INSERT);
449 auto aggGraph = aggregates->GetGraph();
450 auto numAggs = aggGraph.numRows();
452 auto fineCoordsView = fineCoords->getLocalViewDevice(Tpetra::Access::ReadOnly);
453 auto coarseCoordsView = coarseCoords->getLocalViewDevice(Tpetra::Access::OverwriteAll);
459 const auto dim = fineCoords->getNumVectors();
461 typename AppendTrait<
decltype(fineCoordsView), Kokkos::RandomAccess>::type fineCoordsRandomView = fineCoordsView;
462 for (
size_t j = 0; j < dim; j++) {
463 Kokkos::parallel_for(
464 "MueLu::TentativeP::BuildCoords", Kokkos::RangePolicy<local_ordinal_type, execution_space>(0, numAggs),
465 KOKKOS_LAMBDA(
const LO i) {
469 auto aggregate = aggGraph.rowConst(i);
471 coordinate_type sum = 0.0;
472 for (
size_t colID = 0; colID < static_cast<size_t>(aggregate.length); colID++)
473 sum += fineCoordsRandomView(aggregate(colID), j);
475 coarseCoordsView(i, j) = sum / aggregate.length;
481 if (!aggregates->AggregatesCrossProcessors()) {
482 if (Xpetra::Helpers<SC, LO, GO, NO>::isTpetraBlockCrs(A)) {
483 BuildPuncoupledBlockCrs(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace,
486 BuildPuncoupled(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace, coarseLevel.
GetLevelID());
489 BuildPcoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace);
499 if (A->IsView(
"stridedMaps") ==
true)
500 Ptentative->CreateView(
"stridedMaps", A->getRowMap(
"stridedMaps"), coarseMap);
502 if (bTransferCoordinates_) {
503 Set(coarseLevel,
"Coordinates", coarseCoords);
508 RCP<const Teuchos::Comm<int>> nodeComm = Get<RCP<const Teuchos::Comm<int>>>(fineLevel,
"Node Comm");
509 Set<RCP<const Teuchos::Comm<int>>>(coarseLevel,
"Node Comm", nodeComm);
512 Set(coarseLevel,
"Nullspace", coarseNullspace);
513 Set(coarseLevel,
"P", Ptentative);
515 if (pL.get<
bool>(
"sa: keep tentative prolongator")) {
521 RCP<ParameterList> params = rcp(
new ParameterList());
522 params->set(
"printLoadBalancingInfo",
true);
530 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
531 RCP<const Map> coarseMap, RCP<Matrix>& Ptentative,
532 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
533 auto rowMap = A->getRowMap();
534 auto colMap = A->getColMap();
536 const size_t numRows = rowMap->getLocalNumElements();
537 const size_t NSDim = fineNullspace->getNumVectors();
539 typedef KokkosKernels::ArithTraits<SC> ATS;
540 using impl_SC =
typename ATS::val_type;
541 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
542 const impl_SC zero = impl_ATS::zero(), one = impl_ATS::one();
544 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
549 aggGraph = aggregates->GetGraph();
551 auto aggRows = aggGraph.row_map;
552 auto aggCols = aggGraph.entries;
560 goodMap = isGoodMap(*rowMap, *colMap);
564 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
565 "(i.e. \"matching\" row and column maps)");
574 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
576 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
577 GO globalOffset = amalgInfo->GlobalOffset();
580 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
581 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
582 const size_t numAggregates = aggregates->GetNumAggregates();
584 int myPID = aggregates->GetMap()->getComm()->getRank();
589 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
590 AggSizeType aggDofSizes;
592 if (stridedBlockSize == 1) {
596 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
598 auto sizesConst = aggregates->ComputeAggregateSizes();
599 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), sizesConst);
605 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
607 auto nodeMap = aggregates->GetMap()->getLocalMap();
608 auto dofMap = colMap->getLocalMap();
610 Kokkos::parallel_for(
611 "MueLu:TentativePF:Build:compute_agg_sizes",
range_type(0, numAggregates),
612 KOKKOS_LAMBDA(
const LO agg) {
613 auto aggRowView = aggGraph.rowConst(agg);
616 for (LO colID = 0; colID < aggRowView.length; colID++) {
617 GO nodeGID = nodeMap.getGlobalElement(aggRowView(colID));
619 for (LO k = 0; k < stridedBlockSize; k++) {
620 GO dofGID = (nodeGID - indexBase) * fullBlockSize + k + indexBase + globalOffset + stridingOffset;
622 if (dofMap.getLocalElement(dofGID) != INVALID)
626 aggDofSizes(agg + 1) = size;
633 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
634 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
638 Kokkos::parallel_scan(
639 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
640 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
641 update += aggDofSizes(i);
643 aggDofSizes(i) = update;
648 Kokkos::View<LO*, DeviceType>
agg2RowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"agg2row_map_LO"), numRows);
652 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
653 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
655 Kokkos::parallel_for(
656 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
657 KOKKOS_LAMBDA(
const LO lnode) {
658 if (procWinner(lnode, 0) == myPID) {
660 auto aggID = vertex2AggId(lnode, 0);
662 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
666 for (LO k = 0; k < stridedBlockSize; k++)
667 agg2RowMapLO(offset + k) = lnode * stridedBlockSize + k;
674 coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim,
true);
677 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
678 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
682 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
683 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
684 typedef typename local_matrix_type::index_type::non_const_type cols_type;
685 typedef typename local_matrix_type::values_type::non_const_type vals_type;
688 typedef Kokkos::View<int[10], DeviceType> status_type;
689 status_type status(
"status");
694 const ParameterList& pL = GetParameterList();
695 const bool&
doQRStep = pL.get<
bool>(
"tentative: calculate qr");
697 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
699 GetOStream(
Warnings0) <<
"TentativePFactor : for nontrivial nullspace, this may degrade performance" << std::endl;
702 size_t nnzEstimate = numRows * NSDim;
703 rows_type
rowsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_rows"), numRows + 1);
704 cols_type
colsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_cols"), nnzEstimate);
705 vals_type
valsAux(
"Ptent_aux_vals", nnzEstimate);
706 rows_type
rows(
"Ptent_rows", numRows + 1);
713 Kokkos::parallel_for(
714 "MueLu:TentativePF:BuildPuncoupled:for1",
range_type(0, numRows + 1),
715 KOKKOS_LAMBDA(
const LO row) {
718 Kokkos::parallel_for(
719 "MueLu:TentativePF:BuildUncoupled:for2",
range_type(0, nnzEstimate),
720 KOKKOS_LAMBDA(
const LO j) {
737 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
740 Kokkos::parallel_for(
741 "MueLu:TentativePF:BuildUncoupled:main_loop", policy,
742 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
743 auto agg = thread.league_rank();
751 auto norm = impl_ATS::magnitude(zero);
756 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
758 norm += dnorm * dnorm;
772 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
776 rows(localRow + 1) = 1;
782 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
783 Kokkos::deep_copy(statusHost, status);
784 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
786 std::ostringstream oss;
787 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
789 case 0: oss <<
"!goodMap is not implemented";
break;
790 case 1: oss <<
"fine level NS part has a zero column";
break;
796 Kokkos::parallel_for(
797 "MueLu:TentativePF:BuildUncoupled:main_loop_noqr", policy,
798 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
799 auto agg = thread.league_rank();
808 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
812 rows(localRow + 1) = 1;
819 Kokkos::parallel_reduce(
820 "MueLu:TentativeP:CountNNZ",
range_type(0, numRows + 1),
821 KOKKOS_LAMBDA(
const LO i,
size_t& nnz_count) {
822 nnz_count +=
rows(i);
840 Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
842 decltype(aggDofSizes ),
decltype(maxAggSize),
decltype(
agg2RowMapLO),
848 using shared_matrix =
typename decltype(localQRFunctor)::shared_matrix;
850 int n = fineNSRandom.extent(1);
851 int size = shared_matrix::shmem_size(m, n) +
852 shared_matrix::shmem_size(m, m);
854 if (size < policy.scratch_size_max((
int)0))
855 policy.set_scratch_size((
int)0, Kokkos::PerTeam(size));
856 else if (size < policy.scratch_size_max((
int)1))
857 policy.set_scratch_size((
int)1, Kokkos::PerTeam(size));
859 throw Exceptions::RuntimeError(
"Neither L0 scratch memory (max size " + std::to_string(policy.scratch_size_max((
int)0)) +
860 "), nor L1 scratch memory (max size " + std::to_string(policy.scratch_size_max((
int)1)) +
861 ") is large enough for requested allocation of size " + std::to_string(size));
863 Kokkos::parallel_reduce(
"MueLu:TentativePF:BuildUncoupled:main_qr_loop", policy, localQRFunctor, nnz);
866 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
867 Kokkos::deep_copy(statusHost, status);
868 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
870 std::ostringstream oss;
871 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
873 case 0: oss <<
"!goodMap is not implemented";
break;
874 case 1: oss <<
"fine level NS part has a zero column";
break;
887 if (nnz != nnzEstimate) {
892 Kokkos::parallel_scan(
893 "MueLu:TentativePF:Build:compress_rows",
range_type(0, numRows + 1),
894 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
904 cols = cols_type(
"Ptent_cols", nnz);
905 vals = vals_type(
"Ptent_vals", nnz);
910 Kokkos::parallel_for(
911 "MueLu:TentativePF:Build:compress_cols_vals",
range_type(0, numRows),
912 KOKKOS_LAMBDA(
const LO i) {
913 LO rowStart =
rows(i);
918 cols(rowStart + lnnz) =
colsAux(j);
919 vals(rowStart + lnnz) =
valsAux(j);
931 GetOStream(
Runtime1) <<
"TentativePFactory : aggregates do not cross process boundaries" << std::endl;
937 local_matrix_type lclMatrix = local_matrix_type(
"A", numRows, coarseMap->getLocalNumElements(), nnz, vals,
rows, cols);
940 RCP<ParameterList> FCparams;
941 if (pL.isSublist(
"matrixmatrix: kernel params"))
942 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
944 FCparams = rcp(
new ParameterList);
947 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
948 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") +
toString(levelID));
950 auto PtentCrs = CrsMatrixFactory::Build(lclMatrix, rowMap, coarseMap, coarseMap, A->getDomainMap());
951 Ptentative = rcp(
new CrsMatrixWrap(PtentCrs));
958 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
959 RCP<const Map> coarsePointMap, RCP<Matrix>& Ptentative,
960 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
970 RCP<const Map> rowMap = A->getRowMap();
971 RCP<const Map> rangeMap = A->getRangeMap();
972 RCP<const Map> colMap = A->getColMap();
974 const size_t numFineBlockRows = rowMap->getLocalNumElements();
978 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
980 typedef KokkosKernels::ArithTraits<SC> ATS;
981 using impl_SC =
typename ATS::val_type;
982 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
983 const impl_SC one = impl_ATS::one();
986 const size_t NSDim = fineNullspace->getNumVectors();
987 auto aggSizes = aggregates->ComputeAggregateSizes();
992 aggGraph = aggregates->GetGraph();
994 auto aggRows = aggGraph.row_map;
995 auto aggCols = aggGraph.entries;
1001 const size_t numCoarseBlockRows = coarsePointMap->getLocalNumElements() / NSDim;
1002 RCP<const Map> coarseBlockMap = MapFactory::Build(coarsePointMap->lib(),
1003 Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(),
1005 coarsePointMap->getIndexBase(),
1006 coarsePointMap->getComm());
1008 const ParameterList& pL = GetParameterList();
1018 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
1019 "(i.e. \"matching\" row and column maps)");
1028 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
1030 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
1034 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1035 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1036 const size_t numAggregates = aggregates->GetNumAggregates();
1038 int myPID = aggregates->GetMap()->getComm()->getRank();
1043 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
1044 AggSizeType aggDofSizes;
1050 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
1052 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), aggSizes);
1058 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
1059 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
1063 Kokkos::parallel_scan(
1064 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
1065 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
1066 update += aggDofSizes(i);
1068 aggDofSizes(i) = update;
1073 Kokkos::View<LO*, DeviceType> aggToRowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"aggtorow_map_LO"), numFineBlockRows);
1077 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
1078 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
1080 Kokkos::parallel_for(
1081 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
1082 KOKKOS_LAMBDA(
const LO lnode) {
1083 if (procWinner(lnode, 0) == myPID) {
1085 auto aggID = vertex2AggId(lnode, 0);
1087 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
1091 for (LO k = 0; k < stridedBlockSize; k++)
1092 aggToRowMapLO(offset + k) = lnode * stridedBlockSize + k;
1099 coarseNullspace = MultiVectorFactory::Build(coarsePointMap, NSDim,
true);
1102 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
1103 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
1105 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
1106 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
1107 typedef typename local_matrix_type::index_type::non_const_type cols_type;
1111 typedef Kokkos::View<int[10], DeviceType> status_type;
1112 status_type status(
"status");
1118 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
1124 rows_type ia(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1125 cols_type ja(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), numFineBlockRows);
1127 Kokkos::parallel_for(
1128 "MueLu:TentativePF:BlockCrs:graph_init",
range_type(0, numFineBlockRows),
1129 KOKKOS_LAMBDA(
const LO j) {
1133 if (j == (LO)numFineBlockRows - 1)
1134 ia[numFineBlockRows] = numFineBlockRows;
1138 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
1139 Kokkos::parallel_for(
1140 "MueLu:TentativePF:BlockCrs:fillGraph", policy,
1141 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1142 auto agg = thread.league_rank();
1143 Xpetra::global_size_t offset = agg;
1148 for (LO j = 0; j < aggSize; j++) {
1150 const LO localRow = aggToRowMapLO[aggDofSizes[agg] + j];
1151 const size_t rowStart = ia[localRow];
1152 ja[rowStart] = offset;
1162 rows_type i_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1164 Kokkos::parallel_scan(
1165 "MueLu:TentativePF:BlockCrs:compress_rows",
range_type(0, numFineBlockRows),
1166 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
1169 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1170 if (ja[j] != INVALID)
1172 if (
final && i == (LO)numFineBlockRows - 1)
1173 i_temp[numFineBlockRows] = upd;
1177 cols_type j_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), nnz);
1179 Kokkos::parallel_for(
1180 "MueLu:TentativePF:BlockCrs:compress_cols",
range_type(0, numFineBlockRows),
1181 KOKKOS_LAMBDA(
const LO i) {
1182 size_t rowStart = i_temp[i];
1184 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1185 if (ja[j] != INVALID) {
1186 j_temp[rowStart + lnnz] = ja[j];
1195 RCP<CrsGraph> BlockGraph = CrsGraphFactory::Build(rowMap, coarseBlockMap, ia, ja);
1199 RCP<ParameterList> FCparams;
1200 if (pL.isSublist(
"matrixmatrix: kernel params"))
1201 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
1203 FCparams = rcp(
new ParameterList);
1205 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
1206 std::string levelIDs =
toString(levelID);
1207 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") + levelIDs);
1208 RCP<const Export> dummy_e;
1209 RCP<const Import> dummy_i;
1210 BlockGraph->expertStaticFillComplete(coarseBlockMap, rowMap, dummy_i, dummy_e, FCparams);
1220 RCP<Xpetra::CrsMatrix<SC, LO, GO, NO>> P_xpetra = Xpetra::CrsMatrixFactory<SC, LO, GO, NO>::BuildBlock(BlockGraph, coarsePointMap, rangeMap, NSDim);
1221 RCP<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>> P_tpetra = rcp_dynamic_cast<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>>(P_xpetra);
1222 if (P_tpetra.is_null())
throw std::runtime_error(
"BuildPUncoupled: Matrix factory did not return a Tpetra::BlockCrsMatrix");
1223 RCP<CrsMatrixWrap> P_wrap = rcp(
new CrsMatrixWrap(P_xpetra));
1225 auto values = P_tpetra->getTpetra_BlockCrsMatrix()->getValuesDeviceNonConst();
1226 const LO stride = NSDim * NSDim;
1228 Kokkos::parallel_for(
1229 "MueLu:TentativePF:BlockCrs:main_loop_noqr", policy,
1230 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1231 auto agg = thread.league_rank();
1235 Xpetra::global_size_t offset = agg * NSDim;
1238 for (LO j = 0; j < aggSize; j++) {
1239 LO localBlockRow = aggToRowMapLO(
aggRows(agg) + j);
1240 LO rowStart = localBlockRow * stride;
1241 for (LO r = 0; r < (LO)NSDim; r++) {
1242 LO localPointRow = localBlockRow * NSDim + r;
1243 for (LO c = 0; c < (LO)NSDim; c++) {
1244 values[rowStart + r * NSDim + c] = fineNSRandom(localPointRow, c);
1250 for (LO j = 0; j < (LO)NSDim; j++)
1254 Ptentative = P_wrap;