为啥我无法附加到此 MPI 代码的引导队列?
Posted
技术标签:
【中文标题】为啥我无法附加到此 MPI 代码的引导队列?【英文标题】:Why do i get the failed to attach to a bootstrap queue for this MPI code?为什么我无法附加到此 MPI 代码的引导队列? 【发布时间】:2022-01-18 01:17:05 【问题描述】:我正在尝试做的练习要求我们构建一个进程环,其中每个进程将数字 x 传递给下一个进程,只有 rank=0 的进程会减少 x。当 x 等于 0 时,程序结束。 工作代码如下:
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "mpi.h"
int main(int argc, char** argv)
int x = 0;
int tag = 99;
MPI_Status status;
MPI_Init(&argc, &argv);
int myRank;
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (myRank == 0)
printf("Process %d enter a value: \n", myRank);
fflush(stdout);
scanf_s("%d", &x);
while (x>0)
MPI_Send(&x, 1, MPI_INT, 1, tag, MPI_COMM_WORLD);
MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &status);
printf("Process %d : lap number %d \n", myRank, x);
x--;
else
do
MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &status);
printf("Process %d : lap number %d \n", myRank, x);
MPI_Send(&x, 1, MPI_INT, (myRank + 1) % size, tag, MPI_COMM_WORLD);
while (x > 1);
MPI_Finalize();
return 0;
但如果我像这样更改最后一个 do while 循环:
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "mpi.h"
int main(int argc, char** argv)
int x = 0;
int tag = 99;
MPI_Status status;
MPI_Init(&argc, &argv);
int myRank;
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (myRank == 0)
printf("Process %d enter a value: \n", myRank);
fflush(stdout);
scanf_s("%d", &x);
while (x>0)
MPI_Send(&x, 1, MPI_INT, 1, tag, MPI_COMM_WORLD);
MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &status);
printf("Processo %d : giro numero %d \n", myRank, x);
x--;
else
while (x>0)
MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &status);
printf("Processo %d : giro numero %d \n", myRank, x);
MPI_Send(&x, 1, MPI_INT, (myRank + 1) % size, tag, MPI_COMM_WORLD);
MPI_Finalize();
return 0;
我收到此错误:
job aborted:
[ranks] message
[0] fatal error
Fatal error in MPI_Send: Other MPI error, error stack:
MPI_Send(buf=0x000000F6100FF514, count=1, MPI_INT, dest=1, tag=99, MPI_COMM_WORLD) failed
failed to attach to a bootstrap queue - 10616:296
[1-2] terminated
但我不明白为什么……这两个代码不应该是等价的吗?
【问题讨论】:
【参考方案1】:您将x
设置为零,然后除零之外的所有进程都执行while (x>0) stuff
。所以他们什么都不做。
【讨论】:
以上是关于为啥我无法附加到此 MPI 代码的引导队列?的主要内容,如果未能解决你的问题,请参考以下文章