Assume that i have a struct type as follows:
typedef struct {
float x, y, z;
float velocity;
int n, type;
} Particle;
我想要发送它,需要创建一个MPI_Type。我知道4种方法来创建它们,以下是列出的方法。我想知道它们之间的区别、限制和好处。
使用
MPI_Type_extent
使用
stddef.h
中的offsetof()
,在这个答案中有解释:MPI Derived Type Send answer使用
MPI_Get_address
,同样在同一个答案中有例子。使用
reinterpret_cast<const unsigned char*>
,我没有尝试过,但这里有一个例子:MPI Create Custom Data