44 #ifndef AMESOS2_TACHO_DEF_HPP 45 #define AMESOS2_TACHO_DEF_HPP 47 #include <Teuchos_Tuple.hpp> 48 #include <Teuchos_ParameterList.hpp> 49 #include <Teuchos_StandardParameterEntryValidators.hpp> 52 #include "Amesos2_Tacho_decl.hpp" 57 template <
class Matrix,
class Vector>
59 Teuchos::RCP<const Matrix> A,
60 Teuchos::RCP<Vector> X,
61 Teuchos::RCP<const Vector> B )
67 template <
class Matrix,
class Vector>
72 template <
class Matrix,
class Vector>
76 std::ostringstream oss;
77 oss <<
"Tacho solver interface";
81 template<
class Matrix,
class Vector>
88 template <
class Matrix,
class Vector>
94 if(do_optimization()) {
95 this->matrixA_->returnRowPtr_kokkos_view(host_row_ptr_view_);
96 this->matrixA_->returnColInd_kokkos_view(host_cols_view_);
103 data_.solver.analyze(this->globalNumCols_, host_row_ptr_view_, host_cols_view_);
109 template <
class Matrix,
class Vector>
115 if(do_optimization()) {
116 this->matrixA_->returnValues_kokkos_view(device_nzvals_view_);
118 data_.solver.factorize(device_nzvals_view_);
123 template <
class Matrix,
class Vector>
130 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
131 const size_t nrhs = X->getGlobalNumVectors();
140 #ifdef HAVE_AMESOS2_TIMERS 141 Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
142 Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
144 const bool initialize_data =
true;
145 const bool do_not_initialize_data =
false;
146 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
147 device_solve_array_t>::do_get(initialize_data, B, this->bValues_,
149 ROOTED, this->rowIndexBase_);
150 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
151 device_solve_array_t>::do_get(do_not_initialize_data, X, this->xValues_,
153 ROOTED, this->rowIndexBase_);
159 #ifdef HAVE_AMESOS2_TIMER 160 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
163 if (workspace_.extent(0) < this->globalNumRows_ || workspace_.extent(1) < nrhs) {
164 workspace_ = device_solve_array_t(
165 Kokkos::ViewAllocateWithoutInitializing(
"t"), this->globalNumRows_, nrhs);
168 data_.solver.solve(xValues_, bValues_, workspace_);
177 Teuchos::broadcast(*(this->getComm()), 0, &ierr);
179 TEUCHOS_TEST_FOR_EXCEPTION( ierr != 0, std::runtime_error,
180 "tacho_solve has error code: " << ierr );
187 #ifdef HAVE_AMESOS2_TIMERS 188 Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
193 Util::template put_1d_data_helper_kokkos_view<
196 ROOTED, this->rowIndexBase_);
203 template <
class Matrix,
class Vector>
208 return( this->matrixA_->getGlobalNumRows() == this->matrixA_->getGlobalNumCols() );
212 template <
class Matrix,
class Vector>
216 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
224 template <
class Matrix,
class Vector>
225 Teuchos::RCP<const Teuchos::ParameterList>
228 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
230 if( is_null(valid_params) ){
231 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
243 template <
class Matrix,
class Vector>
246 return (this->root_ && (this->matrixA_->getComm()->getSize() == 1));
249 template <
class Matrix,
class Vector>
254 if(current_phase == SOLVE) {
258 if(!do_optimization()) {
259 #ifdef HAVE_AMESOS2_TIMERS 260 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
270 device_nzvals_view_ = device_value_type_array(
271 Kokkos::ViewAllocateWithoutInitializing(
"nzvals"), this->globalNumNonZeros_);
272 host_cols_view_ = host_ordinal_type_array(
273 Kokkos::ViewAllocateWithoutInitializing(
"colind"), this->globalNumNonZeros_);
274 host_row_ptr_view_ = host_size_type_array(
275 Kokkos::ViewAllocateWithoutInitializing(
"rowptr"), this->globalNumRows_ + 1);
278 typename host_size_type_array::value_type nnz_ret = 0;
280 #ifdef HAVE_AMESOS2_TIMERS 281 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
284 TEUCHOS_TEST_FOR_EXCEPTION( this->rowIndexBase_ != this->columnIndexBase_,
286 "Row and column maps have different indexbase ");
289 device_value_type_array, host_ordinal_type_array, host_size_type_array>::do_get(
290 this->matrixA_.ptr(),
296 this->columnIndexBase_);
304 template<
class Matrix,
class Vector>
310 #endif // AMESOS2_TACHO_DEF_HPP Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Amesos2 interface to the Tacho package.
Definition: Amesos2_Tacho_decl.hpp:67
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using Tacho.
Definition: Amesos2_Tacho_def.hpp:90
Definition: Amesos2_TypeDecl.hpp:143
Utility functions for Amesos2.
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Tacho_def.hpp:205
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
int numericFactorization_impl()
Tacho specific numeric factorization.
Definition: Amesos2_Tacho_def.hpp:111
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_Tacho_def.hpp:74
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Tacho_def.hpp:226
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Tacho_def.hpp:83
bool do_optimization() const
can we optimize size_type and ordinal_type for straight pass through
Definition: Amesos2_Tacho_def.hpp:245
Similar to get_ccs_helper , but used to get a CRS representation of the given matrix.
Definition: Amesos2_Util.hpp:970
TachoSolver(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_Tacho_def.hpp:58
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Tacho_def.hpp:251
Definition: Amesos2_TypeDecl.hpp:127
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Tacho specific solve.
Definition: Amesos2_Tacho_def.hpp:125
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176
~TachoSolver()
Destructor.
Definition: Amesos2_Tacho_def.hpp:68