我有一个任务,我需要使用OpenMPI,在这里我需要创建一个新的数据类型来发送消息,因此我搜索了这个并找到了一些东西。MPI派生的数据类型
以下的教程中,我这样做后:
typedef struct {
int a;
int b;
}SpecialData;
SpecialData p,q,vector[size];
MPI_Datatype tipSpecial , oldType[2];
int noBlocks[2];
MPI_Aint offsets[2],extent;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
// setup the 7 double fields
offsets[0] = 0 ;
oldType[0] = MPI_DOUBLE;
noBlocks[0] = 7;
//setup the 4 int fields of the struct
MPI_Type_extent(MPI_DOUBLE, &extent);
offsets[1] = 8 * extent;
oldType[1] = MPI_INT;
noBlocks[1] = 4;
MPI_Type_struct(2, noBlocks, offsets, oldType, &tipSpecial);
MPI_Type_commit(&tipSpecial);
///... Some code here where I do things based on the rank.
p.a = 9;
p.b = 9;
MPI_Send(p, 1, tipSpecial, 0, tag, MPI_COMM_WORLD);
MPI_Recv(q,1, tipSpecial, 0, tag, MPI_COMM_WORLD, &status);
我在送得到一个错误,并在第一个参数专门接收。
Error:
Main.c: In function ‘main’:
Main.c:125:3: error: incompatible type for argument 1 of ‘MPI_Send’
MPI_Send(p, 1, tipSpecial, 0, tag, MPI_COMM_WORLD);
任何想法为什么会发生这种情况?
你还应该包括什么错误信息你得到 – 2014-12-07 15:39:54
你应该提供'MPI_Send'和'MPI_RECV '带有指向数据的指针,即'&p'和'&q'。 – 2014-12-07 16:00:01
我不能相信这是造成这种情绪的原因。非常感谢你。如果你可以请发表你的回复@HristoIliev所以其他人都可以看到它 – tudoricc 2014-12-07 16:04:28