So the choice is<br><br>1. Do the enum, which is a dirty hack, but much less fragile than the current code. It has a bad dependency and will always be a mild pain in the ass, but at least code using it shouldn't be buggy.<br>
<br>2. Do registration which is reliable and extensible without any bad dependencies, but is extra initialization.<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 4, 2012 at 9:32 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">You understand this just fine. ;-)</p>
<p dir="ltr">The dmdasnes, dmdats, etc depends on DM, not vice-versa. But if you have an enum for DM, then DM contains knowledge about users of DM, and you have to modify DM when something outside needs it.</p>
<p dir="ltr">Note that this also sucks if we have users implementing DM in their own codes.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Dec 4, 2012 8:29 PM, "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Dec 4, 2012, at 10:22 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>> wrote:<br>
<br>
> That is what I implemented for TS. The problem is false dependency in the sense that the enum includes extra stuff. For example, DM function pointers are needed by dmdasnes.<br>
<br>
I don't understand this.<br>
<br>
> With dynamic keys, we could avoid that spurious dependency.<br>
<br>
Not worth the extra initialization code.<br>
><br>
> On Dec 4, 2012 8:14 PM, "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> On Dec 4, 2012, at 4:43 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>> wrote:<br>
><br>
> > As usual, anything that is duplicated and not checked by the compiler is broken.<br>
> ><br>
> > $ grep PetscObjectAllocateFortranPointers src/**/*.c<br>
> > src/dm/impls/da/ftn-custom/zda2f.c: PetscObjectAllocateFortranPointers(*da,6);<br>
> > src/dm/impls/da/ftn-custom/zda2f.c: PetscObjectAllocateFortranPointers(*da,6);<br>
> > src/dm/impls/shell/ftn-custom/zdmshellf.c: PetscObjectAllocateFortranPointers(*dm,2);<br>
> > src/dm/impls/shell/ftn-custom/zdmshellf.c: PetscObjectAllocateFortranPointers(*dm,2);<br>
> ><br>
> > Note that changing the type does not reset the function pointers, thus having a DMSHELL, calling DMSetType(dm,DMDA), and then setting a DMDA local function will cause memory corruption.<br>
><br>
> > I cannot express how much I hate this system. The full-blown solution is that for each type, we register a (global) token which is the index of that function pointer. That doesn't have any false dependencies, but is more "initialize" code.<br>
> ><br>
> > An alternative, used in the TS and KSP code below, is to have a common enum that lists all the Fortran functions. It's a false header dependency, but not a binary dependency.<br>
> > What should we do? The current state is a disaster.<br>
><br>
><br>
> Each object gets an enum for each fortran implementable method in that object, names of the enums reflect the object and method name. The final enum for each object is the count of the number of the enums and is used in the AllocationFortranPointers. Yes, some brain numbing work to set up initially but then pretty clean and extensible for the future (since the final enum is the count we don't have to worry about always fixing the count in the AllocateFunctionPointers() each time a new method is added).<br>
><br>
> Barry<br>
><br>
> ><br>
> > src/ksp/ksp/impls/gmres/fgmres/ftn-custom/zmodpcff.c: PetscObjectAllocateFortranPointers(*ksp,3);<br>
> > src/ksp/ksp/interface/ftn-custom/zitfuncf.c: PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);<br>
> > src/ksp/ksp/interface/ftn-custom/zitfuncf.c: PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);<br>
> > src/ksp/pc/impls/mg/ftn-custom/zmgfuncf.c: PetscObjectAllocateFortranPointers(*mat,1);<br>
> > src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c: PetscObjectAllocateFortranPointers(*pc,5);<br>
> > src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c: PetscObjectAllocateFortranPointers(*pc,5);<br>
> > src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c: PetscObjectAllocateFortranPointers(*pc,5);<br>
> > src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c: PetscObjectAllocateFortranPointers(*pc,5);<br>
> > src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c: PetscObjectAllocateFortranPointers(*pc,5);<br>
> > src/mat/impls/mffd/ftn-custom/zmffdf.c: PetscObjectAllocateFortranPointers(*mat,2);<br>
> > src/mat/impls/shell/ftn-custom/zshellf.c: PetscObjectAllocateFortranPointers(*mat,11);<br>
> > src/mat/interface/ftn-custom/zmatrixf.c: PetscObjectAllocateFortranPointers(*sp,1);<br>
> > src/snes/interface/ftn-custom/zsnesf.c: PetscObjectAllocateFortranPointers(*snes,14);<br>
> > src/snes/interface/ftn-custom/zsnesf.c: PetscObjectAllocateFortranPointers(*snes,14);<br>
> > src/snes/interface/ftn-custom/zsnesf.c: PetscObjectAllocateFortranPointers(*snes,14);<br>
> > src/snes/interface/ftn-custom/zsnesf.c: PetscObjectAllocateFortranPointers(*snes,14);<br>
> > src/snes/interface/ftn-custom/zsnesf.c: PetscObjectAllocateFortranPointers(*snes,14);<br>
> > src/snes/linesearch/impls/shell/ftn-custom/zlinesearchshellf.c: PetscObjectAllocateFortranPointers(*linesearch,3);<br>
> > src/snes/linesearch/interface/ftn-custom/zlinesearchf.c: PetscObjectAllocateFortranPointers(*linesearch,3);<br>
> > src/snes/linesearch/interface/ftn-custom/zlinesearchf.c: PetscObjectAllocateFortranPointers(*linesearch,3);<br>
> > src/sys/draw/utils/ftn-custom/zzoomf.c: PetscObjectAllocateFortranPointers(*draw,1);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
> > src/ts/interface/ftn-custom/ztsf.c: PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);<br>
><br>
<br>
</blockquote></div>
</div></div></blockquote></div><br></div>