Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_ShyLUBasker_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 
54 #ifndef AMESOS2_SHYLUBASKER_DEF_HPP
55 #define AMESOS2_SHYLUBASKER_DEF_HPP
56 
57 #include <Teuchos_Tuple.hpp>
58 #include <Teuchos_ParameterList.hpp>
59 #include <Teuchos_StandardParameterEntryValidators.hpp>
60 
63 
64 namespace Amesos2 {
65 
66 
67 template <class Matrix, class Vector>
68 ShyLUBasker<Matrix,Vector>::ShyLUBasker(
69  Teuchos::RCP<const Matrix> A,
70  Teuchos::RCP<Vector> X,
71  Teuchos::RCP<const Vector> B )
72  : SolverCore<Amesos2::ShyLUBasker,Matrix,Vector>(A, X, B)
73  , nzvals_() // initialize to empty arrays
74  , rowind_()
75  , colptr_()
76  , is_contiguous_(true)
77 {
78 
79  //Nothing
80 
81  // Override some default options
82  // TODO: use data_ here to init
83 #if defined(HAVE_AMESOS2_KOKKOS) && defined(KOKKOS_ENABLE_OPENMP)
84  /*
85  static_assert(std::is_same<kokkos_exe,Kokkos::OpenMP>::value,
86  "Kokkos node type not supported by experimental ShyLUBasker Amesos2");
87  */
88  typedef Kokkos::OpenMP Exe_Space;
89 
90  ShyLUbasker = new ::BaskerNS::BaskerTrilinosInterface<local_ordinal_type, slu_type, Exe_Space>();
91  ShyLUbasker->Options.no_pivot = BASKER_TRUE;
92  ShyLUbasker->Options.symmetric = BASKER_FALSE;
93  ShyLUbasker->Options.realloc = BASKER_FALSE;
94  ShyLUbasker->Options.verbose = BASKER_FALSE;
95  ShyLUbasker->Options.matching = BASKER_TRUE;
96  ShyLUbasker->Options.matching_type = 0;
97  ShyLUbasker->Options.btf = BASKER_TRUE;
98  ShyLUbasker->Options.amd_btf = BASKER_TRUE;
99  ShyLUbasker->Options.amd_dom = BASKER_TRUE;
100  ShyLUbasker->Options.transpose = BASKER_FALSE;
101  ShyLUbasker->Options.verbose_matrix_out = BASKER_FALSE;
102  num_threads = Kokkos::OpenMP::max_hardware_threads();
103 #else
104  TEUCHOS_TEST_FOR_EXCEPTION(1 != 0,
105  std::runtime_error,
106  "Amesos2_ShyLUBasker Exception: Do not have supported Kokkos node type (OpenMP) enabled for ShyLUBasker");
107 #endif
108 }
109 
110 
111 template <class Matrix, class Vector>
112 ShyLUBasker<Matrix,Vector>::~ShyLUBasker( )
113 {
114  /* ShyLUBasker will cleanup its own internal memory*/
115 #if defined(HAVE_AMESOS2_KOKKOS) && defined(KOKKOS_ENABLE_OPENMP)
116  delete ShyLUbasker;
117 #endif
118 }
119 
120 template <class Matrix, class Vector>
121 bool
123  return (this->root_ && (this->matrixA_->getComm()->getSize() == 1) && is_contiguous_);
124 }
125 
126 template<class Matrix, class Vector>
127 int
129 {
130  /* TODO: Define what it means for ShyLUBasker
131  */
132 #ifdef HAVE_AMESOS2_TIMERS
133  Teuchos::TimeMonitor preOrderTimer(this->timers_.preOrderTime_);
134 #endif
135 
136  return(0);
137 }
138 
139 
140 template <class Matrix, class Vector>
141 int
143 {
144 
145  if(this->root_)
146  {
147  int info = 0;
148 
149  ShyLUbasker->SetThreads(num_threads);
150 
151 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
152  std::cout << "ShyLUBasker:: Before symbolic factorization" << std::endl;
153  std::cout << "nzvals_ : " << nzvals_.toString() << std::endl;
154  std::cout << "rowind_ : " << rowind_.toString() << std::endl;
155  std::cout << "colptr_ : " << colptr_.toString() << std::endl;
156 #endif
157 
158  // NDE: Special case
159  // Rather than going through the Amesos2 machinery to convert the matrixA_ CRS pointer data to CCS and store in Teuchos::Arrays,
160  // in this special case we pass the CRS raw pointers directly to ShyLUBasker which copies+transposes+sorts the data for CCS format
161  // loadA_impl is essentially an empty function in this case, as the raw pointers are handled here and similarly in Symbolic
162 
163  if ( single_proc_optimization() ) {
164 
165  // this needs to be checked during loadA_impl...
166  auto sp_rowptr = this->matrixA_->returnRowPtr();
167  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
168  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
169  auto sp_colind = this->matrixA_->returnColInd();
170  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
171  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
172 #ifndef HAVE_TEUCHOS_COMPLEX
173  auto sp_values = this->matrixA_->returnValues();
174 #else
175  // NDE: 09/25/2017
176  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
177  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
178  complex_type * sp_values = nullptr;
179  sp_values = reinterpret_cast< complex_type * > ( this->matrixA_->returnValues() );
180 #endif
181  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
182  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
183 
184  // In this case, colptr_, rowind_, nzvals_ are invalid
185  info = ShyLUbasker->Symbolic(this->globalNumRows_,
186  this->globalNumCols_,
187  this->globalNumNonZeros_,
188  sp_rowptr,
189  sp_colind,
190  sp_values,
191  true);
192  }
193  else
194  { //follow original code path if conditions not met
195  // In this case, loadA_impl updates colptr_, rowind_, nzvals_
196  info = ShyLUbasker->Symbolic(this->globalNumRows_,
197  this->globalNumCols_,
198  this->globalNumNonZeros_,
199  colptr_.getRawPtr(),
200  rowind_.getRawPtr(),
201  nzvals_.getRawPtr());
202  }
203  TEUCHOS_TEST_FOR_EXCEPTION(info != 0,
204  std::runtime_error, "Error in ShyLUBasker Symbolic");
205 
206  } // end if (this->root_)
207 
208  /*No symbolic factoriztion*/
209  return(0);
210 }
211 
212 
213 template <class Matrix, class Vector>
214 int
216 {
217  using Teuchos::as;
218 
219  int info = 0;
220  if ( this->root_ ){
221  { // Do factorization
222 #ifdef HAVE_AMESOS2_TIMERS
223  Teuchos::TimeMonitor numFactTimer(this->timers_.numFactTime_);
224 #endif
225 
226 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG
227  std::cout << "ShyLUBasker:: Before numeric factorization" << std::endl;
228  std::cout << "nzvals_ : " << nzvals_.toString() << std::endl;
229  std::cout << "rowind_ : " << rowind_.toString() << std::endl;
230  std::cout << "colptr_ : " << colptr_.toString() << std::endl;
231 #endif
232 
233  // NDE: Special case
234  // Rather than going through the Amesos2 machinery to convert the matrixA_ CRS pointer data to CCS and store in Teuchos::Arrays,
235  // in this special case we pass the CRS raw pointers directly to ShyLUBasker which copies+transposes+sorts the data for CCS format
236  // loadA_impl is essentially an empty function in this case, as the raw pointers are handled here and similarly in Symbolic
237 
238  if ( single_proc_optimization() ) {
239 
240  auto sp_rowptr = this->matrixA_->returnRowPtr();
241  TEUCHOS_TEST_FOR_EXCEPTION(sp_rowptr == nullptr,
242  std::runtime_error, "Amesos2 Runtime Error: sp_rowptr returned null ");
243  auto sp_colind = this->matrixA_->returnColInd();
244  TEUCHOS_TEST_FOR_EXCEPTION(sp_colind == nullptr,
245  std::runtime_error, "Amesos2 Runtime Error: sp_colind returned null ");
246 #ifndef HAVE_TEUCHOS_COMPLEX
247  auto sp_values = this->matrixA_->returnValues();
248 #else
249  // NDE: 09/25/2017
250  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
251  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
252  complex_type * sp_values = nullptr;
253  sp_values = reinterpret_cast< complex_type * > ( this->matrixA_->returnValues() );
254 #endif
255  TEUCHOS_TEST_FOR_EXCEPTION(sp_values == nullptr,
256  std::runtime_error, "Amesos2 Runtime Error: sp_values returned null ");
257 
258  // In this case, colptr_, rowind_, nzvals_ are invalid
259  info = ShyLUbasker->Factor( this->globalNumRows_,
260  this->globalNumCols_,
261  this->globalNumNonZeros_,
262  sp_rowptr,
263  sp_colind,
264  sp_values);
265  }
266  else
267  {
268  // In this case, loadA_impl updates colptr_, rowind_, nzvals_
269  info = ShyLUbasker->Factor(this->globalNumRows_,
270  this->globalNumCols_,
271  this->globalNumNonZeros_,
272  colptr_.getRawPtr(),
273  rowind_.getRawPtr(),
274  nzvals_.getRawPtr());
275  //We need to handle the realloc options
276  }
277 
278  //ShyLUbasker->DEBUG_PRINT();
279 
280  TEUCHOS_TEST_FOR_EXCEPTION(info != 0,
281  std::runtime_error, "Error ShyLUBasker Factor");
282 
283  local_ordinal_type blnnz = local_ordinal_type(0);
284  local_ordinal_type bunnz = local_ordinal_type(0);
285  ShyLUbasker->GetLnnz(blnnz); // Add exception handling?
286  ShyLUbasker->GetUnnz(bunnz);
287 
288  // This is set after numeric factorization complete as pivoting can be used;
289  // In this case, a discrepancy between symbolic and numeric nnz total can occur.
290  this->setNnzLU( as<size_t>( blnnz + bunnz ) );
291 
292  } // end scope for timer
293  } // end if (this->root_)
294 
295  /* All processes should have the same error code */
296  Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &info);
297 
298  //global_size_type info_st = as<global_size_type>(info);
299  /* TODO : Proper error messages*/
300  TEUCHOS_TEST_FOR_EXCEPTION( (info == -1) ,
301  std::runtime_error,
302  "ShyLUBasker: Could not alloc space for L and U");
303  TEUCHOS_TEST_FOR_EXCEPTION( (info == -2),
304  std::runtime_error,
305  "ShyLUBasker: Could not alloc needed work space");
306  TEUCHOS_TEST_FOR_EXCEPTION( (info == -3) ,
307  std::runtime_error,
308  "ShyLUBasker: Could not alloc additional memory needed for L and U");
309  TEUCHOS_TEST_FOR_EXCEPTION( (info > 0) ,
310  std::runtime_error,
311  "ShyLUBasker: Zero pivot found at: " << info );
312 
313  return(info);
314 }
315 
316 
317 template <class Matrix, class Vector>
318 int
320  const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
321  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const
322 {
323  int ierr = 0; // returned error code
324 
325  using Teuchos::as;
326 
327  const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
328  const size_t nrhs = X->getGlobalNumVectors();
329 
330  if ( single_proc_optimization() && nrhs == 1 ) {
331 
332 #ifdef HAVE_AMESOS2_TIMERS
333  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
334 #endif
335 
336 #ifndef HAVE_TEUCHOS_COMPLEX
337  auto b_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( B );
338  auto x_vector = Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( X );
339 #else
340  // NDE: 09/25/2017
341  // Cannot convert Kokkos::complex<T>* to std::complex<T>*; in this case, use reinterpret_cast
342  using complex_type = typename Util::getStdCplxType< magnitude_type, typename matrix_adapter_type::spmtx_vals_t >::type;
343  complex_type * b_vector = reinterpret_cast< complex_type * >( Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( B ) );
344  complex_type * x_vector = reinterpret_cast< complex_type * >( Util::vector_pointer_helper< MultiVecAdapter<Vector>, Vector >::get_pointer_to_vector( X ) );
345 #endif
346  TEUCHOS_TEST_FOR_EXCEPTION(b_vector == nullptr,
347  std::runtime_error, "Amesos2 Runtime Error: b_vector returned null ");
348 
349  TEUCHOS_TEST_FOR_EXCEPTION(x_vector == nullptr,
350  std::runtime_error, "Amesos2 Runtime Error: x_vector returned null ");
351 
352  if ( this->root_ ) {
353  { // Do solve!
354 #ifdef HAVE_AMESOS2_TIMERS
355  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
356 #endif
357  ierr = ShyLUbasker->Solve(nrhs, b_vector, x_vector);
358  } // end scope for timer
359 
360  /* All processes should have the same error code */
361  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
362 
363  TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
364  std::runtime_error,
365  "Encountered zero diag element at: " << ierr);
366  TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
367  std::runtime_error,
368  "Could not alloc needed working memory for solve" );
369  } //end if (this->root_)
370  } // end if ( single_proc_optimization() && nrhs == 1 )
371  else
372  {
373  const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
374 
375  xvals_.resize(val_store_size);
376  bvals_.resize(val_store_size);
377 
378  { // Get values from RHS B
379 #ifdef HAVE_AMESOS2_TIMERS
380  Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
381  Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
382 #endif
383 
384  if ( is_contiguous_ == true ) {
386  slu_type>::do_get(B, bvals_(), as<size_t>(ld_rhs), ROOTED, this->rowIndexBase_);
387  }
388  else {
390  slu_type>::do_get(B, bvals_(), as<size_t>(ld_rhs), CONTIGUOUS_AND_ROOTED, this->rowIndexBase_);
391  }
392  }
393 
394  if ( this->root_ ) {
395  { // Do solve!
396 #ifdef HAVE_AMESOS2_TIMERS
397  Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
398 #endif
399  ierr = ShyLUbasker->Solve(nrhs, bvals_.getRawPtr(), xvals_.getRawPtr());
400  } // end scope for timer
401  } // end if (this->root_)
402 
403  /* All processes should have the same error code */
404  Teuchos::broadcast(*(this->getComm()), 0, &ierr);
405 
406  TEUCHOS_TEST_FOR_EXCEPTION( ierr > 0,
407  std::runtime_error,
408  "Encountered zero diag element at: " << ierr);
409  TEUCHOS_TEST_FOR_EXCEPTION( ierr == -1,
410  std::runtime_error,
411  "Could not alloc needed working memory for solve" );
412 
413  {
414 #ifdef HAVE_AMESOS2_TIMERS
415  Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
416 #endif
417 
418  if ( is_contiguous_ == true ) {
420  MultiVecAdapter<Vector>,slu_type>::do_put(X, xvals_(),
421  as<size_t>(ld_rhs),
422  ROOTED);
423  }
424  else {
426  MultiVecAdapter<Vector>,slu_type>::do_put(X, xvals_(),
427  as<size_t>(ld_rhs),
428  CONTIGUOUS_AND_ROOTED);
429  }
430  } // end scope for timer
431  } // end else
432 
433  return(ierr);
434 }
435 
436 
437 template <class Matrix, class Vector>
438 bool
440 {
441  // The ShyLUBasker can only handle square for right now
442  return( this->globalNumRows_ == this->globalNumCols_ );
443 }
444 
445 
446 template <class Matrix, class Vector>
447 void
448 ShyLUBasker<Matrix,Vector>::setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
449 {
450  using Teuchos::RCP;
451  using Teuchos::getIntegralValue;
452  using Teuchos::ParameterEntryValidator;
453 
454  RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
455 
456  if(parameterList->isParameter("IsContiguous"))
457  {
458  is_contiguous_ = parameterList->get<bool>("IsContiguous");
459  }
460 
461  if(parameterList->isParameter("num_threads"))
462  {
463  num_threads = parameterList->get<int>("num_threads");
464  }
465  if(parameterList->isParameter("pivot"))
466  {
467  ShyLUbasker->Options.no_pivot = (!parameterList->get<bool>("pivot"));
468  }
469  if(parameterList->isParameter("pivot_tol"))
470  {
471  ShyLUbasker->Options.pivot_tol = parameterList->get<double>("pivot_tol");
472  }
473  if(parameterList->isParameter("symmetric"))
474  {
475  ShyLUbasker->Options.symmetric = parameterList->get<bool>("symmetric");
476  }
477  if(parameterList->isParameter("realloc"))
478  {
479  ShyLUbasker->Options.realloc = parameterList->get<bool>("realloc");
480  }
481  if(parameterList->isParameter("verbose"))
482  {
483  ShyLUbasker->Options.verbose = parameterList->get<bool>("verbose");
484  }
485  if(parameterList->isParameter("verbose_matrix"))
486  {
487  ShyLUbasker->Options.verbose_matrix_out = parameterList->get<bool>("verbose_matrix");
488  }
489  if(parameterList->isParameter("matching"))
490  {
491  ShyLUbasker->Options.matching = parameterList->get<bool>("matching");
492  }
493  if(parameterList->isParameter("matching_type"))
494  {
495  ShyLUbasker->Options.matching_type =
496  (local_ordinal_type) parameterList->get<int>("matching_type");
497  }
498  if(parameterList->isParameter("btf"))
499  {
500  ShyLUbasker->Options.btf = parameterList->get<bool>("btf");
501  }
502  if(parameterList->isParameter("amd_btf"))
503  {
504  ShyLUbasker->Options.amd_btf = parameterList->get<bool>("amd_btf");
505  }
506  if(parameterList->isParameter("amd_dom"))
507  {
508  ShyLUbasker->Options.amd_dom = parameterList->get<bool>("amd_dom");
509  }
510  if(parameterList->isParameter("transpose"))
511  {
512  ShyLUbasker->Options.transpose = parameterList->get<bool>("transpose");
513  }
514 
515 }
516 
517 template <class Matrix, class Vector>
518 Teuchos::RCP<const Teuchos::ParameterList>
520 {
521  using Teuchos::ParameterList;
522 
523  static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
524 
525  if( is_null(valid_params) )
526  {
527  Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
528  pl->set("IsContiguous", true,
529  "Are GIDs contiguous");
530  pl->set("num_threads", 1,
531  "Number of threads");
532  pl->set("pivot", false,
533  "Should not pivot");
534  pl->set("pivot_tol", .0001,
535  "Tolerance before pivot, currently not used");
536  pl->set("symmetric", false,
537  "Should Symbolic assume symmetric nonzero pattern");
538  pl->set("realloc" , false,
539  "Should realloc space if not enough");
540  pl->set("verbose", false,
541  "Information about factoring");
542  pl->set("verbose_matrix", false,
543  "Give Permuted Matrices");
544  pl->set("matching", true,
545  "Use WC matching (Not Supported)");
546  pl->set("matching_type", 0,
547  "Type of WC matching (Not Supported)");
548  pl->set("btf", true,
549  "Use BTF ordering");
550  pl->set("amd_btf", true,
551  "Use AMD on BTF blocks (Not Supported)");
552  pl->set("amd_dom", true,
553  "Use CAMD on ND blocks (Not Supported)");
554  pl->set("transpose", false,
555  "Solve the transpose A");
556  valid_params = pl;
557  }
558  return valid_params;
559 }
560 
561 
562 template <class Matrix, class Vector>
563 bool
565 {
566  using Teuchos::as;
567  if(current_phase == SOLVE) return (false);
568 
569  #ifdef HAVE_AMESOS2_TIMERS
570  Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
571  #endif
572 
573 
574  // NDE: Can clean up duplicated code with the #ifdef guards
575  if ( single_proc_optimization() ) {
576  // NDE: Nothing is done in this special case - CRS raw pointers are passed to SHYLUBASKER and transpose of copies handled there
577  // In this case, colptr_, rowind_, nzvals_ are invalid
578  }
579  else
580  {
581 
582  // Only the root image needs storage allocated
583  if( this->root_ ){
584  nzvals_.resize(this->globalNumNonZeros_);
585  rowind_.resize(this->globalNumNonZeros_);
586  colptr_.resize(this->globalNumCols_ + 1); //this will be wrong for case of gapped col ids, e.g. 0,2,4,9; num_cols = 10 ([0,10)) but num GIDs = 4...
587  }
588 
589  local_ordinal_type nnz_ret = 0;
590  {
591  #ifdef HAVE_AMESOS2_TIMERS
592  Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
593  #endif
594 
595  if ( is_contiguous_ == true ) {
597  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
598  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
599  nnz_ret, ROOTED, ARBITRARY, this->rowIndexBase_); // copies from matrixA_ to ShyLUBasker ConcreteSolver cp, ri, nzval members
600  }
601  else {
603  MatrixAdapter<Matrix>,slu_type,local_ordinal_type,local_ordinal_type>
604  ::do_get(this->matrixA_.ptr(), nzvals_(), rowind_(), colptr_(),
605  nnz_ret, CONTIGUOUS_AND_ROOTED, ARBITRARY, this->rowIndexBase_); // copies from matrixA_ to ShyLUBasker ConcreteSolver cp, ri, nzval members
606  }
607  }
608 
609  if( this->root_ ){
610  TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->globalNumNonZeros_),
611  std::runtime_error,
612  "Amesos2_ShyLUBasker loadA_impl: Did not get the expected number of non-zero vals");
613  }
614 
615  } //end alternative path
616  return true;
617 }
618 
619 
620 template<class Matrix, class Vector>
621 const char* ShyLUBasker<Matrix,Vector>::name = "ShyLUBasker";
622 
623 
624 } // end namespace Amesos2
625 
626 #endif // AMESOS2_SHYLUBASKER_DEF_HPP
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
ShyLUBasker specific solve.
Definition: Amesos2_ShyLUBasker_def.hpp:319
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Amesos2 interface to the Baker package.
Definition: Amesos2_ShyLUBasker_decl.hpp:76
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_ShyLUBasker_def.hpp:519
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:266
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_ShyLUBasker_def.hpp:128
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_ShyLUBasker_def.hpp:439
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
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:654
Amesos2 ShyLUBasker declarations.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_ShyLUBasker_def.hpp:564
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int numericFactorization_impl()
ShyLUBasker specific numeric factorization.
Definition: Amesos2_ShyLUBasker_def.hpp:215
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
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through, also check that is_contiguous_ ...
Definition: Amesos2_ShyLUBasker_def.hpp:122