mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 11:49:02 +08:00
Init perf values
This commit is contained in:
parent
2e38666d01
commit
2280f2490e
@ -204,12 +204,12 @@ class SparseLU
|
||||
// Functions
|
||||
void initperfvalues()
|
||||
{
|
||||
m_panel_size = 12;
|
||||
m_relax = 6;
|
||||
m_maxsuper = 100;
|
||||
m_rowblk = 200;
|
||||
m_colblk = 60;
|
||||
m_fillfactor = 20;
|
||||
m_perfv.panel_size = 12;
|
||||
m_perfv.relax = 6;
|
||||
m_perfv.maxsuper = 100;
|
||||
m_perfv.rowblk = 200;
|
||||
m_perfv.colblk = 60;
|
||||
m_perfv.fillfactor = 20;
|
||||
}
|
||||
|
||||
// Variables
|
||||
@ -231,14 +231,7 @@ class SparseLU
|
||||
bool m_symmetricmode;
|
||||
|
||||
// values for performance
|
||||
int m_panel_size; // a panel consists of at most <panel_size> consecutive columns
|
||||
int m_relax; // To control degree of relaxing supernodes. If the number of nodes (columns)
|
||||
// in a subtree of the elimination tree is less than relax, this subtree is considered
|
||||
// as one supernode regardless of the row structures of those columns
|
||||
int m_maxsuper; // The maximum size for a supernode in complete LU
|
||||
int m_rowblk; // The minimum row dimension for 2-D blocking to be used;
|
||||
int m_colblk; // The minimum column dimension for 2-D blocking to be used;
|
||||
int m_fillfactor; // The estimated fills factors for L and U, compared with A
|
||||
LU_perfvalues m_perfv;
|
||||
RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot
|
||||
int m_nnzL, m_nnzU; // Nonzeros in L and U factors
|
||||
|
||||
@ -374,10 +367,10 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
int m = m_mat.rows();
|
||||
int n = m_mat.cols();
|
||||
int nnz = m_mat.nonZeros();
|
||||
int maxpanel = m_panel_size * m;
|
||||
int maxpanel = m_perfv.panel_size * m;
|
||||
// Allocate working storage common to the factor routines
|
||||
int lwork = 0;
|
||||
int info = LUMemInit(m, n, nnz, lwork, m_fillfactor, m_panel_size, m_glu);
|
||||
int info = LUMemInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
|
||||
if (info)
|
||||
{
|
||||
std::cerr << "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
|
||||
@ -401,7 +394,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
ScalarVector dense;
|
||||
dense.setZero(maxpanel);
|
||||
ScalarVector tempv;
|
||||
tempv.setZero(LU_NUM_TEMPV(m, m_panel_size, m_maxsuper, m_rowblk) );
|
||||
tempv.setZero(LU_NUM_TEMPV(m, m_perfv.panel_size, m_perfv.maxsuper, m_perfv.rowblk) );
|
||||
|
||||
// Compute the inverse of perm_c
|
||||
PermutationType iperm_c(m_perm_c.inverse());
|
||||
@ -409,9 +402,9 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
// Identify initial relaxed snodes
|
||||
IndexVector relax_end(n);
|
||||
if ( m_symmetricmode == true )
|
||||
LU_heap_relax_snode<IndexVector>(n, m_etree, m_relax, marker, relax_end);
|
||||
LU_heap_relax_snode<IndexVector>(n, m_etree, m_perfv.relax, marker, relax_end);
|
||||
else
|
||||
LU_relax_snode<IndexVector>(n, m_etree, m_relax, marker, relax_end);
|
||||
LU_relax_snode<IndexVector>(n, m_etree, m_perfv.relax, marker, relax_end);
|
||||
|
||||
|
||||
m_perm_r.resize(m);
|
||||
@ -499,7 +492,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
{ // Work on one panel of panel_size columns
|
||||
|
||||
// Adjust panel size so that a panel won't overlap with the next relaxed snode.
|
||||
int panel_size = m_panel_size; // upper bound on panel width
|
||||
int panel_size = m_perfv.panel_size; // upper bound on panel width
|
||||
for (k = jcol + 1; k < std::min(jcol+panel_size, n); k++)
|
||||
{
|
||||
if (relax_end(k) != IND_EMPTY)
|
||||
@ -515,7 +508,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
LU_panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu);
|
||||
|
||||
// Numeric sup-panel updates in topological order
|
||||
LU_panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
|
||||
LU_panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_perfv, m_glu);
|
||||
|
||||
// Sparse LU within the panel, and below the panel diagonal
|
||||
for ( jj = jcol; jj< jcol + panel_size; jj++)
|
||||
@ -526,7 +519,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
||||
//Depth-first-search for the current column
|
||||
VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
|
||||
VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
|
||||
info = LU_column_dfs(m, jj, m_perm_r.indices(), m_maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu);
|
||||
info = LU_column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu);
|
||||
if ( info )
|
||||
{
|
||||
std::cerr << "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() \n";
|
||||
|
@ -88,4 +88,16 @@ struct LU_GlobalLU_t {
|
||||
Index n; // Number of columns in the matrix
|
||||
int num_expansions;
|
||||
};
|
||||
|
||||
// Values to set for performance
|
||||
struct LU_perfvalues {
|
||||
int panel_size; // a panel consists of at most <panel_size> consecutive columns
|
||||
int relax; // To control degree of relaxing supernodes. If the number of nodes (columns)
|
||||
// in a subtree of the elimination tree is less than relax, this subtree is considered
|
||||
// as one supernode regardless of the row structures of those columns
|
||||
int maxsuper; // The maximum size for a supernode in complete LU
|
||||
int rowblk; // The minimum row dimension for 2-D blocking to be used;
|
||||
int colblk; // The minimum column dimension for 2-D blocking to be used;
|
||||
int fillfactor; // The estimated fills factors for L and U, compared with A
|
||||
};
|
||||
#endif
|
@ -49,7 +49,7 @@
|
||||
*
|
||||
*/
|
||||
template <typename DenseIndexBlock, typename IndexVector, typename ScalarVector>
|
||||
void LU_panel_bmod(const int m, const int w, const int jcol, const int nseg, ScalarVector& dense, ScalarVector& tempv, DenseIndexBlock& segrep, DenseIndexBlock& repfnz, LU_GlobalLU_t<IndexVector,ScalarVector>& glu)
|
||||
void LU_panel_bmod(const int m, const int w, const int jcol, const int nseg, ScalarVector& dense, ScalarVector& tempv, DenseIndexBlock& segrep, DenseIndexBlock& repfnz, LU_perfvalues& perfv, LU_GlobalLU_t<IndexVector,ScalarVector>& glu)
|
||||
{
|
||||
typedef typename ScalarVector::Scalar Scalar;
|
||||
|
||||
@ -95,7 +95,7 @@ void LU_panel_bmod(const int m, const int w, const int jcol, const int nseg, Sca
|
||||
|
||||
// if the blocks are large enough, use level 3
|
||||
// TODO find better heuristics!
|
||||
if( nsupc >= 50 && nrow > 50 && u_cols>6)
|
||||
if( nsupc >= perfv.colblk && nrow > perfv.rowblk && u_cols>perfv.relax)
|
||||
{
|
||||
Map<Matrix<Scalar,Dynamic,Dynamic> > U(tempv.data(), u_rows, u_cols);
|
||||
|
||||
|
@ -24,11 +24,13 @@ int main(int argc, char **args)
|
||||
typedef Matrix<scalar, Dynamic, 1> DenseRhs;
|
||||
Matrix<scalar, Dynamic, 1> b, x, tmp;
|
||||
// SparseLU<SparseMatrix<scalar, ColMajor>, AMDOrdering<int> > solver;
|
||||
#ifdef EIGEN_METIS_SUPPORT
|
||||
SparseLU<SparseMatrix<scalar, ColMajor>, MetisOrdering<int> > solver;
|
||||
#else
|
||||
// #ifdef EIGEN_METIS_SUPPORT
|
||||
// SparseLU<SparseMatrix<scalar, ColMajor>, MetisOrdering<int> > solver;
|
||||
// std::cout<< "ORDERING : METIS\n";
|
||||
// #else
|
||||
SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<int> > solver;
|
||||
#endif
|
||||
std::cout<< "ORDERING : COLAMD\n";
|
||||
// #endif
|
||||
|
||||
ifstream matrix_file;
|
||||
string line;
|
||||
|
Loading…
x
Reference in New Issue
Block a user