我试图从进程0发送数据处理1.当缓冲区大小小于64KB这个计划成功,但如果缓冲区变得更大挂起.以下代码应该重现此问题(应该挂起),但如果n修改为小于8000 则应该成功.
int main(int argc, char *argv[]){
int world_size, world_rank,
count;
MPI_Status status;
MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
if(world_size < 2){
printf("Please add another process\n");
exit(1);
}
int n = 8200;
double *d = malloc(sizeof(double)*n);
double *c = malloc(sizeof(double)*n);
printf("malloc results %p %p\n", d, c);
if(world_rank == 0){
printf("sending\n");
MPI_Send(c, n, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD);
printf("sent\n");
}
if(world_rank == 1){
printf("recv\n");
MPI_Recv(d, n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status);
MPI_Get_count(&status, MPI_DOUBLE, &count);
printf("recved, count:%d source:%d tag:%d error:%d\n", count, …Run Code Online (Sandbox Code Playgroud)