Compatibility with mpi4py <= 1.3.1.

This commit is contained in:
Pierre Chanial 2015-05-20 10:46:48 +02:00
parent 8d87184330
commit 1892b77a46
3 changed files with 13 additions and 1 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@
/sharp_oracle.inc
/python/libsharp/libsharp.c
/python/libsharp/libsharp_mpi.c

View file

@ -105,7 +105,8 @@ def sht(jobtype, geom_info ginfo, alm_info ainfo, double[:, :, ::1] input,
from mpi4py import MPI
if not isinstance(comm, MPI.Comm):
raise TypeError('comm must be an mpi4py communicator')
comm_ptr = <void*><size_t>MPI._addressof(comm)
from .libsharp_mpi import _addressof
comm_ptr = <void*><size_t>_addressof(comm)
with nogil:
r = sharp_execute_mpi_maybe (
comm_ptr, jobtype_i,

View file

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