Skip to content

Commit

Permalink
Added options to produce output from pardiso and mkl_dss.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMaas1978 committed Oct 16, 2024
1 parent 9d0c54a commit 6756157
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
23 changes: 20 additions & 3 deletions NumCore/MKLDSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ SOFTWARE.*/
#define PARDISO
#endif

BEGIN_FECORE_CLASS(MKLDSSolver, LinearSolver)
END_FECORE_CLASS();

#ifdef PARDISO
class MKLDSSolver::Imp
{
Expand All @@ -48,8 +45,14 @@ class MKLDSSolver::Imp
_MKL_DSS_HANDLE_t handle = nullptr;
MKL_INT opt = MKL_DSS_DEFAULTS;
MKL_INT sym = MKL_DSS_SYMMETRIC;

int msglvl = 0;
};

BEGIN_FECORE_CLASS(MKLDSSolver, LinearSolver)
ADD_PARAMETER(m->msglvl, "msglvl");
END_FECORE_CLASS();

//-----------------------------------------------------------------------------
MKLDSSolver::MKLDSSolver(FEModel* fem) : LinearSolver(fem), m(new MKLDSSolver::Imp)
{
Expand Down Expand Up @@ -96,6 +99,7 @@ bool MKLDSSolver::PreProcess()
// create handle
if (m->handle == nullptr)
{
m->opt = MKL_DSS_DEFAULTS;
MKL_INT error = dss_create(m->handle, m->opt);
if (error != MKL_DSS_SUCCESS) return false;
}
Expand All @@ -111,6 +115,19 @@ bool MKLDSSolver::PreProcess()
error = dss_reorder(m->handle, m->opt, 0);
if (error != MKL_DSS_SUCCESS) return false;

if (m->msglvl != 0)
{
m->opt = MKL_DSS_DEFAULTS;
const char* szstat = "PeakMem,FactorMem";
double ret[2];
dss_statistics(m->handle, m->opt, szstat, ret);
fprintf(stdout, "\nMKLDSS Memory info:\n");
fprintf(stdout, "===================\n");
fprintf(stdout, "Peak memory of symbolic factorization phase ........... : %lg KB\n", ret[0]);
fprintf(stdout, "Permanent memory for the factorization and solve phases : %lg KB\n", ret[1]);
fprintf(stdout, "\n");
}

return LinearSolver::PreProcess();
}

Expand Down
15 changes: 13 additions & 2 deletions NumCore/PardisoSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void print_err(int nerror)
BEGIN_FECORE_CLASS(PardisoSolver, LinearSolver)
ADD_PARAMETER(m_print_cn, "print_condition_number");
ADD_PARAMETER(m_iparm3 , "precondition");
ADD_PARAMETER(m_msglvl , "msglvl");
END_FECORE_CLASS();

//-----------------------------------------------------------------------------
Expand All @@ -99,6 +100,7 @@ PardisoSolver::PardisoSolver(FEModel* fem) : LinearSolver(fem), m_pA(0)
m_mtype = -2;
m_iparm3 = false;
m_isFactored = false;
m_msglvl = 0; /* 0 Suppress printing, 1 Print statistical information */
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -168,8 +170,6 @@ bool PardisoSolver::PreProcess()
m_maxfct = 1; /* Maximum number of numerical factorizations */
m_mnum = 1; /* Which factorization to use */

m_msglvl = 0; /* 0 Suppress printing, 1 Print statistical information */

return LinearSolver::PreProcess();
}

Expand Down Expand Up @@ -197,6 +197,17 @@ bool PardisoSolver::Factor()
exit(2);
}

if (m_msglvl == 1)
{
int* ip = m_iparm;
fprintf(stdout, "\nMemory info:\n");
fprintf(stdout, "============\n");
fprintf(stdout, "Peak memory on symbolic factorization ............. : %d KB\n", ip[14]);
fprintf(stdout, "Permanent memory on symbolic factorization ........ : %d KB\n", ip[15]);
fprintf(stdout, "Peak memory on numerical factorization and solution : %d KB\n", ip[16]);
fprintf(stdout, "Total peak memory ................................. : %d KB\n\n", max(ip[14], ip[15]+ip[16]));
}

// ------------------------------------------------------------------------------
// This step does the factorization
// ------------------------------------------------------------------------------
Expand Down

0 comments on commit 6756157

Please sign in to comment.