408 typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinate_type;
409 typedef Xpetra::MultiVectorFactory<coordinate_type, LO, GO, NO> RealValuedMultiVectorFactory;
410 const ParameterList& pL = GetParameterList();
411 std::string nspName =
"Nullspace";
412 if (pL.isParameter(
"Nullspace name")) nspName = pL.get<std::string>(
"Nullspace name");
414 auto A = Get<RCP<Matrix>>(fineLevel,
"A");
415 auto aggregates = Get<RCP<Aggregates>>(fineLevel,
"Aggregates");
416 auto amalgInfo = Get<RCP<AmalgamationInfo>>(fineLevel,
"UnAmalgamationInfo");
417 auto fineNullspace = Get<RCP<MultiVector>>(fineLevel, nspName);
418 auto coarseMap = Get<RCP<const Map>>(fineLevel,
"CoarseMap");
419 RCP<RealValuedMultiVector> fineCoords;
420 if (bTransferCoordinates_) {
421 fineCoords = Get<RCP<RealValuedMultiVector>>(fineLevel,
"Coordinates");
424 RCP<Matrix> Ptentative;
427 if (aggregates->GetNumGlobalAggregatesComputeIfNeeded() == 0) {
428 Ptentative = Teuchos::null;
429 Set(coarseLevel,
"P", Ptentative);
432 RCP<MultiVector> coarseNullspace;
433 RCP<RealValuedMultiVector> coarseCoords;
435 if (bTransferCoordinates_) {
436 RCP<const Map> coarseCoordMap;
439 if (rcp_dynamic_cast<const StridedMap>(coarseMap) != Teuchos::null)
440 blkSize = rcp_dynamic_cast<const StridedMap>(coarseMap)->getFixedBlockSize();
445 coarseCoordMap = coarseMap;
451 coarseCoords = RealValuedMultiVectorFactory::Build(coarseCoordMap, fineCoords->getNumVectors());
454 auto uniqueMap = fineCoords->getMap();
455 RCP<RealValuedMultiVector> ghostedCoords = fineCoords;
456 if (aggregates->AggregatesCrossProcessors()) {
457 auto nonUniqueMap = aggregates->GetMap();
458 auto importer = ImportFactory::Build(uniqueMap, nonUniqueMap);
460 ghostedCoords = RealValuedMultiVectorFactory::Build(nonUniqueMap, fineCoords->getNumVectors());
461 ghostedCoords->doImport(*fineCoords, *importer, Xpetra::INSERT);
466 auto aggGraph = aggregates->GetGraph();
467 auto numAggs = aggGraph.numRows();
469 auto fineCoordsView = fineCoords->getLocalViewDevice(Tpetra::Access::ReadOnly);
470 auto coarseCoordsView = coarseCoords->getLocalViewDevice(Tpetra::Access::OverwriteAll);
476 const auto dim = fineCoords->getNumVectors();
478 typename AppendTrait<
decltype(fineCoordsView), Kokkos::RandomAccess>::type fineCoordsRandomView = fineCoordsView;
479 for (
size_t j = 0; j < dim; j++) {
480 Kokkos::parallel_for(
481 "MueLu::TentativeP::BuildCoords", Kokkos::RangePolicy<local_ordinal_type, execution_space>(0, numAggs),
482 KOKKOS_LAMBDA(
const LO i) {
486 auto aggregate = aggGraph.rowConst(i);
488 coordinate_type sum = 0.0;
489 for (
size_t colID = 0; colID < static_cast<size_t>(aggregate.length); colID++)
490 sum += fineCoordsRandomView(aggregate(colID), j);
492 coarseCoordsView(i, j) = sum / aggregate.length;
498 if (!aggregates->AggregatesCrossProcessors()) {
499 if (Xpetra::Helpers<SC, LO, GO, NO>::isTpetraBlockCrs(A)) {
500 BuildPuncoupledBlockCrs(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace,
503 BuildPuncoupled(coarseLevel, A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace, coarseLevel.
GetLevelID());
506 BuildPcoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace);
516 if (A->IsView(
"stridedMaps") ==
true)
517 Ptentative->CreateView(
"stridedMaps", A->getRowMap(
"stridedMaps"), coarseMap);
519 Ptentative->CreateView(
"stridedMaps", Ptentative->getRangeMap(), coarseMap);
521 if (bTransferCoordinates_) {
522 Set(coarseLevel,
"Coordinates", coarseCoords);
527 RCP<const Teuchos::Comm<int>> nodeComm = Get<RCP<const Teuchos::Comm<int>>>(fineLevel,
"Node Comm");
528 Set<RCP<const Teuchos::Comm<int>>>(coarseLevel,
"Node Comm", nodeComm);
531 Set(coarseLevel,
"Nullspace", coarseNullspace);
532 Set(coarseLevel,
"P", Ptentative);
535 RCP<ParameterList> params = rcp(
new ParameterList());
536 params->set(
"printLoadBalancingInfo",
true);
544 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
545 RCP<const Map> coarseMap, RCP<Matrix>& Ptentative,
546 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
547 auto rowMap = A->getRowMap();
548 auto colMap = A->getColMap();
550 const size_t numRows = rowMap->getLocalNumElements();
551 const size_t NSDim = fineNullspace->getNumVectors();
553#if KOKKOS_VERSION >= 40799
554 typedef KokkosKernels::ArithTraits<SC> ATS;
556 typedef Kokkos::ArithTraits<SC> ATS;
558 using impl_SC =
typename ATS::val_type;
559#if KOKKOS_VERSION >= 40799
560 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
562 using impl_ATS = Kokkos::ArithTraits<impl_SC>;
564 const impl_SC zero = impl_ATS::zero(), one = impl_ATS::one();
566 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
571 aggGraph = aggregates->GetGraph();
573 auto aggRows = aggGraph.row_map;
574 auto aggCols = aggGraph.entries;
582 goodMap = isGoodMap(*rowMap, *colMap);
586 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
587 "(i.e. \"matching\" row and column maps)");
596 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
598 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
599 GO globalOffset = amalgInfo->GlobalOffset();
602 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
603 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
604 const size_t numAggregates = aggregates->GetNumAggregates();
606 int myPID = aggregates->GetMap()->getComm()->getRank();
611 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
612 AggSizeType aggDofSizes;
614 if (stridedBlockSize == 1) {
618 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
620 auto sizesConst = aggregates->ComputeAggregateSizes();
621 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), sizesConst);
627 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
629 auto nodeMap = aggregates->GetMap()->getLocalMap();
630 auto dofMap = colMap->getLocalMap();
632 Kokkos::parallel_for(
633 "MueLu:TentativePF:Build:compute_agg_sizes",
range_type(0, numAggregates),
634 KOKKOS_LAMBDA(
const LO agg) {
635 auto aggRowView = aggGraph.rowConst(agg);
638 for (LO colID = 0; colID < aggRowView.length; colID++) {
639 GO nodeGID = nodeMap.getGlobalElement(aggRowView(colID));
641 for (LO k = 0; k < stridedBlockSize; k++) {
642 GO dofGID = (nodeGID - indexBase) * fullBlockSize + k + indexBase + globalOffset + stridingOffset;
644 if (dofMap.getLocalElement(dofGID) != INVALID)
648 aggDofSizes(agg + 1) = size;
655 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
656 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
660 Kokkos::parallel_scan(
661 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
662 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
663 update += aggDofSizes(i);
665 aggDofSizes(i) = update;
670 Kokkos::View<LO*, DeviceType>
agg2RowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"agg2row_map_LO"), numRows);
674 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
675 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
677 Kokkos::parallel_for(
678 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
679 KOKKOS_LAMBDA(
const LO lnode) {
680 if (procWinner(lnode, 0) == myPID) {
682 auto aggID = vertex2AggId(lnode, 0);
684 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
688 for (LO k = 0; k < stridedBlockSize; k++)
689 agg2RowMapLO(offset + k) = lnode * stridedBlockSize + k;
696 coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
699 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
700 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::OverwriteAll);
704 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
705 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
706 typedef typename local_matrix_type::index_type::non_const_type cols_type;
707 typedef typename local_matrix_type::values_type::non_const_type vals_type;
710 typedef Kokkos::View<int[10], DeviceType> status_type;
711 status_type status(
"status");
716 const ParameterList& pL = GetParameterList();
717 const bool&
doQRStep = pL.get<
bool>(
"tentative: calculate qr");
719 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
721 GetOStream(
Warnings0) <<
"TentativePFactor : for nontrivial nullspace, this may degrade performance" << std::endl;
724 size_t nnzEstimate = numRows * NSDim;
725 rows_type
rowsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_rows"), numRows + 1);
726 cols_type
colsAux(Kokkos::ViewAllocateWithoutInitializing(
"Ptent_aux_cols"), nnzEstimate);
727 vals_type
valsAux(
"Ptent_aux_vals", nnzEstimate);
728 rows_type
rows(
"Ptent_rows", numRows + 1);
735 Kokkos::parallel_for(
736 "MueLu:TentativePF:BuildPuncoupled:for1",
range_type(0, numRows + 1),
737 KOKKOS_LAMBDA(
const LO row) {
740 Kokkos::parallel_for(
741 "MueLu:TentativePF:BuildUncoupled:for2",
range_type(0, nnzEstimate),
742 KOKKOS_LAMBDA(
const LO j) {
759 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
762 Kokkos::parallel_for(
763 "MueLu:TentativePF:BuildUncoupled:main_loop", policy,
764 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
765 auto agg = thread.league_rank();
773 auto norm = impl_ATS::magnitude(zero);
778 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
780 norm += dnorm * dnorm;
794 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
798 rows(localRow + 1) = 1;
804 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
805 Kokkos::deep_copy(statusHost, status);
806 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
808 std::ostringstream oss;
809 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
811 case 0: oss <<
"!goodMap is not implemented";
break;
812 case 1: oss <<
"fine level NS part has a zero column";
break;
818 Kokkos::parallel_for(
819 "MueLu:TentativePF:BuildUncoupled:main_loop_noqr", policy,
820 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
821 auto agg = thread.league_rank();
830 for (
decltype(aggSize) k = 0; k < aggSize; k++) {
834 rows(localRow + 1) = 1;
841 Kokkos::parallel_reduce(
842 "MueLu:TentativeP:CountNNZ",
range_type(0, numRows + 1),
843 KOKKOS_LAMBDA(
const LO i,
size_t& nnz_count) {
844 nnz_count +=
rows(i);
862 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
864 decltype(aggDofSizes ),
decltype(maxAggSize),
decltype(
agg2RowMapLO),
869 Kokkos::parallel_reduce(
"MueLu:TentativePF:BuildUncoupled:main_qr_loop", policy, localQRFunctor, nnz);
872 typename status_type::host_mirror_type statusHost = Kokkos::create_mirror_view(status);
873 Kokkos::deep_copy(statusHost, status);
874 for (
decltype(statusHost.size()) i = 0; i < statusHost.size(); i++)
876 std::ostringstream oss;
877 oss <<
"MueLu::TentativePFactory::MakeTentative: ";
879 case 0: oss <<
"!goodMap is not implemented";
break;
880 case 1: oss <<
"fine level NS part has a zero column";
break;
893 if (nnz != nnzEstimate) {
898 Kokkos::parallel_scan(
899 "MueLu:TentativePF:Build:compress_rows",
range_type(0, numRows + 1),
900 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
910 cols = cols_type(
"Ptent_cols", nnz);
911 vals = vals_type(
"Ptent_vals", nnz);
916 Kokkos::parallel_for(
917 "MueLu:TentativePF:Build:compress_cols_vals",
range_type(0, numRows),
918 KOKKOS_LAMBDA(
const LO i) {
919 LO rowStart =
rows(i);
924 cols(rowStart + lnnz) =
colsAux(j);
925 vals(rowStart + lnnz) =
valsAux(j);
937 GetOStream(
Runtime1) <<
"TentativePFactory : aggregates do not cross process boundaries" << std::endl;
943 local_matrix_type lclMatrix = local_matrix_type(
"A", numRows, coarseMap->getLocalNumElements(), nnz, vals,
rows, cols);
946 RCP<ParameterList> FCparams;
947 if (pL.isSublist(
"matrixmatrix: kernel params"))
948 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
950 FCparams = rcp(
new ParameterList);
953 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
954 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") +
toString(levelID));
956 auto PtentCrs = CrsMatrixFactory::Build(lclMatrix, rowMap, coarseMap, coarseMap, A->getDomainMap());
957 Ptentative = rcp(
new CrsMatrixWrap(PtentCrs));
964 RCP<AmalgamationInfo> amalgInfo, RCP<MultiVector> fineNullspace,
965 RCP<const Map> coarsePointMap, RCP<Matrix>& Ptentative,
966 RCP<MultiVector>& coarseNullspace,
const int levelID)
const {
976 RCP<const Map> rowMap = A->getRowMap();
977 RCP<const Map> rangeMap = A->getRangeMap();
978 RCP<const Map> colMap = A->getColMap();
980 const size_t numFineBlockRows = rowMap->getLocalNumElements();
984 const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
986#if KOKKOS_VERSION >= 40799
987 typedef KokkosKernels::ArithTraits<SC> ATS;
989 typedef Kokkos::ArithTraits<SC> ATS;
991 using impl_SC =
typename ATS::val_type;
992#if KOKKOS_VERSION >= 40799
993 using impl_ATS = KokkosKernels::ArithTraits<impl_SC>;
995 using impl_ATS = Kokkos::ArithTraits<impl_SC>;
997 const impl_SC one = impl_ATS::one();
1000 const size_t NSDim = fineNullspace->getNumVectors();
1001 auto aggSizes = aggregates->ComputeAggregateSizes();
1006 aggGraph = aggregates->GetGraph();
1008 auto aggRows = aggGraph.row_map;
1009 auto aggCols = aggGraph.entries;
1015 const size_t numCoarseBlockRows = coarsePointMap->getLocalNumElements() / NSDim;
1016 RCP<const Map> coarseBlockMap = MapFactory::Build(coarsePointMap->lib(),
1017 Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(),
1019 coarsePointMap->getIndexBase(),
1020 coarsePointMap->getComm());
1022 const ParameterList& pL = GetParameterList();
1032 "MueLu: TentativePFactory_kokkos: for now works only with good maps "
1033 "(i.e. \"matching\" row and column maps)");
1042 LO fullBlockSize, blockID, stridingOffset, stridedBlockSize;
1044 amalgInfo->GetStridingInformation(fullBlockSize, blockID, stridingOffset, stridedBlockSize, indexBase);
1048 auto procWinner = aggregates->GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1049 auto vertex2AggId = aggregates->GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadOnly);
1050 const size_t numAggregates = aggregates->GetNumAggregates();
1052 int myPID = aggregates->GetMap()->getComm()->getRank();
1057 typedef typename Aggregates::aggregates_sizes_type::non_const_type AggSizeType;
1058 AggSizeType aggDofSizes;
1064 aggDofSizes = AggSizeType(
"agg_dof_sizes", numAggregates + 1);
1066 Kokkos::deep_copy(Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(1), numAggregates + 1)), aggSizes);
1072 ReduceMaxFunctor<LO,
decltype(aggDofSizes)> reduceMax(aggDofSizes);
1073 Kokkos::parallel_reduce(
"MueLu:TentativePF:Build:max_agg_size",
range_type(0, aggDofSizes.extent(0)), reduceMax, maxAggSize);
1077 Kokkos::parallel_scan(
1078 "MueLu:TentativePF:Build:aggregate_sizes:stage1_scan",
range_type(0, numAggregates + 1),
1079 KOKKOS_LAMBDA(
const LO i, LO& update,
const bool& final_pass) {
1080 update += aggDofSizes(i);
1082 aggDofSizes(i) = update;
1087 Kokkos::View<LO*, DeviceType> aggToRowMapLO(Kokkos::ViewAllocateWithoutInitializing(
"aggtorow_map_LO"), numFineBlockRows);
1091 AggSizeType aggOffsets(Kokkos::ViewAllocateWithoutInitializing(
"aggOffsets"), numAggregates);
1092 Kokkos::deep_copy(aggOffsets, Kokkos::subview(aggDofSizes, Kokkos::make_pair(
static_cast<size_t>(0), numAggregates)));
1094 Kokkos::parallel_for(
1095 "MueLu:TentativePF:Build:createAgg2RowMap",
range_type(0, vertex2AggId.extent(0)),
1096 KOKKOS_LAMBDA(
const LO lnode) {
1097 if (procWinner(lnode, 0) == myPID) {
1099 auto aggID = vertex2AggId(lnode, 0);
1101 auto offset = Kokkos::atomic_fetch_add(&aggOffsets(aggID), stridedBlockSize);
1105 for (LO k = 0; k < stridedBlockSize; k++)
1106 aggToRowMapLO(offset + k) = lnode * stridedBlockSize + k;
1113 coarseNullspace = MultiVectorFactory::Build(coarsePointMap, NSDim);
1116 auto fineNS = fineNullspace->getLocalViewDevice(Tpetra::Access::ReadWrite);
1117 auto coarseNS = coarseNullspace->getLocalViewDevice(Tpetra::Access::OverwriteAll);
1119 typedef typename Xpetra::Matrix<SC, LO, GO, NO>::local_matrix_device_type local_matrix_type;
1120 typedef typename local_matrix_type::row_map_type::non_const_type rows_type;
1121 typedef typename local_matrix_type::index_type::non_const_type cols_type;
1125 typedef Kokkos::View<int[10], DeviceType> status_type;
1126 status_type status(
"status");
1132 GetOStream(
Runtime1) <<
"TentativePFactory : bypassing local QR phase" << std::endl;
1138 rows_type ia(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1139 cols_type ja(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), numFineBlockRows);
1141 Kokkos::parallel_for(
1142 "MueLu:TentativePF:BlockCrs:graph_init",
range_type(0, numFineBlockRows),
1143 KOKKOS_LAMBDA(
const LO j) {
1147 if (j == (LO)numFineBlockRows - 1)
1148 ia[numFineBlockRows] = numFineBlockRows;
1152 const Kokkos::TeamPolicy<execution_space> policy(numAggregates, 1);
1153 Kokkos::parallel_for(
1154 "MueLu:TentativePF:BlockCrs:fillGraph", policy,
1155 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1156 auto agg = thread.league_rank();
1157 Xpetra::global_size_t offset = agg;
1162 for (LO j = 0; j < aggSize; j++) {
1164 const LO localRow = aggToRowMapLO[aggDofSizes[agg] + j];
1165 const size_t rowStart = ia[localRow];
1166 ja[rowStart] = offset;
1176 rows_type i_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_rowptr"), numFineBlockRows + 1);
1178 Kokkos::parallel_scan(
1179 "MueLu:TentativePF:BlockCrs:compress_rows",
range_type(0, numFineBlockRows),
1180 KOKKOS_LAMBDA(
const LO i, LO& upd,
const bool&
final) {
1183 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1184 if (ja[j] != INVALID)
1186 if (
final && i == (LO)numFineBlockRows - 1)
1187 i_temp[numFineBlockRows] = upd;
1191 cols_type j_temp(Kokkos::ViewAllocateWithoutInitializing(
"BlockGraph_colind"), nnz);
1193 Kokkos::parallel_for(
1194 "MueLu:TentativePF:BlockCrs:compress_cols",
range_type(0, numFineBlockRows),
1195 KOKKOS_LAMBDA(
const LO i) {
1196 size_t rowStart = i_temp[i];
1198 for (
auto j = ia[i]; j < ia[i + 1]; j++)
1199 if (ja[j] != INVALID) {
1200 j_temp[rowStart + lnnz] = ja[j];
1209 RCP<CrsGraph> BlockGraph = CrsGraphFactory::Build(rowMap, coarseBlockMap, ia, ja);
1213 RCP<ParameterList> FCparams;
1214 if (pL.isSublist(
"matrixmatrix: kernel params"))
1215 FCparams = rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
1217 FCparams = rcp(
new ParameterList);
1219 FCparams->set(
"compute global constants", FCparams->get(
"compute global constants",
false));
1220 std::string levelIDs =
toString(levelID);
1221 FCparams->set(
"Timer Label", std::string(
"MueLu::TentativeP-") + levelIDs);
1222 RCP<const Export> dummy_e;
1223 RCP<const Import> dummy_i;
1224 BlockGraph->expertStaticFillComplete(coarseBlockMap, rowMap, dummy_i, dummy_e, FCparams);
1234 RCP<Xpetra::CrsMatrix<SC, LO, GO, NO>> P_xpetra = Xpetra::CrsMatrixFactory<SC, LO, GO, NO>::BuildBlock(BlockGraph, coarsePointMap, rangeMap, NSDim);
1235 RCP<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>> P_tpetra = rcp_dynamic_cast<Xpetra::TpetraBlockCrsMatrix<SC, LO, GO, NO>>(P_xpetra);
1236 if (P_tpetra.is_null())
throw std::runtime_error(
"BuildPUncoupled: Matrix factory did not return a Tpetra::BlockCrsMatrix");
1237 RCP<CrsMatrixWrap> P_wrap = rcp(
new CrsMatrixWrap(P_xpetra));
1239 auto values = P_tpetra->getTpetra_BlockCrsMatrix()->getValuesDeviceNonConst();
1240 const LO stride = NSDim * NSDim;
1242 Kokkos::parallel_for(
1243 "MueLu:TentativePF:BlockCrs:main_loop_noqr", policy,
1244 KOKKOS_LAMBDA(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread) {
1245 auto agg = thread.league_rank();
1249 Xpetra::global_size_t offset = agg * NSDim;
1252 for (LO j = 0; j < aggSize; j++) {
1253 LO localBlockRow = aggToRowMapLO(
aggRows(agg) + j);
1254 LO rowStart = localBlockRow * stride;
1255 for (LO r = 0; r < (LO)NSDim; r++) {
1256 LO localPointRow = localBlockRow * NSDim + r;
1257 for (LO c = 0; c < (LO)NSDim; c++) {
1258 values[rowStart + r * NSDim + c] = fineNSRandom(localPointRow, c);
1264 for (LO j = 0; j < (LO)NSDim; j++)
1268 Ptentative = P_wrap;