53#ifndef AMESOS2_BASKER_DEF_HPP
54#define AMESOS2_BASKER_DEF_HPP
56#include <Teuchos_Tuple.hpp>
57#include <Teuchos_ParameterList.hpp>
58#include <Teuchos_StandardParameterEntryValidators.hpp>
66template <
class Matrix,
class Vector>
67Basker<Matrix,Vector>::Basker(
68 Teuchos::RCP<const Matrix> A,
69 Teuchos::RCP<Vector> X,
70 Teuchos::RCP<const Vector> B )
72 , is_contiguous_(true)
79template <
class Matrix,
class Vector>
80Basker<Matrix,Vector>::~Basker( )
83template <
class Matrix,
class Vector>
86 return (this->
root_ && (this->
matrixA_->getComm()->getSize() == 1) && is_contiguous_);
89template<
class Matrix,
class Vector>
95#ifdef HAVE_AMESOS2_TIMERS
96 Teuchos::TimeMonitor preOrderTimer(this->
timers_.preOrderTime_);
103template <
class Matrix,
class Vector>
105Basker<Matrix,Vector>::symbolicFactorization_impl()
112template <
class Matrix,
class Vector>
121 #ifdef HAVE_AMESOS2_TIMERS
122 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
125 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
126 std::cout <<
"Basker:: Before numeric factorization" << std::endl;
127 std::cout <<
"nzvals_ : " << nzvals_.toString() << std::endl;
128 std::cout <<
"rowind_ : " << rowind_.toString() << std::endl;
129 std::cout <<
"colptr_ : " << colptr_.toString() << std::endl;
132 basker_dtype * pBaskerValues = function_map::convert_scalar(
host_nzvals_view_.data());
137 this->
setNnzLU( as<size_t>(basker.get_NnzLU() ) ) ;
143 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
147 TEUCHOS_TEST_FOR_EXCEPTION( (info == -1) ,
149 "Basker: Could not alloc space for L and U");
150 TEUCHOS_TEST_FOR_EXCEPTION( (info == -2),
152 "Basker: Could not alloc needed work space");
153 TEUCHOS_TEST_FOR_EXCEPTION( (info == -3) ,
155 "Basker: Could not alloc additional memory needed for L and U");
156 TEUCHOS_TEST_FOR_EXCEPTION( (info > 0) ,
158 "Basker: Zero pivot found at: " << info );
164template <
class Matrix,
class Vector>
174 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
175 const size_t nrhs = X->getGlobalNumVectors();
179#ifdef HAVE_AMESOS2_TIMERS
180 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
181 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
184 const bool initialize_data =
true;
185 const bool do_not_initialize_data =
false;
188 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
189 host_solve_array_t>::do_get(initialize_data, B,
bValues_, as<size_t>(ld_rhs));
191 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
192 host_solve_array_t>::do_get(do_not_initialize_data, X,
xValues_, as<size_t>(ld_rhs));
195 if ( is_contiguous_ ==
true ) {
196 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
200 Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
205 if ( is_contiguous_ ==
true ) {
206 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
210 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
217#ifdef HAVE_AMESOS2_TIMERS
218 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
221 basker_dtype * pxBaskerValues = function_map::convert_scalar(
xValues_.data());
222 basker_dtype * pbBaskerValues = function_map::convert_scalar(
bValues_.data());
223 ierr = basker.solveMultiple(nrhs, pbBaskerValues, pxBaskerValues);
227 Teuchos::broadcast(*(this->
getComm()), 0, &ierr);
229 TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
231 "Encountered zero diag element at: " << ierr);
232 TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
234 "Could not alloc needed working memory for solve" );
239#ifdef HAVE_AMESOS2_TIMERS
240 Teuchos::TimeMonitor redistTimer(this->
timers_.vecRedistTime_);
242 if ( is_contiguous_ ==
true ) {
243 Util::put_1d_data_helper_kokkos_view<
249 Util::put_1d_data_helper_kokkos_view<
260template <
class Matrix,
class Vector>
269template <
class Matrix,
class Vector>
271Basker<Matrix,Vector>::setParameters_impl(
const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
274 using Teuchos::getIntegralValue;
275 using Teuchos::ParameterEntryValidator;
277 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
279 if(parameterList->isParameter(
"IsContiguous"))
281 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
286template <
class Matrix,
class Vector>
287Teuchos::RCP<const Teuchos::ParameterList>
290 using Teuchos::ParameterList;
292 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
294 if( is_null(valid_params) ){
295 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
297 pl->set(
"IsContiguous",
true,
"Are GIDs contiguous");
298 pl->set(
"alnnz", 2,
"Approx number of nonzeros in L, default is 2*nnz(A)");
299 pl->set(
"aunnx", 2,
"Approx number of nonzeros in I, default is 2*nnz(U)");
306template <
class Matrix,
class Vector>
311 if(current_phase == SOLVE)
return (
false);
313 #ifdef HAVE_AMESOS2_TIMERS
314 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
320 Kokkos::ViewAllocateWithoutInitializing(
"host_nzvals_view_"), this->
globalNumNonZeros_);
322 Kokkos::ViewAllocateWithoutInitializing(
"host_rows_view_"), this->
globalNumNonZeros_);
324 Kokkos::ViewAllocateWithoutInitializing(
"host_col_ptr_view_"), this->
globalNumRows_ + 1);
327 local_ordinal_type nnz_ret = 0;
329 #ifdef HAVE_AMESOS2_TIMERS
330 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
333 if ( is_contiguous_ ==
true ) {
348 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
350 "Amesos2_Basker loadA_impl: Did not get the expected number of non-zero vals");
356template<
class Matrix,
class Vector>
Amesos2 Basker declarations.
@ ROOTED
Definition Amesos2_TypeDecl.hpp:127
@ CONTIGUOUS_AND_ROOTED
Definition Amesos2_TypeDecl.hpp:128
@ ARBITRARY
Definition Amesos2_TypeDecl.hpp:143
Amesos2 interface to the Baker package.
Definition Amesos2_Basker_decl.hpp:74
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_Basker_def.hpp:91
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Basker_def.hpp:262
host_ordinal_type_array host_rows_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Basker_decl.hpp:197
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_Basker_def.hpp:308
host_solve_array_t bValues_
Persisting 1D store for B.
Definition Amesos2_Basker_decl.hpp:210
host_solve_array_t xValues_
Persisting 1D store for X.
Definition Amesos2_Basker_decl.hpp:207
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:166
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through,
Definition Amesos2_Basker_def.hpp:85
host_ordinal_type_array host_col_ptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Basker_decl.hpp:199
host_value_type_array host_nzvals_view_
Stores the values of the nonzero entries for CHOLMOD.
Definition Amesos2_Basker_decl.hpp:195
int numericFactorization_impl()
Basker specific numeric factorization.
Definition Amesos2_Basker_def.hpp:114
static const char * name
Name of this solver interface.
Definition Amesos2_Basker_decl.hpp:81
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Basker_def.hpp:288
A Matrix adapter interface for Amesos2.
Definition Amesos2_MatrixAdapter_decl.hpp:76
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:106
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
Definition Amesos2_SolverCore_decl.hpp:455
bool root_
Definition Amesos2_SolverCore_decl.hpp:506
void setNnzLU(size_t nnz)
Definition Amesos2_SolverCore_decl.hpp:452
global_size_type rowIndexBase_
Definition Amesos2_SolverCore_decl.hpp:485
global_size_type globalNumCols_
Definition Amesos2_SolverCore_decl.hpp:479
Timers timers_
Definition Amesos2_SolverCore_decl.hpp:497
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Definition Amesos2_SolverCore_decl.hpp:363
global_size_type globalNumNonZeros_
Definition Amesos2_SolverCore_decl.hpp:482
global_size_type globalNumRows_
Definition Amesos2_SolverCore_decl.hpp:476
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:65
A templated MultiVector class adapter for Amesos2.
Definition Amesos2_MultiVecAdapter_decl.hpp:176
A generic helper class for getting a CCS representation of a Matrix.
Definition Amesos2_Util.hpp:652