我正在尝试编译 MPI_Exchange 函数,但不断收到以下错误。
错误:
OddEvenSort.c: In function ‘MPI_Exchange’:
OddEvenSort.c:75: warning: passing argument 7 of ‘MPI_Recv’ from incompatible pointer type
/usr/lib/openmpi/include/mpi.h:1174: note: expected ‘struct MPI_Status *’ but argument is of type ‘int *’
OddEvenSort.c:84: warning: passing argument 7 of ‘MPI_Recv’ from incompatible pointer type
/usr/lib/openmpi/include/mpi.h:1174: note: expected ‘struct MPI_Status *’ but argument is of type ‘int *’
/usr/bin/mpicc -o OddEvenSort OddEvenSort.o -lm
代码:
int MPI_Exchange( int n, double *a, int rank1, int rank2,MPI_Comm comm )
{
int rank, tag1, tag2, size, i, status;
double * b, * c;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
if(rank == rank1){
MPI_Send(&a[0],n,MPI_DOUBLE,rank2,tag1,comm);
MPI_Recv(&b[0],n,MPI_DOUBLE,rank2,tag2,comm,&status);
c = merge_array(n,a,n,b);
for(i=0;i<n;i++){
a[i] = c[i];
}
}
else if(rank == rank2){
MPI_Send(&a[0],n,MPI_DOUBLE,rank1,tag1,comm);
MPI_Recv(&b[0],n,MPI_DOUBLE,rank1,tag2,comm,&status);
c = merge_array(n,a,n,b);
for(i=0;i<n;i++){
a[i] = c[i+n];
}
}
return MPI_SUCCESS;
}
我相信错误指的是
&status
的两个实例中的 MPI_Recv
。我正在尝试获取状态地址,该地址之前在我的代码中声明为 MPI_Status status
。
您已
status
宣布为当地人 int
:
int rank, tag1, tag2, size, i, status;
它会覆盖代码中之前的
status
的任何全局声明。
更改本地
status
变量的名称或将其设置为适当的类型。