Skip to content

Commit 1892b77

Browse files
committed
Compatibility with mpi4py <= 1.3.1.
1 parent 8d87184 commit 1892b77

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/sharp_oracle.inc
1515

1616
/python/libsharp/libsharp.c
17+
/python/libsharp/libsharp_mpi.c

python/libsharp/libsharp.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def sht(jobtype, geom_info ginfo, alm_info ainfo, double[:, :, ::1] input,
105105
from mpi4py import MPI
106106
if not isinstance(comm, MPI.Comm):
107107
raise TypeError('comm must be an mpi4py communicator')
108-
comm_ptr = <void*><size_t>MPI._addressof(comm)
108+
from .libsharp_mpi import _addressof
109+
comm_ptr = <void*><size_t>_addressof(comm)
109110
with nogil:
110111
r = sharp_execute_mpi_maybe (
111112
comm_ptr, jobtype_i,

python/libsharp/libsharp_mpi.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from mpi4py.MPI cimport Comm
2+
cdef extern from "Python.h":
3+
object PyLong_FromVoidPtr(void*)
4+
5+
# For compatibility with mpi4py <= 1.3.1
6+
# Newer versions could use the MPI._addressof function
7+
def _addressof(comm):
8+
cdef void *ptr = NULL
9+
ptr = <void*>&(<Comm>comm).ob_mpi
10+
return PyLong_FromVoidPtr(ptr)

0 commit comments

Comments
 (0)