使用MPI_Gather会导致无法附加到引导队列错误
Using MPI_Gather leads to failed to attach to a bootstrap queue error
我需要编写代码,将矩阵列从每个进程发送到根进程。
我有以下代码:
int task8(int argc, char* argv[])
{
int rank, size;
double matrix[100][150];
double result_matrix[100][150];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
// generate matrix
srand((int)(MPI_Wtime() * 1e4));
for (int i = 0; i < 100; ++i)
{
for (int j = 0; j < 150; ++j)
{
matrix[i][j] = rand();
}
}
if (rank != 0)
{
// for (int i = rank; i < 100; i += size)
// {
// MPI_Gather(&matrix[i], 150, MPI_DOUBLE, &matrix[i], 150, MPI_DOUBLE, 0, MPI_COMM_WORLD);
// }
// for (int i = 0; i <= size; i++)
// {
// MPI_Gather(&matrix[i], 150, MPI_DOUBLE, &result_matrix[i], 150, MPI_DOUBLE, 0, MPI_COMM_WORLD);
// }
MPI_Gather(matrix[rank], 150, MPI_DOUBLE, result_matrix[rank], 150, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}
MPI_Finalize();
return 0;
}
但我不明白为什么突出显示的示例不起作用 - 它会产生错误:
C:UsersDima>mpiexec -n 4 D:codeparallellabs_examProject1DebugProject1.exe
job aborted:
[ranks] message
[0-1] terminated
[2] fatal error
Fatal error in MPI_Gather: Other MPI error, error stack:
MPI_Gather(sbuf=0x00212AB0, scount=150, MPI_DOUBLE, rbuf=0x001F55E8, rcount=150, MPI_DOUBLE, root=0, MPI_COMM_WORLD) failed
failed to attach to a bootstrap queue - 11660:216
[3] terminated
---- error analysis -----
[2] on DESKTOP-5SK57UV
mpi has detected a fatal error and aborted D:codeparallellabs_examProject1DebugProject1.exe
---- error analysis -----
我尝试从 mpi 文档中运行简单的示例,这些示例使用了MPI_gather函数并且它们工作正常。
MPI_Gather()
是一个集体操作,因此必须在通信器的所有级别上调用(使用兼容的参数(。
在程序中,秩0
不会调用MPI_Gather()
因此程序将死锁或中止。
相关文章:
- boost::进程间消息队列引发错误
- 尝试将lambda函数放在队列中时出现一般分配器错误(可能是与unique_ptr有关的错误)
- 在C++中创建队列 - 什么是 malloc 错误?
- C++数组队列实现方法错误
- 使用MPI_Gather会导致无法附加到引导队列错误
- 使用 <list> (错误 C2760) 打印队列的元素
- 使用 std::forward_list 返回错误的队列实现
- 更改队列指针成员的值需要在 C++ 中出现奇怪的错误
- 获取错误:之前在此处声明的布尔队列的编辑<T>
- C++:自定义数据类型向量错误的队列
- 为什么STL优先级队列错误地分配了我的类对象
- 前缀表示法 C++,分段错误(堆栈和队列)
- 线程安全队列出现分段错误
- 队列验证层错误:队列族索引在 pCreateInfo->pQueueCreateInfos 数组中不是唯一的
- 交换优先级队列时尝试引用已删除的函数错误
- 为什么我的简单C++程序使用队列和 fstream 错误到无效指针
- 尝试编译队列时static_initialization_and_destruction错误
- 队列类的取消排队方法"Aborted (core dumped)"错误
- 在.c文件接收函数中使用Linux中的MSGGET创建消息队列未实现错误
- 尝试使用堆栈创建队列.为什么我会遇到int转换错误的空白