[petsc-users] [petsc4py] Interoperability with PyCUDA?

Ashwin Srinath ashwinsrnth at gmail.com
Tue Sep 9 10:15:02 CDT 2014


Hello, petsc-users

I posted about this before without luck, but perhaps that was a little too
specific a request:

http://lists.mcs.anl.gov/pipermail/petsc-users/2014-July/022145.html

In general, it would be great to be able to use PyCUDA and petsc4py
together. Here is an example of how I'd like to be able to do this (based
on this PyCUDA example <http://documen.tician.de/pycuda/tutorial.html>):

from petsc4py import PETSc as petsc
import pycuda.driver as cuda
from pycuda import autoinit
from pycuda.compiler import SourceModule

mod = SourceModule("""
  __global__ void doublify(double *a)
  {
    int idx = threadIdx.x + threadIdx.y*4;
    a[idx] *= 2;
  }
  """)

v = petsc.Vec()
v.create()
v.setSizes(16)
v.setType('cusp')
v.set(1)

func = mod.get_function("doublify")
*func(???, block=(4,4,1))*

`func` accepts as ??? an object that supports the Python buffer interface,
see here
<http://documen.tician.de/pycuda/driver.html#pycuda.driver.Function>, and
I'm wondering if it's possible for petsc4py cusp vectors to support that?

Are there any other ways to use custom kernels with petsc4py cusp vectors?
petsc4py users - if you use CUSP vectors in your petsc4py code, may I ask
how?

Thanks so much,
Ashwin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140909/a9592609/attachment.html>


More information about the petsc-users mailing list