Work around a bug in Cython with using my mpi4py

This commit is contained in:
Dag Sverre Seljebotn 2015-06-03 23:50:59 +02:00
parent f8e6119f5d
commit 2ad975760f

View file

@ -1,10 +1,17 @@
from mpi4py.MPI cimport Comm
cdef extern from "mpi.h":
ctypedef void *MPI_Comm
cdef extern from "Python.h":
object PyLong_FromVoidPtr(void*)
cdef extern:
ctypedef class mpi4py.MPI.Comm [object PyMPICommObject]:
cdef MPI_Comm ob_mpi
cdef unsigned flags
# For compatibility with mpi4py <= 1.3.1
# Newer versions could use the MPI._addressof function
def _addressof(comm):
def _addressof(Comm comm):
cdef void *ptr = NULL
ptr = <void*>&(<Comm>comm).ob_mpi
ptr = <void*>&comm.ob_mpi
return PyLong_FromVoidPtr(ptr)