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> 64 #include "Kokkos_Core.hpp" 70 template <
class Matrix,
class Vector>
71 Basker<Matrix,Vector>::Basker(
72 Teuchos::RCP<const Matrix> A,
73 Teuchos::RCP<Vector> X,
74 Teuchos::RCP<const Vector> B )
89 #ifdef HAVE_AMESOS2_KOKKOS 91 typedef Kokkos::OpenMP Exe_Space;
93 basker = new ::BaskerNS::Basker<local_ordinal_type, slu_type, Exe_Space>();
95 printf(
"Constructor Called \n");
97 basker->Options.no_pivot =
true;
98 basker->Options.symmetric =
false;
99 basker->Options.realloc =
false;
100 basker->Options.verbose =
false;
101 basker->Options.btf =
true;
103 num_threads = Kokkos::OpenMP::max_hardware_threads();
112 template <
class Matrix,
class Vector>
113 Basker<Matrix,Vector>::~Basker( )
115 printf(
"Destructor Call \n");
117 #ifdef HAVE_AMESOS2_KOKKOS 125 template<
class Matrix,
class Vector>
131 #ifdef HAVE_AMESOS2_TIMERS 132 Teuchos::TimeMonitor preOrderTimer(this->
timers_.preOrderTime_);
139 template <
class Matrix,
class Vector>
150 basker->SetThreads(num_threads);
155 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 156 std::cout <<
"Basker:: Before symbolic factorization" << std::endl;
157 std::cout <<
"nzvals_ : " <<
nzvals_.toString() << std::endl;
158 std::cout <<
"rowind_ : " <<
rowind_.toString() << std::endl;
159 std::cout <<
"colptr_ : " <<
colptr_.toString() << std::endl;
182 template <
class Matrix,
class Vector>
191 #ifdef HAVE_AMESOS2_TIMERS 192 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
195 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 196 std::cout <<
"Basker:: Before numeric factorization" << std::endl;
197 std::cout <<
"nzvals_ : " <<
nzvals_.toString() << std::endl;
198 std::cout <<
"rowind_ : " <<
rowind_.toString() << std::endl;
199 std::cout <<
"colptr_ : " <<
colptr_.toString() << std::endl;
203 std::cout <<
"SHYLUBASKER FACTOR " << std::endl;
223 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
227 TEUCHOS_TEST_FOR_EXCEPTION( (info == -1) ,
229 "Basker: Could not alloc space for L and U");
230 TEUCHOS_TEST_FOR_EXCEPTION( (info == -2),
232 "Basker: Could not alloc needed work space");
233 TEUCHOS_TEST_FOR_EXCEPTION( (info == -3) ,
235 "Basker: Could not alloc additional memory needed for L and U");
236 TEUCHOS_TEST_FOR_EXCEPTION( (info > 0) ,
238 "Basker: Zero pivot found at: " << info );
244 template <
class Matrix,
class Vector>
252 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
253 const size_t nrhs = X->getGlobalNumVectors();
255 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
257 xvals_.resize(val_store_size);
258 bvals_.resize(val_store_size);
261 #ifdef HAVE_AMESOS2_TIMERS 262 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
263 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
266 slu_type>::do_get(B,
bvals_(),as<size_t>(ld_rhs),
274 #ifdef HAVE_AMESOS2_TIMERS 275 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
280 std::cout <<
"SHYLUBASKER Only handles 1 solve right now" << std::endl;
281 ierr = basker->Solve(nrhs,
bvals_.getRawPtr(),
xvals_.getRawPtr());
284 ierr = basker.solveMultiple(nrhs,
bvals_.getRawPtr(),
xvals_.getRawPtr());
291 Teuchos::broadcast(*(this->
getComm()), 0, &ierr);
293 TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
295 "Encountered zero diag element at: " << ierr);
296 TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
298 "Could not alloc needed working memory for solve" );
301 #ifdef HAVE_AMESOS2_TIMERS 302 Teuchos::TimeMonitor redistTimer(this->
timers_.vecRedistTime_);
315 template <
class Matrix,
class Vector>
324 template <
class Matrix,
class Vector>
329 using Teuchos::getIntegralValue;
330 using Teuchos::ParameterEntryValidator;
334 if(parameterList->isParameter(
"num_threads"))
336 num_threads = parameterList->get<
int>(
"num_threads");
340 template <
class Matrix,
class Vector>
341 Teuchos::RCP<const Teuchos::ParameterList>
344 using Teuchos::ParameterList;
346 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
350 if( is_null(valid_params) )
352 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
353 pl->set(
"num_threads", 1,
"Number of threads");
358 if( is_null(valid_params) ){
359 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
361 pl->set(
"alnnz", 2,
"Approx number of nonzeros in L, default is 2*nnz(A)");
362 pl->set(
"aunnx", 2,
"Approx number of nonzeros in I, default is 2*nnz(U)");
370 template <
class Matrix,
class Vector>
376 if(current_phase == SOLVE)
return (
false);
378 #ifdef HAVE_AMESOS2_TIMERS 379 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
391 local_ordinal_type nnz_ret = 0;
393 #ifdef HAVE_AMESOS2_TIMERS 394 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
405 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
407 "Did not get the expected number of non-zero vals");
414 template<
class Matrix,
class Vector>
420 #endif // AMESOS2_Basker_DEF_HPP Definition: basker.cpp:35
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
global_size_type globalNumCols_
Number of global columns in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:479
bool root_
If true, then this is the root processor.
Definition: Amesos2_SolverCore_decl.hpp:507
global_size_type globalNumRows_
Number of global rows in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:476
Teuchos::Array< slu_type > bvals_
Persisting 1D store for B.
Definition: Amesos2_Basker_decl.hpp:192
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Basker_def.hpp:372
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:243
Definition: Amesos2_TypeDecl.hpp:142
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Basker_def.hpp:342
Teuchos::Array< local_ordinal_type > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Basker_decl.hpp:187
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:580
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns a pointer to the Teuchos::Comm communicator with this operator.
Definition: Amesos2_SolverCore_decl.hpp:363
Amesos2 interface to the Baker package.
Definition: Amesos2_Basker_decl.hpp:75
Amesos2 Basker declarations.
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Basker_decl.hpp:185
Teuchos::Array< slu_type > xvals_
Persisting 1D store for X.
Definition: Amesos2_Basker_decl.hpp:190
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
Teuchos::Array< slu_type > nzvals_
Stores the values of the nonzero entries for Basker.
Definition: Amesos2_Basker_decl.hpp:183
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Basker_def.hpp:317
global_size_type globalNumNonZeros_
Number of global non-zero values in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:482
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Basker_def.hpp:127
Definition: Amesos2_TypeDecl.hpp:127
Timers timers_
Various timing statistics.
Definition: Amesos2_SolverCore_decl.hpp:498
int numericFactorization_impl()
Basker specific numeric factorization.
Definition: Amesos2_Basker_def.hpp:184
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:296
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:175
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
The LHS operator.
Definition: Amesos2_SolverCore_decl.hpp:455
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:246