I am trying to wrap a C++ function that doesn't take any input and returns the MPI communicator.
Foo.h
class Foo{
public:
Foo(MPI_Comm _comm){
_comm = comm;
}
MPI_Comm getMPIComm(){
return comm
}
virtual void Foo1() = 0
I have tried that following:
source.pyx
cimport mpi4py.MPI as MPI
from mpi4py.libmpi cimport *
cdef extern from Foo.h:
cdef cppclass Foo:
Foo(MPI_Comm _comm)
MPI_Comm getMPIComm()
void Foo1()
cdef class pyFoo:
cdef Foo *thisptr
def __cinit__(self,MPI.Comm _comm):
pass
def get MPIComm(self):
c_comm = self.thisptr.getMPIComm()
return <MPI.Comm> c_comm
def Foo1(self):
pass
This code compiled and I was able to write a python code that inherits this class. However, when I tried to access getMPIComm at the python level, I encountered a segmentation fault and the error given by valgrind is:
Access not within mapped region at address 0x8
Does that mean that I did not wrap getMPIComm() properly? Does anyone know how I should approach it?