I am trying to use MPI_Datatype to send the below structure but the MPI_Send crashes while sending the structure. I am wondering how to handle this situation. Here is the code I have written to define new MPI data-type:
typedef struct
{
double x;
double y;
} vertex;
typedef struct
{
int num_vertices;
vertex vertex[2];
} vertex_list;
MPI_Datatype vertexType;
MPI_Type_contiguous(2,MPI_DOUBLE,&vertexType);
MPI_Type_commit(&vertexType);
MPI_Datatype vertexListType;
MPI_Datatype typev[3] = {MPI_INT, vertexType, MPI_UB};
int blocklenv[3] = {1, 2, 1};
MPI_Aint dispv[3];
/* compute displacements of structure components */
MPI_Address( vertexl, dispv);
MPI_Address( vertexl[0].vertex, dispv+1);
MPI_Address( vertexl+1, dispv+2);
base = dispv[0];
for (i=0; i <3; i++)
dispv[i] -= base;
/* build datatype describing structure */
MPI_Type_struct( 3, blocklenv, dispv, typev, &vertexListType);
MPI_Type_commit(&vertexListType);
https://docs.google.com/document/d/1OQFtx0ClkKQx7X91BlVgiizs5D9jShhtgsKafrgC7hk/edit?hl=en
pmgsays, you can edit your own post and using the code formatting helps to get a quicker response.