[petsc-users] Overhead in snes function calls
Adolfo Rodriguez
adantra at gmail.com
Thu Sep 17 12:55:09 CDT 2020
Sorry I was not clear before.
I have to call some functions in order to assemble the Jacobian. I created
a FormJacobian function according to the specifications and set this
function using
SNESSetJacobian
<https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html#SNESSetJacobian>(snes,J,J,FormJacobian,&ctx);
within FormJacobian I need to make some calls to some functions
implemented in my code which is written in c++. These functions are
passed through the context pointer (ctx)
I noticed that when I call these functions within FormJacobian, there
is an overhead which in my case is about 0.08 seconds per call and I
need to make a few calls like this.
I am measuring the time by doing
clock_t t0;
t0=clock();
function call
dtime = (double)(clock()-t0)/CLOCKS_PER_SEC;
When I do this call and compute the time anywhere in y code I found
dtime = x seconds, while if I make the same call inside FormJacobian I
get dtime ~ x + 0.08 seconds.
I hope the explanation is clear.
Any clue?
Adolfo
On Thu, Sep 17, 2020 at 12:05 PM Matthew Knepley <knepley at gmail.com> wrote:
> On Thu, Sep 17, 2020 at 12:00 PM Adolfo Rodriguez <adantra at gmail.com>
> wrote:
>
>> I am porting a non-linear solution problem implemented explicitly to an
>> snes implementation. Everything seems to be working fine, except for the
>> fact that function calls done from snes to my jacobian and residual
>> construction subroutines are slower than the regular direct call to the
>> same subroutines (I hope this is clear). I wonder if somebody have observed
>> this behavior and found a solution.
>>
>
> It is not quite clear. I do not see a way that the calls themselves are
> slower, but perhaps there are intervening computations? How are you timing
> things.
>
> Thanks,
>
> Matt
>
>
>> Regards,
>>
>> Adolfo
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200917/aebf207e/attachment.html>
More information about the petsc-users
mailing list