12 #include <Eigen/SparseCore>
16 #include <Eigen/Cholesky>
17 #include <Eigen/Jacobi>
18 #include <Eigen/Householder>
19 #include <Eigen/IterativeLinearSolvers>
20 #include <unsupported/Eigen/IterativeSolvers>
22 #include <unsupported/Eigen/SparseExtra>
23 #include <Eigen/SparseLU>
27 #ifdef EIGEN_METIS_SUPPORT
28 #include <Eigen/MetisSupport>
31 #ifdef EIGEN_CHOLMOD_SUPPORT
32 #include <Eigen/CholmodSupport>
35 #ifdef EIGEN_UMFPACK_SUPPORT
36 #include <Eigen/UmfPackSupport>
39 #ifdef EIGEN_KLU_SUPPORT
40 #include <Eigen/KLUSupport>
43 #ifdef EIGEN_PARDISO_SUPPORT
44 #include <Eigen/PardisoSupport>
47 #ifdef EIGEN_SUPERLU_SUPPORT
48 #include <Eigen/SuperLUSupport>
51 #ifdef EIGEN_PASTIX_SUPPORT
52 #include <Eigen/PaStiXSupport>
56 #define EIGEN_UMFPACK 10
58 #define EIGEN_SUPERLU 20
59 #define EIGEN_PASTIX 30
60 #define EIGEN_PARDISO 40
61 #define EIGEN_SPARSELU_COLAMD 50
62 #define EIGEN_SPARSELU_METIS 51
63 #define EIGEN_BICGSTAB 60
64 #define EIGEN_BICGSTAB_ILUT 61
65 #define EIGEN_GMRES 70
66 #define EIGEN_GMRES_ILUT 71
67 #define EIGEN_SIMPLICIAL_LDLT 80
68 #define EIGEN_CHOLMOD_LDLT 90
69 #define EIGEN_PASTIX_LDLT 100
70 #define EIGEN_PARDISO_LDLT 110
71 #define EIGEN_SIMPLICIAL_LLT 120
72 #define EIGEN_CHOLMOD_SUPERNODAL_LLT 130
73 #define EIGEN_CHOLMOD_SIMPLICIAL_LLT 140
74 #define EIGEN_PASTIX_LLT 150
75 #define EIGEN_PARDISO_LLT 160
77 #define EIGEN_CG_PRECOND 180
79 using namespace Eigen;
101 inline float test_precision<std::complex<float> >() {
105 inline double test_precision<std::complex<double> >() {
114 out <<
"<?xml version='1.0' encoding='UTF-8'?> \n";
115 out <<
"<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
116 out <<
"<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
117 out <<
"\n\n<!-- Generated by the Eigen library -->\n";
119 out <<
"\n<BENCH> \n";
123 out <<
" <AVAILSOLVER> \n";
124 #ifdef EIGEN_UMFPACK_SUPPORT
126 out <<
" <TYPE> LU </TYPE> \n";
127 out <<
" <PACKAGE> UMFPACK </PACKAGE> \n";
128 out <<
" </SOLVER> \n";
130 #ifdef EIGEN_KLU_SUPPORT
132 out <<
" <TYPE> LU </TYPE> \n";
133 out <<
" <PACKAGE> KLU </PACKAGE> \n";
134 out <<
" </SOLVER> \n";
136 #ifdef EIGEN_SUPERLU_SUPPORT
138 out <<
" <TYPE> LU </TYPE> \n";
139 out <<
" <PACKAGE> SUPERLU </PACKAGE> \n";
140 out <<
" </SOLVER> \n";
142 #ifdef EIGEN_CHOLMOD_SUPPORT
144 out <<
" <TYPE> LLT SP</TYPE> \n";
145 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
146 out <<
" </SOLVER> \n";
149 out <<
" <TYPE> LLT</TYPE> \n";
150 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
151 out <<
" </SOLVER> \n";
154 out <<
" <TYPE> LDLT </TYPE> \n";
155 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
156 out <<
" </SOLVER> \n";
158 #ifdef EIGEN_PARDISO_SUPPORT
160 out <<
" <TYPE> LU </TYPE> \n";
161 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
162 out <<
" </SOLVER> \n";
165 out <<
" <TYPE> LLT </TYPE> \n";
166 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
167 out <<
" </SOLVER> \n";
170 out <<
" <TYPE> LDLT </TYPE> \n";
171 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
172 out <<
" </SOLVER> \n";
174 #ifdef EIGEN_PASTIX_SUPPORT
176 out <<
" <TYPE> LU </TYPE> \n";
177 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
178 out <<
" </SOLVER> \n";
181 out <<
" <TYPE> LLT </TYPE> \n";
182 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
183 out <<
" </SOLVER> \n";
186 out <<
" <TYPE> LDLT </TYPE> \n";
187 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
188 out <<
" </SOLVER> \n";
192 out <<
" <TYPE> BICGSTAB </TYPE> \n";
193 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
194 out <<
" </SOLVER> \n";
197 out <<
" <TYPE> BICGSTAB_ILUT </TYPE> \n";
198 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
199 out <<
" </SOLVER> \n";
202 out <<
" <TYPE> GMRES_ILUT </TYPE> \n";
203 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
204 out <<
" </SOLVER> \n";
207 out <<
" <TYPE> LDLT </TYPE> \n";
208 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
209 out <<
" </SOLVER> \n";
212 out <<
" <TYPE> LLT </TYPE> \n";
213 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
214 out <<
" </SOLVER> \n";
217 out <<
" <TYPE> CG </TYPE> \n";
218 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
219 out <<
" </SOLVER> \n";
222 out <<
" <TYPE> LU_COLAMD </TYPE> \n";
223 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
224 out <<
" </SOLVER> \n";
226 #ifdef EIGEN_METIS_SUPPORT
228 out <<
" <TYPE> LU_METIS </TYPE> \n";
229 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
230 out <<
" </SOLVER> \n";
232 out <<
" </AVAILSOLVER> \n";
235 template <
typename Solver,
typename Scalar>
248 std::cerr <<
"Solver failed ... \n";
252 compute_time =
timer.value();
253 statbuf <<
" <TIME>\n";
254 statbuf <<
" <COMPUTE> " <<
timer.value() <<
"</COMPUTE>\n";
255 std::cout <<
"COMPUTE TIME : " <<
timer.value() << std::endl;
261 std::cerr <<
"Solver failed ... \n";
265 solve_time =
timer.value();
266 statbuf <<
" <SOLVE> " <<
timer.value() <<
"</SOLVE>\n";
267 std::cout <<
"SOLVE TIME : " <<
timer.value() << std::endl;
269 total_time = solve_time + compute_time;
270 statbuf <<
" <TOTAL> " << total_time <<
"</TOTAL>\n";
271 std::cout <<
"TOTAL TIME : " << total_time << std::endl;
272 statbuf <<
" </TIME>\n";
275 if (refX.size() != 0)
276 rel_error = (refX -
x).norm() / refX.norm();
281 rel_error = (
b - temp).norm() /
b.norm();
283 statbuf <<
" <ERROR> " << rel_error <<
"</ERROR>\n";
284 std::cout <<
"REL. ERROR : " << rel_error <<
"\n\n";
285 if (rel_error <=
RelErr) {
294 template <
typename Solver,
typename Scalar>
298 std::ofstream statbuf(statFile.c_str(), std::ios::app);
299 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
301 statbuf <<
" </SOLVER_STAT>\n";
305 template <
typename Solver,
typename Scalar>
312 std::ofstream statbuf(statFile.c_str(), std::ios::app);
313 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
315 statbuf <<
" <ITER> " <<
solver.iterations() <<
"</ITER>\n";
316 statbuf <<
" </SOLVER_STAT>\n";
317 std::cout <<
"ITERATIONS : " <<
solver.iterations() <<
"\n\n\n";
320 template <
typename Scalar>
328 #ifdef EIGEN_UMFPACK_SUPPORT
330 cout <<
"Solving with UMFPACK LU ... \n";
336 #ifdef EIGEN_KLU_SUPPORT
338 cout <<
"Solving with KLU LU ... \n";
344 #ifdef EIGEN_SUPERLU_SUPPORT
346 cout <<
"\nSolving with SUPERLU ... \n";
353 #ifdef EIGEN_PASTIX_SUPPORT
355 cout <<
"\nSolving with PASTIX LU ... \n";
362 #ifdef EIGEN_PARDISO_SUPPORT
364 cout <<
"\nSolving with PARDISO LU ... \n";
371 cout <<
"\n Solving with Sparse LU AND COLAMD ... \n";
375 #ifdef EIGEN_METIS_SUPPORT
377 cout <<
"\n Solving with Sparse LU AND METIS ... \n";
385 cout <<
"\nSolving with BiCGSTAB ... \n";
391 cout <<
"\nSolving with BiCGSTAB and ILUT ... \n";
404 cout <<
"\nSolving with GMRES and ILUT ... \n";
413 cout <<
"\nSolving with Simplicial LDLT ... \n";
419 #ifdef EIGEN_CHOLMOD_SUPPORT
421 cout <<
"\nSolving with CHOLMOD LDLT ... \n";
429 #ifdef EIGEN_PASTIX_SUPPORT
431 cout <<
"\nSolving with PASTIX LDLT ... \n";
438 #ifdef EIGEN_PARDISO_SUPPORT
440 cout <<
"\nSolving with PARDISO LDLT ... \n";
451 cout <<
"\nSolving with SIMPLICIAL LLT ... \n";
457 #ifdef EIGEN_CHOLMOD_SUPPORT
460 cout <<
"\nSolving with CHOLMOD LLT (Supernodal)... \n";
465 cout <<
"\nSolving with CHOLMOD LLT (Simplicial) ... \n";
472 #ifdef EIGEN_PASTIX_SUPPORT
474 cout <<
"\nSolving with PASTIX LLT ... \n";
481 #ifdef EIGEN_PARDISO_SUPPORT
483 cout <<
"\nSolving with PARDISO LLT ... \n";
491 cout <<
"\nSolving with CG ... \n";
509 template <
typename Scalar>
516 if (statFileExists) {
517 std::ofstream statbuf(statFile.c_str(), std::ios::app);
518 statbuf <<
"<LINEARSYSTEM> \n";
519 statbuf <<
" <MATRIX> \n";
520 statbuf <<
" <NAME> " << it.
matname() <<
" </NAME>\n";
521 statbuf <<
" <SIZE> " << it.
matrix().
rows() <<
" </SIZE>\n";
522 statbuf <<
" <ENTRIES> " << it.
matrix().
nonZeros() <<
"</ENTRIES>\n";
524 statbuf <<
" <SYMMETRY> Symmetric </SYMMETRY>\n";
526 statbuf <<
" <POSDEF> YES </POSDEF>\n";
528 statbuf <<
" <POSDEF> NO </POSDEF>\n";
531 statbuf <<
" <SYMMETRY> NonSymmetric </SYMMETRY>\n";
532 statbuf <<
" <POSDEF> NO </POSDEF>\n";
534 statbuf <<
" </MATRIX> \n";
538 cout <<
"\n\n===================================================== \n";
539 cout <<
" ====== SOLVING WITH MATRIX " << it.
matname() <<
" ====\n";
540 cout <<
" =================================================== \n\n";
544 SelectSolvers<Scalar>(it.
matrix(), it.
sym(), it.
rhs(), refX, statFile);
546 if (statFileExists) {
547 std::ofstream statbuf(statFile.c_str(), std::ios::app);
548 statbuf <<
" <BEST_SOLVER ID='" <<
best_time_id <<
"'></BEST_SOLVER>\n";
549 statbuf <<
" </LINEARSYSTEM> \n";
556 int idx = 1,
found =
false;
557 while (idx < argc && !
found) {
558 if (option.compare(
args[idx]) == 0) {
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Eigen::SparseMatrix< double > SpMat
Definition: Tutorial_sparse_example.cpp:5
Scalar * b
Definition: benchVecAdd.cpp:17
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Definition: BenchTimer.h:55
A bi conjugate gradient stabilized solver for sparse square problems.
Definition: BiCGSTAB.h:153
A general Cholesky factorization and solver based on Cholmod.
Definition: CholmodSupport.h:689
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition: ConjugateGradient.h:152
A GMRES solver for sparse square problems.
Definition: GMRES.h:255
Definition: KLUSupport.h:70
Iterator to browse matrices from a specified folder.
Definition: MatrixMarketIterator.h:42
bool hasrefX()
Definition: MatrixMarketIterator.h:152
VectorType & refX()
Definition: MatrixMarketIterator.h:132
std::string & matname()
Definition: MatrixMarketIterator.h:147
VectorType & rhs()
Definition: MatrixMarketIterator.h:103
MatrixType & matrix()
Definition: MatrixMarketIterator.h:70
int sym()
Definition: MatrixMarketIterator.h:149
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:467
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:413
A sparse direct LU factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:365
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:572
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:497
Interface to the PaStix solver.
Definition: PaStiXSupport.h:398
A direct sparse LDLT Cholesky factorizations without square root.
Definition: SimplicialCholesky.h:453
A direct sparse LLT Cholesky factorizations.
Definition: SimplicialCholesky.h:371
Sparse supernodal LU factorization for general matrices.
Definition: SparseLU.h:151
Index nonZeros() const
Definition: SparseCompressedBase.h:64
Index rows() const
Definition: SparseMatrix.h:159
A sparse direct LU factorization and solver based on the SuperLU library.
Definition: SuperLUSupport.h:431
A sparse LU factorization and solver based on UmfPack.
Definition: UmfPackSupport.h:302
@ NumericalIssue
Definition: Constants.h:442
@ Success
Definition: Constants.h:440
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
NumTraits< T >::Real test_precision()
Definition: main.h:412
squared absolute value
Definition: GlobalFunctions.h:87
@ NonSymmetric
Definition: MatrixMarketIterator.h:19
@ SPD
Definition: MatrixMarketIterator.h:19
float test_precision< float >()
Definition: main.h:416
double test_precision< double >()
Definition: main.h:420
@ CholmodSimplicialLLt
Definition: CholmodSupport.h:237
@ CholmodLDLt
Definition: CholmodSupport.h:237
@ CholmodSupernodalLLt
Definition: CholmodSupport.h:237
bool found
Definition: MergeRestartFiles.py:24
args
Definition: compute_granudrum_aor.py:143
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
list x
Definition: plotDoE.py:28
double timer
Definition: oomph_metis_from_parmetis_3.1.1/struct.h:210
#define EIGEN_PASTIX_LLT
Definition: spbenchsolver.h:74
void call_itersolver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
Definition: spbenchsolver.h:306
void call_directsolver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
Definition: spbenchsolver.h:295
#define EIGEN_KLU
Definition: spbenchsolver.h:57
bool get_options(int argc, char **args, string option, string *value=0)
Definition: spbenchsolver.h:555
#define EIGEN_PASTIX_LDLT
Definition: spbenchsolver.h:69
#define EIGEN_CHOLMOD_SUPERNODAL_LLT
Definition: spbenchsolver.h:72
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT
Definition: spbenchsolver.h:73
#define EIGEN_PARDISO
Definition: spbenchsolver.h:60
void call_solver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::ofstream &statbuf)
Definition: spbenchsolver.h:236
#define EIGEN_PASTIX
Definition: spbenchsolver.h:59
#define EIGEN_SIMPLICIAL_LDLT
Definition: spbenchsolver.h:67
#define EIGEN_SUPERLU
Definition: spbenchsolver.h:58
int MaximumIters
Definition: spbenchsolver.h:83
#define EIGEN_SPARSELU_METIS
Definition: spbenchsolver.h:62
void SelectSolvers(const SparseMatrix< Scalar > &A, unsigned int sym, Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
Definition: spbenchsolver.h:321
double RelErr
Definition: spbenchsolver.h:84
#define EIGEN_BICGSTAB
Definition: spbenchsolver.h:63
#define EIGEN_SPARSELU_COLAMD
Definition: spbenchsolver.h:61
#define EIGEN_CHOLMOD_LDLT
Definition: spbenchsolver.h:68
#define EIGEN_PARDISO_LDLT
Definition: spbenchsolver.h:70
#define EIGEN_SIMPLICIAL_LLT
Definition: spbenchsolver.h:71
#define EIGEN_PARDISO_LLT
Definition: spbenchsolver.h:75
int best_time_id
Definition: spbenchsolver.h:86
#define EIGEN_CG
Definition: spbenchsolver.h:76
double best_time_val
Definition: spbenchsolver.h:85
void printStatheader(std::ofstream &out)
Definition: spbenchsolver.h:109
void Browse_Matrices(const string folder, bool statFileExists, std::string &statFile, int maxiters, double tol)
Definition: spbenchsolver.h:510
#define EIGEN_BICGSTAB_ILUT
Definition: spbenchsolver.h:64
#define EIGEN_GMRES_ILUT
Definition: spbenchsolver.h:66
#define EIGEN_UMFPACK
Definition: spbenchsolver.h:56
void printBenchStyle(std::ofstream &out)
Definition: spbenchstyle.h:13
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
std::ofstream out("Result.txt")