I have a structure of type:
typedef struct{
double x;
double y;
double z;
}bodyType;
and I want to use allgatherv to exchange only the the x and y members of the structure. Is this possible using the MPI_Type_vector or it doesn't apply for structures?
I tried the following:
MPI_Datatype MPI_Position_type;
MPI_Datatype pos_types= {MPI_DOUBLE,MPI_DOUBLE};
int blocklen[2] = {1,1};
MPI_Aint dis[2];
size_t offset_x_1 = offsetof(bodyType,x);
size_t offset_y_1 = offsetof(bodyType,y);
dis[0] = offset_x_1;
dis[1] = offset_y_1;
MPI_Type_create_struct(2,blocklen,dis,&pos_types,&MPI_Position_type);
MPI_Type_commit(&MPI_Position_type);
...
MPI_Allgatherv(MPI_IN_PLACE,0,MPI_Position_type,bodies,counts,displacements,MPI_Position_type,MPI_COMM_WORLD);
but I get a SEGFAULT.
Actually, I cannot see how AllgatherV will use counts and displacements in this case. My intention is to exchange only some members of the struct in order to reduce the communication overhead.