38 #include "superlu_ddefs.h" 39 #include "supermatrix.h" 56 #if SUPERLU_DIST_MAJOR_VERSION > 4 74 for ( i = 1; i*i <= NumProcs; i++ )
77 for ( NumProcRows = i-1 ; done == false ; ) {
78 int NumCols = NumProcs / NumProcRows ;
79 if ( NumProcRows * NumCols == NumProcs )
92 if (nprow < 1 ) nprow = 1;
93 npcol = MaxProcesses / nprow;
95 if( nprow <=0 || npcol <= 0 || MaxProcesses <=0 ) {
96 std::cerr <<
"Amesos_Superludist: wrong value for MaxProcs (" 97 << MaxProcesses <<
"), or nprow (" << nprow
98 <<
") or npcol (" << npcol <<
")" << std::endl;
110 FactorizationDone_(0),
111 FactorizationOK_(false),
115 PrintNonzeros_(false),
120 IterRefine_(
"NOT SET"),
121 ReplaceTinyPivot_(true),
138 #if (SUPERLU_DIST_MAJOR_VERSION > 5) || ( SUPERLU_DIST_MAJOR_VERSION == 5 && SUPERLU_DIST_MINOR_VERSION > 3) 197 if( SuperludistParams.
isParameter(
"ReuseSymbolic") )
199 std::string FactOption =
"NotSet";
202 FactOption = SuperludistParams.
get<std::string>(
"Fact");
206 else if ( FactOption !=
"NotSet" )
210 Equil_ = SuperludistParams.
get<
bool>(
"Equil");
213 ColPerm_ = SuperludistParams.
get<std::string>(
"ColPerm");
217 perm_c_ = SuperludistParams.
get<
int*>(
"perm_c");
220 RowPerm_ = SuperludistParams.
get<std::string>(
"RowPerm");
223 perm_r_ = SuperludistParams.
get<
int*>(
"perm_r");
229 if (SuperludistParams.
isParameter(
"ReplaceTinyPivot"))
232 if (SuperludistParams.
isParameter(
"PrintNonzeros"))
261 int MyFirstElement = iam * m_per_p +
EPETRA_MIN( iam, remainder );
262 int MyFirstNonElement = (iam+1) * m_per_p +
EPETRA_MIN( iam+1, remainder );
263 int NumExpectedElements = MyFirstNonElement - MyFirstElement ;
266 NumExpectedElements = 0;
322 if (
Comm().NumProc() == 1)
332 if (
Comm().NumProc() == 1)
354 Ap_.resize( NumMyElements+1 );
365 std::vector<double> RowValuesV_(MaxNumEntries_);
366 std::vector<int> ColIndicesV_(MaxNumEntries_);
374 for (MyRow = 0; MyRow < NumMyElements ; MyRow++)
384 &RowValuesV_[0], &ColIndicesV_[0]);
385 RowValues = &RowValuesV_[0];
386 ColIndices = &ColIndicesV_[0];
393 for (
int i = 0 ; i < NzThisRow ; ++i) {
394 if (ColIndices[i] == MyRow) {
401 Ap_[MyRow] = Ai_index ;
402 for (
int j = 0; j < NzThisRow; j++ ) {
404 Aval_[Ai_index] = RowValues[j] ;
408 assert( NumMyElements == MyRow );
409 Ap_[ NumMyElements ] = Ai_index ;
447 nnz_loc, NumMyElements, MyActualFirstElement,
449 SLU_NR_loc, SLU_D, SLU_GE );
454 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG 479 #if (SUPERLU_DIST_MAJOR_VERSION > 5) || ( SUPERLU_DIST_MAJOR_VERSION == 5 && SUPERLU_DIST_MINOR_VERSION > 3) 495 #ifdef HAVE_SUPERLUDIST_ENUM_NAMESPACE 504 #ifdef HAVE_SUPERLUDIST_ENUM_NAMESPACE 595 std::vector<int> ColIndicesV_(MaxNumEntries_);
596 std::vector<double> RowValuesV_(MaxNumEntries_);
603 for ( MyRow = 0; MyRow < NumMyElements ; MyRow++ ) {
604 if ( SuperluCrs != 0 ) {
610 NzThisRow, &RowValuesV_[0],
612 RowValues = &RowValuesV_[0];
613 ColIndices = &ColIndicesV_[0];
619 for (
int j = 0; j < NzThisRow; j++ ) {
622 Aval_[Ai_index] = RowValues[j] ;
664 if (
GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints() !=
665 GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints())
725 if (vecX == 0 || vecB == 0)
746 vecX->
Update(1.0, *vecB, 0.0);
761 std::vector<double>berr(nrhs);
791 "Amesos_Superludist");
808 std::string p =
"Amesos_Superludist : ";
814 <<
" and " << NNZ <<
" nonzeros" << std::endl;
815 std::cout << p <<
"Nonzero elements per row = " 817 std::cout << p <<
"Percentage of nonzero elements = " 819 std::cout << p <<
"Use transpose = " <<
UseTranspose() << std::endl;
820 std::cout << p <<
"Redistribute = " <<
Redistribute_ << std::endl;
821 std::cout << p <<
"# available processes = " <<
Comm().
NumProc() << std::endl;
822 std::cout << p <<
"# processes used in computation = " <<
nprow_ *
npcol_ 823 <<
" ( = " <<
nprow_ <<
"x" <<
npcol_ <<
")" << std::endl;
824 std::cout << p <<
"Equil = " <<
Equil_ << std::endl;
825 std::cout << p <<
"ColPerm = " <<
ColPerm_ << std::endl;
826 std::cout << p <<
"RowPerm = " <<
RowPerm_ << std::endl;
827 std::cout << p <<
"IterRefine = " <<
IterRefine_ << std::endl;
829 std::cout << p <<
"AddZeroToDiag = " <<
AddZeroToDiag_ << std::endl;
830 std::cout << p <<
"Redistribute = " <<
Redistribute_ << std::endl;
856 std::string p =
"Amesos_Superludist : ";
859 std::cout << p <<
"Time to convert matrix to Superludist format = " 860 << ConTime <<
" (s)" << std::endl;
861 std::cout << p <<
"Time to redistribute matrix = " 862 << MatTime <<
" (s)" << std::endl;
863 std::cout << p <<
"Time to redistribute vectors = " 864 << VecTime <<
" (s)" << std::endl;
865 std::cout << p <<
"Number of symbolic factorizations = " 867 std::cout << p <<
"Time for sym fact = 0.0 (s), avg = 0.0 (s)" << std::endl;
868 std::cout << p <<
"Number of numeric factorizations = " 870 std::cout << p <<
"Time for num fact = " 871 << NumTime *
NumNumericFact_ <<
" (s), avg = " << NumTime <<
" (s)" << std::endl;
872 std::cout << p <<
"Number of solve phases = " 874 std::cout << p <<
"Time for solve = " 875 << SolTime *
NumSolve_ <<
" (s), avg = " << SolTime <<
" (s)" << std::endl;
880 std::cout << p <<
"Total time spent in Amesos = " << tt <<
" (s) " << std::endl;
881 std::cout << p <<
"Total time spent in the Amesos interface = " << OveTime <<
" (s)" << std::endl;
882 std::cout << p <<
"(the above time does not include SuperLU_DIST time)" << std::endl;
883 std::cout << p <<
"Amesos interface time / total time = " << OveTime / tt << std::endl;
void PrintTiming() const
Print various timig.
int NumSymbolicFact_
Number of symbolic factorization phases.
double GetTime(const std::string what) const
Gets the cumulative time using the string.
int MyGlobalElements(int *MyGlobalElementList) const
virtual const Epetra_Map & RowMatrixRowMap() const=0
int Solve()
Solves A X = B (or AT x = B)
bool ReuseSymbolic_
Allows FactOption to be used on subsequent calls to pdgssvx from NumericFactorization.
void PrintStatus() const
Print various information about the parameters used by Superludist.
bool FactorizationOK_
true if NumericFactorization() has been successfully called.
int LRID(int GRID_in) const
T & get(ParameterList &l, const std::string &name)
bool UseTranspose() const
Always returns false. Superludist doesn't support transpose solve.
~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)
static void SetTracebackMode(int TracebackModeValue)
bool isSublist(const std::string &name) const
const Epetra_LinearProblem * GetProblem() const
Returns the Epetra_LinearProblem.
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.
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
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 NumSolve_
Number of solves.
Epetra_CrsMatrix & CrsUniformMatrix()
Epetra_RowMatrix * RowMatrixA_
virtual int MaxNumEntries() const=0
std::vector< double > Aval_
const Epetra_Import & Importer() const
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
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().
void SetControlParameters(const Teuchos::ParameterList &ParameterList)
RCP< Epetra_Map > UniformMap_
#define AMESOS_CHK_ERR(a)
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.
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().
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Epetra_MultiVector * GetRHS() const
RCP< Epetra_RowMatrix > UniformMatrix_
virtual int NumProc() const=0
int NumGlobalRows_
Global dimension of the matrix.
int SetNPRowAndCol(const int MaxProcesses, int &nprow, int &npcol)
const Epetra_RowMatrix & UniformMatrix() const
static int GetTracebackMode()
Amesos_Superludist(const Epetra_LinearProblem &LinearProblem)
Amesos_Superludist Constructor.
int NumGlobalElements() const
Teuchos::RCP< Epetra_Import > Importer_
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.
bool isParameter(const std::string &name) const
void ResetTimer(const int timerID=0)
Resets the internally stored time object.
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const=0
Epetra_MultiVector * GetLHS() const
virtual const Epetra_Map & RowMatrixColMap() const=0
int ExtractView(double **A, int *MyLDA) const
SOLVEstruct_t SOLVEstruct_
int Superludist_NumProcRows(int NumProcs)
Epetra_Operator * GetOperator() const
const Epetra_LinearProblem * Problem_
bool MatrixShapeOK() const
Returns true if SUPERLUDIST can handle this matrix shape.
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
RCP< Epetra_CrsMatrix > CrsUniformMatrix_
virtual int NumGlobalRows() const=0
virtual int NumMyNonzeros() const=0
void PrintLine() const
Prints line on std::cout.
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.