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> 66 template <
class Matrix,
class Vector>
67 Basker<Matrix,Vector>::Basker(
68 Teuchos::RCP<const Matrix> A,
69 Teuchos::RCP<Vector> X,
70 Teuchos::RCP<const Vector> B )
85 #ifdef HAVE_AMESOS2_KOKKOS 86 #ifdef KOKKOS_HAVE_OPENMP 91 typedef Kokkos::OpenMP Exe_Space;
92 #elif defined(KOKKOS_HAVE_SERIAL) 93 typedef Kokkos::Serial Exe_Space;
95 TEUCHOS_TEST_FOR_EXCEPTION(1 != 0,
97 "Do not have supported Kokkos node type for Basker");
100 basker = new ::BaskerNS::Basker<local_ordinal_type, slu_type, Exe_Space>();
101 basker->Options.no_pivot = BASKER_TRUE;
102 basker->Options.symmetric = BASKER_FALSE;
103 basker->Options.realloc = BASKER_FALSE;
104 basker->Options.verbose = BASKER_FALSE;
105 basker->Options.matching = BASKER_TRUE;
106 basker->Options.matching_type = 0;
107 basker->Options.btf = BASKER_TRUE;
108 basker->Options.amd_btf = BASKER_TRUE;
109 basker->Options.amd_dom = BASKER_TRUE;
110 basker->Options.transpose = BASKER_FALSE;
111 basker->Options.verbose_matrix_out = BASKER_FALSE;
112 num_threads = Kokkos::OpenMP::max_hardware_threads();
119 template <
class Matrix,
class Vector>
120 Basker<Matrix,Vector>::~Basker( )
123 #ifdef HAVE_AMESOS2_KOKKOS 132 template<
class Matrix,
class Vector>
138 #ifdef HAVE_AMESOS2_TIMERS 139 Teuchos::TimeMonitor preOrderTimer(this->timers_.preOrderTime_);
146 template <
class Matrix,
class Vector>
156 basker->SetThreads(num_threads);
158 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 159 std::cout <<
"Basker:: Before symbolic factorization" << std::endl;
160 std::cout <<
"nzvals_ : " << nzvals_.toString() << std::endl;
161 std::cout <<
"rowind_ : " << rowind_.toString() << std::endl;
162 std::cout <<
"colptr_ : " << colptr_.toString() << std::endl;
165 info =basker->Symbolic(this->globalNumRows_,
166 this->globalNumCols_,
167 this->globalNumNonZeros_,
170 nzvals_.getRawPtr());
172 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,
174 "Error in Basker Symbolic");
184 template <
class Matrix,
class Vector>
193 #ifdef HAVE_AMESOS2_TIMERS 194 Teuchos::TimeMonitor numFactTimer(this->timers_.numFactTime_);
197 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 198 std::cout <<
"Basker:: Before numeric factorization" << std::endl;
199 std::cout <<
"nzvals_ : " << nzvals_.toString() << std::endl;
200 std::cout <<
"rowind_ : " << rowind_.toString() << std::endl;
201 std::cout <<
"colptr_ : " << colptr_.toString() << std::endl;
206 info = basker->Factor(this->globalNumRows_,
207 this->globalNumCols_,
208 this->globalNumNonZeros_,
211 nzvals_.getRawPtr());
216 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,
218 "Error Basker Factor");
222 info =basker.factor(this->globalNumRows_, this->globalNumCols_, this->globalNumNonZeros_, colptr_.getRawPtr(), rowind_.getRawPtr(), nzvals_.getRawPtr());
230 Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &info);
234 TEUCHOS_TEST_FOR_EXCEPTION( (info == -1) ,
236 "Basker: Could not alloc space for L and U");
237 TEUCHOS_TEST_FOR_EXCEPTION( (info == -2),
239 "Basker: Could not alloc needed work space");
240 TEUCHOS_TEST_FOR_EXCEPTION( (info == -3) ,
242 "Basker: Could not alloc additional memory needed for L and U");
243 TEUCHOS_TEST_FOR_EXCEPTION( (info > 0) ,
245 "Basker: Zero pivot found at: " << info );
251 template <
class Matrix,
class Vector>
259 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
260 const size_t nrhs = X->getGlobalNumVectors();
262 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
264 xvals_.resize(val_store_size);
265 bvals_.resize(val_store_size);
268 #ifdef HAVE_AMESOS2_TIMERS 269 Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
270 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
273 slu_type>::do_get(B, bvals_(),as<size_t>(ld_rhs),
281 #ifdef HAVE_AMESOS2_TIMERS 282 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
286 ierr = basker->Solve(nrhs, bvals_.getRawPtr(),
289 ierr = basker.solveMultiple(nrhs, bvals_.getRawPtr(),xvals_.getRawPtr());
296 Teuchos::broadcast(*(this->getComm()), 0, &ierr);
298 TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
300 "Encountered zero diag element at: " << ierr);
301 TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
303 "Could not alloc needed working memory for solve" );
306 #ifdef HAVE_AMESOS2_TIMERS 307 Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
320 template <
class Matrix,
class Vector>
325 return( this->globalNumRows_ == this->globalNumCols_ );
329 template <
class Matrix,
class Vector>
334 using Teuchos::getIntegralValue;
335 using Teuchos::ParameterEntryValidator;
337 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
340 if(parameterList->isParameter(
"num_threads"))
342 num_threads = parameterList->get<
int>(
"num_threads");
344 if(parameterList->isParameter(
"pivot"))
346 basker->Options.no_pivot = (!parameterList->get<
bool>(
"pivot"));
348 if(parameterList->isParameter(
"pivot_tol"))
350 basker->Options.pivot_tol = parameterList->get<
double>(
"pivot_tol");
352 if(parameterList->isParameter(
"symmetric"))
354 basker->Options.symmetric = parameterList->get<
bool>(
"symmetric");
356 if(parameterList->isParameter(
"realloc"))
358 basker->Options.realloc = parameterList->get<
bool>(
"realloc");
360 if(parameterList->isParameter(
"verbose"))
362 basker->Options.verbose = parameterList->get<
bool>(
"verbose");
364 if(parameterList->isParameter(
"verbose_matrix"))
366 basker->Options.verbose_matrix_out = parameterList->get<
bool>(
"verbose_matrix");
368 if(parameterList->isParameter(
"matching"))
370 basker->Options.matching = parameterList->get<
bool>(
"matching");
372 if(parameterList->isParameter(
"matching_type"))
374 basker->Options.matching_type =
375 (local_ordinal_type) parameterList->get<
int>(
"matching_type");
377 if(parameterList->isParameter(
"btf"))
379 basker->Options.btf = parameterList->get<
bool>(
"btf");
381 if(parameterList->isParameter(
"amd_btf"))
383 basker->Options.amd_btf = parameterList->get<
bool>(
"amd_btf");
385 if(parameterList->isParameter(
"amd_dom"))
387 basker->Options.amd_dom = parameterList->get<
bool>(
"amd_dom");
389 if(parameterList->isParameter(
"transpose"))
391 basker->Options.transpose = parameterList->get<
bool>(
"transpose");
397 template <
class Matrix,
class Vector>
398 Teuchos::RCP<const Teuchos::ParameterList>
401 using Teuchos::ParameterList;
403 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
407 if( is_null(valid_params) )
409 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
410 pl->set(
"num_threads", 1,
411 "Number of threads");
412 pl->set(
"pivot",
false,
414 pl->set(
"pivot_tol", .0001,
415 "Tolerance before pivot, currently not used");
416 pl->set(
"symmetric",
false,
417 "Should Symbolic assume symmetric nonzero pattern");
418 pl->set(
"realloc" ,
false,
419 "Should realloc space if not enough");
420 pl->set(
"verbose",
false,
421 "Information about factoring");
422 pl->set(
"verbose_matrix",
false,
423 "Give Permuted Matrices");
424 pl->set(
"matching",
true,
425 "Use WC matching (Not Supported)");
426 pl->set(
"matching_type", 0,
427 "Type of WC matching (Not Supported)");
430 pl->set(
"amd_btf",
true,
431 "Use AMD on BTF blocks (Not Supported)");
432 pl->set(
"amd_dom",
true,
433 "Use CAMD on ND blocks (Not Supported)");
434 pl->set(
"transpose",
false,
435 "Solve the transpose A");
440 if( is_null(valid_params) ){
441 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
443 pl->set(
"alnnz", 2,
"Approx number of nonzeros in L, default is 2*nnz(A)");
444 pl->set(
"aunnx", 2,
"Approx number of nonzeros in I, default is 2*nnz(U)");
452 template <
class Matrix,
class Vector>
458 if(current_phase == SOLVE)
return (
false);
460 #ifdef HAVE_AMESOS2_TIMERS 461 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
468 nzvals_.resize(this->globalNumNonZeros_);
469 rowind_.resize(this->globalNumNonZeros_);
470 colptr_.resize(this->globalNumCols_ + 1);
473 local_ordinal_type nnz_ret = 0;
475 #ifdef HAVE_AMESOS2_TIMERS 476 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
481 ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
487 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->globalNumNonZeros_),
489 "Did not get the expected number of non-zero vals");
496 template<
class Matrix,
class Vector>
502 #endif // AMESOS2_Basker_DEF_HPP Definition: basker.cpp:35
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Basker_def.hpp:399
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Basker_def.hpp:454
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:243
Definition: Amesos2_TypeDecl.hpp:142
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:580
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:253
Amesos2 interface to the Baker package.
Definition: Amesos2_Basker_decl.hpp:74
Amesos2 Basker declarations.
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Basker_def.hpp:134
Definition: Amesos2_TypeDecl.hpp:127
int numericFactorization_impl()
Basker specific numeric factorization.
Definition: Amesos2_Basker_def.hpp:186
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
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Basker_def.hpp:322