[petsc-dev] [petsc4py] Extending the Mat extension type

Florian Rathgeber florian.rathgeber at gmail.com
Mon Oct 29 07:46:56 CDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[Apologies if this should have gone to petsc-users instead]

I'd like to extend petsc4py's Mat extension type to expose
MatCreateSeqAIJWithArrays and MatGetArray/MatRestoreArray to python,
ideally via attributes/methods directly on the extension type.

I know these shouldn't normally be used and reading this thread [1]
I'm assuming Lisandro doesn't currently have any plans for adding
either of those to petsc4py?

We're using PETSc as the linear algebra backend with matrices
assembled from FEM kernels on different hardware platforms (CPU, GPU),
so we need to transfer data back and forth between CPU and GPU memory
and we really don't want to create another temporary copy on the CPU
each time. Since we control the matrix format that should be safe.

The options as far as I can see (and I'm new to Cython, so might miss
a more elegant way) are:

1) Maintaining our own fork of petsc4py, adding those methods and
making our code depend on that fork. I'm reluctant to do that due to
the maintenance effort of keeping up with an actively developed
project such as petsc4py.

2) Inheriting the PETSc.Mat extension type in an extension module in
our code and adding those methods. This would mean replicating a lot
of the smarts petsc4py uses in its implementation (CHKERR, the numpy
helpers etc.) or Cython #include'ing bits of petsc4py's
implementation. Neither of those seem particularly elegant.

Suggestions and recommendations for how to deal with this situation
would be greatly appreciated.

Many thanks,
Florian

[1]:
https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2012-May/013380.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCOesAACgkQ8Z6llsctAxaBWQCeK6mXPv1DDJmRnh9pPRMtDVtE
ORIAoN7JT6DzFPgP5WLzNsBnSLIcmbxE
=Uy/E
-----END PGP SIGNATURE-----

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2913 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20121029/81cdec48/attachment.p7s>


More information about the petsc-dev mailing list