Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Using MPI derived datatypes
From: Grzegorz Maj (maju3_at_[hidden])
Date: 2012-08-03 07:36:35

I would like my MPI processes to exchange some structural data. That
data is represented by plain structures containing basic datatypes. I
would like to use MPI derived datatypes, because of its portability
and good performance.

I would like to be able to send/receive any of my structures in the
same part of code. In the low-level network programming it is usually
done by having each struct of this pattern:
struct S1 {
  int structType;
And then you first read structType and know what bytes to expect next.

Is there a good way to do it using MPI derived datatypes?

I was thinking of having separate MPI_Request for each of my
structures and calling multiple MPI_Irecv + MPI_Waitany. But then, how
to do this for MPI_Bcast?

My second question is about having arbitrary size structures, i.e. the
ones having 'char buf[0]' as the last field, where you allocate memory
of size 'sizeof(S) + bufLen'. Is there a way to convert such a struct
into MPI derived datatype?

Thanks for any help,
Grzegorz Maj