Work around a bug in Cython with using my mpi4py
This commit is contained in:
parent
f8e6119f5d
commit
2ad975760f
1 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue