Pergunta

I am trying to send and receive data in MPI4Py, using the structured array from NumPy. The following is my array structure:

numpy.zeros(FILE_LINES, dtype='i4,54b')

and I am using the Sendrecv method for exchanging the data, as follows:

comm.Sendrecv(data_send, dest=partner_rank, sendtag=data_tag, \
        recvbuf=data_receive, source=partner_rank, recvtag=data_tag, status=None)

But I get an exception when the communication method is called:

Traceback (most recent call last):
  File "bipy.py", line 91, in <module>
  bitonic_sort()
File "bipy.py", line 72, in bitonic_sort
  bitonic_merge(i, ixj, (i & k) == 0)
File "bipy.py", line 51, in bitonic_merge
  recvbuf=data_receive, source=partner_rank, recvtag=data_tag, status=None)
File "Comm.pyx", line 166, in mpi4py.MPI.Comm.Sendrecv (src/mpi4py.MPI.c:58898)
File "message.pxi", line 318, in mpi4py.MPI.message_p2p_send (src/mpi4py.MPI.c:21422)
File "message.pxi", line 301, in mpi4py.MPI._p_msg_p2p.for_send (src/mpi4py.MPI.c:21285)
File "message.pxi", line 111, in mpi4py.MPI.message_simple (src/mpi4py.MPI.c:19256)
File "message.pxi", line 58, in mpi4py.MPI.message_basic (src/mpi4py.MPI.c:18509)
KeyError: 'T{=l:f0:(54)b:f1:}'

It works when using an array with only one datatype (all bytes, for example). Is MPI4Py not able to send these structured arrays, or am I doing something wrong?

Foi útil?

Solução

As already mentioned by Jonathan Dursi in his comment: the communication routines with capital first letter (e.g. Sendrecv()) can only communicate "memory buffers", i.e. data structures that provide a certain C API. Structured arrays do not seem to be such a data structure. To send it anyway, use sendrecv().

See in the MPI4Py docs at http://mpi4py.scipy.org/docs/usrman/mpi4py.html.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top