37 #include "mkl_pardiso.h"
38 #include "mkl_cluster_sparse_solver.h"
39 #define IPARM(i) iparm_[i-1]
41 using namespace Teuchos;
59 for(
int i = 0; i < 64; ++i ){
82 for (
int i = 0; i < 64; i++) {
98 void *bdummy, *xdummy;
100 cluster_sparse_solver(
pt_, const_cast<int*>(&
maxfct_),
104 const_cast<int*>(&
msglvl_), &bdummy, &xdummy, &CssComm, &error );
125 #ifdef HAVE_AMESOS_EPETRAEXT
128 std::cerr <<
"Amesos_CssMKL requires CsrMatrix to reindex matrices." << std::endl;
131 const Epetra_Map& OriginalMap = CrsMatrix->RowMap();
135 std::cerr <<
"Amesos_CssMKL reindexing failed" << std::endl;
139 std::cerr <<
"Amesos_CssMKL requires EpetraExt to reindex matrices." << std::endl;
153 ia_.resize( NumMyElements+1 );
157 std::vector<int> ColIndicesV_(MaxNumEntries_);
158 std::vector<double> RowValuesV_(MaxNumEntries_);
163 typedef std::pair<int, double> Data;
164 std::vector<Data> sort_array(MaxNumEntries_);
169 for (
int MyRow = 0; MyRow < NumMyElements ; MyRow++)
172 &RowValuesV_[0], &ColIndicesV_[0]);
175 double *RowValues = &RowValuesV_[0];
176 int *ColIndices = &ColIndicesV_[0];
179 for (
int j = 0; j < NzThisRow; j++ ) {
180 sort_array[j].first = Global_Columns_[ColIndices[j]];
181 sort_array[j].second = RowValues[j];
183 std::sort(&sort_array[0], &sort_array[NzThisRow]);
185 ia_[MyRow] = Ai_index ;
186 for (
int j = 0; j < NzThisRow; j++ ) {
187 ja_[Ai_index] = sort_array[j].first;
188 aa_[Ai_index] = sort_array[j].second;
192 ia_[ NumMyElements ] = Ai_index;
193 assert( NumMyElements == MyRow );
217 iparm_[1] =
param_.
get<
int>(
"Use METIS reordering" , 10);
218 iparm_[7] =
param_.
get<
int>(
"Max num of iterative refinement steps", 0);
219 iparm_[9] =
param_.
get<
int>(
"Perturbation for pivot elements 10^-k", 13);
220 iparm_[10] =
param_.
get<
int>(
"Use (non-)symmetric scaling vectors", 0);
221 iparm_[11] =
param_.
get<
int>(
"Solve transposed", 0);
222 iparm_[12] =
param_.
get<
int>(
"Use (non-)symmetric matchings", 0);
223 iparm_[17] =
param_.
get<
int>(
"Number of non-zeros in LU; -1 to compute", -1);
224 iparm_[20] =
param_.
get<
int>(
"Pivot for symmetric indefinite matrix", -1);
238 const MPI_Comm CssEComm = EMpiComm.
Comm();
244 int first_row = rangeMap.MinMyGID();
245 int last_row = rangeMap.MaxMyGID();
255 void *bdummy, *xdummy;
258 cluster_sparse_solver(
pt_, const_cast<int*>(&
maxfct_),
262 const_cast<int*>(&
msglvl_), &bdummy, &xdummy, &CssComm, &error );
280 void *bdummy, *xdummy;
282 cluster_sparse_solver(
pt_, const_cast<int*>(&
maxfct_),
286 const_cast<int*>(&
msglvl_), &bdummy, &xdummy, &CssComm, &error );
300 if (
GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints() !=
301 GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints() )
368 if ((X == 0) || (B == 0))
371 int NumVectors = X->NumVectors();
372 if (NumVectors != B->NumVectors())
396 cluster_sparse_solver(
pt_, const_cast<int*>(&
maxfct_),
410 if (
Comm().MyPID() == 0) {
437 std::string p =
"Amesos_CssMKL : ";
443 std::cout << p <<
"Matrix has " << n <<
" rows"
444 <<
" and " << nnz <<
" nonzeros" << std::endl;
445 std::cout << p <<
"Nonzero elements per row = "
446 << 1.0 * nnz / n << std::endl;
447 std::cout << p <<
"Percentage of nonzero elements = "
448 << 100.0 * nnz /(pow(n,2.0)) << std::endl;
449 std::cout << p <<
"Use transpose = " <<
UseTranspose_ << std::endl;
450 std::cout << p <<
"Number of performed iterative ref. steps = " <<
IPARM(9) << std::endl;
451 std::cout << p <<
"Peak memory symbolic factorization = " <<
IPARM(15) << std::endl;
452 std::cout << p <<
"Permanent memory symbolic factorization = " <<
IPARM(16) << std::endl;
453 std::cout << p <<
"Memory numerical fact. and solution = " <<
IPARM(17) << std::endl;
454 std::cout << p <<
"Number of nonzeros in factors = " <<
IPARM(18) << std::endl;
455 std::cout << p <<
"MFlops of factorization = " <<
IPARM(19) << std::endl;
456 std::cout << p <<
"CG/CGS diagnostic = " <<
IPARM(20) << std::endl;
457 std::cout << p <<
"Inertia: Number of positive eigenvalues = " <<
IPARM(22) << std::endl;
458 std::cout << p <<
"Inertia: Number of negative eigenvalues = " <<
IPARM(23) << std::endl;
487 std::string p =
"Amesos_CssMKL : ";
490 std::cout << p <<
"Time to convert matrix to CssMKL format = "
491 << ConTime <<
" (s)" << std::endl;
492 std::cout << p <<
"Time to redistribute matrix = "
493 << MatTime <<
" (s)" << std::endl;
494 std::cout << p <<
"Time to redistribute vectors = "
495 << VecTime <<
" (s)" << std::endl;
496 std::cout << p <<
"Number of symbolic factorizations = "
498 std::cout << p <<
"Time for sym fact = "
499 << SymTime <<
" (s), avg = " << SymTime <<
" (s)" << std::endl;
500 std::cout << p <<
"Number of numeric factorizations = "
502 std::cout << p <<
"Time for num fact = "
503 << NumTime <<
" (s), avg = " << NumTime <<
" (s)" << std::endl;
504 std::cout << p <<
"Number of solve phases = "
506 std::cout << p <<
"Time for solve = "
507 << SolTime <<
" (s), avg = " << SolTime <<
" (s)" << std::endl;
520 std::cerr <<
"Amesos: CSS returned error code " << error << std::endl;
521 std::cerr <<
"Amesos: Related message from manual is:" << std::endl;
526 std::cerr <<
"Input inconsistent" << std::endl;
529 std::cerr <<
"Not enough memory" << std::endl;
532 std::cerr <<
"Reordering problems" << std::endl;
535 std::cerr <<
"Zero pivot, numerical fact. or iterative refinement problem. " << std::endl;
538 std::cerr <<
"Unclassified (internal) error" << std::endl;
541 std::cerr <<
"Preordering failed (matrix types 11, 13 only)" << std::endl;
544 std::cerr <<
"Diagonal matrix problem." << std::endl;
int NumSymbolicFact_
Number of symbolic factorization phases.
void PrintTiming() const
Prints timing information.
Teuchos::RCP< Amesos_StandardIndex > StdIndex_
virtual const Epetra_Map & RowMatrixRowMap() const =0
void PrintLine() const
Prints line on std::cout.
Epetra_MultiVector * GetLHS() const
int msglvl_
Actual matrix for solution phase (always 1)
Epetra_MultiVector * GetRHS() const
std::vector< double > aa_
bool IsSymbolicFactorizationOK_
If true, SymbolicFactorization() has been successfully called.
int MyGlobalElements(int *MyGlobalElementList) const
T & get(ParameterList &l, const std::string &name)
int PerformSymbolicFactorization()
Teuchos::ParameterList param_
int Solve()
Solves A X = B (or AT X = B)
const Epetra_LinearProblem * Problem_
Pointer to the linear system problem.
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
const Epetra_LinearProblem * GetProblem() const
Get a pointer to the Problem.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object.
int MtxConvTime_
Quick access pointers to the internal timing data.
int NumNumericFact_
Number of numeric factorization phases.
virtual int NumGlobalNonzeros() const =0
virtual int MyPID() const =0
const Epetra_RowMatrix & Matrix() const
Amesos_CssMKL(const Epetra_LinearProblem &LinearProblem)
Constructor.
~Amesos_CssMKL()
Destructor.
int NumSolve_
Number of solves.
virtual int MaxNumEntries() const =0
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)
#define AMESOS_CHK_ERR(a)
bool isSublist(const std::string &name) const
bool UseTranspose() const
Returns the current UseTranspose setting.
bool UseTranspose_
If true, the transpose of A is used.
bool MatrixShapeOK() const
Returns true if CSSMKL can handle this matrix shape.
bool PrintTiming_
If true, prints timing information in the destructor.
virtual int NumMyRows() const =0
const Epetra_RowMatrix * OriginalMatrix_
bool PrintStatus_
If true, print additional information in the destructor.
#define AMESOS_RETURN(amesos_err)
int AddTime(const std::string what, int dataID, const int timerID=0)
Adds to field what the time elapsed since last call to ResetTimer().
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
bool Reindex_
If true, the Amesos class should reindex the matrix to standard indexing (i.e.
void PrintStatus() const
Prints information about the factorization and solution phases.
const Epetra_RowMatrix * Matrix_
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 NumericFactorization()
Performs NumericFactorization on the matrix A.
int PerformNumericFactorization()
int SetParameters(Teuchos::ParameterList &ParameterList)
Set parameters from the input parameters list, returns 0 if successful.
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_Operator * GetOperator() const
virtual const Epetra_Map & RowMatrixColMap() const =0
int verbose_
Toggles the output level.
double GetTime(const std::string what) const
Gets the cumulative time using the string.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
#define AMESOS_CHK_ERRV(amesos_err)
bool IsNumericFactorizationOK_
If true, NumericFactorization() has been successfully called.
virtual int NumGlobalRows() const =0
virtual int NumMyNonzeros() const =0
int CheckError(const int error) 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.
bool ComputeTrueResidual_
If true, computes the true residual in Solve().