10#ifndef IFPACK2_LOCALSPARSETRIANGULARSOLVER_DEF_HPP
11#define IFPACK2_LOCALSPARSETRIANGULARSOLVER_DEF_HPP
16#include "Ifpack2_LocalSparseTriangularSolver_decl.hpp"
17#include "Tpetra_CrsMatrix.hpp"
18#include "Tpetra_Core.hpp"
19#include "Teuchos_StandardParameterEntryValidators.hpp"
20#include "Tpetra_Details_determineLocalTriangularStructure.hpp"
21#include "KokkosSparse_sptrsv.hpp"
22#include "KokkosSparse_trsv.hpp"
24#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
25#include "shylu_hts.hpp"
32#if defined(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE) && defined(KOKKOS_ENABLE_CUDA)
34inline void cusparse_error_throw(cusparseStatus_t cusparseStatus,
const char* name,
35 const char* file,
const int line) {
36 std::ostringstream out;
37#if defined(CUSPARSE_VERSION) && (10300 <= CUSPARSE_VERSION)
38 out << name <<
" error( " << cusparseGetErrorName(cusparseStatus) <<
"): " << cusparseGetErrorString(cusparseStatus);
40 out << name <<
" error( ";
41 switch (cusparseStatus) {
42 case CUSPARSE_STATUS_NOT_INITIALIZED:
43 out <<
"CUSPARSE_STATUS_NOT_INITIALIZED): cusparse handle was not "
46 case CUSPARSE_STATUS_ALLOC_FAILED:
47 out <<
"CUSPARSE_STATUS_ALLOC_FAILED): you might tried to allocate too "
50 case CUSPARSE_STATUS_INVALID_VALUE: out <<
"CUSPARSE_STATUS_INVALID_VALUE)";
break;
51 case CUSPARSE_STATUS_ARCH_MISMATCH: out <<
"CUSPARSE_STATUS_ARCH_MISMATCH)";
break;
52 case CUSPARSE_STATUS_MAPPING_ERROR: out <<
"CUSPARSE_STATUS_MAPPING_ERROR)";
break;
53 case CUSPARSE_STATUS_EXECUTION_FAILED: out <<
"CUSPARSE_STATUS_EXECUTION_FAILED)";
break;
54 case CUSPARSE_STATUS_INTERNAL_ERROR: out <<
"CUSPARSE_STATUS_INTERNAL_ERROR)";
break;
55 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED: out <<
"CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED)";
break;
56 case CUSPARSE_STATUS_ZERO_PIVOT: out <<
"CUSPARSE_STATUS_ZERO_PIVOT)";
break;
57 default: out <<
"unrecognized error code): this is bad!";
break;
61 out <<
" " << file <<
":" << line;
63 throw std::runtime_error(out.str());
66inline void cusparse_safe_call(cusparseStatus_t cusparseStatus,
const char* name,
const char* file =
nullptr,
68 if (CUSPARSE_STATUS_SUCCESS != cusparseStatus) {
69 cusparse_error_throw(cusparseStatus, name, file, line);
73#define IFPACK2_DETAILS_CUSPARSE_SAFE_CALL(call) \
74 Ifpack2::Details::cusparse_safe_call(call, #call, __FILE__, __LINE__)
85 static void loadPLTypeOption(Teuchos::Array<std::string>& type_strs, Teuchos::Array<Enum>& type_enums) {
87 type_strs[0] =
"Internal";
89 type_strs[2] =
"KSPTRSV";
91 type_enums[0] = Internal;
93 type_enums[2] = KSPTRSV;
98template <
class MatrixType>
99class LocalSparseTriangularSolver<MatrixType>::HtsImpl {
101 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>
crs_matrix_type;
104#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
105 Timpl_ = Teuchos::null;
106 levelset_block_size_ = 1;
112#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
113 const char* block_size_s =
"trisolver: block size";
114 if (pl.isParameter(block_size_s)) {
115 TEUCHOS_TEST_FOR_EXCEPT_MSG(!pl.isType<
int>(block_size_s),
116 "The parameter \"" << block_size_s <<
"\" must be of type int.");
117 levelset_block_size_ = pl.get<
int>(block_size_s);
119 if (levelset_block_size_ < 1)
120 levelset_block_size_ = 1;
129#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
131 transpose_ = conjugate_ =
false;
138#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
139 using Teuchos::ArrayRCP;
141 auto rowptr = T_in.getLocalRowPtrsHost();
142 auto colidx = T_in.getLocalIndicesHost();
143 auto val = T_in.getLocalValuesHost(Tpetra::Access::ReadOnly);
146 Teuchos::RCP<HtsCrsMatrix> T_hts = Teuchos::rcpWithDealloc(
147 HTST::make_CrsMatrix(rowptr.size() - 1,
148 rowptr.data(), colidx.data(),
151 transpose_, conjugate_),
152 HtsCrsMatrixDeleter());
154 if (Teuchos::nonnull(Timpl_)) {
156 HTST::reprocess_numeric(Timpl_.get(), T_hts.get());
159 if (T_in.getCrsGraph().is_null()) {
160 if (Teuchos::nonnull(out))
161 *out <<
"HTS compute failed because T_in.getCrsGraph().is_null().\n";
164 if (!T_in.getCrsGraph()->isSorted()) {
165 if (Teuchos::nonnull(out))
166 *out <<
"HTS compute failed because ! T_in.getCrsGraph().isSorted().\n";
169 if (!T_in.isStorageOptimized()) {
170 if (Teuchos::nonnull(out))
171 *out <<
"HTS compute failed because ! T_in.isStorageOptimized().\n";
175 typename HTST::PreprocessArgs args;
176 args.T = T_hts.get();
179 args.nthreads = omp_get_max_threads();
183 args.save_for_reprocess =
true;
184 typename HTST::Options opts;
185 opts.levelset_block_size = levelset_block_size_;
186 args.options = &opts;
189 Timpl_ = Teuchos::rcpWithDealloc(HTST::preprocess(args), TImplDeleter());
190 }
catch (
const std::exception& e) {
191 if (Teuchos::nonnull(out))
192 *out <<
"HTS preprocess threw: " << e.what() <<
"\n";
201#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
202 return Teuchos::nonnull(Timpl_);
209 void localApply(
const MV& X, MV& Y,
210 const Teuchos::ETransp ,
216#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
217 const auto& X_view = X.getLocalViewHost(Tpetra::Access::ReadOnly);
218 const auto& Y_view = Y.getLocalViewHost(Tpetra::Access::ReadWrite);
221 HTST::reset_max_nrhs(Timpl_.get(), X_view.extent(1));
223 HTST::solve_omp(Timpl_.get(),
225 reinterpret_cast<const scalar_type*
>(X_view.data()),
234#ifdef HAVE_IFPACK2_SHYLU_NODEHTS
235 typedef ::Experimental::HTS<local_ordinal_type, size_t, scalar_type> HTST;
236 typedef typename HTST::Impl TImpl;
237 typedef typename HTST::CrsMatrix HtsCrsMatrix;
239 struct TImplDeleter {
240 void free(TImpl* impl) {
241 HTST::delete_Impl(impl);
245 struct HtsCrsMatrixDeleter {
246 void free(HtsCrsMatrix* T) {
247 HTST::delete_CrsMatrix(T);
251 Teuchos::RCP<TImpl> Timpl_;
252 bool transpose_, conjugate_;
253 int levelset_block_size_;
257template <
class MatrixType>
264 Teuchos::RCP<const crs_matrix_type> A_crs =
265 Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A);
266 TEUCHOS_TEST_FOR_EXCEPTION(A_crs.is_null(), std::invalid_argument,
267 "Ifpack2::LocalSparseTriangularSolver constructor: "
268 "The input matrix A is not a Tpetra::CrsMatrix.");
273template <
class MatrixType>
276 const Teuchos::RCP<Teuchos::FancyOStream>& out)
280 if (!out_.is_null()) {
281 *out_ <<
">>> DEBUG Ifpack2::LocalSparseTriangularSolver constructor"
286 Teuchos::RCP<const crs_matrix_type> A_crs =
287 Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A);
288 TEUCHOS_TEST_FOR_EXCEPTION(A_crs.is_null(), std::invalid_argument,
289 "Ifpack2::LocalSparseTriangularSolver constructor: "
290 "The input matrix A is not a Tpetra::CrsMatrix.");
295template <
class MatrixType>
301template <
class MatrixType>
306 if (!out_.is_null()) {
307 *out_ <<
">>> DEBUG Ifpack2::LocalSparseTriangularSolver constructor"
312template <
class MatrixType>
314 isInitialized_ =
false;
316 reverseStorage_ =
false;
317 isInternallyChanged_ =
false;
321 initializeTime_ = 0.0;
324 isKokkosKernelsSptrsv_ =
false;
325 isKokkosKernelsStream_ =
false;
331template <
class MatrixType>
334 if (!isKokkosKernelsStream_) {
335 if (Teuchos::nonnull(kh_)) {
336 kh_->destroy_sptrsv_handle();
339 for (
size_t i = 0; i < kh_v_.size(); i++) {
340 if (Teuchos::nonnull(kh_v_[i])) {
341 kh_v_[i]->destroy_sptrsv_handle();
347template <
class MatrixType>
350 using Teuchos::Array;
351 using Teuchos::ParameterList;
354 Details::TrisolverType::Enum trisolverType = Details::TrisolverType::Internal;
356 static const char typeName[] =
"trisolver: type";
358 if (!pl.isType<std::string>(typeName))
break;
361 Array<std::string> trisolverTypeStrs;
362 Array<Details::TrisolverType::Enum> trisolverTypeEnums;
363 Details::TrisolverType::loadPLTypeOption(trisolverTypeStrs, trisolverTypeEnums);
364 Teuchos::StringToIntegralParameterEntryValidator<Details::TrisolverType::Enum>
365 s2i(trisolverTypeStrs(), trisolverTypeEnums(), typeName,
false);
367 trisolverType = s2i.getIntegralValue(pl.get<std::string>(typeName));
370 if (trisolverType == Details::TrisolverType::HTS) {
371 htsImpl_ = Teuchos::rcp(
new HtsImpl());
372 htsImpl_->setParameters(pl);
375 if (trisolverType == Details::TrisolverType::KSPTRSV) {
376 this->isKokkosKernelsSptrsv_ =
true;
378 this->isKokkosKernelsSptrsv_ =
false;
381 if (pl.isParameter(
"trisolver: reverse U"))
382 reverseStorage_ = pl.get<
bool>(
"trisolver: reverse U");
384 TEUCHOS_TEST_FOR_EXCEPTION(reverseStorage_ && (trisolverType == Details::TrisolverType::HTS || trisolverType == Details::TrisolverType::KSPTRSV),
386 "Ifpack2::LocalSparseTriangularSolver::setParameters: "
387 "You are not allowed to enable both HTS or KSPTRSV and the \"trisolver: reverse U\" "
388 "options. See GitHub issue #2647.");
391template <
class MatrixType>
394 using Tpetra::Details::determineLocalTriangularStructure;
396 using local_matrix_type =
typename crs_matrix_type::local_matrix_device_type;
399 const char prefix[] =
"Ifpack2::LocalSparseTriangularSolver::initialize: ";
400 if (!out_.is_null()) {
401 *out_ <<
">>> DEBUG " << prefix << std::endl;
404 if (!isKokkosKernelsStream_) {
405 TEUCHOS_TEST_FOR_EXCEPTION(A_.is_null(), std::runtime_error, prefix <<
"You must call "
406 "setMatrix() with a nonnull input matrix before you may call "
407 "initialize() or compute().");
408 if (A_crs_.is_null()) {
409 auto A_crs = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_);
410 TEUCHOS_TEST_FOR_EXCEPTION(A_crs.get() ==
nullptr, std::invalid_argument,
411 prefix <<
"The input matrix A is not a Tpetra::CrsMatrix.");
414 auto G = A_crs_->getGraph();
415 TEUCHOS_TEST_FOR_EXCEPTION(G.is_null(), std::logic_error, prefix <<
"A_ and A_crs_ are nonnull, "
416 "but A_crs_'s RowGraph G is null. "
417 "Please report this bug to the Ifpack2 developers.");
421 TEUCHOS_TEST_FOR_EXCEPTION(!G->isFillComplete(), std::runtime_error,
422 "If you call this method, "
423 "the matrix's graph must be fill complete. It is not.");
426 constexpr bool ignoreMapsForTriStructure =
true;
427 auto lclTriStructure = [&] {
428 auto lclMatrix = A_crs_->getLocalMatrixDevice();
429 auto lclRowMap = A_crs_->getRowMap()->getLocalMap();
430 auto lclColMap = A_crs_->getColMap()->getLocalMap();
432 determineLocalTriangularStructure(lclMatrix.graph,
435 ignoreMapsForTriStructure);
436 const LO lclNumRows = lclRowMap.getLocalNumElements();
437 this->diag_ = (lclTriStruct.diagCount < lclNumRows) ?
"U" :
"N";
438 this->uplo_ = lclTriStruct.couldBeLowerTriangular ?
"L" : (lclTriStruct.couldBeUpperTriangular ?
"U" :
"N");
442 if (reverseStorage_ && lclTriStructure.couldBeUpperTriangular &&
443 htsImpl_.is_null()) {
445 auto Alocal = A_crs_->getLocalMatrixDevice();
446 auto ptr = Alocal.graph.row_map;
447 auto ind = Alocal.graph.entries;
448 auto val = Alocal.values;
450 auto numRows = Alocal.numRows();
451 auto numCols = Alocal.numCols();
452 auto numNnz = Alocal.nnz();
454 typename decltype(ptr)::non_const_type newptr(
"ptr", ptr.extent(0));
455 typename decltype(ind)::non_const_type newind(
"ind", ind.extent(0));
456 decltype(val) newval(
"val", val.extent(0));
459 typename crs_matrix_type::execution_space().fence();
462 auto A_r = Alocal.row(numRows - 1 - row);
464 auto numEnt = A_r.length;
466 newind(rowStart + k) = numCols - 1 - A_r.colidx(numEnt - 1 - k);
467 newval(rowStart + k) = A_r.value(numEnt - 1 - k);
470 newptr(row + 1) = rowStart;
472 typename crs_matrix_type::execution_space().fence();
475 Teuchos::RCP<map_type> newRowMap, newColMap;
478 auto rowMap = A_->getRowMap();
479 auto numElems = rowMap->getLocalNumElements();
480 auto rowElems = rowMap->getLocalElementList();
482 Teuchos::Array<global_ordinal_type> newRowElems(rowElems.size());
483 for (
size_t i = 0; i < numElems; i++)
484 newRowElems[i] = rowElems[numElems - 1 - i];
486 newRowMap = Teuchos::rcp(
new map_type(rowMap->getGlobalNumElements(), newRowElems, rowMap->getIndexBase(), rowMap->getComm()));
490 auto colMap = A_->getColMap();
491 auto numElems = colMap->getLocalNumElements();
492 auto colElems = colMap->getLocalElementList();
494 Teuchos::Array<global_ordinal_type> newColElems(colElems.size());
495 for (
size_t i = 0; i < numElems; i++)
496 newColElems[i] = colElems[numElems - 1 - i];
498 newColMap = Teuchos::rcp(
new map_type(colMap->getGlobalNumElements(), newColElems, colMap->getIndexBase(), colMap->getComm()));
502 local_matrix_type newLocalMatrix(
"Upermuted", numRows, numCols, numNnz, newval, newptr, newind);
504 A_crs_ = Teuchos::rcp(
new crs_matrix_type(newLocalMatrix, newRowMap, newColMap, A_crs_->getDomainMap(), A_crs_->getRangeMap()));
506 isInternallyChanged_ =
true;
511 auto newLclTriStructure =
512 determineLocalTriangularStructure(newLocalMatrix.graph,
513 newRowMap->getLocalMap(),
514 newColMap->getLocalMap(),
515 ignoreMapsForTriStructure);
516 const LO newLclNumRows = newRowMap->getLocalNumElements();
517 this->diag_ = (newLclTriStructure.diagCount < newLclNumRows) ?
"U" :
"N";
518 this->uplo_ = newLclTriStructure.couldBeLowerTriangular ?
"L" : (newLclTriStructure.couldBeUpperTriangular ?
"U" :
"N");
521 bool prev_ambiguous =
false;
522 bool all_ambiguous =
true;
523 for (
int i = 0; i < num_streams_; i++) {
524 TEUCHOS_TEST_FOR_EXCEPTION(A_crs_v_[i].is_null(), std::runtime_error, prefix <<
"You must call "
525 "setMatrix() with a nonnull input matrix before you may call "
526 "initialize() or compute().");
527 auto G = A_crs_v_[i]->getGraph();
528 TEUCHOS_TEST_FOR_EXCEPTION(G.is_null(), std::logic_error, prefix <<
"A_crs_ are nonnull, "
529 "but A_crs_'s RowGraph G is null. "
530 "Please report this bug to the Ifpack2 developers.");
534 TEUCHOS_TEST_FOR_EXCEPTION(!G->isFillComplete(), std::runtime_error,
535 "If you call this method, "
536 "the matrix's graph must be fill complete. It is not.");
539 constexpr bool ignoreMapsForTriStructure =
true;
540 std::string prev_uplo = this->uplo_;
541 std::string prev_diag = this->diag_;
542 auto lclMatrix = A_crs_v_[i]->getLocalMatrixDevice();
543 auto lclRowMap = A_crs_v_[i]->getRowMap()->getLocalMap();
544 auto lclColMap = A_crs_v_[i]->getColMap()->getLocalMap();
546 determineLocalTriangularStructure(lclMatrix.graph,
549 ignoreMapsForTriStructure);
550 const LO lclNumRows = lclRowMap.getLocalNumElements();
551 this->diag_ = (lclTriStruct.diagCount < lclNumRows) ?
"U" :
"N";
552 const bool could_be_lower = lclTriStruct.couldBeLowerTriangular;
553 const bool could_be_upper = lclTriStruct.couldBeUpperTriangular;
554 if (could_be_lower && could_be_upper) {
556 this->uplo_ = prev_uplo;
557 prev_ambiguous =
true;
559 this->uplo_ = could_be_lower ?
"L" : (could_be_upper ?
"U" :
"N");
560 if (this->uplo_ !=
"N" && prev_uplo ==
"N" && prev_ambiguous) {
561 prev_uplo = this->uplo_;
563 prev_ambiguous =
false;
565 all_ambiguous &= prev_ambiguous;
567 TEUCHOS_TEST_FOR_EXCEPTION((this->diag_ != prev_diag) || (this->uplo_ != prev_uplo),
568 std::logic_error, prefix <<
"A_crs_'s structures in streams "
569 "are different. Please report this bug to the Ifpack2 developers.");
578 if (Teuchos::nonnull(htsImpl_)) {
579 htsImpl_->initialize(*A_crs_);
580 isInternallyChanged_ =
true;
583 const bool ksptrsv_valid_uplo = (this->uplo_ !=
"N");
584 kh_v_nonnull_ =
false;
585 if (this->isKokkosKernelsSptrsv_ && ksptrsv_valid_uplo && this->diag_ !=
"U") {
586 if (!isKokkosKernelsStream_) {
587 kh_ = Teuchos::rcp(
new k_handle());
588 const bool is_lower_tri = (this->uplo_ ==
"L") ?
true :
false;
590 auto A_crs = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_,
true);
591 auto Alocal = A_crs->getLocalMatrixDevice();
592 auto ptr = Alocal.graph.row_map;
593 auto ind = Alocal.graph.entries;
594 auto val = Alocal.values;
596 auto numRows = Alocal.numRows();
597 kh_->create_sptrsv_handle(kokkosKernelsAlgorithm(), numRows, is_lower_tri);
598 KokkosSparse::sptrsv_symbolic(kh_.getRawPtr(), ptr, ind, val);
600 kh_v_ = std::vector<Teuchos::RCP<k_handle>>(num_streams_);
601 for (
int i = 0; i < num_streams_; i++) {
602 kh_v_[i] = Teuchos::rcp(
new k_handle());
603 auto A_crs_i = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_crs_v_[i],
true);
604 auto Alocal_i = A_crs_i->getLocalMatrixDevice();
605 auto ptr_i = Alocal_i.graph.row_map;
606 auto ind_i = Alocal_i.graph.entries;
607 auto val_i = Alocal_i.values;
609 auto numRows_i = Alocal_i.numRows();
611 const bool is_lower_tri = (this->uplo_ ==
"L") ?
true :
false;
612 kh_v_[i]->create_sptrsv_handle(kokkosKernelsAlgorithm(), numRows_i, is_lower_tri);
613 KokkosSparse::sptrsv_symbolic(kh_v_[i].getRawPtr(), ptr_i, ind_i, val_i);
615 kh_v_nonnull_ =
true;
619 isInitialized_ =
true;
623template <
class MatrixType>
624KokkosSparse::Experimental::SPTRSVAlgorithm
626#if defined(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE) && defined(KOKKOS_ENABLE_CUDA)
629 if constexpr (std::is_same<Kokkos::Cuda, HandleExecSpace>::value &&
630 std::is_same<int, local_ordinal_type>::value &&
631 (std::is_same<scalar_type, float>::value ||
632 std::is_same<scalar_type, double>::value ||
633 std::is_same<impl_scalar_type, Kokkos::complex<float>>::value ||
634 std::is_same<impl_scalar_type, Kokkos::complex<double>>::value)) {
635 return KokkosSparse::Experimental::SPTRSVAlgorithm::SPTRSV_CUSPARSE;
638 return KokkosSparse::Experimental::SPTRSVAlgorithm::SEQLVLSCHD_TP1;
641template <
class MatrixType>
644 const char prefix[] =
"Ifpack2::LocalSparseTriangularSolver::compute: ";
645 if (!out_.is_null()) {
646 *out_ <<
">>> DEBUG " << prefix << std::endl;
649 if (!isKokkosKernelsStream_) {
650 TEUCHOS_TEST_FOR_EXCEPTION(A_.is_null(), std::runtime_error, prefix <<
"You must call "
651 "setMatrix() with a nonnull input matrix before you may call "
652 "initialize() or compute().");
653 TEUCHOS_TEST_FOR_EXCEPTION(A_crs_.is_null(), std::logic_error, prefix <<
"A_ is nonnull, but "
654 "A_crs_ is null. Please report this bug to the Ifpack2 developers.");
656 TEUCHOS_TEST_FOR_EXCEPTION(!A_crs_->isFillComplete(), std::runtime_error,
658 "method, the matrix must be fill complete. It is not.");
660 for (
int i = 0; i < num_streams_; i++) {
661 TEUCHOS_TEST_FOR_EXCEPTION(A_crs_v_[i].is_null(), std::runtime_error, prefix <<
"You must call "
662 "setMatrices() with a nonnull input matrix before you may call "
663 "initialize() or compute().");
665 TEUCHOS_TEST_FOR_EXCEPTION(!A_crs_v_[i]->isFillComplete(), std::runtime_error,
667 "method, the matrix must be fill complete. It is not.");
671 if (!isInitialized_) {
674 TEUCHOS_TEST_FOR_EXCEPTION(!isInitialized_, std::logic_error, prefix <<
"initialize() should have "
675 "been called by this point, but isInitialized_ is false. "
676 "Please report this bug to the Ifpack2 developers.");
685#if defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE) && (CUDA_VERSION >= 11030)
686 if constexpr (std::is_same_v<typename crs_matrix_type::execution_space, Kokkos::Cuda>) {
687 if (this->isKokkosKernelsSptrsv_) {
688 if (Teuchos::nonnull(kh_) && !isKokkosKernelsStream_) {
689 auto A_crs = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_crs_,
true);
690 auto Alocal = A_crs->getLocalMatrixDevice();
691 auto val = Alocal.values;
692 auto ptr = Alocal.graph.row_map;
693 auto ind = Alocal.graph.entries;
694 KokkosSparse::sptrsv_symbolic(kh_.getRawPtr(), ptr, ind, val);
695 }
else if (kh_v_nonnull_) {
696 for (
int i = 0; i < num_streams_; i++) {
697 auto A_crs_i = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_crs_v_[i],
true);
698 auto Alocal_i = A_crs_i->getLocalMatrixDevice();
699 auto val_i = Alocal_i.values;
700 auto ptr_i = Alocal_i.graph.row_map;
701 auto ind_i = Alocal_i.graph.entries;
702 KokkosSparse::sptrsv_symbolic(exec_space_instances_[i], kh_v_[i].getRawPtr(), ptr_i, ind_i, val_i);
710 if (Teuchos::nonnull(htsImpl_))
711 htsImpl_->compute(*A_crs_, out_);
718template <
class MatrixType>
724 Teuchos::ETransp mode,
729 using Teuchos::rcpFromRef;
731 typedef Teuchos::ScalarTraits<ST> STS;
732 const char prefix[] =
"Ifpack2::LocalSparseTriangularSolver::apply: ";
734 if (!out_.is_null()) {
735 *out_ <<
">>> DEBUG " << prefix;
736 if (!isKokkosKernelsStream_) {
737 if (A_crs_.is_null()) {
738 *out_ <<
"A_crs_ is null!" << std::endl;
740 Teuchos::RCP<const crs_matrix_type> A_crs =
741 Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_);
742 const std::string uplo = this->uplo_;
743 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" : (mode == Teuchos::TRANS ?
"T" :
"N");
744 const std::string diag = this->diag_;
745 *out_ <<
"uplo=\"" << uplo
746 <<
"\", trans=\"" << trans
747 <<
"\", diag=\"" << diag <<
"\"" << std::endl;
750 for (
int i = 0; i < num_streams_; i++) {
751 if (A_crs_v_[i].is_null()) {
752 *out_ <<
"A_crs_v_[" << i <<
"]"
753 <<
" is null!" << std::endl;
755 const std::string uplo = this->uplo_;
756 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" : (mode == Teuchos::TRANS ?
"T" :
"N");
757 const std::string diag = this->diag_;
758 *out_ <<
"A_crs_v_[" << i <<
"]: "
760 <<
"\", trans=\"" << trans
761 <<
"\", diag=\"" << diag <<
"\"" << std::endl;
767 TEUCHOS_TEST_FOR_EXCEPTION(!isComputed(), std::runtime_error, prefix <<
"If compute() has not yet "
768 "been called, or if you have changed the matrix via setMatrix(), you must "
769 "call compute() before you may call this method.");
772 if (!isKokkosKernelsStream_) {
773 TEUCHOS_TEST_FOR_EXCEPTION(A_.is_null(), std::logic_error, prefix <<
"A_ is null. "
774 "Please report this bug to the Ifpack2 developers.");
775 TEUCHOS_TEST_FOR_EXCEPTION(A_crs_.is_null(), std::logic_error, prefix <<
"A_crs_ is null. "
776 "Please report this bug to the Ifpack2 developers.");
779 TEUCHOS_TEST_FOR_EXCEPTION(!A_crs_->isFillComplete(), std::runtime_error,
781 "method, the matrix must be fill complete. It is not. This means that "
782 " you must have called resumeFill() on the matrix before calling apply(). "
783 "This is NOT allowed. Note that this class may use the matrix's data in "
784 "place without copying it. Thus, you cannot change the matrix and expect "
785 "the solver to stay the same. If you have changed the matrix, first call "
786 "fillComplete() on it, then call compute() on this object, before you call"
787 " apply(). You do NOT need to call setMatrix, as long as the matrix "
788 "itself (that is, its address in memory) is the same.");
790 for (
int i = 0; i < num_streams_; i++) {
791 TEUCHOS_TEST_FOR_EXCEPTION(A_crs_v_[i].is_null(), std::logic_error, prefix <<
"A_crs_ is null. "
792 "Please report this bug to the Ifpack2 developers.");
795 TEUCHOS_TEST_FOR_EXCEPTION(!A_crs_v_[i]->isFillComplete(), std::runtime_error,
797 "method, the matrix must be fill complete. It is not. This means that "
798 " you must have called resumeFill() on the matrix before calling apply(). "
799 "This is NOT allowed. Note that this class may use the matrix's data in "
800 "place without copying it. Thus, you cannot change the matrix and expect "
801 "the solver to stay the same. If you have changed the matrix, first call "
802 "fillComplete() on it, then call compute() on this object, before you call"
803 " apply(). You do NOT need to call setMatrix, as long as the matrix "
804 "itself (that is, its address in memory) is the same.");
811 if (!isKokkosKernelsStream_) {
812 auto G = A_crs_->getGraph();
813 TEUCHOS_TEST_FOR_EXCEPTION(G.is_null(), std::logic_error, prefix <<
"A_ and A_crs_ are nonnull, "
814 "but A_crs_'s RowGraph G is null. "
815 "Please report this bug to the Ifpack2 developers.");
816 auto importer = G->getImporter();
817 auto exporter = G->getExporter();
819 if (!importer.is_null()) {
820 if (X_colMap_.is_null() || X_colMap_->getNumVectors() != X.getNumVectors()) {
821 X_colMap_ = rcp(
new MV(importer->getTargetMap(), X.getNumVectors()));
823 X_colMap_->putScalar(STS::zero());
828 X_colMap_->doImport(X, *importer, Tpetra::ZERO);
830 X_cur = importer.is_null() ? rcpFromRef(X) : Teuchos::rcp_const_cast<const MV>(X_colMap_);
832 if (!exporter.is_null()) {
833 if (Y_rowMap_.is_null() || Y_rowMap_->getNumVectors() != Y.getNumVectors()) {
834 Y_rowMap_ = rcp(
new MV(exporter->getSourceMap(), Y.getNumVectors()));
836 Y_rowMap_->putScalar(STS::zero());
838 Y_rowMap_->doExport(Y, *importer, Tpetra::ADD);
840 Y_cur = exporter.is_null() ? rcpFromRef(Y) : Y_rowMap_;
844 X_cur = rcpFromRef(X);
845 Y_cur = rcpFromRef(Y);
848 localApply(*X_cur, *Y_cur, mode, alpha, beta);
850 if (!isKokkosKernelsStream_) {
851 auto G = A_crs_->getGraph();
852 auto exporter = G->getExporter();
853 if (!exporter.is_null()) {
854 Y.putScalar(STS::zero());
855 Y.doExport(*Y_cur, *exporter, Tpetra::ADD);
861template <
class MatrixType>
865 const Teuchos::ETransp mode)
const {
866 using Teuchos::CONJ_TRANS;
867 using Teuchos::NO_TRANS;
868 using Teuchos::TRANS;
869 const char tfecfFuncName[] =
"localTriangularSolve: ";
871 if (!isKokkosKernelsStream_) {
872 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!A_crs_->isFillComplete(), std::runtime_error,
873 "The matrix is not fill complete.");
874 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(A_crs_->getLocalNumRows() > 0 && this->uplo_ ==
"N", std::runtime_error,
875 "The matrix is neither upper triangular or lower triangular. "
876 "You may only call this method if the matrix is triangular. "
877 "Remember that this is a local (per MPI process) property, and that "
878 "Tpetra only knows how to do a local (per process) triangular solve.");
880 for (
int i = 0; i < num_streams_; i++) {
881 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!A_crs_v_[i]->isFillComplete(), std::runtime_error,
882 "The matrix is not fill complete.");
883 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(A_crs_v_[i]->getLocalNumRows() > 0 && this->uplo_ ==
"N", std::runtime_error,
884 "The matrix is neither upper triangular or lower triangular. "
885 "You may only call this method if the matrix is triangular. "
886 "Remember that this is a local (per MPI process) property, and that "
887 "Tpetra only knows how to do a local (per process) triangular solve.");
890 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!X.isConstantStride() || !Y.isConstantStride(), std::invalid_argument,
891 "X and Y must be constant stride.");
892 using STS = Teuchos::ScalarTraits<scalar_type>;
893 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(STS::isComplex && mode == TRANS, std::logic_error,
895 "not currently support non-conjugated transposed solve (mode == "
896 "Teuchos::TRANS) for complex scalar types.");
898 const std::string uplo = this->uplo_;
899 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" : (mode == Teuchos::
TRANS ?
"T" :
"N");
900 const size_t numVecs = std::min(X.getNumVectors(), Y.getNumVectors());
902 if (Teuchos::nonnull(kh_) && this->isKokkosKernelsSptrsv_ && trans ==
"N") {
903 auto A_crs = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(this->A_);
904 auto A_lclk = A_crs->getLocalMatrixDevice();
905 auto ptr = A_lclk.graph.row_map;
906 auto ind = A_lclk.graph.entries;
907 auto val = A_lclk.values;
909 for (
size_t j = 0; j < numVecs; ++j) {
910 auto X_j = X.getVectorNonConst(j);
911 auto Y_j = Y.getVector(j);
912 auto X_lcl = X_j->getLocalViewDevice(Tpetra::Access::ReadWrite);
913 auto Y_lcl = Y_j->getLocalViewDevice(Tpetra::Access::ReadOnly);
914 auto X_lcl_1d = Kokkos::subview(X_lcl, Kokkos::ALL(), 0);
915 auto Y_lcl_1d = Kokkos::subview(Y_lcl, Kokkos::ALL(), 0);
916 KokkosSparse::sptrsv_solve(kh_.getRawPtr(), ptr, ind, val, Y_lcl_1d, X_lcl_1d);
918 typename k_handle::HandleExecSpace().fence();
921 else if (kh_v_nonnull_ && this->isKokkosKernelsSptrsv_ && trans ==
"N") {
922 std::vector<lno_row_view_t> ptr_v(num_streams_);
923 std::vector<lno_nonzero_view_t> ind_v(num_streams_);
924 std::vector<scalar_nonzero_view_t> val_v(num_streams_);
925 std::vector<k_handle*> KernelHandle_rawptr_v_(num_streams_);
926 for (
size_t j = 0; j < numVecs; ++j) {
927 auto X_j = X.getVectorNonConst(j);
928 auto Y_j = Y.getVector(j);
929 auto X_lcl = X_j->getLocalViewDevice(Tpetra::Access::ReadWrite);
930 auto Y_lcl = Y_j->getLocalViewDevice(Tpetra::Access::ReadOnly);
931 auto X_lcl_1d = Kokkos::subview(X_lcl, Kokkos::ALL(), 0);
932 auto Y_lcl_1d = Kokkos::subview(Y_lcl, Kokkos::ALL(), 0);
933 std::vector<
decltype(X_lcl_1d)> x_v(num_streams_);
934 std::vector<
decltype(Y_lcl_1d)> y_v(num_streams_);
935 local_ordinal_type stream_begin = 0;
936 local_ordinal_type stream_end;
937 for (
int i = 0; i < num_streams_; i++) {
938 auto A_crs_i = Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A_crs_v_[i]);
939 auto Alocal_i = A_crs_i->getLocalMatrixDevice();
940 ptr_v[i] = Alocal_i.graph.row_map;
941 ind_v[i] = Alocal_i.graph.entries;
942 val_v[i] = Alocal_i.values;
943 stream_end = stream_begin + Alocal_i.numRows();
944 x_v[i] = Kokkos::subview(X_lcl, Kokkos::make_pair(stream_begin, stream_end), 0);
945 y_v[i] = Kokkos::subview(Y_lcl, Kokkos::make_pair(stream_begin, stream_end), 0);
946 KernelHandle_rawptr_v_[i] = kh_v_[i].getRawPtr();
947 stream_begin = stream_end;
950 KokkosSparse::Experimental::sptrsv_solve_streams(exec_space_instances_, KernelHandle_rawptr_v_,
951 ptr_v, ind_v, val_v, y_v, x_v);
952 for (
int i = 0; i < num_streams_; i++) exec_space_instances_[i].fence();
957 const std::string diag = this->diag_;
962 auto A_lcl = this->A_crs_->getLocalMatrixHost();
964 if (X.isConstantStride() && Y.isConstantStride()) {
965 auto X_lcl = X.getLocalViewHost(Tpetra::Access::ReadWrite);
966 auto Y_lcl = Y.getLocalViewHost(Tpetra::Access::ReadOnly);
967 KokkosSparse::trsv(uplo.c_str(), trans.c_str(), diag.c_str(),
968 A_lcl, Y_lcl, X_lcl);
970 for (
size_t j = 0; j < numVecs; ++j) {
971 auto X_j = X.getVectorNonConst(j);
972 auto Y_j = Y.getVector(j);
973 auto X_lcl = X_j->getLocalViewHost(Tpetra::Access::ReadWrite);
974 auto Y_lcl = Y_j->getLocalViewHost(Tpetra::Access::ReadOnly);
975 KokkosSparse::trsv(uplo.c_str(), trans.c_str(),
976 diag.c_str(), A_lcl, Y_lcl, X_lcl);
982template <
class MatrixType>
983void LocalSparseTriangularSolver<MatrixType>::
984 localApply(
const MV& X,
986 const Teuchos::ETransp mode,
987 const scalar_type& alpha,
988 const scalar_type& beta)
const {
989 if (mode == Teuchos::NO_TRANS && Teuchos::nonnull(htsImpl_) &&
990 htsImpl_->isComputed()) {
991 htsImpl_->localApply(X, Y, mode, alpha, beta);
996 typedef scalar_type ST;
997 typedef Teuchos::ScalarTraits<ST> STS;
999 if (beta == STS::zero()) {
1000 if (alpha == STS::zero()) {
1001 Y.putScalar(STS::zero());
1003 this->localTriangularSolve(X, Y, mode);
1004 if (alpha != STS::one()) {
1009 if (alpha == STS::zero()) {
1012 MV Y_tmp(Y, Teuchos::Copy);
1013 this->localTriangularSolve(X, Y_tmp, mode);
1014 Y.update(alpha, Y_tmp, beta);
1019template <
class MatrixType>
1022 return numInitialize_;
1025template <
class MatrixType>
1031template <
class MatrixType>
1037template <
class MatrixType>
1041 return initializeTime_;
1044template <
class MatrixType>
1048 return computeTime_;
1051template <
class MatrixType>
1058template <
class MatrixType>
1062 std::ostringstream os;
1067 os <<
"\"Ifpack2::LocalSparseTriangularSolver\": {";
1068 if (this->getObjectLabel() !=
"") {
1069 os <<
"Label: \"" << this->getObjectLabel() <<
"\", ";
1071 os <<
"Initialized: " << (isInitialized() ?
"true" :
"false") <<
", "
1072 <<
"Computed: " << (isComputed() ?
"true" :
"false") <<
", ";
1074 if (isKokkosKernelsSptrsv_) os <<
"KK-SPTRSV, ";
1075 if (isKokkosKernelsStream_) os <<
"KK-SolveStream, ";
1078 os <<
"Matrix: null";
1080 os <<
"Matrix dimensions: ["
1081 << A_->getGlobalNumRows() <<
", "
1082 << A_->getGlobalNumCols() <<
"]"
1083 <<
", Number of nonzeros: " << A_->getGlobalNumEntries();
1086 if (Teuchos::nonnull(htsImpl_))
1087 os <<
", HTS computed: " << (htsImpl_->isComputed() ?
"true" :
"false");
1092template <
class MatrixType>
1094 describe(Teuchos::FancyOStream& out,
1095 const Teuchos::EVerbosityLevel verbLevel)
const {
1099 const Teuchos::EVerbosityLevel vl = (verbLevel == Teuchos::VERB_DEFAULT) ? Teuchos::VERB_LOW : verbLevel;
1101 if (vl != Teuchos::VERB_NONE) {
1106 auto comm = A_.is_null() ? Tpetra::getDefaultComm() : A_->getComm();
1110 if (!comm.is_null() && comm->getRank() == 0) {
1112 Teuchos::OSTab tab0(out);
1115 out <<
"\"Ifpack2::LocalSparseTriangularSolver\":" << endl;
1116 Teuchos::OSTab tab1(out);
1117 out <<
"Scalar: " << Teuchos::TypeNameTraits<scalar_type>::name() << endl
1118 <<
"LocalOrdinal: " << Teuchos::TypeNameTraits<local_ordinal_type>::name() << endl
1119 <<
"GlobalOrdinal: " << Teuchos::TypeNameTraits<global_ordinal_type>::name() << endl
1120 <<
"Node: " << Teuchos::TypeNameTraits<node_type>::name() << endl;
1125template <
class MatrixType>
1126Teuchos::RCP<const typename LocalSparseTriangularSolver<MatrixType>::map_type>
1129 TEUCHOS_TEST_FOR_EXCEPTION(A_.is_null(), std::runtime_error,
1130 "Ifpack2::LocalSparseTriangularSolver::getDomainMap: "
1131 "The matrix is null. Please call setMatrix() with a nonnull input "
1132 "before calling this method.");
1133 return A_->getDomainMap();
1136template <
class MatrixType>
1137Teuchos::RCP<const typename LocalSparseTriangularSolver<MatrixType>::map_type>
1140 TEUCHOS_TEST_FOR_EXCEPTION(A_.is_null(), std::runtime_error,
1141 "Ifpack2::LocalSparseTriangularSolver::getRangeMap: "
1142 "The matrix is null. Please call setMatrix() with a nonnull input "
1143 "before calling this method.");
1144 return A_->getRangeMap();
1147template <
class MatrixType>
1149 setMatrix(
const Teuchos::RCP<const row_matrix_type>& A) {
1150 const char prefix[] =
"Ifpack2::LocalSparseTriangularSolver::setMatrix: ";
1156 if (A.getRawPtr() != A_.getRawPtr() || isInternallyChanged_) {
1158 TEUCHOS_TEST_FOR_EXCEPTION(!A.is_null() && A->getComm()->getSize() == 1 &&
1159 A->getLocalNumRows() != A->getLocalNumCols(),
1160 std::runtime_error, prefix <<
"If A's communicator only contains one "
1161 "process, then A must be square. Instead, you provided a matrix A with "
1162 << A->getLocalNumRows() <<
" rows and " << A->getLocalNumCols() <<
" columns.");
1167 isInitialized_ =
false;
1168 isComputed_ =
false;
1171 A_crs_ = Teuchos::null;
1174 Teuchos::RCP<const crs_matrix_type> A_crs =
1175 Teuchos::rcp_dynamic_cast<const crs_matrix_type>(A);
1176 TEUCHOS_TEST_FOR_EXCEPTION(A_crs.is_null(), std::invalid_argument, prefix <<
"The input matrix A is not a Tpetra::CrsMatrix.");
1181 if (Teuchos::nonnull(htsImpl_))
1186template <
class MatrixType>
1188 setStreamInfo(
const bool& isKokkosKernelsStream,
const int& num_streams,
1189 const std::vector<HandleExecSpace>& exec_space_instances) {
1190 isKokkosKernelsStream_ = isKokkosKernelsStream;
1191 num_streams_ = num_streams;
1192 exec_space_instances_ = exec_space_instances;
1193 A_crs_v_ = std::vector<Teuchos::RCP<crs_matrix_type>>(num_streams_);
1196template <
class MatrixType>
1198 setMatrices(
const std::vector<Teuchos::RCP<crs_matrix_type>>& A_crs_v) {
1199 const char prefix[] =
"Ifpack2::LocalSparseTriangularSolver::setMatrixWithStreams: ";
1201 for (
int i = 0; i < num_streams_; i++) {
1206 if (A_crs_v[i].getRawPtr() != A_crs_v_[i].getRawPtr() || isInternallyChanged_) {
1208 TEUCHOS_TEST_FOR_EXCEPTION(!A_crs_v[i].is_null() && A_crs_v[i]->getComm()->getSize() == 1 &&
1209 A_crs_v[i]->getLocalNumRows() != A_crs_v[i]->getLocalNumCols(),
1210 std::runtime_error, prefix <<
"If A's communicator only contains one "
1211 "process, then A must be square. Instead, you provided a matrix A with "
1212 << A_crs_v[i]->getLocalNumRows() <<
" rows and " << A_crs_v[i]->getLocalNumCols() <<
" columns.");
1217 isInitialized_ =
false;
1218 isComputed_ =
false;
1220 if (A_crs_v[i].is_null()) {
1221 A_crs_v_[i] = Teuchos::null;
1223 Teuchos::RCP<crs_matrix_type> A_crs =
1224 Teuchos::rcp_dynamic_cast<crs_matrix_type>(A_crs_v[i]);
1225 TEUCHOS_TEST_FOR_EXCEPTION(A_crs.is_null(), std::invalid_argument, prefix <<
"The input matrix A is not a Tpetra::CrsMatrix.");
1226 A_crs_v_[i] = A_crs;
1234#define IFPACK2_LOCALSPARSETRIANGULARSOLVER_INSTANT(S, LO, GO, N) \
1235 template class Ifpack2::LocalSparseTriangularSolver<Tpetra::RowMatrix<S, LO, GO, N>>;
"Preconditioner" that solves local sparse triangular systems.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:54
bool isComputed() const
Return true if compute() has been called.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:192
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with given verbosity to the given output stream.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1094
std::string description() const
A one-line description of this object.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1061
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:70
LocalSparseTriangularSolver()
Constructor that takes no input matrix.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:297
MatrixType::local_ordinal_type local_ordinal_type
Type of the local indices of the input matrix.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:61
void setParameters(const Teuchos::ParameterList ¶ms)
Set this object's parameters.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:349
double getComputeTime() const
Return the time spent in compute().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1047
void initialize()
"Symbolic" phase of setup
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:393
MatrixType::global_ordinal_type global_ordinal_type
Type of the global indices of the input matrix.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:63
int getNumCompute() const
Return the number of calls to compute().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1027
double getInitializeTime() const
Return the time spent in initialize().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1040
Teuchos::RCP< const map_type > getDomainMap() const
The domain of this operator.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1128
MatrixType::scalar_type scalar_type
Scalar type of the entries of the input matrix.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:57
MatrixType::node_type node_type
Node type of the input matrix.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:65
int getNumInitialize() const
Return the number of calls to initialize().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1021
void setStreamInfo(const bool &isKokkosKernelsStream, const int &num_streams, const std::vector< HandleExecSpace > &exec_space_instances)
Set this triangular solver's stream information.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1188
Tpetra::CrsMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > crs_matrix_type
Specialization of Tpetra::CrsMatrix used by this class.
Definition Ifpack2_LocalSparseTriangularSolver_decl.hpp:78
Teuchos::RCP< const map_type > getRangeMap() const
The range of this operator.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1139
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set this preconditioner's matrix.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1149
void setMatrices(const std::vector< Teuchos::RCP< crs_matrix_type > > &A_crs_v)
Set this preconditioner's matrices (used by stream interface of triangular solve).
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1198
virtual ~LocalSparseTriangularSolver()
Destructor (virtual for memory safety).
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:333
double getApplyTime() const
Return the time spent in apply().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1054
void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Apply the preconditioner to X, and put the result in Y.
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:720
int getNumApply() const
Return the number of calls to apply().
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:1033
void compute()
"Numeric" phase of setup
Definition Ifpack2_LocalSparseTriangularSolver_def.hpp:643
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40