Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_KLU2_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Amesos2: Templated Direct Sparse Solver Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
52 #ifndef AMESOS2_KLU2_DEF_HPP
53 #define AMESOS2_KLU2_DEF_HPP
54 
55 #include <Teuchos_Tuple.hpp>
56 #include <Teuchos_ParameterList.hpp>
57 #include <Teuchos_StandardParameterEntryValidators.hpp>
58 
60 #include "Amesos2_KLU2_decl.hpp"
61 
62 namespace Amesos2 {
63 
64 
65 template <class Matrix, class Vector>
67  Teuchos::RCP<const Matrix> A,
68  Teuchos::RCP<Vector> X,
69  Teuchos::RCP<const Vector> B )
70  : SolverCore<Amesos2::KLU2,Matrix,Vector>(A, X, B)
71  , nzvals_() // initialize to empty arrays
72  , rowind_()
73  , colptr_()
74  , transFlag_(0)
75  , is_contiguous_(true)
76 {
77  ::KLU2::klu_defaults<slu_type, local_ordinal_type> (&(data_.common_)) ;
78  data_.symbolic_ = NULL;
79  data_.numeric_ = NULL;
80 
81  // Override some default options
82  // TODO: use data_ here to init
83 }
84 
85 
86 template <class Matrix, class Vector>
88 {
89  /* Free KLU2 data_types
90  * - Matrices
91  * - Vectors
92  * - Other data
93  */
94  if (data_.symbolic_ != NULL)
95  ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
96  (&(data_.symbolic_), &(data_.common_)) ;
97  if (data_.numeric_ != NULL)
98  ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
99  (&(data_.numeric_), &(data_.common_)) ;
100 
101  // Storage is initialized in numericFactorization_impl()
102  //if ( data_.A.Store != NULL ){
103  // destoy
104  //}
105 
106  // only root allocated these SuperMatrices.
107  //if ( data_.L.Store != NULL ){ // will only be true for this->root_
108  // destroy ..
109  //}
110 }
111 
112 template<class Matrix, class Vector>
113 int
115 {
116  /* TODO: Define what it means for KLU2
117  */
118 #ifdef HAVE_AMESOS2_TIMERS
119  Teuchos::TimeMonitor preOrderTimer(this->timers_.preOrderTime_);
120 #endif
121 
122  return(0);
123 }
124 
125 
126 template <class Matrix, class Vector>
127 int
129 {
130  if (data_.symbolic_ != NULL) {
131  ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
132  (&(data_.symbolic_), &(data_.common_)) ;
133  }
134 
135 #ifndef HAVE_TEUCHOS_COMPLEX
136  bool single_process_optim_check = ( (this->matrixA_->getComm()->getRank() == 0) && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_ ) ;
137  if ( single_process_optim_check ) {
138 
139  auto sp_rowptr = this->matrixA_->returnRowPtr();
140  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
141  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
142  auto sp_colind = this->matrixA_->returnColInd();
143  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
144  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
145  auto sp_values = this->matrixA_->returnValues();
146  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
147  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
148 
149  // sp_rowptr can cause compile-time matching issues
150  // e.g const long unsigned int* , not convertible/compatible with int*
151  // Need sp_rowptr and sp_colind to have same ordinal type for KLU2 interface
152  Teuchos::Array< local_ordinal_type > sp_rowptr_with_common_type( this->globalNumRows_ + 1 );
153  for ( global_size_type i = 0; i < this->globalNumRows_+1; ++i ) {
154  //sp_rowptr_with_common_type[i] = static_cast<local_ordinal_type>(sp_rowptr[i]);
155  sp_rowptr_with_common_type[i] = sp_rowptr[i];
156  }
157 
158  data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
159  ((local_ordinal_type)this->globalNumCols_, sp_rowptr_with_common_type.getRawPtr(),
160  sp_colind, &(data_.common_)) ;
161  }
162  else
163 #endif
164  {
165  data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
166  ((local_ordinal_type)this->globalNumCols_, colptr_.getRawPtr(),
167  rowind_.getRawPtr(), &(data_.common_)) ;
168 
169  } //end single_process_optim_check = false
170 
171  return(0);
172 }
173 
174 
175 template <class Matrix, class Vector>
176 int
178 {
179  using Teuchos::as;
180 
181  // Cleanup old L and U matrices if we are not reusing a symbolic
182  // factorization. Stores and other data will be allocated in gstrf.
183  // Only rank 0 has valid pointers, TODO: for KLU2
184 
185  int info = 0;
186  if ( this->root_ ){
187 
188  { // Do factorization
189 #ifdef HAVE_AMESOS2_TIMERS
190  Teuchos::TimeMonitor numFactTimer(this->timers_.numFactTime_);
191 #endif
192 
193 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
194  std::cout << "KLU2:: Before numeric factorization" << std::endl;
195  std::cout << "nzvals_ : " << nzvals_.toString() << std::endl;
196  std::cout << "rowind_ : " << rowind_.toString() << std::endl;
197  std::cout << "colptr_ : " << colptr_.toString() << std::endl;
198 #endif
199 
200  if (data_.numeric_ != NULL) {
201  ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
202  (&(data_.numeric_), &(data_.common_)) ;
203  }
204 
205 #ifndef HAVE_TEUCHOS_COMPLEX
206  bool single_process_optim_check = ( (this->matrixA_->getComm()->getRank() == 0) && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_ ) ;
207  if ( single_process_optim_check ) {
208 
209  auto sp_rowptr = this->matrixA_->returnRowPtr();
210  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
211  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
212  auto sp_colind = this->matrixA_->returnColInd();
213  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
214  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
215  auto sp_values = this->matrixA_->returnValues();
216  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
217  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
218 
219  // sp_rowptr can cause compile-time matching issues
220  // e.g const long unsigned int* , not convertible/compatible with int*
221  // Need sp_rowptr and sp_colind to have same ordinal type for KLU2 interface
222  Teuchos::Array< local_ordinal_type > sp_rowptr_with_common_type( this->globalNumRows_ + 1 );
223  for ( global_size_type i = 0; i < this->globalNumRows_+1; ++i ) {
224  //sp_rowptr_with_common_type[i] = static_cast<local_ordinal_type>(sp_rowptr[i]);
225  sp_rowptr_with_common_type[i] = sp_rowptr[i];
226  }
227 
228  data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
229  (sp_rowptr_with_common_type.getRawPtr(), sp_colind, sp_values,
230  data_.symbolic_, &(data_.common_)) ;
231  }
232  else
233 #endif
234  {
235 
236  data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
237  (colptr_.getRawPtr(), rowind_.getRawPtr(), nzvals_.getRawPtr(),
238  data_.symbolic_, &(data_.common_)) ;
239  } //end single_process_optim_check = false
240 
241  // This is set after numeric factorization complete as pivoting can be used;
242  // In this case, a discrepancy between symbolic and numeric nnz total can occur.
243  this->setNnzLU( as<size_t>((data_.numeric_)->lnz) + as<size_t>((data_.numeric_)->unz) );
244  } // end scope
245 
246  } // end this->root_
247 
248  /* All processes should have the same error code */
249  Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &info);
250 
251  //global_size_type info_st = as<global_size_type>(info); // unused
252  /* TODO : Proper error messages
253  TEUCHOS_TEST_FOR_EXCEPTION( (info_st > 0) && (info_st <= this->globalNumCols_),
254  std::runtime_error,
255  "Factorization complete, but matrix is singular. Division by zero eminent");
256  TEUCHOS_TEST_FOR_EXCEPTION( (info_st > 0) && (info_st > this->globalNumCols_),
257  std::runtime_error,
258  "Memory allocation failure in KLU2 factorization");*/
259 
260  //data_.options.Fact = SLU::FACTORED;
261  //same_symbolic_ = true;
262 
263  return(info);
264 }
265 
266 
267 template <class Matrix, class Vector>
268 int
270  const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
271  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
272 {
273  using Teuchos::as;
274  int ierr = 0; // returned error code
275 
276  const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
277  const size_t nrhs = X->getGlobalNumVectors();
278 
279  bool single_process_optim_check = false;
280 #ifndef HAVE_TEUCHOS_COMPLEX
281  single_process_optim_check = ( (this->matrixA_->getComm()->getRank() == 0) && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_ ) ;
282  if ( single_process_optim_check && (nrhs == 1) ) {
283 #ifdef HAVE_AMESOS2_TIMERS
284  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
285 #endif
286 
287  auto sp_rowptr = this->matrixA_->returnRowPtr();
288  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
289  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
290  auto sp_colind = this->matrixA_->returnColInd();
291  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
292  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
293  auto sp_values = this->matrixA_->returnValues();
294  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
295  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
296 
297  auto b_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( B );
298  TEUCHOS_TEST_FOR_EXCEPTION(b_vector == nullptr,
299  std::runtime_error, "Amesos2 Runtime Error: b_vector returned null ");
300  auto x_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( X );
301  TEUCHOS_TEST_FOR_EXCEPTION(x_vector == nullptr,
302  std::runtime_error, "Amesos2 Runtime Error: x_vector returned null ");
303 
304  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
305  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
306  // Thus, if the transFlag_ is true, the non-transpose solve should be used
307  if (transFlag_ == 0)
308  {
309  ::KLU2::klu_tsolve2<slu_type, local_ordinal_type>
310  (data_.symbolic_, data_.numeric_,
311  (local_ordinal_type)this->globalNumCols_,
312  (local_ordinal_type)nrhs,
313  b_vector, x_vector, &(data_.common_)) ;
314  }
315  else {
316  ::KLU2::klu_solve2<slu_type, local_ordinal_type>
317  (data_.symbolic_, data_.numeric_,
318  (local_ordinal_type)this->globalNumCols_,
319  (local_ordinal_type)nrhs,
320  b_vector, x_vector, &(data_.common_)) ;
321  }
322 
323  /* All processes should have the same error code */
324  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
325 
326  } // end single_process_optim_check
327  else
328 #endif
329  {
330  const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
331  Teuchos::Array<slu_type> bValues(val_store_size);
332 
333  { // Get values from RHS B
334 #ifdef HAVE_AMESOS2_TIMERS
335  Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
336  Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
337 #endif
338  if ( is_contiguous_ == true ) {
340  slu_type>::do_get(B, bValues(),
341  as<size_t>(ld_rhs),
342  ROOTED, this->rowIndexBase_);
343  }
344  else {
346  slu_type>::do_get(B, bValues(),
347  as<size_t>(ld_rhs),
349  }
350  } // end Timer scope
351 
352  if ( this->root_ ) {
353  //local_ordinal_type i_ld_rhs = as<local_ordinal_type>(ld_rhs);
354  { // Do solve!
355 #ifdef HAVE_AMESOS2_TIMERS
356  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
357 #endif
358  if (transFlag_ == 0)
359  {
360  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
361  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
362  // Thus, if the transFlag_ is true, the non-transpose solve should be used
363  if ( single_process_optim_check == true ) {
364  ::KLU2::klu_tsolve<slu_type, local_ordinal_type>
365  (data_.symbolic_, data_.numeric_,
366  (local_ordinal_type)this->globalNumCols_,
367  (local_ordinal_type)nrhs,
368  bValues.getRawPtr(), &(data_.common_)) ;
369  }
370  else {
371  ::KLU2::klu_solve<slu_type, local_ordinal_type>
372  (data_.symbolic_, data_.numeric_,
373  (local_ordinal_type)this->globalNumCols_,
374  (local_ordinal_type)nrhs,
375  bValues.getRawPtr(), &(data_.common_)) ;
376  }
377  }
378  else
379  {
380  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
381  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
382  // Thus, if the transFlag_ is true, the non-transpose solve should be used
383  if ( single_process_optim_check == true ) {
384  ::KLU2::klu_solve<slu_type, local_ordinal_type>
385  (data_.symbolic_, data_.numeric_,
386  (local_ordinal_type)this->globalNumCols_,
387  (local_ordinal_type)nrhs,
388  bValues.getRawPtr(), &(data_.common_)) ;
389  }
390  else {
391  ::KLU2::klu_tsolve<slu_type, local_ordinal_type>
392  (data_.symbolic_, data_.numeric_,
393  (local_ordinal_type)this->globalNumCols_,
394  (local_ordinal_type)nrhs,
395  bValues.getRawPtr(), &(data_.common_)) ;
396  }
397  }
398  } //end Timer scope
399  } // end root_
400 
401  /* All processes should have the same error code */
402  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
403 
404  // global_size_type ierr_st = as<global_size_type>(ierr); // unused
405  // TODO
406  //TEUCHOS_TEST_FOR_EXCEPTION( ierr < 0,
407  //std::invalid_argument,
408  //"Argument " << -ierr << " to KLU2 xgssvx had illegal value" );
409  //TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0 && ierr_st <= this->globalNumCols_,
410  //std::runtime_error,
411  //"Factorization complete, but U is exactly singular" );
412  //TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0 && ierr_st > this->globalNumCols_ + 1,
413  //std::runtime_error,
414  //"KLU2 allocated " << ierr - this->globalNumCols_ << " bytes of "
415  //"memory before allocation failure occured." );
416 
417  /* Update X's global values */
418  {
419 #ifdef HAVE_AMESOS2_TIMERS
420  Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
421 #endif
422 
423  if ( is_contiguous_ == true ) {
425  MultiVecAdapter<Vector>,slu_type>::do_put(X, bValues(),
426  as<size_t>(ld_rhs),
427  ROOTED);
428  }
429  else {
431  MultiVecAdapter<Vector>,slu_type>::do_put(X, bValues(),
432  as<size_t>(ld_rhs),
434  }
435  } // end Timer scope
436  } //end else
437 
438  return(ierr);
439 }
440 
441 
442 template <class Matrix, class Vector>
443 bool
445 {
446  // The KLU2 factorization routines can handle square as well as
447  // rectangular matrices, but KLU2 can only apply the solve routines to
448  // square matrices, so we check the matrix for squareness.
449  return( this->matrixA_->getGlobalNumRows() == this->matrixA_->getGlobalNumCols() );
450 }
451 
452 
453 template <class Matrix, class Vector>
454 void
455 KLU2<Matrix,Vector>::setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
456 {
457  using Teuchos::RCP;
458  using Teuchos::getIntegralValue;
459  using Teuchos::ParameterEntryValidator;
460 
461  RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
462 
463  transFlag_ = this->control_.useTranspose_ ? 1: 0;
464  // The KLU2 transpose option can override the Amesos2 option
465  if( parameterList->isParameter("Trans") ){
466  RCP<const ParameterEntryValidator> trans_validator = valid_params->getEntry("Trans").validator();
467  parameterList->getEntry("Trans").setValidator(trans_validator);
468 
469  transFlag_ = getIntegralValue<int>(*parameterList, "Trans");
470  }
471 
472  if( parameterList->isParameter("IsContiguous") ){
473  is_contiguous_ = parameterList->get<bool>("IsContiguous");
474  }
475 }
476 
477 
478 template <class Matrix, class Vector>
479 Teuchos::RCP<const Teuchos::ParameterList>
481 {
482  using std::string;
483  using Teuchos::tuple;
484  using Teuchos::ParameterList;
485  using Teuchos::setStringToIntegralParameter;
486 
487  static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
488 
489  if( is_null(valid_params) )
490  {
491  Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
492 
493  pl->set("Equil", true, "Whether to equilibrate the system before solve, does nothing now");
494  pl->set("IsContiguous", true, "Whether GIDs contiguous");
495 
496  setStringToIntegralParameter<int>("Trans", "NOTRANS",
497  "Solve for the transpose system or not",
498  tuple<string>("NOTRANS","TRANS","CONJ"),
499  tuple<string>("Solve with transpose",
500  "Do not solve with transpose",
501  "Solve with the conjugate transpose"),
502  tuple<int>(0, 1, 2),
503  pl.getRawPtr());
504  valid_params = pl;
505  }
506 
507  return valid_params;
508 }
509 
510 
511 template <class Matrix, class Vector>
512 bool
514 {
515  using Teuchos::as;
516 
517  if(current_phase == SOLVE)return(false);
518 
519 #ifndef HAVE_TEUCHOS_COMPLEX
520  bool single_process_optim_check = ( (this->matrixA_->getComm()->getRank() == 0) && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_ ) ;
521  if ( single_process_optim_check ) {
522  // Do nothing in this case - Crs raw pointers will be used
523  }
524  else
525 #endif
526  {
527 
528 #ifdef HAVE_AMESOS2_TIMERS
529  Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
530 #endif
531 
532  // Only the root image needs storage allocated
533  if( this->root_ ){
534  nzvals_.resize(this->globalNumNonZeros_);
535  rowind_.resize(this->globalNumNonZeros_);
536  colptr_.resize(this->globalNumCols_ + 1);
537  }
538 
539  local_ordinal_type nnz_ret = 0;
540  {
541 #ifdef HAVE_AMESOS2_TIMERS
542  Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
543 #endif
544 
545  if ( is_contiguous_ == true ) {
547  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
548  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
549  nnz_ret, ROOTED, ARBITRARY, this->rowIndexBase_);
550  }
551  else {
553  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
554  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
556  }
557  }
558 
559 
560  if( this->root_ ){
561  TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->globalNumNonZeros_),
562  std::runtime_error,
563  "Did not get the expected number of non-zero vals");
564  }
565 
566  } //end else single_process_optim_check = false
567 
568  return true;
569 }
570 
571 
572 template<class Matrix, class Vector>
573 const char* KLU2<Matrix,Vector>::name = "KLU2";
574 
575 
576 } // end namespace Amesos2
577 
578 #endif // AMESOS2_KLU2_DEF_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
Teuchos::Array< slu_type > nzvals_
Stores the values of the nonzero entries for KLU2.
Definition: Amesos2_KLU2_decl.hpp:230
KLU2(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_KLU2_def.hpp:66
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Amesos2 KLU2 declarations.
global_size_type globalNumCols_
Number of global columns in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:478
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_KLU2_def.hpp:480
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_KLU2_def.hpp:513
bool root_
If true, then this is the root processor.
Definition: Amesos2_SolverCore_decl.hpp:506
global_size_type globalNumRows_
Number of global rows in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:475
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:266
~KLU2()
Destructor.
Definition: Amesos2_KLU2_def.hpp:87
Definition: Amesos2_TypeDecl.hpp:143
Control control_
Parameters for solving.
Definition: Amesos2_SolverCore_decl.hpp:494
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns a pointer to the Teuchos::Comm communicator with this operator.
Definition: Amesos2_SolverCore_decl.hpp:362
Helper struct for getting pointers to the MV data - only used when number of vectors = 1 and single M...
Definition: Amesos2_MultiVecAdapter_decl.hpp:218
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_KLU2_def.hpp:455
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using KLU2.
Definition: Amesos2_KLU2_def.hpp:128
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:626
Definition: Amesos2_KLU2_FunctionMap.hpp:67
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_KLU2_def.hpp:114
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_KLU2_decl.hpp:232
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
KLU2 specific solve.
Definition: Amesos2_KLU2_def.hpp:269
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_KLU2_def.hpp:444
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int numericFactorization_impl()
KLU2 specific numeric factorization.
Definition: Amesos2_KLU2_def.hpp:177
Teuchos::Array< local_ordinal_type > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_KLU2_decl.hpp:234
Amesos2 interface to the KLU2 package.
Definition: Amesos2_KLU2_decl.hpp:72
global_size_type globalNumNonZeros_
Number of global non-zero values in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:481
void setNnzLU(size_t nnz)
Set the number of non-zero values in the and factors.
Definition: Amesos2_SolverCore_decl.hpp:451
int transFlag_
Definition: Amesos2_KLU2_decl.hpp:243
Definition: Amesos2_TypeDecl.hpp:127
Timers timers_
Various timing statistics.
Definition: Amesos2_SolverCore_decl.hpp:497
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:322
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
The LHS operator.
Definition: Amesos2_SolverCore_decl.hpp:454
global_size_type rowIndexBase_
Index base of rowmap of matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:484
Definition: Amesos2_TypeDecl.hpp:128