<div dir="ltr">Disregard this thread. I think the problem has to do with my data structure. <div><br></div><div>Thanks!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 17, 2020 at 12:55 PM Adolfo Rodriguez <<a href="mailto:adantra@gmail.com">adantra@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Sorry I was not clear before.<div><br></div><div>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 </div><div><br></div><div><pre width="80" style="color:rgb(0,0,0)"><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html#SNESSetJacobian" target="_blank">SNESSetJacobian</a>(snes,J,J,FormJacobian,&ctx);</pre><pre width="80" style="color:rgb(0,0,0)">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)</pre><pre width="80" style="color:rgb(0,0,0)">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.</pre><pre width="80" style="color:rgb(0,0,0)">I am measuring the time by doing </pre><pre width="80" style="color:rgb(0,0,0)">clock_t t0;</pre><pre width="80" style="color:rgb(0,0,0)">t0=clock();</pre><pre width="80" style="color:rgb(0,0,0)">function call</pre><pre width="80" style="color:rgb(0,0,0)">dtime = (double)(clock()-t0)/CLOCKS_PER_SEC;</pre><pre width="80" style="color:rgb(0,0,0)"><br></pre><pre width="80" style="color:rgb(0,0,0)">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.</pre><pre width="80" style="color:rgb(0,0,0)"><br></pre><pre width="80" style="color:rgb(0,0,0)">I hope the explanation is clear.</pre><pre width="80" style="color:rgb(0,0,0)"><br></pre><pre width="80" style="color:rgb(0,0,0)">Any clue?</pre><pre width="80" style="color:rgb(0,0,0)"><br></pre><pre width="80" style="color:rgb(0,0,0)">Adolfo</pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 17, 2020 at 12:05 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Thu, Sep 17, 2020 at 12:00 PM Adolfo Rodriguez <<a href="mailto:adantra@gmail.com" target="_blank">adantra@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">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.</div></blockquote><div><br></div><div>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.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Regards,</div><div><br></div><div>Adolfo</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div>