MPI and C structs

Posted by hanno on Stack Overflow See other posts from Stack Overflow or by hanno
Published on 2010-05-02T16:24:39Z Indexed on 2010/05/02 16:27 UTC
Read the original article Hit count: 301

Filed under:
|
|

I have to admit, I was quite shocked to see how many lines of code are required to transfer one C struct with MPI.

Under what circumstances will it work to simply transmit a struct using the predefined dataype MPI_CHAR? Consider the following example:

struct particle {
   double x;
   double y;
   long   i;
};

struct particle p;
MPI_Isend(&p, sizeof(particle), MPI_CHAR, tag, MPI_COMM_WORLD, &sendr);

In my case, all processes run on the same architecture. Is padding the only issue?

© Stack Overflow or respective owner

Related posts about mpi

Related posts about struct