我是MPI
的新用户并尝试编写测试程序,我使用MPI_Send
和MPI_Recv
在根目录之间传递两个数字"a"
和"b"
流程为0
,下一个为1
。但每次我得到相同的错误:“Test.exe已触发断点。”你能帮我吗?
#include <iostream>
#include "mpi.h"
using namespace std;
int main(int argc, char** argv) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
unsigned int a;
unsigned int b;
MPI_Status status;
if (rank == 0) {
a = 1;
MPI_Send(&a,1,MPI_INTEGER,1,MPI_ANY_TAG,MPI_COMM_WORLD);
MPI_Recv(&b, 1, MPI_INTEGER, 1, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
printf("Root has now B: ", rank, b);
}
else {
b = 2;
MPI_Recv(&a, 1, MPI_INTEGER, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
MPI_Send(&b, 1, MPI_INTEGER, 0, MPI_ANY_TAG, MPI_COMM_WORLD);
printf("Proc 1 has now B: ", rank, a);
}
MPI_Finalize();
return(0);
}