[petsc-dev] PetscStackCall() and CHKMEMQ

Barry Smith bsmith at mcs.anl.gov
Mon Apr 1 11:14:07 CDT 2013


On Apr 1, 2013, at 11:01 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> Many uses of PetscStackCall() are O(1) calls per iteration or
> communication, thus I think acceptable in debug mode. But some of them
> are called O(n) times, such as in gamg/agg.c:
> 
>      /* QR */
>      ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr);
>      PetscStackCall("LAPACKgeqrf",LAPACKgeqrf_(&Mdata, &N, qqc, &LDA, TAU, WORK, &LWORK, &INFO));
>      ierr = PetscFPTrapPop();CHKERRQ(ierr);
> 
>      PetscStackCall("LAPACKgeqrf",LAPACKgeqrf_(&Mdata, &N, qqc, &LDA, TAU, WORK, &LWORK, &INFO));
> 
> and in blockinvert.h. Presumably we need two versions of PetscCallStack,
> one that is used to call "safe" functions or those that are only called
> O(1) times, and one that is used to call "unsafe" or
> performance-sensitive functions.

   Is the only issue that PetscStackCall() has a CHKMEMQ() within it? Otherwise it seems PetscStackCall() costs no more than any other PETSc function call with PetscFunctionBegin/Return(). Perhaps it could take a flag argument indicating if the memory check should be performed? For BLAS/LAPACK assuming we've allocated enough work space the memory check is likely not needed, should we have a PetscStackCallBLASLAPACK() (that possibly even handles the info flag when it exists?) which does not do a CHKMEMQ?

   Barry





More information about the petsc-dev mailing list