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