[petsc-dev] on implementing a new PetscViewer

Jed Brown jed at jedbrown.org
Fri Jul 17 12:28:48 CDT 2015


Marco Zocca <zocca.marco at gmail.com> writes:

> Dear PETSc,
>  in writing the foreign-function wrappers for the library in Haskell,
> I found the need for an operation that copies the contents of a Mat or
> Vec, 

I think this is actually not great design for an FFI to an object
library like PETSc.  The interface strategy you seem to be modeling your
approach after is designed for libraries that operate on raw arrays with
no encapsulation instead of objects.

A critical question is what to do about mutability.  Haskell likes
functional data structures which typically have at least a "lazy spine"
and thus the new objects that you are constantly creating can share the
heavier parts.  Though some PETSc objects (like IS) are effectively
immutable, objects like matrices and Krylov solvers are mutated in-place
(MatSetValues and per-iteration recurrences and diagnostics).

Also, distributed memory systems have famously different failure
semantics than non-distributed systems.

For these reasons, I think it will be challenging to write a nice
functional interface to PETSc.  The obvious thing is to put it in a
monad, but I think that would be a desperately hard sell for other
Haskell users.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20150717/8b395038/attachment.sig>


More information about the petsc-dev mailing list