[petsc-users] Is it possible to use global variables in Petsc code?

Sean Farley sean at mcs.anl.gov
Wed Jul 21 18:35:57 CDT 2010


>
> save running time.
>

You will see no measurable difference in runtime by using global variables
(as opposed to calling a function). If you are worried about performance at
this level, then you should consider writing your code in assembly.

To verify, try running any of the many helpful examples in PETSc with the
option -log_summary to see where most of the time is being spent. You should
concentrate on improving your solver or discretization method to improve
your program's speed.

But I don't see any examples of using this in PETSc before. And I've tried
> this but it doesn't work or cannot pass the compiling check.
>

There is a reason people don't use global variables in writing code, and
that is extendability and robustness. You will waste FAR more time debugging
code with global variables than you would ever see in the (nonexistent)
speedup.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100721/af611197/attachment.htm>


More information about the petsc-users mailing list