19#ifndef AMESOS2_BASKER_DEF_HPP
20#define AMESOS2_BASKER_DEF_HPP
22#include <Teuchos_Tuple.hpp>
23#include <Teuchos_ParameterList.hpp>
24#include <Teuchos_StandardParameterEntryValidators.hpp>
32template <
class Matrix,
class Vector>
33Basker<Matrix,Vector>::Basker(
34 Teuchos::RCP<const Matrix> A,
35 Teuchos::RCP<Vector> X,
36 Teuchos::RCP<const Vector> B )
38 , is_contiguous_(true)
45template <
class Matrix,
class Vector>
46Basker<Matrix,Vector>::~Basker( )
49template <
class Matrix,
class Vector>
52 return (this->
root_ && (this->
matrixA_->getComm()->getSize() == 1) && is_contiguous_);
55template<
class Matrix,
class Vector>
61#ifdef HAVE_AMESOS2_TIMERS
62 Teuchos::TimeMonitor preOrderTimer(this->
timers_.preOrderTime_);
69template <
class Matrix,
class Vector>
71Basker<Matrix,Vector>::symbolicFactorization_impl()
78template <
class Matrix,
class Vector>
87 #ifdef HAVE_AMESOS2_TIMERS
88 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
91 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
92 std::cout <<
"Basker:: Before numeric factorization" << std::endl;
93 std::cout <<
"nzvals_ : " << nzvals_.toString() << std::endl;
94 std::cout <<
"rowind_ : " << rowind_.toString() << std::endl;
95 std::cout <<
"colptr_ : " << colptr_.toString() << std::endl;
98 basker_dtype * pBaskerValues = function_map::convert_scalar(
host_nzvals_view_.data());
103 this->
setNnzLU( as<size_t>(basker.get_NnzLU() ) ) ;
109 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
113 TEUCHOS_TEST_FOR_EXCEPTION( (info == -1) ,
115 "Basker: Could not alloc space for L and U");
116 TEUCHOS_TEST_FOR_EXCEPTION( (info == -2),
118 "Basker: Could not alloc needed work space");
119 TEUCHOS_TEST_FOR_EXCEPTION( (info == -3) ,
121 "Basker: Could not alloc additional memory needed for L and U");
122 TEUCHOS_TEST_FOR_EXCEPTION( (info > 0) ,
124 "Basker: Zero pivot found at: " << info );
130template <
class Matrix,
class Vector>
140 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
141 const size_t nrhs = X->getGlobalNumVectors();
145#ifdef HAVE_AMESOS2_TIMERS
146 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
147 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
150 const bool initialize_data =
true;
151 const bool do_not_initialize_data =
false;
154 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
155 host_solve_array_t>::do_get(initialize_data, B,
bValues_, as<size_t>(ld_rhs));
157 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
158 host_solve_array_t>::do_get(do_not_initialize_data, X,
xValues_, as<size_t>(ld_rhs));
161 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
162 host_solve_array_t>::do_get(initialize_data, B,
bValues_,
168 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
169 host_solve_array_t>::do_get(do_not_initialize_data, X,
xValues_,
177#ifdef HAVE_AMESOS2_TIMERS
178 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
181 basker_dtype * pxBaskerValues = function_map::convert_scalar(
xValues_.data());
182 basker_dtype * pbBaskerValues = function_map::convert_scalar(
bValues_.data());
183 ierr = basker.solveMultiple(nrhs, pbBaskerValues, pxBaskerValues);
187 Teuchos::broadcast(*(this->
getComm()), 0, &ierr);
189 TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
191 "Encountered zero diag element at: " << ierr);
192 TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
194 "Could not alloc needed working memory for solve" );
199#ifdef HAVE_AMESOS2_TIMERS
200 Teuchos::TimeMonitor redistTimer(this->
timers_.vecRedistTime_);
203 Util::put_1d_data_helper_kokkos_view<MultiVecAdapter<Vector>,
204 host_solve_array_t>::do_put(X,
xValues_,
213template <
class Matrix,
class Vector>
222template <
class Matrix,
class Vector>
224Basker<Matrix,Vector>::setParameters_impl(
const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
227 using Teuchos::getIntegralValue;
228 using Teuchos::ParameterEntryValidator;
230 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
232 if(parameterList->isParameter(
"IsContiguous"))
234 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
239template <
class Matrix,
class Vector>
240Teuchos::RCP<const Teuchos::ParameterList>
243 using Teuchos::ParameterList;
245 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
247 if( is_null(valid_params) ){
248 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
250 pl->set(
"IsContiguous",
true,
"Are GIDs contiguous");
251 pl->set(
"alnnz", 2,
"Approx number of nonzeros in L, default is 2*nnz(A)");
252 pl->set(
"aunnx", 2,
"Approx number of nonzeros in I, default is 2*nnz(U)");
259template <
class Matrix,
class Vector>
264 if(current_phase == SOLVE)
return (
false);
266 #ifdef HAVE_AMESOS2_TIMERS
267 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
273 Kokkos::ViewAllocateWithoutInitializing(
"host_nzvals_view_"), this->
globalNumNonZeros_);
275 Kokkos::ViewAllocateWithoutInitializing(
"host_rows_view_"), this->
globalNumNonZeros_);
277 Kokkos::ViewAllocateWithoutInitializing(
"host_col_ptr_view_"), this->
globalNumRows_ + 1);
280 local_ordinal_type nnz_ret = 0;
282 #ifdef HAVE_AMESOS2_TIMERS
283 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
292 this->rowIndexBase_);
296 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
298 "Amesos2_Basker loadA_impl: Did not get the expected number of non-zero vals");
304template<
class Matrix,
class Vector>
Amesos2 Basker declarations.
@ ROOTED
Definition Amesos2_TypeDecl.hpp:93
@ CONTIGUOUS_AND_ROOTED
Definition Amesos2_TypeDecl.hpp:94
@ ARBITRARY
Definition Amesos2_TypeDecl.hpp:109
Amesos2 interface to the Baker package.
Definition Amesos2_Basker_decl.hpp:40
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_Basker_def.hpp:57
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Basker_def.hpp:215
host_ordinal_type_array host_rows_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Basker_decl.hpp:163
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_Basker_def.hpp:261
host_solve_array_t bValues_
Persisting 1D store for B.
Definition Amesos2_Basker_decl.hpp:176
host_solve_array_t xValues_
Persisting 1D store for X.
Definition Amesos2_Basker_decl.hpp:173
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Basker specific solve.
Definition Amesos2_Basker_def.hpp:132
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through,
Definition Amesos2_Basker_def.hpp:51
host_ordinal_type_array host_col_ptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Basker_decl.hpp:165
host_value_type_array host_nzvals_view_
Stores the values of the nonzero entries for CHOLMOD.
Definition Amesos2_Basker_decl.hpp:161
int numericFactorization_impl()
Basker specific numeric factorization.
Definition Amesos2_Basker_def.hpp:80
static const char * name
Name of this solver interface.
Definition Amesos2_Basker_decl.hpp:47
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Basker_def.hpp:241
A Matrix adapter interface for Amesos2.
Definition Amesos2_MatrixAdapter_decl.hpp:42
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
Definition Amesos2_SolverCore_decl.hpp:421
bool root_
Definition Amesos2_SolverCore_decl.hpp:472
void setNnzLU(size_t nnz)
Definition Amesos2_SolverCore_decl.hpp:418
global_size_type rowIndexBase_
Definition Amesos2_SolverCore_decl.hpp:451
global_size_type globalNumCols_
Definition Amesos2_SolverCore_decl.hpp:445
Timers timers_
Definition Amesos2_SolverCore_decl.hpp:463
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
Definition Amesos2_SolverCore_decl.hpp:329
global_size_type globalNumNonZeros_
Definition Amesos2_SolverCore_decl.hpp:448
global_size_type globalNumRows_
Definition Amesos2_SolverCore_decl.hpp:442
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:31
A templated MultiVector class adapter for Amesos2.
Definition Amesos2_MultiVecAdapter_decl.hpp:142
A generic helper class for getting a CCS representation of a Matrix.
Definition Amesos2_Util.hpp:615