38 #include "superlu_ddefs.h" 
   39 #include "supermatrix.h" 
   43 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2) 
   44   #define ScalePermstruct_t dScalePermstruct_t 
   45   #define LUstruct_t dLUstruct_t 
   46   #define SOLVEstruct_t dSOLVEstruct_t 
   47   #define ScalePermstructInit dScalePermstructInit 
   48   #define ScalePermstructFree dScalePermstructFree 
   49   #define Destroy_LU dDestroy_LU 
   50   #define LUstructFree dLUstructFree 
   51   #define LUstructInit dLUstructInit 
   67 #if SUPERLU_DIST_MAJOR_VERSION > 4 
   85   for ( i = 1; i*i <= NumProcs; i++ ) 
 
   88   for ( NumProcRows = i-1 ; done == false ; ) {
 
   89     int NumCols = NumProcs / NumProcRows ; 
 
   90     if ( NumProcRows * NumCols == NumProcs ) 
 
  103   if (nprow < 1 ) nprow = 1;
 
  104   npcol = MaxProcesses / nprow;
 
  106   if( nprow <=0 || npcol <= 0 || MaxProcesses <=0 ) {
 
  107     std::cerr << 
"Amesos_Superludist: wrong value for MaxProcs (" 
  108    << MaxProcesses << 
"), or nprow (" << nprow 
 
  109    << 
") or npcol (" << npcol << 
")" << std::endl;
 
  121   FactorizationDone_(0), 
 
  122   FactorizationOK_(false),    
 
  126   PrintNonzeros_(false),
 
  131   IterRefine_(
"NOT SET"),
 
  132   ReplaceTinyPivot_(true),
 
  149 #if (SUPERLU_DIST_MAJOR_VERSION > 5) || ( SUPERLU_DIST_MAJOR_VERSION == 5 && SUPERLU_DIST_MINOR_VERSION > 3) 
  203   if (ParameterList.
isSublist(
"Superludist") ) 
 
  206       ParameterList.
sublist(
"Superludist") ;
 
  208     if( SuperludistParams.
isParameter(
"ReuseSymbolic") )
 
  210     std::string FactOption = 
"NotSet";
 
  213       FactOption = SuperludistParams.
get<std::string>(
"Fact");
 
  217     else if ( FactOption != 
"NotSet" ) 
 
  221       Equil_ = SuperludistParams.
get<
bool>(
"Equil");
 
  224       ColPerm_ = SuperludistParams.
get<std::string>(
"ColPerm");
 
  228         perm_c_ = SuperludistParams.
get<
int*>(
"perm_c");
 
  231       RowPerm_ = SuperludistParams.
get<std::string>(
"RowPerm");
 
  234         perm_r_ = SuperludistParams.
get<
int*>(
"perm_r");
 
  240     if (SuperludistParams.
isParameter(
"ReplaceTinyPivot"))
 
  243     if (SuperludistParams.
isParameter(
"PrintNonzeros"))
 
  272   int MyFirstElement = iam * m_per_p + 
EPETRA_MIN( iam, remainder );
 
  273   int MyFirstNonElement = (iam+1) * m_per_p + EPETRA_MIN( iam+1, remainder );
 
  274   int NumExpectedElements = MyFirstNonElement - MyFirstElement ; 
 
  277     NumExpectedElements = 0; 
 
  333   if (
Comm().NumProc() == 1)
 
  343     if (
Comm().NumProc() == 1)
 
  365   Ap_.resize( NumMyElements+1 );
 
  376   std::vector<double> RowValuesV_(MaxNumEntries_);
 
  377   std::vector<int>    ColIndicesV_(MaxNumEntries_);
 
  385   for (MyRow = 0; MyRow < NumMyElements ; MyRow++) 
 
  395                                               &RowValuesV_[0], &ColIndicesV_[0]);
 
  396       RowValues =  &RowValuesV_[0];
 
  397       ColIndices = &ColIndicesV_[0];
 
  404       for (
int i = 0 ; i < NzThisRow ; ++i) {
 
  405         if (ColIndices[i] == MyRow) {
 
  412     Ap_[MyRow] = Ai_index ; 
 
  413     for ( 
int j = 0; j < NzThisRow; j++ ) { 
 
  415       Aval_[Ai_index] = RowValues[j] ;
 
  419   assert( NumMyElements == MyRow );
 
  420   Ap_[ NumMyElements ] = Ai_index ; 
 
  458             nnz_loc, NumMyElements, MyActualFirstElement,
 
  460             SLU_NR_loc, SLU_D, SLU_GE );
 
  466 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2) 
  469 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG 
  495 #if (SUPERLU_DIST_MAJOR_VERSION > 5) || ( SUPERLU_DIST_MAJOR_VERSION == 5 && SUPERLU_DIST_MINOR_VERSION > 3) 
  511 #ifdef HAVE_SUPERLUDIST_ENUM_NAMESPACE 
  520 #ifdef HAVE_SUPERLUDIST_ENUM_NAMESPACE 
  611   std::vector<int> ColIndicesV_(MaxNumEntries_);
 
  612   std::vector<double> RowValuesV_(MaxNumEntries_);
 
  619   for ( MyRow = 0; MyRow < NumMyElements ; MyRow++ ) {
 
  620     if ( SuperluCrs != 0 ) {
 
  626                                               NzThisRow, &RowValuesV_[0], 
 
  628       RowValues =  &RowValuesV_[0];
 
  629       ColIndices = &ColIndicesV_[0];
 
  635     for ( 
int j = 0; j < NzThisRow; j++ ) { 
 
  638       Aval_[Ai_index] = RowValues[j] ;  
 
  680   if (
GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints() != 
 
  681       GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints()) 
 
  741   if (vecX == 0 || vecB == 0)
 
  744   int nrhs = vecX->NumVectors() ; 
 
  745   if (vecB->NumVectors() != nrhs)
 
  762     vecX->Update(1.0, *vecB, 0.0);
 
  777     std::vector<double>berr(nrhs);
 
  807                         "Amesos_Superludist");
 
  812   OverheadTime_ = 
AddTime(
"Total Amesos overhead time", OverheadTime_, 1);
 
  824   std::string p = 
"Amesos_Superludist : ";
 
  830        << 
" and " << NNZ << 
" nonzeros" << std::endl;
 
  831   std::cout << p << 
"Nonzero elements per row = " 
  833   std::cout << p << 
"Percentage of nonzero elements = " 
  835   std::cout << p << 
"Use transpose = " << 
UseTranspose() << std::endl;
 
  836   std::cout << p << 
"Redistribute = " << 
Redistribute_ << std::endl;
 
  837   std::cout << p << 
"# available processes = " << 
Comm().
NumProc() << std::endl;
 
  838   std::cout << p << 
"# processes used in computation = " << 
nprow_ * 
npcol_ 
  839        << 
" ( = " << 
nprow_ << 
"x" << 
npcol_ << 
")" << std::endl;
 
  840   std::cout << p << 
"Equil = " << 
Equil_ << std::endl;
 
  841   std::cout << p << 
"ColPerm = " << 
ColPerm_ << std::endl;
 
  842   std::cout << p << 
"RowPerm = " << 
RowPerm_ << std::endl;
 
  843   std::cout << p << 
"IterRefine = " << 
IterRefine_ << std::endl;
 
  845   std::cout << p << 
"AddZeroToDiag = " << 
AddZeroToDiag_ << std::endl;
 
  846   std::cout << p << 
"Redistribute = " << 
Redistribute_ << std::endl;
 
  872   std::string p = 
"Amesos_Superludist : ";
 
  875   std::cout << p << 
"Time to convert matrix to Superludist format = " 
  876        << ConTime << 
" (s)" << std::endl;
 
  877   std::cout << p << 
"Time to redistribute matrix = " 
  878        << MatTime << 
" (s)" << std::endl;
 
  879   std::cout << p << 
"Time to redistribute vectors = " 
  880        << VecTime << 
" (s)" << std::endl;
 
  881   std::cout << p << 
"Number of symbolic factorizations = " 
  883   std::cout << p << 
"Time for sym fact = 0.0 (s), avg = 0.0 (s)" << std::endl;
 
  884   std::cout << p << 
"Number of numeric factorizations = " 
  886   std::cout << p << 
"Time for num fact = " 
  887        << NumTime * 
NumNumericFact_ << 
" (s), avg = " << NumTime << 
" (s)" << std::endl;
 
  888   std::cout << p << 
"Number of solve phases = " 
  890   std::cout << p << 
"Time for solve = " 
  891        << SolTime * 
NumSolve_ << 
" (s), avg = " << SolTime << 
" (s)" << std::endl;
 
  896     std::cout << p << 
"Total time spent in Amesos = " << tt << 
" (s) " << std::endl;
 
  897     std::cout << p << 
"Total time spent in the Amesos interface = " << OveTime << 
" (s)" << std::endl;
 
  898     std::cout << p << 
"(the above time does not include SuperLU_DIST time)" << std::endl;
 
  899     std::cout << p << 
"Amesos interface time / total time = " << OveTime / tt << std::endl;
 
int NumSymbolicFact_
Number of symbolic factorization phases. 
bool UseTranspose() const 
Always returns false. Superludist doesn't support transpose solve. 
int LRID(int GRID_in) const 
int NumGlobalElements() const 
virtual const Epetra_Map & RowMatrixRowMap() const =0
void PrintLine() const 
Prints line on std::cout. 
int Solve()
Solves A X = B (or AT x = B) 
bool ReuseSymbolic_
Allows FactOption to be used on subsequent calls to pdgssvx from NumericFactorization. 
Epetra_MultiVector * GetLHS() const 
Epetra_MultiVector * GetRHS() const 
bool MatrixShapeOK() const 
Returns true if SUPERLUDIST can handle this matrix shape. 
bool FactorizationOK_
true if NumericFactorization() has been successfully called. 
int MyGlobalElements(int *MyGlobalElementList) const 
T & get(ParameterList &l, const std::string &name)
~Amesos_Superludist(void)
Amesos_Superludist Destructor. 
bool Redistribute_
redistribute the input matrix prior to calling Superludist 
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
const Epetra_Import & Importer() const 
ScalePermstruct_t ScalePermstruct_
bool AddZeroToDiag_
Adds zero to diagonal of redistributed matrix (some solvers choke on a matrix with a partly empty dia...
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A. 
void SetMaxProcesses(int &MaxProcesses, const Epetra_RowMatrix &A)
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object. 
const Epetra_RowMatrix & UniformMatrix() const 
int NumNumericFact_
Number of numeric factorization phases. 
virtual int NumGlobalNonzeros() const =0
int GridCreated_
true if the SuperLU_DIST's grid has been created (and has to be free'd) 
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables. 
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const 
int NumSolve_
Number of solves. 
bool isParameter(const std::string &name) const 
Epetra_CrsMatrix & CrsUniformMatrix()
Epetra_RowMatrix * RowMatrixA_
virtual int MaxNumEntries() const =0
std::vector< double > Aval_
int NumericFactorization()
Performs NumericFactorization on the matrix A. 
void SetStatusParameters(const Teuchos::ParameterList &ParameterList)
const Epetra_LinearProblem * GetProblem() const 
Returns the Epetra_LinearProblem. 
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(). 
void SetControlParameters(const Teuchos::ParameterList &ParameterList)
RCP< Epetra_Map > UniformMap_
#define AMESOS_CHK_ERR(a)
bool isSublist(const std::string &name) const 
bool PrintTiming_
If true, prints timing information in the destructor. 
virtual int NumMyRows() const =0
gridinfo_t grid_
SuperLU_DIST's grid information. 
int * Global_Columns_
Contains the global ID of local columns. 
bool PrintStatus_
If true, print additional information in the destructor. 
Teuchos::RCP< Amesos_Superlu_Pimpl > PrivateSuperluData_
int AddTime(const std::string what, int dataID, const int timerID=0)
Adds to field what the time elapsed since last call to ResetTimer(). 
RCP< Epetra_RowMatrix > UniformMatrix_
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. 
int NumGlobalRows_
Global dimension of the matrix. 
int SetNPRowAndCol(const int MaxProcesses, int &nprow, int &npcol)
Amesos_Superludist(const Epetra_LinearProblem &LinearProblem)
Amesos_Superludist Constructor. 
Teuchos::RCP< Epetra_Import > Importer_
const Epetra_Comm & Comm() const 
Returns a pointer to the Epetra_Comm communicator associated with this operator. 
void ResetTimer(const int timerID=0)
Resets the internally stored time object. 
void PrintStatus() const 
Print various information about the parameters used by Superludist. 
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
SOLVEstruct_t SOLVEstruct_
double GetTime(const std::string what) const 
Gets the cumulative time using the string. 
int Superludist_NumProcRows(int NumProcs)
const Epetra_LinearProblem * Problem_
RCP< Epetra_CrsMatrix > CrsUniformMatrix_
virtual int NumGlobalRows() const =0
virtual int NumMyNonzeros() const =0
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. 
void PrintTiming() const 
Print various timig. 
bool ComputeTrueResidual_
If true, computes the true residual in Solve(). 
superlu_options_t options_
Vector of options. 
double AddToDiag_
Add this value to the diagonal.