From 6756157077b76918fdf09705c43910e39f73dca3 Mon Sep 17 00:00:00 2001 From: SteveMaas1978 Date: Wed, 16 Oct 2024 13:00:03 -0600 Subject: [PATCH] Added options to produce output from pardiso and mkl_dss. --- NumCore/MKLDSSolver.cpp | 23 ++++++++++++++++++++--- NumCore/PardisoSolver.cpp | 15 +++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/NumCore/MKLDSSolver.cpp b/NumCore/MKLDSSolver.cpp index 0f5502b1b..6a18d4de6 100644 --- a/NumCore/MKLDSSolver.cpp +++ b/NumCore/MKLDSSolver.cpp @@ -37,9 +37,6 @@ SOFTWARE.*/ #define PARDISO #endif -BEGIN_FECORE_CLASS(MKLDSSolver, LinearSolver) -END_FECORE_CLASS(); - #ifdef PARDISO class MKLDSSolver::Imp { @@ -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) { @@ -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; } @@ -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(); } diff --git a/NumCore/PardisoSolver.cpp b/NumCore/PardisoSolver.cpp index abcaeb030..d82781261 100644 --- a/NumCore/PardisoSolver.cpp +++ b/NumCore/PardisoSolver.cpp @@ -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(); //----------------------------------------------------------------------------- @@ -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 */ } //----------------------------------------------------------------------------- @@ -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(); } @@ -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 // ------------------------------------------------------------------------------