[petsc-dev] Counting Fortran function pointers
Peter Brune
prbrune at gmail.com
Tue Dec 4 17:10:39 CST 2012
Is it possible that recent changes make this solution easier?
DMKSP/SNES/TS is now a PETSc object. Should we be attaching
context-appropriate pointers there so that they can be copied along with
this context?
There's also the last-ditch approach I took to having a SNESShell properly
take an implementation-specific fortran pointer, which was to compose it
with the object (yeah yeah string lookups)
https://bitbucket.org/petsc/petsc-dev/src/d646bb69827f0fe12031068d40b072920e0212b4/src/snes/impls/shell/ftn-custom/zsnesshellf.c?at=default
- Peter
On Tue, Dec 4, 2012 at 4:43 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> As usual, anything that is duplicated and not checked by the compiler is
> broken.
>
> $ grep PetscObjectAllocateFortranPointers src/**/*.c
>
>
> src/dm/impls/da/ftn-custom/zda2f.c:
> PetscObjectAllocateFortranPointers(*da,6);
> src/dm/impls/da/ftn-custom/zda2f.c:
> PetscObjectAllocateFortranPointers(*da,6);
> src/dm/impls/shell/ftn-custom/zdmshellf.c:
> PetscObjectAllocateFortranPointers(*dm,2);
> src/dm/impls/shell/ftn-custom/zdmshellf.c:
> PetscObjectAllocateFortranPointers(*dm,2);
>
> 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.
>
> 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.
>
> 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.
>
> What should we do? The current state is a disaster.
>
> src/ksp/ksp/impls/gmres/fgmres/ftn-custom/zmodpcff.c:
> PetscObjectAllocateFortranPointers(*ksp,3);
> src/ksp/ksp/interface/ftn-custom/zitfuncf.c:
> PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);
> src/ksp/ksp/interface/ftn-custom/zitfuncf.c:
> PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);
> src/ksp/pc/impls/mg/ftn-custom/zmgfuncf.c:
> PetscObjectAllocateFortranPointers(*mat,1);
> src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:
> PetscObjectAllocateFortranPointers(*pc,5);
> src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:
> PetscObjectAllocateFortranPointers(*pc,5);
> src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:
> PetscObjectAllocateFortranPointers(*pc,5);
> src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:
> PetscObjectAllocateFortranPointers(*pc,5);
> src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:
> PetscObjectAllocateFortranPointers(*pc,5);
> src/mat/impls/mffd/ftn-custom/zmffdf.c:
> PetscObjectAllocateFortranPointers(*mat,2);
> src/mat/impls/shell/ftn-custom/zshellf.c:
> PetscObjectAllocateFortranPointers(*mat,11);
> src/mat/interface/ftn-custom/zmatrixf.c:
> PetscObjectAllocateFortranPointers(*sp,1);
> src/snes/interface/ftn-custom/zsnesf.c:
> PetscObjectAllocateFortranPointers(*snes,14);
> src/snes/interface/ftn-custom/zsnesf.c:
> PetscObjectAllocateFortranPointers(*snes,14);
> src/snes/interface/ftn-custom/zsnesf.c:
> PetscObjectAllocateFortranPointers(*snes,14);
> src/snes/interface/ftn-custom/zsnesf.c:
> PetscObjectAllocateFortranPointers(*snes,14);
> src/snes/interface/ftn-custom/zsnesf.c:
> PetscObjectAllocateFortranPointers(*snes,14);
> src/snes/linesearch/impls/shell/ftn-custom/zlinesearchshellf.c:
> PetscObjectAllocateFortranPointers(*linesearch,3);
> src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:
> PetscObjectAllocateFortranPointers(*linesearch,3);
> src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:
> PetscObjectAllocateFortranPointers(*linesearch,3);
> src/sys/draw/utils/ftn-custom/zzoomf.c:
> PetscObjectAllocateFortranPointers(*draw,1);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
> src/ts/interface/ftn-custom/ztsf.c:
> PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20121204/3a789d9e/attachment.html>
More information about the petsc-dev
mailing list