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 bool
115  return (this->root_ && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_);
116 }
117 
118 template<class Matrix, class Vector>
119 int
121 {
122  /* TODO: Define what it means for KLU2
123  */
124 #ifdef HAVE_AMESOS2_TIMERS
125  Teuchos::TimeMonitor preOrderTimer(this->timers_.preOrderTime_);
126 #endif
127 
128  return(0);
129 }
130 
131 
132 template <class Matrix, class Vector>
133 int
135 {
136  if (data_.symbolic_ != NULL) {
137  ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
138  (&(data_.symbolic_), &(data_.common_)) ;
139  }
140 
141  if ( single_proc_optimization() ) {
142 
143  auto sp_rowptr = this->matrixA_->returnRowPtr();
144  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
145  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
146  auto sp_colind = this->matrixA_->returnColInd();
147  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
148  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
149 #ifndef HAVE_TEUCHOS_COMPLEX
150  auto sp_values = this->matrixA_->returnValues();
151 #else
152  // NDE: 09/25/2017
153  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
154  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
155  complex_type * sp_values = nullptr;
156  sp_values = reinterpret_cast< complex_type * > ( this->matrixA_->returnValues() );
157 #endif
158  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
159  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
160 
161  // sp_rowptr can cause compile-time matching issues
162  // e.g const long unsigned int* , not convertible/compatible with int*
163  // Need sp_rowptr and sp_colind to have same ordinal type for KLU2 interface
164  Teuchos::Array< local_ordinal_type > sp_rowptr_with_common_type( this->globalNumRows_ + 1 );
165  for ( global_size_type i = 0; i < this->globalNumRows_+1; ++i ) {
166  //sp_rowptr_with_common_type[i] = static_cast<local_ordinal_type>(sp_rowptr[i]);
167  sp_rowptr_with_common_type[i] = sp_rowptr[i];
168  }
169 
170  data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
171  ((local_ordinal_type)this->globalNumCols_, sp_rowptr_with_common_type.getRawPtr(),
172  sp_colind, &(data_.common_)) ;
173  }
174  else
175  {
176  data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
177  ((local_ordinal_type)this->globalNumCols_, colptr_.getRawPtr(),
178  rowind_.getRawPtr(), &(data_.common_)) ;
179 
180  } //end single_process_optim_check = false
181 
182  return(0);
183 }
184 
185 
186 template <class Matrix, class Vector>
187 int
189 {
190  using Teuchos::as;
191 
192  // Cleanup old L and U matrices if we are not reusing a symbolic
193  // factorization. Stores and other data will be allocated in gstrf.
194  // Only rank 0 has valid pointers, TODO: for KLU2
195 
196  int info = 0;
197  if ( this->root_ ) {
198 
199  { // Do factorization
200 #ifdef HAVE_AMESOS2_TIMERS
201  Teuchos::TimeMonitor numFactTimer(this->timers_.numFactTime_);
202 #endif
203 
204 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
205  std::cout << "KLU2:: Before numeric factorization" << std::endl;
206  std::cout << "nzvals_ : " << nzvals_.toString() << std::endl;
207  std::cout << "rowind_ : " << rowind_.toString() << std::endl;
208  std::cout << "colptr_ : " << colptr_.toString() << std::endl;
209 #endif
210 
211  if (data_.numeric_ != NULL) {
212  ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
213  (&(data_.numeric_), &(data_.common_)) ;
214  }
215 
216  if ( single_proc_optimization() ) {
217 
218  auto sp_rowptr = this->matrixA_->returnRowPtr();
219  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
220  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
221  auto sp_colind = this->matrixA_->returnColInd();
222  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
223  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
224 #ifndef HAVE_TEUCHOS_COMPLEX
225  auto sp_values = this->matrixA_->returnValues();
226 #else
227  // NDE: 09/25/2017
228  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
229  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
230  complex_type * sp_values = nullptr;
231  sp_values = reinterpret_cast< complex_type * > ( this->matrixA_->returnValues() );
232 #endif
233  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
234  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
235 
236  // sp_rowptr can cause compile-time matching issues
237  // e.g const long unsigned int* , not convertible/compatible with int*
238  // Need sp_rowptr and sp_colind to have same ordinal type for KLU2 interface
239  Teuchos::Array< local_ordinal_type > sp_rowptr_with_common_type( this->globalNumRows_ + 1 );
240  for ( global_size_type i = 0; i < this->globalNumRows_+1; ++i ) {
241  //sp_rowptr_with_common_type[i] = static_cast<local_ordinal_type>(sp_rowptr[i]);
242  sp_rowptr_with_common_type[i] = sp_rowptr[i];
243  }
244 
245  data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
246  (sp_rowptr_with_common_type.getRawPtr(), sp_colind, sp_values,
247  data_.symbolic_, &(data_.common_)) ;
248  }
249  else {
250  data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
251  (colptr_.getRawPtr(), rowind_.getRawPtr(), nzvals_.getRawPtr(),
252  data_.symbolic_, &(data_.common_)) ;
253  } //end single_process_optim_check = false
254 
255  // This is set after numeric factorization complete as pivoting can be used;
256  // In this case, a discrepancy between symbolic and numeric nnz total can occur.
257  this->setNnzLU( as<size_t>((data_.numeric_)->lnz) + as<size_t>((data_.numeric_)->unz) );
258  } // end scope
259 
260  } // end this->root_
261 
262  /* All processes should have the same error code */
263  Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &info);
264 
265  //global_size_type info_st = as<global_size_type>(info); // unused
266  /* TODO : Proper error messages
267  TEUCHOS_TEST_FOR_EXCEPTION( (info_st > 0) && (info_st <= this->globalNumCols_),
268  std::runtime_error,
269  "Factorization complete, but matrix is singular. Division by zero eminent");
270  TEUCHOS_TEST_FOR_EXCEPTION( (info_st > 0) && (info_st > this->globalNumCols_),
271  std::runtime_error,
272  "Memory allocation failure in KLU2 factorization");*/
273 
274  //data_.options.Fact = SLU::FACTORED;
275  //same_symbolic_ = true;
276 
277  return(info);
278 }
279 
280 
281 template <class Matrix, class Vector>
282 int
284  const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
285  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
286 {
287  using Teuchos::as;
288  int ierr = 0; // returned error code
289 
290  const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
291  const size_t nrhs = X->getGlobalNumVectors();
292 
293  if ( single_proc_optimization() && nrhs == 1 ) {
294 #ifdef HAVE_AMESOS2_TIMERS
295  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
296 #endif
297 
298 #ifndef HAVE_TEUCHOS_COMPLEX
299  auto b_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( B );
300  auto x_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( X );
301 #else
302  // NDE: 09/25/2017
303  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
304  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
305  complex_type * b_vector = reinterpret_cast< complex_type * >( Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( B ) );
306  complex_type * x_vector = reinterpret_cast< complex_type * >( Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( X ) );
307 #endif
308  TEUCHOS_TEST_FOR_EXCEPTION(b_vector == nullptr,
309  std::runtime_error, "Amesos2 Runtime Error: b_vector returned null ");
310 
311  TEUCHOS_TEST_FOR_EXCEPTION(x_vector == nullptr,
312  std::runtime_error, "Amesos2 Runtime Error: x_vector returned null ");
313 
314  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
315  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
316  // Thus, if the transFlag_ is true, the non-transpose solve should be used
317  if (transFlag_ == 0)
318  {
319  ::KLU2::klu_tsolve2<slu_type, local_ordinal_type>
320  (data_.symbolic_, data_.numeric_,
321  (local_ordinal_type)this->globalNumCols_,
322  (local_ordinal_type)nrhs,
323  b_vector, x_vector, &(data_.common_)) ;
324  }
325  else {
326  ::KLU2::klu_solve2<slu_type, local_ordinal_type>
327  (data_.symbolic_, data_.numeric_,
328  (local_ordinal_type)this->globalNumCols_,
329  (local_ordinal_type)nrhs,
330  b_vector, x_vector, &(data_.common_)) ;
331  }
332 
333  /* All processes should have the same error code */
334  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
335 
336  } // end single_process_optim_check && nrhs == 1
337  else // single proc optimizations but nrhs > 1,
338  // or distributed over processes case
339  {
340  const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
341  Teuchos::Array<slu_type> bValues(val_store_size);
342 
343  { // Get values from RHS B
344 #ifdef HAVE_AMESOS2_TIMERS
345  Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
346  Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
347 #endif
348  if ( is_contiguous_ == true ) {
350  slu_type>::do_get(B, bValues(),
351  as<size_t>(ld_rhs),
352  ROOTED, this->rowIndexBase_);
353  }
354  else {
356  slu_type>::do_get(B, bValues(),
357  as<size_t>(ld_rhs),
358  CONTIGUOUS_AND_ROOTED, this->rowIndexBase_);
359  }
360  } // end Timer scope
361 
362  if ( this->root_ ) {
363  //local_ordinal_type i_ld_rhs = as<local_ordinal_type>(ld_rhs);
364  { // Do solve!
365 #ifdef HAVE_AMESOS2_TIMERS
366  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
367 #endif
368  if (transFlag_ == 0)
369  {
370  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
371  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
372  // Thus, if the transFlag_ is true, the non-transpose solve should be used
373  if ( single_proc_optimization() ) {
374  ::KLU2::klu_tsolve<slu_type, local_ordinal_type>
375  (data_.symbolic_, data_.numeric_,
376  (local_ordinal_type)this->globalNumCols_,
377  (local_ordinal_type)nrhs,
378  bValues.getRawPtr(), &(data_.common_)) ;
379  }
380  else {
381  ::KLU2::klu_solve<slu_type, local_ordinal_type>
382  (data_.symbolic_, data_.numeric_,
383  (local_ordinal_type)this->globalNumCols_,
384  (local_ordinal_type)nrhs,
385  bValues.getRawPtr(), &(data_.common_)) ;
386  }
387  }
388  else
389  {
390  // For this case, Crs matrix raw pointers wereused, so the non-transpose default solve
391  // is actually the transpose solve as klu_solve expects Ccs matrix pointers
392  // Thus, if the transFlag_ is true, the non-transpose solve should be used
393  if ( single_proc_optimization() ) {
394  ::KLU2::klu_solve<slu_type, local_ordinal_type>
395  (data_.symbolic_, data_.numeric_,
396  (local_ordinal_type)this->globalNumCols_,
397  (local_ordinal_type)nrhs,
398  bValues.getRawPtr(), &(data_.common_)) ;
399  }
400  else {
401  ::KLU2::klu_tsolve<slu_type, local_ordinal_type>
402  (data_.symbolic_, data_.numeric_,
403  (local_ordinal_type)this->globalNumCols_,
404  (local_ordinal_type)nrhs,
405  bValues.getRawPtr(), &(data_.common_)) ;
406  }
407  }
408  } //end Timer scope
409  } // end root_
410 
411  /* All processes should have the same error code */
412  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
413 
414  // global_size_type ierr_st = as<global_size_type>(ierr); // unused
415  // TODO
416  //TEUCHOS_TEST_FOR_EXCEPTION( ierr < 0,
417  //std::invalid_argument,
418  //"Argument " << -ierr << " to KLU2 xgssvx had illegal value" );
419  //TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0 && ierr_st <= this->globalNumCols_,
420  //std::runtime_error,
421  //"Factorization complete, but U is exactly singular" );
422  //TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0 && ierr_st > this->globalNumCols_ + 1,
423  //std::runtime_error,
424  //"KLU2 allocated " << ierr - this->globalNumCols_ << " bytes of "
425  //"memory before allocation failure occured." );
426 
427  /* Update X's global values */
428  {
429 #ifdef HAVE_AMESOS2_TIMERS
430  Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
431 #endif
432 
433  if ( is_contiguous_ == true ) {
435  MultiVecAdapter<Vector>,slu_type>::do_put(X, bValues(),
436  as<size_t>(ld_rhs),
437  ROOTED, this->rowIndexBase_);
438  }
439  else {
441  MultiVecAdapter<Vector>,slu_type>::do_put(X, bValues(),
442  as<size_t>(ld_rhs),
443  CONTIGUOUS_AND_ROOTED, this->rowIndexBase_);
444  }
445  } // end Timer scope
446  } //end else
447 
448  return(ierr);
449 }
450 
451 
452 template <class Matrix, class Vector>
453 bool
455 {
456  // The KLU2 factorization routines can handle square as well as
457  // rectangular matrices, but KLU2 can only apply the solve routines to
458  // square matrices, so we check the matrix for squareness.
459  return( this->matrixA_->getGlobalNumRows() == this->matrixA_->getGlobalNumCols() );
460 }
461 
462 
463 template <class Matrix, class Vector>
464 void
465 KLU2<Matrix,Vector>::setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
466 {
467  using Teuchos::RCP;
468  using Teuchos::getIntegralValue;
469  using Teuchos::ParameterEntryValidator;
470 
471  RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
472 
473  transFlag_ = this->control_.useTranspose_ ? 1: 0;
474  // The KLU2 transpose option can override the Amesos2 option
475  if( parameterList->isParameter("Trans") ){
476  RCP<const ParameterEntryValidator> trans_validator = valid_params->getEntry("Trans").validator();
477  parameterList->getEntry("Trans").setValidator(trans_validator);
478 
479  transFlag_ = getIntegralValue<int>(*parameterList, "Trans");
480  }
481 
482  if( parameterList->isParameter("IsContiguous") ){
483  is_contiguous_ = parameterList->get<bool>("IsContiguous");
484  }
485 }
486 
487 
488 template <class Matrix, class Vector>
489 Teuchos::RCP<const Teuchos::ParameterList>
491 {
492  using std::string;
493  using Teuchos::tuple;
494  using Teuchos::ParameterList;
495  using Teuchos::setStringToIntegralParameter;
496 
497  static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
498 
499  if( is_null(valid_params) )
500  {
501  Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
502 
503  pl->set("Equil", true, "Whether to equilibrate the system before solve, does nothing now");
504  pl->set("IsContiguous", true, "Whether GIDs contiguous");
505 
506  setStringToIntegralParameter<int>("Trans", "NOTRANS",
507  "Solve for the transpose system or not",
508  tuple<string>("NOTRANS","TRANS","CONJ"),
509  tuple<string>("Solve with transpose",
510  "Do not solve with transpose",
511  "Solve with the conjugate transpose"),
512  tuple<int>(0, 1, 2),
513  pl.getRawPtr());
514  valid_params = pl;
515  }
516 
517  return valid_params;
518 }
519 
520 
521 template <class Matrix, class Vector>
522 bool
524 {
525  using Teuchos::as;
526 
527  if(current_phase == SOLVE)return(false);
528 
529  if ( single_proc_optimization() ) {
530  // Do nothing in this case - Crs raw pointers will be used
531  }
532  else
533  {
534 
535 #ifdef HAVE_AMESOS2_TIMERS
536  Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
537 #endif
538 
539  // Only the root image needs storage allocated
540  if( this->root_ ){
541  nzvals_.resize(this->globalNumNonZeros_);
542  rowind_.resize(this->globalNumNonZeros_);
543  colptr_.resize(this->globalNumCols_ + 1);
544  }
545 
546  local_ordinal_type nnz_ret = 0;
547  {
548 #ifdef HAVE_AMESOS2_TIMERS
549  Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
550 #endif
551 
552  if ( is_contiguous_ == true ) {
554  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
555  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
556  nnz_ret, ROOTED, ARBITRARY, this->rowIndexBase_);
557  }
558  else {
560  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
561  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
562  nnz_ret, CONTIGUOUS_AND_ROOTED, ARBITRARY, this->rowIndexBase_);
563  }
564  }
565 
566 
567  if( this->root_ ){
568  TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->globalNumNonZeros_),
569  std::runtime_error,
570  "Did not get the expected number of non-zero vals");
571  }
572 
573  } //end else single_process_optim_check = false
574 
575  return true;
576 }
577 
578 
579 template<class Matrix, class Vector>
580 const char* KLU2<Matrix,Vector>::name = "KLU2";
581 
582 
583 } // end namespace Amesos2
584 
585 #endif // AMESOS2_KLU2_DEF_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
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
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:283
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Amesos2 KLU2 declarations.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_KLU2_def.hpp:523
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:266
~KLU2()
Destructor.
Definition: Amesos2_KLU2_def.hpp:87
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
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_KLU2_def.hpp:465
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using KLU2.
Definition: Amesos2_KLU2_def.hpp:134
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:654
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_KLU2_def.hpp:120
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_KLU2_def.hpp:454
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int numericFactorization_impl()
KLU2 specific numeric factorization.
Definition: Amesos2_KLU2_def.hpp:188
Amesos2 interface to the KLU2 package.
Definition: Amesos2_KLU2_decl.hpp:72
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through, also check that is_contiguous_ ...
Definition: Amesos2_KLU2_def.hpp:114
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_KLU2_def.hpp:490
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