[GiNaC-list] custom print function for GiNaC::add and GiNaC::mul for deterministic printing
Diddens, Christian (UT-TNW)
c.diddens at utwente.nl
Tue Oct 12 11:10:12 CEST 2021
Dear GiNaC guys,
first of all: Thanks once more for your powerful library!
I have written a neat C code generation for the just-in-time
compilation of arbitrary multiphysics finite element equations. The
equations are defined in python, can be coupled and combined, and are
finally monolithically solved via the library oomph-lib.
While code generation is fast, the compilation of the generated code
takes some time (~10 seconds for complicated couplings of Navier-
Stokes, advection-diffusion, Marangoni flow, mesh node positions for
ALE methods, etc.)
Now, if the code generation was deterministic, I could check whether
the same code has already been compiled in a previous run and skip the
compilation in that case. I could also use the tool "ccache" for this.
As proposed in the manual, I therefore wanted to write my own print
implementation and make sure that in particular "add" and "mul" are
written in an e.g. lexiographical order.
However, it is a bit problematic since the properties "epvector seq"
and "ex overall_coeff" from the class "expairseq" are protected without
any public getter functions.
Of course, I could iterate over the "::op(index)", but this would
convert each "expair" first in an "ex" and I think the "expair"
together with the "overall_coeff" is definitely the better way to go.
So is there any neat way to access there properties from outside of the
class?
I understand your decision for using hashes and do not focus on a
determinstic order, but in my case, it would definitely help to same
some redundant JIT compilation time.
Thanks for any help, you are doing a perfect job with GiNaC.
Best regards,
Christian
More information about the GiNaC-list
mailing list