diff --git a/python/libsharp/libsharp_mpi.pyx b/python/libsharp/libsharp_mpi.pyx index 402b4f6..e819a77 100644 --- a/python/libsharp/libsharp_mpi.pyx +++ b/python/libsharp/libsharp_mpi.pyx @@ -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 = &(comm).ob_mpi + ptr = &comm.ob_mpi return PyLong_FromVoidPtr(ptr)