Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos_Dscpack.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Amesos: Direct Sparse Solver Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
29 #include "Amesos_Dscpack.h"
30 #include "Epetra_Map.h"
31 #include "Epetra_Import.h"
32 #include "Epetra_CrsMatrix.h"
33 #include "Epetra_Vector.h"
34 #include "Epetra_Util.h"
35 #include "Teuchos_RCP.hpp"
36 #include <algorithm>
37 
38 #define DBL_R_NUM
39 extern "C" {
40 #include "dscmain.h"
41 }
42 
44 public:
45  DSC_Solver MyDSCObject_;
46 } ;
47 //=============================================================================
49  PrivateDscpackData_( rcp( new Amesos_Dscpack_Pimpl() ) ),
50  DscNumProcs(-1), // will be set later
51  MaxProcs_(-1),
52  MtxRedistTime_(-1),
53  MtxConvTime_(-1),
54  VecRedistTime_(-1),
55  SymFactTime_(-1),
56  NumFactTime_(-1),
57  SolveTime_(-1),
58  OverheadTime_(-1)
59 {
60  Problem_ = &prob ;
61  A_and_LU_built = false ;
62  FirstCallToSolve_ = true ;
63  PrivateDscpackData_->MyDSCObject_ = DSC_Begin() ;
64 
65  MyDscRank = -1 ;
66 }
67 
68 //=============================================================================
70 {
71  // MS // print out some information if required by the user
72  if( (verbose_ && PrintTiming_) || verbose_ == 2 ) PrintTiming();
73  if( (verbose_ && PrintStatus_) || verbose_ == 2 ) PrintStatus();
74 
75  if ( MyDscRank>=0 && A_and_LU_built ) {
76  DSC_FreeAll( PrivateDscpackData_->MyDSCObject_ ) ;
77  DSC_Close0( PrivateDscpackData_->MyDSCObject_ ) ;
78  }
79  DSC_End( PrivateDscpackData_->MyDSCObject_ ) ;
80 }
81 
82 //=============================================================================
84 {
85  // ========================================= //
86  // retrive DSCPACK's parameters from list. //
87  // default values defined in the constructor //
88  // ========================================= //
89 
90  // retrive general parameters
91 
92  SetStatusParameters( ParameterList );
93 
94  SetControlParameters( ParameterList );
95 
96  // MS // NO DSCPACK-specify parameters at this point, uncomment
97  // MS // as necessary
98  /*
99  if (ParameterList.isSublist("Dscpack") ) {
100  Teuchos::ParameterList DscpackParams = ParameterList.sublist("Dscpack") ;
101  }
102  */
103 
104  return 0;
105 }
106 
107 //=============================================================================
109 {
110  ResetTimer(0);
111  ResetTimer(1);
112 
113  MyPID_ = Comm().MyPID();
114  NumProcs_ = Comm().NumProc();
115 
116  Epetra_RowMatrix *RowMatrixA = Problem_->GetMatrix();
117  if (RowMatrixA == 0)
118  AMESOS_CHK_ERR(-1);
119 
120  const Epetra_Map& OriginalMap = RowMatrixA->RowMatrixRowMap() ;
121  const Epetra_MpiComm& comm1 = dynamic_cast<const Epetra_MpiComm &> (Comm());
122  int numrows = RowMatrixA->NumGlobalRows();
123  int numentries = RowMatrixA->NumGlobalNonzeros();
124 
126 
127  Epetra_CrsMatrix* CastCrsMatrixA =
128  dynamic_cast<Epetra_CrsMatrix*>(RowMatrixA);
129 
130  if (CastCrsMatrixA)
131  {
132  Graph = Teuchos::rcp(const_cast<Epetra_CrsGraph*>(&(CastCrsMatrixA->Graph())), false);
133  }
134  else
135  {
136  int MaxNumEntries = RowMatrixA->MaxNumEntries();
137  Graph = Teuchos::rcp(new Epetra_CrsGraph(Copy, OriginalMap, MaxNumEntries));
138 
139  std::vector<int> Indices(MaxNumEntries);
140  std::vector<double> Values(MaxNumEntries);
141 
142  for (int i = 0 ; i < RowMatrixA->NumMyRows() ; ++i)
143  {
144  int NumEntries;
145  RowMatrixA->ExtractMyRowCopy(i, MaxNumEntries, NumEntries,
146  &Values[0], &Indices[0]);
147 
148  for (int j = 0 ; j < NumEntries ; ++j)
149  Indices[j] = RowMatrixA->RowMatrixColMap().GID(Indices[j]);
150 
151  int GlobalRow = RowMatrixA->RowMatrixRowMap().GID(i);
152  Graph->InsertGlobalIndices(GlobalRow, NumEntries, &Indices[0]);
153  }
154 
155  Graph->FillComplete();
156  }
157 
158  //
159  // Create a replicated map and graph
160  //
161  std::vector<int> AllIDs( numrows ) ;
162  for ( int i = 0; i < numrows ; i++ ) AllIDs[i] = i ;
163 
164  Epetra_Map ReplicatedMap( -1, numrows, &AllIDs[0], 0, Comm());
165  Epetra_Import ReplicatedImporter(ReplicatedMap, OriginalMap);
166  Epetra_CrsGraph ReplicatedGraph( Copy, ReplicatedMap, 0 );
167 
168  AMESOS_CHK_ERR(ReplicatedGraph.Import(*Graph, ReplicatedImporter, Insert));
169  AMESOS_CHK_ERR(ReplicatedGraph.FillComplete());
170 
171  //
172  // Convert the matrix to Ap, Ai
173  //
174  std::vector <int> Replicates(numrows);
175  std::vector <int> Ap(numrows + 1);
176  std::vector <int> Ai(EPETRA_MAX(numrows, numentries));
177 
178  for( int i = 0 ; i < numrows; i++ ) Replicates[i] = 1;
179 
180  int NumEntriesPerRow ;
181  int *ColIndices = 0 ;
182  int Ai_index = 0 ;
183  for ( int MyRow = 0; MyRow <numrows; MyRow++ ) {
184  AMESOS_CHK_ERR( ReplicatedGraph.ExtractMyRowView( MyRow, NumEntriesPerRow, ColIndices ) );
185  Ap[MyRow] = Ai_index ;
186  for ( int j = 0; j < NumEntriesPerRow; j++ ) {
187  Ai[Ai_index] = ColIndices[j] ;
188  Ai_index++;
189  }
190  }
191  assert( Ai_index == numentries ) ;
192  Ap[ numrows ] = Ai_index ;
193 
194  MtxConvTime_ = AddTime("Total matrix conversion time", MtxConvTime_, 0);
195 
196  ResetTimer(0);
197 
198  //
199  // Call Dscpack Symbolic Factorization
200  //
201  int OrderCode = 2;
202  std::vector<double> MyANonZ;
203 
204  NumLocalNonz = 0 ;
205  GlobalStructNewColNum = 0 ;
206  GlobalStructNewNum = 0 ;
207  GlobalStructOwner = 0 ;
208  LocalStructOldNum = 0 ;
209 
210  NumGlobalCols = 0 ;
211 
212  // MS // Have to define the maximum number of processes to be used
213  // MS // This is only a suggestion as Dscpack uses a number of processes that is a power of 2
214 
215  int NumGlobalNonzeros = GetProblem()->GetMatrix()->NumGlobalNonzeros();
216  int NumRows = GetProblem()->GetMatrix()->NumGlobalRows();
217 
218  // optimal value for MaxProcs == -1
219 
220  int OptNumProcs1 = 1+EPETRA_MAX( NumRows/10000, NumGlobalNonzeros/1000000 );
221  OptNumProcs1 = EPETRA_MIN(NumProcs_,OptNumProcs1 );
222 
223  // optimal value for MaxProcs == -2
224 
225  int OptNumProcs2 = (int)sqrt(1.0 * NumProcs_);
226  if( OptNumProcs2 < 1 ) OptNumProcs2 = 1;
227 
228  // fix the value of MaxProcs
229 
230  switch (MaxProcs_)
231  {
232  case -1:
233  MaxProcs_ = EPETRA_MIN(OptNumProcs1, NumProcs_);
234  break;
235  case -2:
236  MaxProcs_ = EPETRA_MIN(OptNumProcs2, NumProcs_);
237  break;
238  case -3:
240  break;
241  }
242 
243 #if 0
244  if (MyDscRank>=0 && A_and_LU_built) {
245  DSC_ReFactorInitialize(PrivateDscpackData_->MyDSCObject);
246  }
247 #endif
248  // if ( ! A_and_LU_built ) {
249  // DSC_End( PrivateDscpackData_->MyDSCObject ) ;
250  // PrivateDscpackData_->MyDSCObject = DSC_Begin() ;
251  // }
252 
253  // MS // here I continue with the old code...
254 
255  OverheadTime_ = AddTime("Total Amesos overhead time", OverheadTime_, 1);
256 
257  DscNumProcs = 1 ;
258  int DscMax = DSC_Analyze( numrows, &Ap[0], &Ai[0], &Replicates[0] );
259 
260  while ( DscNumProcs * 2 <=EPETRA_MIN( MaxProcs_, DscMax ) ) DscNumProcs *= 2 ;
261 
262  MyDscRank = -1;
263  DSC_Open0( PrivateDscpackData_->MyDSCObject_, DscNumProcs, &MyDscRank, comm1.Comm()) ;
264 
265  NumLocalCols = 0 ; // This is for those processes not in the Dsc grid
266  if ( MyDscRank >= 0 ) {
267  assert( MyPID_ == MyDscRank ) ;
268  AMESOS_CHK_ERR( DSC_Order ( PrivateDscpackData_->MyDSCObject_, OrderCode, numrows, &Ap[0], &Ai[0],
269  &Replicates[0], &NumGlobalCols, &NumLocalStructs,
270  &NumLocalCols, &NumLocalNonz,
273  assert( NumGlobalCols == numrows ) ;
274  assert( NumLocalCols == NumLocalStructs ) ;
275  }
276 
277  if ( MyDscRank >= 0 ) {
278  int MaxSingleBlock;
279 
280  const int Limit = 5000000 ; // Memory Limit set to 5 Terabytes
282  &MaxSingleBlock, Limit, DSC_LBLAS3, DSC_DBLAS2 ) ) ;
283 
284  }
285 
286  // A_and_LU_built = true; // If you uncomment this, TestOptions fails
287 
288  SymFactTime_ = AddTime("Total symbolic factorization time", SymFactTime_, 0);
289 
290  return(0);
291 }
292 
293 //=============================================================================
295 {
296  ResetTimer(0);
297  ResetTimer(1);
298 
299  Epetra_RowMatrix* RowMatrixA = Problem_->GetMatrix();
300  if (RowMatrixA == 0)
301  AMESOS_CHK_ERR(-1);
302 
303  const Epetra_Map& OriginalMap = RowMatrixA->RowMatrixRowMap() ;
304 
305  int numrows = RowMatrixA->NumGlobalRows();
306  assert( numrows == RowMatrixA->NumGlobalCols() );
307 
308  //
309  // Call Dscpack to perform Numeric Factorization
310  //
311  std::vector<double> MyANonZ;
312 #if 0
313  if ( IsNumericFactorizationOK_ ) {
314  DSC_ReFactorInitialize(PrivateDscpackData_->MyDSCObject);
315  }
316 #endif
317 
319  LocalStructOldNum, 0, Comm()));
320 
321  if (DscRowMap_.get() == 0)
322  AMESOS_CHK_ERR(-1);
323 
324  Importer_ = rcp(new Epetra_Import(DscRowMap(), OriginalMap));
325 
326  //
327  // Import from the CrsMatrix
328  //
329  Epetra_CrsMatrix DscMat(Copy, DscRowMap(), 0);
330  AMESOS_CHK_ERR(DscMat.Import(*RowMatrixA, Importer(), Insert));
331  AMESOS_CHK_ERR(DscMat.FillComplete());
332 
334 
335  assert( MyDscRank >= 0 || NumLocalNonz == 0 ) ;
336  assert( MyDscRank >= 0 || NumLocalCols == 0 ) ;
337  assert( MyDscRank >= 0 || NumGlobalCols == 0 ) ;
338  MyANonZ.resize( NumLocalNonz ) ;
339  int NonZIndex = 0 ;
340 
341  int max_num_entries = DscMat.MaxNumEntries() ;
342  std::vector<int> col_indices( max_num_entries ) ;
343  std::vector<double> mat_values( max_num_entries ) ;
344  assert( NumLocalCols == DscRowMap().NumMyElements() ) ;
345  std::vector<int> my_global_elements( NumLocalCols ) ;
346  AMESOS_CHK_ERR(DscRowMap().MyGlobalElements( &my_global_elements[0] ) ) ;
347 
348  std::vector<int> GlobalStructOldColNum( NumGlobalCols ) ;
349 
350  typedef std::pair<int, double> Data;
351  std::vector<Data> sort_array(max_num_entries);
352  std::vector<int> sort_indices(max_num_entries);
353 
354  for ( int i = 0; i < NumLocalCols ; i++ ) {
355  assert( my_global_elements[i] == LocalStructOldNum[i] ) ;
356  int num_entries_this_row;
357 #ifdef USE_LOCAL
358  AMESOS_CHK_ERR( DscMat.ExtractMyRowCopy( i, max_num_entries, num_entries_this_row,
359  &mat_values[0], &col_indices[0] ) ) ;
360 #else
361  AMESOS_CHK_ERR( DscMat.ExtractGlobalRowCopy( DscMat.GRID(i), max_num_entries, num_entries_this_row,
362  &mat_values[0], &col_indices[0] ) ) ;
363 #endif
364  int OldRowNumber = LocalStructOldNum[i] ;
365  if (GlobalStructOwner[ OldRowNumber ] == -1)
366  AMESOS_CHK_ERR(-1);
367 
368  int NewRowNumber = GlobalStructNewColNum[ my_global_elements[ i ] ] ;
369 
370  //
371  // Sort the column elements
372  //
373 
374  for ( int j = 0; j < num_entries_this_row; j++ ) {
375 #ifdef USE_LOCAL
376  sort_array[j].first = GlobalStructNewColNum[ DscMat.GCID( col_indices[j])] ;
377  sort_indices[j] = GlobalStructNewColNum[ DscMat.GCID( col_indices[j])] ;
378 #else
379  sort_array[j].first = GlobalStructNewColNum[ col_indices[j] ];
380 #endif
381  sort_array[j].second = mat_values[j] ;
382  }
383  sort(&sort_array[0], &sort_array[num_entries_this_row]);
384 
385  for ( int j = 0; j < num_entries_this_row; j++ ) {
386  int NewColNumber = sort_array[j].first ;
387  if ( NewRowNumber <= NewColNumber ) MyANonZ[ NonZIndex++ ] = sort_array[j].second ;
388 
389 #ifndef USE_LOCAL
390  assert( NonZIndex <= NumLocalNonz ); // This assert can fail on non-symmetric matrices
391 #endif
392  }
393  }
394 
395  OverheadTime_ = AddTime("Total Amesos overhead time", OverheadTime_, 1);
396 
397  if ( MyDscRank >= 0 ) {
398  const int SchemeCode = 1;
399 #ifndef USE_LOCAL
400  assert( NonZIndex == NumLocalNonz );
401 #endif
402 
403  AMESOS_CHK_ERR( DSC_NFactor ( PrivateDscpackData_->MyDSCObject_, SchemeCode, &MyANonZ[0],
404  DSC_LLT, DSC_LBLAS3, DSC_DBLAS2 ) ) ;
405 
406  } // if ( MyDscRank >= 0 )
407 
408  IsNumericFactorizationOK_ = true ;
409 
410  NumFactTime_ = AddTime("Total numeric factorization time", NumFactTime_, 0);
411 
412  return(0);
413 }
414 
416 {
417  bool OK = GetProblem()->IsOperatorSymmetric() ;
418 
419  //
420  // The following test is redundant. I have left it here in case the
421  // IsOperatorSymmetric test turns out not to be reliable.
422  //
423  if ( GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints() !=
424  GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints() ) OK = false;
425  return OK;
426 }
427 
428 //=============================================================================
430 {
433 
434  CreateTimer(Comm(), 2);
435 
437 
440 
441  return(0);
442 }
443 
444 //=============================================================================
446 {
448 
451 
453 
455  NumNumericFact_++;
456 
457  return(0);
458 }
459 
460 //=============================================================================
462 {
463  if (IsNumericFactorizationOK_ == false)
465 
466  ResetTimer(0);
467  ResetTimer(1);
468 
469  Epetra_RowMatrix *RowMatrixA = Problem_->GetMatrix();
470  if (RowMatrixA == 0)
471  AMESOS_CHK_ERR(-1);
472 
473  // MS // some checks on matrix size
474  if (RowMatrixA->NumGlobalRows() != RowMatrixA->NumGlobalCols())
475  AMESOS_CHK_ERR(-1);
476 
477  // Convert vector b to a vector in the form that DSCPACK needs it
478  //
479  Epetra_MultiVector* vecX = Problem_->GetLHS();
480  Epetra_MultiVector* vecB = Problem_->GetRHS();
481 
482  if ((vecX == 0) || (vecB == 0))
483  AMESOS_CHK_ERR(-1); // something wrong with input
484 
485  int NumVectors = vecX->NumVectors();
486  if (NumVectors != vecB->NumVectors())
487  AMESOS_CHK_ERR(-2);
488 
489  double *dscmapXvalues ;
490  int dscmapXlda ;
491  Epetra_MultiVector dscmapX(DscRowMap(),NumVectors) ;
492  int ierr;
493  AMESOS_CHK_ERR(dscmapX.ExtractView(&dscmapXvalues,&dscmapXlda));
494  assert (dscmapXlda == NumLocalCols);
495 
496  double *dscmapBvalues ;
497  int dscmapBlda ;
498  Epetra_MultiVector dscmapB(DscRowMap(), NumVectors ) ;
499  ierr = dscmapB.ExtractView( &dscmapBvalues, &dscmapBlda );
500  AMESOS_CHK_ERR(ierr);
501  assert( dscmapBlda == NumLocalCols ) ;
502 
503  AMESOS_CHK_ERR(dscmapB.Import(*vecB, Importer(), Insert));
504 
505  VecRedistTime_ = AddTime("Total vector redistribution time", VecRedistTime_, 0);
506  ResetTimer(0);
507 
508  // MS // now solve the problem
509 
510  std::vector<double> ValuesInNewOrder( NumLocalCols ) ;
511 
512  OverheadTime_ = AddTime("Total Amesos overhead time", OverheadTime_, 1);
513 
514  if ( MyDscRank >= 0 ) {
515  for ( int j =0 ; j < NumVectors; j++ ) {
516  for ( int i = 0; i < NumLocalCols; i++ ) {
517  ValuesInNewOrder[i] = dscmapBvalues[DscColMap().LID( LocalStructOldNum[i] ) +j*dscmapBlda ] ;
518  }
519  AMESOS_CHK_ERR( DSC_InputRhsLocalVec ( PrivateDscpackData_->MyDSCObject_, &ValuesInNewOrder[0], NumLocalCols ) ) ;
520  AMESOS_CHK_ERR( DSC_Solve ( PrivateDscpackData_->MyDSCObject_ ) ) ;
521  AMESOS_CHK_ERR( DSC_GetLocalSolution ( PrivateDscpackData_->MyDSCObject_, &ValuesInNewOrder[0], NumLocalCols ) ) ;
522  for ( int i = 0; i < NumLocalCols; i++ ) {
523  dscmapXvalues[DscColMap().LID( LocalStructOldNum[i] ) +j*dscmapXlda ] = ValuesInNewOrder[i];
524  }
525  }
526  }
527 
528  SolveTime_ = AddTime("Total solve time", SolveTime_, 0);
529  ResetTimer(0);
530  ResetTimer(1);
531 
532  vecX->Export( dscmapX, Importer(), Insert ) ;
533 
534  VecRedistTime_ = AddTime("Total vector redistribution time", VecRedistTime_, 0);
535 
537  ComputeTrueResidual(*(GetProblem()->GetMatrix()), *vecX, *vecB,
538  false, "Amesos_Dscpack");
539 
541  ComputeVectorNorms(*vecX, *vecB, "Amesos_Dscpack");
542  OverheadTime_ = AddTime("Total Amesos overhead time", OverheadTime_, 1);
543 
544  NumSolve_++;
545 
546  return(0) ;
547 }
548 
549 // ======================================================================
551 {
552  if (Problem_->GetOperator() != 0 && MyPID_ != 0)
553  {
554  std::string p = "Amesos_Dscpack : ";
555  PrintLine();
556 
557  int n = GetProblem()->GetMatrix()->NumGlobalRows();
558  int nnz = GetProblem()->GetMatrix()->NumGlobalNonzeros();
559 
560  std::cout << p << "Matrix has " << n << " rows"
561  << " and " << nnz << " nonzeros" << std::endl;
562  std::cout << p << "Nonzero elements per row = "
563  << 1.0 * nnz / n << std::endl;
564  std::cout << p << "Percentage of nonzero elements = "
565  << 100.0 * nnz /(pow(n,2.0)) << std::endl;
566  std::cout << p << "Available process(es) = " << NumProcs_ << std::endl;
567  std::cout << p << "Process(es) used = " << DscNumProcs
568  << ", idle = " << NumProcs_ - DscNumProcs << std::endl;
569  std::cout << p << "Estimated total memory for factorization = "
570  << TotalMemory_ << " Mbytes" << std::endl;
571  }
572 
573  if ( MyDscRank >= 0 )
574  DSC_DoStats( PrivateDscpackData_->MyDSCObject_ );
575 
576  if (!MyPID_)
577  PrintLine();
578 
579  return;
580 }
581 
582 // ======================================================================
584 {
585  if (Problem_->GetOperator() == 0 || MyPID_ != 0)
586  return;
587 
588  double ConTime = GetTime(MtxConvTime_);
589  double MatTime = GetTime(MtxRedistTime_);
590  double VecTime = GetTime(VecRedistTime_);
591  double SymTime = GetTime(SymFactTime_);
592  double NumTime = GetTime(NumFactTime_);
593  double SolTime = GetTime(SolveTime_);
594  double OveTime = GetTime(OverheadTime_);
595 
596  if (NumSymbolicFact_)
597  SymTime /= NumSymbolicFact_;
598 
599  if (NumNumericFact_)
600  NumTime /= NumNumericFact_;
601 
602  if (NumSolve_)
603  SolTime /= NumSolve_;
604 
605  std::string p = "Amesos_Dscpack : ";
606  PrintLine();
607 
608  std::cout << p << "Time to convert matrix to DSCPACK format = "
609  << ConTime << " (s)" << std::endl;
610  std::cout << p << "Time to redistribute matrix = "
611  << MatTime << " (s)" << std::endl;
612  std::cout << p << "Time to redistribute vectors = "
613  << VecTime << " (s)" << std::endl;
614  std::cout << p << "Number of symbolic factorizations = "
615  << NumSymbolicFact_ << std::endl;
616  std::cout << p << "Time for sym fact = "
617  << SymTime * NumSymbolicFact_ << " (s), avg = " << SymTime << " (s)" << std::endl;
618  std::cout << p << "Number of numeric factorizations = "
619  << NumNumericFact_ << std::endl;
620  std::cout << p << "Time for num fact = "
621  << NumTime * NumNumericFact_ << " (s), avg = " << NumTime << " (s)" << std::endl;
622  std::cout << p << "Number of solve phases = "
623  << NumSolve_ << std::endl;
624  std::cout << p << "Time for solve = "
625  << SolTime * NumSolve_ << " (s), avg = " << SolTime << " (s)" << std::endl;
626 
627  double tt = SymTime * NumSymbolicFact_ + NumTime * NumNumericFact_ + SolTime * NumSolve_;
628  if (tt != 0)
629  {
630  std::cout << p << "Total time spent in Amesos = " << tt << " (s) " << std::endl;
631  std::cout << p << "Total time spent in the Amesos interface = " << OveTime << " (s)" << std::endl;
632  std::cout << p << "(the above time does not include DSCPACK time)" << std::endl;
633  std::cout << p << "Amesos interface time / total time = " << OveTime / tt << std::endl;
634  }
635 
636  PrintLine();
637 
638  return;
639 }
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:67
RCP< Epetra_Map > DscColMap_
RCP< Epetra_Import > Importer_
const Epetra_Map & DscColMap() const
virtual const Epetra_Map & RowMatrixRowMap() const =0
void PrintLine() const
Prints line on std::cout.
Definition: Amesos_Utils.h:71
Epetra_MultiVector * GetLHS() const
Epetra_MultiVector * GetRHS() const
int ExtractGlobalRowCopy(int_type Row, int Length, int &NumEntries, double *values, int_type *Indices) const
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
const Epetra_LinearProblem * GetProblem() const
Returns the Epetra_LinearProblem.
bool IsSymbolicFactorizationOK_
If true, SymbolicFactorization() has been successfully called.
Definition: Amesos_Status.h:48
bool A_and_LU_built
Tells us whether to free them.
const Epetra_Import & Importer() const
T * get() const
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object.
Definition: Amesos_Time.h:64
bool IsOperatorSymmetric() const
#define EPETRA_MIN(x, y)
int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type *Indices)
void PrintTiming() const
Prints timing information.
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:69
virtual int NumGlobalNonzeros() const =0
bool MatrixShapeOK() const
Returns true if DSCPACK can handle this matrix shape.
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:71
virtual int MaxNumEntries() const =0
const Epetra_LinearProblem * Problem_
Pointer to the linear problem.
Teuchos::RCP< Amesos_Dscpack_Pimpl > PrivateDscpackData_
void SetStatusParameters(const Teuchos::ParameterList &ParameterList)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool ComputeVectorNorms_
If true, prints the norms of X and B in Solve().
Definition: Amesos_Status.h:56
void SetControlParameters(const Teuchos::ParameterList &ParameterList)
#define AMESOS_CHK_ERR(a)
int MaxNumEntries() const
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int GID(int LID) const
bool PrintTiming_
If true, prints timing information in the destructor.
Definition: Amesos_Status.h:52
virtual int NumMyRows() const =0
int PerformSymbolicFactorization()
Performs the symbolic factorization.
MPI_Comm Comm() const
int NumericFactorization()
Performs NumericFactorization on the matrix A.
bool PrintStatus_
If true, print additional information in the destructor.
Definition: Amesos_Status.h:54
int * GlobalStructNewColNum
virtual int NumGlobalCols() const =0
int LID(int GID) const
int AddTime(const std::string what, int dataID, const int timerID=0)
Adds to field what the time elapsed since last call to ResetTimer().
Definition: Amesos_Time.h:80
Amesos_Dscpack(const Epetra_LinearProblem &LinearProblem)
Amesos_Dscpack Constructor.
int ExtractMyRowView(int LocalRow, int &NumIndices, int *&Indices) const
const Epetra_Map & RowMatrixColMap() const
~Amesos_Dscpack(void)
Amesos_Dscpack Destructor.
int Solve()
Solves A X = B (or AT x = B)
Epetra_RowMatrix * GetMatrix() const
virtual int NumProc() const =0
void ComputeTrueResidual(const Epetra_RowMatrix &Matrix, const Epetra_MultiVector &X, const Epetra_MultiVector &B, const bool UseTranspose, const std::string prefix) const
Computes the true residual, B - Matrix * X, and prints the results.
Definition: Amesos_Utils.h:29
int GRID(int LRID_in) const
RCP< Epetra_Map > DscRowMap_
void PrintStatus() const
Prints information about the factorization and solution phases.
void ResetTimer(const int timerID=0)
Resets the internally stored time object.
Definition: Amesos_Time.h:74
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
Epetra_Operator * GetOperator() const
virtual const Epetra_Map & RowMatrixColMap() const =0
int PerformNumericFactorization()
Performs the numeric factorization.
int * GlobalStructNewNum
int verbose_
Toggles the output level.
Definition: Amesos_Status.h:61
int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
double GetTime(const std::string what) const
Gets the cumulative time using the string.
Definition: Amesos_Time.h:102
const Epetra_CrsGraph & Graph() const
bool IsNumericFactorizationOK_
If true, NumericFactorization() has been successfully called.
Definition: Amesos_Status.h:50
int n
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
const Epetra_Map & DscRowMap() const
virtual int NumGlobalRows() const =0
#define EPETRA_MAX(x, y)
int GCID(int LCID_in) const
void ComputeVectorNorms(const Epetra_MultiVector &X, const Epetra_MultiVector &B, const std::string prefix) const
Computes the norms of X and B and print the results.
Definition: Amesos_Utils.h:52
bool ComputeTrueResidual_
If true, computes the true residual in Solve().
Definition: Amesos_Status.h:58