Skip to content

Commit

Permalink
update vec logging macros
Browse files Browse the repository at this point in the history
  • Loading branch information
gardner48 committed Oct 15, 2024
1 parent 2d51119 commit b5f0089
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 88 deletions.
14 changes: 7 additions & 7 deletions doc/superbuild/source/developers/style_guide/SourceCode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ To log extra debugging messages use the following macros:

.. versionadded:: x.y.z

.. c:macro:: SUNLogExtraDebugVec(logger, label, msg_txt, vec, ...)
.. c:macro:: SUNLogExtraDebugVec(logger, label, vec, msg_txt, ...)
When extra debugging logging is enabled with
:cmakeop:`SUNDIALS_LOGGING_LEVEL`, this function-like macro expands to a call
Expand All @@ -672,13 +672,13 @@ To log extra debugging messages use the following macros:

:param logger: the :c:type:`SUNLogger`
:param label: the ``const char*`` message label
:param msg_txt: the ``const char*`` message text
:param vec: the ``N_Vector`` to print
:param msg_txt: the ``const char*`` message text
:param ...: the format string arguments

.. versionadded:: x.y.z

.. c:macro:: SUNLogExtraDebugVecIf(condition, logger, label, msg_txt, vec, ...)
.. c:macro:: SUNLogExtraDebugVecIf(condition, logger, label, vec, msg_txt, ...)
When extra debugging logging is enabled with
:cmakeop:`SUNDIALS_LOGGING_LEVEL`, this function-like macro expands to a
Expand All @@ -689,11 +689,11 @@ To log extra debugging messages use the following macros:
should be queued.
:param logger: the :c:type:`SUNLogger`
:param label: the ``const char*`` message label
:param msg_txt: the ``const char*`` message text
:param vec: the ``N_Vector`` to print
:param msg_txt: the ``const char*`` message text
:param ...: the format string arguments

.. c:macro:: SUNLogExtraDebugVecArray(logger, label, msg_txt, vecs, nvecs)
.. c:macro:: SUNLogExtraDebugVecArray(logger, label, nvecs, vecs, msg_txt)
When extra debugging logging is enabled with
:cmakeop:`SUNDIALS_LOGGING_LEVEL`, this function-like macro expands to a loop
Expand All @@ -702,9 +702,9 @@ To log extra debugging messages use the following macros:

:param logger: the :c:type:`SUNLogger`
:param label: the ``const char*`` message label
:param msg_txt: the ``const char*`` message text
:param vecs: the ``N_Vector`` to print
:param nvecs: the ``int`` number of vectors to print
:param vecs: the ``N_Vector`` to print
:param msg_txt: the ``const char*`` message text

.. warning::

Expand Down
43 changes: 20 additions & 23 deletions src/arkode/arkode_arkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,11 +1830,11 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
"stage = %i, implicit = %i, tcur = %" RSYM, 0, implicit_stage,
ark_mem->tcur);
SUNLogExtraDebugVecIf(is_start == 1, ARK_LOGGER, "explicit stage",
"z_%i(:) =", ark_mem->ycur, 0);
ark_mem->ycur, "z_0(:) =");
SUNLogExtraDebugVecIf(is_start == 1 && step_mem->implicit, ARK_LOGGER,
"implicit RHS", "Fi_%i(:) =", step_mem->Fi[0], 0);
"implicit RHS", step_mem->Fi[0], "Fi_0(:) =");
SUNLogExtraDebugVecIf(is_start == 1 && step_mem->explicit, ARK_LOGGER,
"explicit RHS", "Fe_%i(:) =", step_mem->Fe[0], 0);
"explicit RHS", step_mem->Fe[0], "Fe_0(:) =");
SUNLogInfoIf(is_start == 1, ARK_LOGGER, "end-stage", "status = success");

/* loop over internal stages to the step */
Expand Down Expand Up @@ -1899,8 +1899,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
}

SUNLogExtraDebugVec(ARK_LOGGER, "predictor", "zpred(:) =", step_mem->zpred,
"");
SUNLogExtraDebugVec(ARK_LOGGER, "predictor", step_mem->zpred, "zpred(:) =");

/* set up explicit data for evaluation of ARK stage (store in sdata) */
retval = arkStep_StageSetup(ark_mem, implicit_stage);
Expand All @@ -1911,8 +1910,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
return (retval);
}

SUNLogExtraDebugVec(ARK_LOGGER, "rhs data", "sdata(:) =", step_mem->sdata,
"");
SUNLogExtraDebugVec(ARK_LOGGER, "rhs data", step_mem->sdata, "sdata(:) =");

/* perform implicit solve if required */
if (implicit_stage)
Expand All @@ -1927,8 +1925,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
return (TRY_AGAIN);
}

SUNLogExtraDebugVec(ARK_LOGGER, "implicit stage",
"z_%i(:) =", ark_mem->ycur, is);
SUNLogExtraDebugVec(ARK_LOGGER, "implicit stage", ark_mem->ycur,
"z_%i(:) =", is);

/* otherwise no implicit solve is needed */
}
Expand All @@ -1952,8 +1950,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
or updated in prev. block) */
N_VLinearSum(ONE, ark_mem->yn, ONE, step_mem->sdata, ark_mem->ycur);

SUNLogExtraDebugVec(ARK_LOGGER, "explicit stage",
"z_%i(:) =", ark_mem->ycur, is);
SUNLogExtraDebugVec(ARK_LOGGER, "explicit stage", ark_mem->ycur,
"z_%i(:) =", is);
}

/* apply user-supplied stage postprocessing function (if supplied) */
Expand Down Expand Up @@ -1985,8 +1983,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->user_data);
step_mem->nfi++;

SUNLogExtraDebugVec(ARK_LOGGER, "implicit RHS",
"Fi_%i(:) =", step_mem->Fi[is], is);
SUNLogExtraDebugVec(ARK_LOGGER, "implicit RHS", step_mem->Fi[is],
"Fi_%i(:) =", is);
SUNLogInfoIf(retval != 0, ARK_LOGGER, "end-stage",
"status = failed implicit rhs eval, retval = %i", retval);

Expand Down Expand Up @@ -2015,8 +2013,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
-ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]);
}

SUNLogExtraDebugVec(ARK_LOGGER, "implicit RHS",
"Fi_%i(:) =", step_mem->Fi[is], is);
SUNLogExtraDebugVec(ARK_LOGGER, "implicit RHS", step_mem->Fi[is],
"Fi_%i(:) =", is);
}
}

Expand All @@ -2027,8 +2025,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data);
step_mem->nfe++;

SUNLogExtraDebugVec(ARK_LOGGER, "explicit RHS",
"Fe_%i(:) =", step_mem->Fe[is], is);
SUNLogExtraDebugVec(ARK_LOGGER, "explicit RHS", step_mem->Fe[is],
"Fe_%i(:) =", is);
SUNLogInfoIf(retval != 0, ARK_LOGGER, "end-stage",
"status = failed explicit rhs eval, retval = %i", retval);

Expand All @@ -2045,8 +2043,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
*nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fi[is],
step_mem->nlscoef);

SUNLogExtraDebugVec(ARK_LOGGER, "M^{-1} implicit RHS",
"Fi_%i(:) =", step_mem->Fi[is], is);
SUNLogExtraDebugVec(ARK_LOGGER, "M^{-1} implicit RHS", step_mem->Fi[is],
"Fi_%i(:) =", is);

if (*nflagPtr != ARK_SUCCESS)
{
Expand All @@ -2059,8 +2057,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
{
*nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fe[is],
step_mem->nlscoef);
SUNLogExtraDebugVec(ARK_LOGGER, "M^{-1} explicit RHS",
"Fe_%i(:) =", step_mem->Fe[is], is);
SUNLogExtraDebugVec(ARK_LOGGER, "M^{-1} explicit RHS", step_mem->Fe[is],
"Fe_%i(:) =", is);
if (*nflagPtr != ARK_SUCCESS)
{
SUNLogInfo(ARK_LOGGER, "end-stage",
Expand All @@ -2085,8 +2083,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
if (*nflagPtr < 0) { return (*nflagPtr); }
if (*nflagPtr > 0) { return (TRY_AGAIN); }

SUNLogExtraDebugVec(ARK_LOGGER, "updated solution",
"ycur(:) =", ark_mem->ycur, "");
SUNLogExtraDebugVec(ARK_LOGGER, "updated solution", ark_mem->ycur, "ycur(:) =");

return (ARK_SUCCESS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_arkstep_nls.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag)
ark_mem->ewt, step_mem->nlscoef, callLSetup,
ark_mem);

SUNLogExtraDebugVec(ARK_LOGGER, "correction", "zcor(:) =", step_mem->zcor, "");
SUNLogExtraDebugVec(ARK_LOGGER, "correction", step_mem->zcor, "zcor(:) =");

/* increment counters */
(void)SUNNonlinSolGetNumIters(step_mem->NLS, &nls_iters_inc);
Expand Down
11 changes: 5 additions & 6 deletions src/arkode/arkode_erkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)

SUNLogInfo(ARK_LOGGER, "begin-stage", "stage = 0, tcur = %" RSYM,
ark_mem->tcur);
SUNLogExtraDebugVec(ARK_LOGGER, "stage", "z_0(:) =", ark_mem->ycur, "");
SUNLogExtraDebugVec(ARK_LOGGER, "stage RHS", "F_0(:) =", step_mem->F[0], "");
SUNLogExtraDebugVec(ARK_LOGGER, "stage", ark_mem->ycur, "z_0(:) =");
SUNLogExtraDebugVec(ARK_LOGGER, "stage RHS", step_mem->F[0], "F_0(:) =");
SUNLogInfo(ARK_LOGGER, "end-stage", "status = success");

/* Call the full RHS if needed. If this is the first step then we may need to
Expand Down Expand Up @@ -696,8 +696,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->user_data);
step_mem->nfe++;

SUNLogExtraDebugVec(ARK_LOGGER, "stage RHS", "F_%i(:) =", step_mem->F[is],
is);
SUNLogExtraDebugVec(ARK_LOGGER, "stage RHS", step_mem->F[is],
"F_%i(:) =", is);
SUNLogInfoIf(retval != 0, ARK_LOGGER, "end-stage",
"status = failed rhs eval, retval = %i", retval);

Expand All @@ -712,8 +712,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
retval = erkStep_ComputeSolutions(ark_mem, dsmPtr);
if (retval < 0) { return (retval); }

SUNLogExtraDebugVec(ARK_LOGGER, "updated solution",
"ycur(:) =", ark_mem->ycur, "");
SUNLogExtraDebugVec(ARK_LOGGER, "updated solution", ark_mem->ycur, "ycur(:) =");

return (ARK_SUCCESS);
}
Expand Down
26 changes: 14 additions & 12 deletions src/arkode/arkode_mristep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,11 +1493,11 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
SUNLogInfo(ARK_LOGGER, "begin-stage",
"stage = 0, stage type = %d, tcur = %" RSYM, MRISTAGE_ERK_NOFAST,
ark_mem->tcur);
SUNLogExtraDebugVec(ARK_LOGGER, "slow stage", "z_0(:) =", ark_mem->ycur, "");
SUNLogExtraDebugVec(ARK_LOGGER, "slow stage", ark_mem->ycur, "z_0(:) =");
SUNLogExtraDebugVecIf(step_mem->explicit_rhs, ARK_LOGGER, "slow explicit RHS",
"Fse_0(:) =", step_mem->Fse[0], "");
step_mem->Fse[0], "Fse_0(:) =");
SUNLogExtraDebugVecIf(step_mem->implicit_rhs, ARK_LOGGER, "slow implicit RHS",
"Fsi_0(:) =", step_mem->Fsi[0], "");
step_mem->Fsi[0], "Fsi_0(:) =");
SUNLogInfo(ARK_LOGGER, "end-stage", "status = success");

/* The first stage is the previous time-step solution, so its RHS
Expand Down Expand Up @@ -1541,7 +1541,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
if (retval != ARK_SUCCESS) { return (retval); }

SUNLogExtraDebugVec(ARK_LOGGER, "slow stage", "z_%i(:) =", ark_mem->ycur, is);
SUNLogExtraDebugVec(ARK_LOGGER, "slow stage", ark_mem->ycur, "z_%i(:) =", is);

/* apply user-supplied stage postprocessing function (if supplied) */
if (ark_mem->ProcessStage != NULL)
Expand Down Expand Up @@ -1582,8 +1582,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
ark_mem->user_data);
step_mem->nfse++;

SUNLogExtraDebugVec(ARK_LOGGER, "slow explicit RHS", "Fse_%i(:) =",
step_mem->Fse[step_mem->stage_map[is]], is);
SUNLogExtraDebugVec(ARK_LOGGER, "slow explicit RHS",
step_mem->Fse[step_mem->stage_map[is]],
"Fse_%i(:) =", is);
SUNLogInfoIf(retval != 0, ARK_LOGGER, "end-stage",
"status = failed explicit rhs eval, retval = %i", retval);

Expand All @@ -1609,8 +1610,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
step_mem->Fsi[step_mem->stage_map[is]]);
}

SUNLogExtraDebugVec(ARK_LOGGER, "slow implicit RHS", "Fsi_%i(:) =",
step_mem->Fsi[step_mem->stage_map[is]], is);
SUNLogExtraDebugVec(ARK_LOGGER, "slow implicit RHS",
step_mem->Fsi[step_mem->stage_map[is]],
"Fsi_%i(:) =", is);
SUNLogInfoIf(retval != 0, ARK_LOGGER, "end-stage",
"status = failed implicit rhs eval, retval = %i", retval);

Expand Down Expand Up @@ -2129,7 +2131,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem,
if (retval > 0) { return (TRY_AGAIN); }
}

SUNLogExtraDebugVec(ARK_LOGGER, "predictor", "zpred(:) =", step_mem->zpred, "");
SUNLogExtraDebugVec(ARK_LOGGER, "predictor", step_mem->zpred, "zpred(:) =");

/* determine effective DIRK coefficients (store in cvals) */
retval = mriStep_RKCoeffs(step_mem->MRIC, is, step_mem->stage_map,
Expand All @@ -2140,7 +2142,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem,
retval = mriStep_StageSetup(ark_mem);
if (retval != ARK_SUCCESS) { return (retval); }

SUNLogExtraDebugVec(ARK_LOGGER, "rhs data", "sdata(:) =", step_mem->sdata, "");
SUNLogExtraDebugVec(ARK_LOGGER, "rhs data", step_mem->sdata, "sdata(:) =");

/* perform implicit solve (result is stored in ark_mem->ycur); return
with positive value on anything but success */
Expand Down Expand Up @@ -2272,8 +2274,8 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem,
if (retval != 0) { return (ARK_VECTOROP_ERR); }
}

SUNLogExtraDebugVecArray(ARK_LOGGER, "forcing",
"forcing_%i(:) =", step_mem->stepper->forcing, nmat);
SUNLogExtraDebugVecArray(ARK_LOGGER, "forcing", nmat,
step_mem->stepper->forcing, "forcing_%i(:) =");

return (ARK_SUCCESS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_mristep_nls.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag)
ark_mem->ewt, step_mem->nlscoef, callLSetup,
ark_mem);

SUNLogExtraDebugVec(ARK_LOGGER, "correction", "zcor(:) =", step_mem->zcor, "");
SUNLogExtraDebugVec(ARK_LOGGER, "correction", step_mem->zcor, "zcor(:) =");

/* increment counters */
(void)SUNNonlinSolGetNumIters(step_mem->NLS, &nls_iters_inc);
Expand Down
4 changes: 2 additions & 2 deletions src/arkode/arkode_relaxation.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem,
/* Get the change in state (delta_y = tempv2) */
N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->yn, ark_mem->tempv2);

SUNLogExtraDebugVec(ARK_LOGGER, "compute delta y",
"delta_y(:) =", ark_mem->tempv2, "");
SUNLogExtraDebugVec(ARK_LOGGER, "compute delta y", ark_mem->tempv2,
"delta_y(:) =");

/* Store the current relaxation function value */
retval = relax_mem->relax_fn(ark_mem->yn, &(relax_mem->e_old),
Expand Down
2 changes: 1 addition & 1 deletion src/cvode/cvode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,7 @@ static void cvPredict(CVodeMem cv_mem)
}
}

SUNLogExtraDebugVec(CV_LOGGER, "return", "zn_0(:) =", cv_mem->cv_zn[0], "");
SUNLogExtraDebugVec(CV_LOGGER, "return", cv_mem->cv_zn[0], "zn_0(:) =");
}

/*
Expand Down
13 changes: 6 additions & 7 deletions src/cvodes/cvodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6567,7 +6567,7 @@ static void cvPredict(CVodeMem cv_mem)
}
}

SUNLogExtraDebugVec(CV_LOGGER, "forward", "zn_0(:) =", cv_mem->cv_zn[0], "");
SUNLogExtraDebugVec(CV_LOGGER, "forward", cv_mem->cv_zn[0], "zn_0(:) =");

if (cv_mem->cv_quadr)
{
Expand All @@ -6580,7 +6580,7 @@ static void cvPredict(CVodeMem cv_mem)
}
}

SUNLogExtraDebugVec(CV_LOGGER, "quad", "znQ_0(:) =", cv_mem->cv_znQ[0], "");
SUNLogExtraDebugVec(CV_LOGGER, "quad", cv_mem->cv_znQ[0], "znQ_0(:) =");
}

if (cv_mem->cv_sensi)
Expand All @@ -6592,8 +6592,8 @@ static void cvPredict(CVodeMem cv_mem)
(void)N_VLinearSumVectorArray(cv_mem->cv_Ns, ONE, cv_mem->cv_znS[j - 1],
ONE, cv_mem->cv_znS[j],
cv_mem->cv_znS[j - 1]);
SUNLogExtraDebugVecArray(CV_LOGGER, "sensi",
"znS_%d(:) =", cv_mem->cv_znS[0], cv_mem->cv_Ns);
SUNLogExtraDebugVecArray(CV_LOGGER, "sensi", cv_mem->cv_Ns,
cv_mem->cv_znS[0], "znS_%d(:) =");
}
}
}
Expand All @@ -6607,9 +6607,8 @@ static void cvPredict(CVodeMem cv_mem)
(void)N_VLinearSumVectorArray(cv_mem->cv_Ns, ONE, cv_mem->cv_znQS[j - 1],
ONE, cv_mem->cv_znQS[j],
cv_mem->cv_znQS[j - 1]);
SUNLogExtraDebugVecArray(CV_LOGGER, "quad-sensi",
"znQS_%d(:) =", cv_mem->cv_znQS[0],
cv_mem->cv_Ns);
SUNLogExtraDebugVecArray(CV_LOGGER, "quad-sensi", cv_mem->cv_Ns,
cv_mem->cv_znQS[0], "znQS_%d(:) =");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/kinsol/kinsol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,7 @@ static int KINFP(KINMem kin_mem)
ret = CONTINUE_ITERATIONS;
tolfac = ONE;

SUNLogExtraDebugVec(KIN_LOGGER, "begin", "u_0(:) =", kin_mem->kin_uu, "");
SUNLogExtraDebugVec(KIN_LOGGER, "begin", kin_mem->kin_uu, "u_0(:) =");

/* initialize iteration count */
kin_mem->kin_nni = 0;
Expand All @@ -2852,7 +2852,7 @@ static int KINFP(KINMem kin_mem)
kin_mem->kin_nfe++;

SUNLogExtraDebugVec(KIN_LOGGER, "while-loop-before-compute-new",
"G_%ld(:) =", kin_mem->kin_fval, kin_mem->kin_nni - 1);
kin_mem->kin_fval, "G_%ld(:) =", kin_mem->kin_nni - 1);

if (retval < 0)
{
Expand Down Expand Up @@ -2904,7 +2904,7 @@ static int KINFP(KINMem kin_mem)
}

SUNLogExtraDebugVec(KIN_LOGGER, "while-loop-after-compute-new",
"u_%ld(:) =", kin_mem->kin_unew, kin_mem->kin_nni);
kin_mem->kin_unew, "u_%ld(:) =", kin_mem->kin_nni);

/* compute change between iterations */
N_VLinearSum(ONE, kin_mem->kin_unew, -ONE, kin_mem->kin_uu, delta);
Expand Down
Loading

0 comments on commit b5f0089

Please sign in to comment.