mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 02:29:33 +08:00
add SparseLU in sparse bench
This commit is contained in:
parent
5433986f5a
commit
2c99d84133
File diff suppressed because it is too large
Load Diff
@ -27,8 +27,10 @@
|
|||||||
#define EIGEN_ORDERING_H
|
#define EIGEN_ORDERING_H
|
||||||
|
|
||||||
#include "Amd.h"
|
#include "Amd.h"
|
||||||
#include "Eigen_Colamd.h"
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
|
#include "Eigen_Colamd.h"
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,18 +133,18 @@ class COLAMDOrdering
|
|||||||
int n = mat.cols();
|
int n = mat.cols();
|
||||||
int nnz = mat.nonZeros();
|
int nnz = mat.nonZeros();
|
||||||
// Get the recommended value of Alen to be used by colamd
|
// Get the recommended value of Alen to be used by colamd
|
||||||
int Alen = eigen_colamd_recommended(nnz, m, n);
|
int Alen = internal::colamd_recommended(nnz, m, n);
|
||||||
// Set the default parameters
|
// Set the default parameters
|
||||||
double knobs [EIGEN_COLAMD_KNOBS];
|
double knobs [COLAMD_KNOBS];
|
||||||
int stats [EIGEN_COLAMD_STATS];
|
int stats [COLAMD_STATS];
|
||||||
eigen_colamd_set_defaults(knobs);
|
internal::colamd_set_defaults(knobs);
|
||||||
|
|
||||||
int info;
|
int info;
|
||||||
IndexVector p(n+1), A(Alen);
|
IndexVector p(n+1), A(Alen);
|
||||||
for(int i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
|
for(int i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
|
||||||
for(int i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
|
for(int i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
|
||||||
// Call Colamd routine to compute the ordering
|
// Call Colamd routine to compute the ordering
|
||||||
info = eigen_colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
|
info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
|
||||||
eigen_assert( info && "COLAMD failed " );
|
eigen_assert( info && "COLAMD failed " );
|
||||||
|
|
||||||
perm.resize(n);
|
perm.resize(n);
|
||||||
|
@ -205,7 +205,7 @@ class SparseLU
|
|||||||
void initperfvalues()
|
void initperfvalues()
|
||||||
{
|
{
|
||||||
m_perfv.panel_size = 12;
|
m_perfv.panel_size = 12;
|
||||||
m_perfv.relax = 6;
|
m_perfv.relax = 1;
|
||||||
m_perfv.maxsuper = 100;
|
m_perfv.maxsuper = 100;
|
||||||
m_perfv.rowblk = 200;
|
m_perfv.rowblk = 200;
|
||||||
m_perfv.colblk = 60;
|
m_perfv.colblk = 60;
|
||||||
|
@ -55,6 +55,12 @@ if(PASTIX_FOUND AND BLAS_FOUND)
|
|||||||
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${BLAS_LIBRARIES})
|
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${BLAS_LIBRARIES})
|
||||||
endif(PASTIX_FOUND AND BLAS_FOUND)
|
endif(PASTIX_FOUND AND BLAS_FOUND)
|
||||||
|
|
||||||
|
if(METIS_FOUND)
|
||||||
|
include_directories(${METIS_INCLUDES})
|
||||||
|
set (SPARSE_LIBS ${SPARSE_LIBS} ${METIS_LIBRARIES})
|
||||||
|
add_definitions("-DEIGEN_METIS_SUPPORT")
|
||||||
|
endif(METIS_FOUND)
|
||||||
|
|
||||||
find_library(RT_LIBRARY rt)
|
find_library(RT_LIBRARY rt)
|
||||||
if(RT_LIBRARY)
|
if(RT_LIBRARY)
|
||||||
set(SPARSE_LIBS ${SPARSE_LIBS} ${RT_LIBRARY})
|
set(SPARSE_LIBS ${SPARSE_LIBS} ${RT_LIBRARY})
|
||||||
@ -66,11 +72,6 @@ target_link_libraries (spbenchsolver ${SPARSE_LIBS})
|
|||||||
add_executable(spsolver sp_solver.cpp)
|
add_executable(spsolver sp_solver.cpp)
|
||||||
target_link_libraries (spsolver ${SPARSE_LIBS})
|
target_link_libraries (spsolver ${SPARSE_LIBS})
|
||||||
|
|
||||||
if(METIS_FOUND)
|
|
||||||
include_directories(${METIS_INCLUDES})
|
|
||||||
set (SPARSE_LIBS ${SPARSE_LIBS} ${METIS_LIBRARIES})
|
|
||||||
add_definitions("-DEIGEN_METIS_SUPPORT")
|
|
||||||
endif(METIS_FOUND)
|
|
||||||
|
|
||||||
add_executable(test_sparseLU test_sparseLU.cpp)
|
add_executable(test_sparseLU test_sparseLU.cpp)
|
||||||
target_link_libraries (test_sparseLU ${SPARSE_LIBS})
|
target_link_libraries (test_sparseLU ${SPARSE_LIBS})
|
||||||
|
@ -21,9 +21,14 @@
|
|||||||
#include <unsupported/Eigen/IterativeSolvers>
|
#include <unsupported/Eigen/IterativeSolvers>
|
||||||
#include <Eigen/LU>
|
#include <Eigen/LU>
|
||||||
#include <unsupported/Eigen/SparseExtra>
|
#include <unsupported/Eigen/SparseExtra>
|
||||||
|
#include <Eigen/SparseLU>
|
||||||
|
|
||||||
#include "spbenchstyle.h"
|
#include "spbenchstyle.h"
|
||||||
|
|
||||||
|
#ifdef EIGEN_METIS_SUPPORT
|
||||||
|
#include <Eigen/MetisSupport>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EIGEN_CHOLMOD_SUPPORT
|
#ifdef EIGEN_CHOLMOD_SUPPORT
|
||||||
#include <Eigen/CholmodSupport>
|
#include <Eigen/CholmodSupport>
|
||||||
#endif
|
#endif
|
||||||
@ -45,26 +50,27 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
#define EIGEN_UMFPACK 0
|
#define EIGEN_UMFPACK 10
|
||||||
#define EIGEN_SUPERLU 1
|
#define EIGEN_SUPERLU 20
|
||||||
#define EIGEN_PASTIX 2
|
#define EIGEN_PASTIX 30
|
||||||
#define EIGEN_PARDISO 3
|
#define EIGEN_PARDISO 40
|
||||||
#define EIGEN_BICGSTAB 4
|
#define EIGEN_SPARSELU_COLAMD 50
|
||||||
#define EIGEN_BICGSTAB_ILUT 5
|
#define EIGEN_SPARSELU_METIS 51
|
||||||
#define EIGEN_GMRES 6
|
#define EIGEN_BICGSTAB 60
|
||||||
#define EIGEN_GMRES_ILUT 7
|
#define EIGEN_BICGSTAB_ILUT 61
|
||||||
#define EIGEN_SIMPLICIAL_LDLT 8
|
#define EIGEN_GMRES 70
|
||||||
#define EIGEN_CHOLMOD_LDLT 9
|
#define EIGEN_GMRES_ILUT 71
|
||||||
#define EIGEN_PASTIX_LDLT 10
|
#define EIGEN_SIMPLICIAL_LDLT 80
|
||||||
#define EIGEN_PARDISO_LDLT 11
|
#define EIGEN_CHOLMOD_LDLT 90
|
||||||
#define EIGEN_SIMPLICIAL_LLT 12
|
#define EIGEN_PASTIX_LDLT 100
|
||||||
#define EIGEN_CHOLMOD_SUPERNODAL_LLT 13
|
#define EIGEN_PARDISO_LDLT 110
|
||||||
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT 14
|
#define EIGEN_SIMPLICIAL_LLT 120
|
||||||
#define EIGEN_PASTIX_LLT 15
|
#define EIGEN_CHOLMOD_SUPERNODAL_LLT 130
|
||||||
#define EIGEN_PARDISO_LLT 16
|
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT 140
|
||||||
#define EIGEN_CG 17
|
#define EIGEN_PASTIX_LLT 150
|
||||||
#define EIGEN_CG_PRECOND 18
|
#define EIGEN_PARDISO_LLT 160
|
||||||
#define EIGEN_ALL_SOLVERS 19
|
#define EIGEN_CG 170
|
||||||
|
#define EIGEN_CG_PRECOND 180
|
||||||
|
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -188,6 +194,17 @@ void printStatheader(std::ofstream& out)
|
|||||||
out << " <PACKAGE> EIGEN </PACKAGE> \n";
|
out << " <PACKAGE> EIGEN </PACKAGE> \n";
|
||||||
out << " </SOLVER> \n";
|
out << " </SOLVER> \n";
|
||||||
|
|
||||||
|
out <<" <SOLVER ID='" << EIGEN_SPARSELU_COLAMD << "'>\n";
|
||||||
|
out << " <TYPE> LU_COLAMD </TYPE> \n";
|
||||||
|
out << " <PACKAGE> EIGEN </PACKAGE> \n";
|
||||||
|
out << " </SOLVER> \n";
|
||||||
|
|
||||||
|
#ifdef EIGEN_METIS_SUPPORT
|
||||||
|
out <<" <SOLVER ID='" << EIGEN_SPARSELU_METIS << "'>\n";
|
||||||
|
out << " <TYPE> LU_METIS </TYPE> \n";
|
||||||
|
out << " <PACKAGE> EIGEN </PACKAGE> \n";
|
||||||
|
out << " </SOLVER> \n";
|
||||||
|
#endif
|
||||||
out << " </AVAILSOLVER> \n";
|
out << " </AVAILSOLVER> \n";
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -326,7 +343,18 @@ void SelectSolvers(const SparseMatrix<Scalar>&A, unsigned int sym, Matrix<Scalar
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Eigen SparseLU METIS
|
||||||
|
cout << "\n Solving with Sparse LU AND COLAMD ... \n";
|
||||||
|
SparseLU<SpMat, COLAMDOrdering<int> > solver;
|
||||||
|
call_directsolver(solver, EIGEN_SPARSELU_COLAMD, A, b, refX, statFile);
|
||||||
|
// Eigen SparseLU METIS
|
||||||
|
#ifdef EIGEN_METIS_SUPPORT
|
||||||
|
{
|
||||||
|
cout << "\n Solving with Sparse LU AND METIS ... \n";
|
||||||
|
SparseLU<SpMat, MetisOrdering<int> > solver;
|
||||||
|
call_directsolver(solver, EIGEN_SPARSELU_METIS, A, b, refX, statFile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//BiCGSTAB
|
//BiCGSTAB
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user