Creating an MPI_Datatype for a structure containing pointers

后端 未结 3 807
北海茫月
北海茫月 2020-12-03 11:39

I have the following structure.

typedef struct
{
 int *Ai;
 double *Ax;
 int nz;
}column;

I want to transfer this structure using MPI

3条回答
  •  借酒劲吻你
    2020-12-03 12:12

    "The wise thing to do is to transform your program to use arrays of structures"

    Often that's conceptually also better.

    I would like to point out another mechanism: using MPI_Pack and MPI_Unpack. For instance, with the original structure you could pack the first integer, then pack the two arrays. The receiver would unpack the integer and then know how many of the other thingies to unpack.

    This is also a good solution if your object is not directly accessible but can only be accessed through an iterator or so.

提交回复
热议问题