- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在执行 MPI 非阻塞发送时遇到问题,它会导致机器因段错误而崩溃。所有机器都正确接收数据,但是id为0的机器在MPI_Waitall()
操作过程中崩溃了。任何人都可以确定导致问题的原因吗?谢谢!
这是程序的源代码和我在运行时得到的错误报告:
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define BLOCK_LOW(id,p,n) ((id)*(n)/(p))
#define BLOCK_HIGH(id,p,n) (BLOCK_LOW((id)+1,p,n)-1)
#define BLOCK_SIZE(id,p,n) (BLOCK_HIGH(id,p,n)-BLOCK_LOW(id,p,n)+1)
#define BLOCK_OWNER(id,p,n) (((p)*((id)+1)-1)/(n))
#define LENGTH 100
int main(int argc, char *argv[]) {
int id, p, i;
MPI_Request* sendRequests;
MPI_Status* sendStatuses;
MPI_Request receiveRequest;
MPI_Status receiveStatus;
int array[LENGTH];
int array2[LENGTH];
MPI_Init(&argc, &argv);
MPI_Barrier(MPI_COMM_WORLD);
for (i = 0; i < LENGTH; i++) {
array[i] = i * 5;
array2[i] = 0;
}
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Comm_size(MPI_COMM_WORLD, &p);
if (id == 0) {
sendRequests = malloc((p-1) * sizeof(MPI_Request));
for (i = 1; i < p; i++) {
MPI_Isend(array + BLOCK_LOW(i-1, p-1, LENGTH), BLOCK_SIZE(i-1, p-1, LENGTH), MPI_INT, i, 0, MPI_COMM_WORLD, &sendRequests[i-1]);
}
MPI_Waitall(p-1, sendRequests, sendStatuses);
} else {
MPI_Recv(array2, BLOCK_SIZE(id-1, p-1, LENGTH), MPI_INT, 0, 0, MPI_COMM_WORLD, &receiveStatus);
for (i = 0; i < BLOCK_SIZE(id-1, p-1, LENGTH); i++) {
printf("Element %d (%d): %d\n", i, i + BLOCK_LOW(id-1, p-1, LENGTH), array2[i]);
}
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}
这是我在运行代码时遇到的错误:
[lin12p5:13467] *** Process received signal ***
[lin12p5:13467] Signal: Segmentation fault (11)
[lin12p5:13467] Signal code: Invalid permissions (2)
[lin12p5:13467] Failing at address: 0x400f30
[lin12p5:13467] [ 0] /lib/libpthread.so.0(+0xeff0) [0x7fa96ab4eff0]
[lin12p5:13467] [ 1] /usr/lib/libmpi.so.0(+0x37f01) [0x7fa96bad5f01]
[lin12p5:13467] [ 2] /usr/lib/libmpi.so.0(PMPI_Waitall+0xb3) [0x7fa96bb06b73]
[lin12p5:13467] [ 3] mpi-test(main+0x232) [0x400da6]
[lin12p5:13467] [ 4] /lib/libc.so.6(__libc_start_main+0xfd) [0x7fa96a7fcc8d]
[lin12p5:13467] [ 5] mpi-test() [0x400ab9]
[lin12p5:13467] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 13467 on node lab12p5 exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
[lin13p5][[33088,1],1][../../../../../../ompi/mca/btl/tcp/btl_tcp_frag.c:216:mca_btl_tcp_frag_recv] mca_btl_tcp_frag_recv: readv failed: Connection reset by peer (104)
最佳答案
您还没有为 sendStatuses
分配任何空间。您将需要 malloc()
一些空间,就像您为 sendRequests
所做的那样。您还应该在完成后 free()
这些以防止内存泄漏。
关于c - MPI_Isend 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13543723/
在我的程序中的某个时刻,我正在使用 MPI_Isend 来通知某个事件的所有其他进程,但其中一些进程没有监听,这很好。我已经测试了这种情况,似乎可以正常完成。 我这样做可以吗?我是否应该保留每个 Is
我无法让 MPI_Isend 发送到随机目的地。如果我对目的地进行硬编码,它工作正常,但如果我尝试生成一个随机的目的地,它就不会。这是一些相关代码: MPI_Init(&argc,&argv)
我在执行 MPI 非阻塞发送时遇到问题,它会导致机器因段错误而崩溃。所有机器都正确接收数据,但是id为0的机器在MPI_Waitall()操作过程中崩溃了。任何人都可以确定导致问题的原因吗?谢谢! 这
关于 MPI_Isend,MPI 标准说“非阻塞发送调用表示系统可能开始从发送缓冲区复制数据。在调用非阻塞发送操作后,发送方不应访问发送缓冲区的任何部分,直到发送完成。 ” ( http://www.
例如, if (rank == 0) { MPI_Isend(&sendbuf, ..., 1, ..., &request); MPI_Wait(&request, ...); /
我正在尝试从左向右发送缓冲区(0->1、1->2 2->3 等...)。我非常确定进程正在从正确的合作伙伴发送和接收,但代码挂起或输出段错误。 #include "mpi.h" #include i
我正在研究异步通信并计划实现以下例程:每个进程都拥有一个必须与之通信的进程 vector ,按升序排列。它向所有较小的 rank 发送非阻塞接收,向所有较大的 rank 发送非阻塞发送。对于除进程 0
我使用 MPI 在 4 个节点上传递了总共 8 条消息。我注意到有两条消息的数组没有提供有意义的结果。我复制了下面代码的摘录?这些是我根据以下代码/结果提出的一些相关问题: MPI_Isend 是否也
我想将不同类型的数据从一个节点发送到另一个节点。例如,我有 2 个不同类型的数据:int 和 double。但是,在我将它们发送出去之后,即使我指定了类型,接收数据的节点也会收到错误的值。从下面的示例
我的程序的目的是计算内导体和外导体之间的静电势,方法是将其分成网格,然后再分成网格切片。每个处理器获取一个切片并在每个切片上运行计算。我使用 MPI_Isend 和 MPI_Irecv 在处理器之间发
对于MPI中的异步通信,以下哪个更好(在性能、可靠性、可读性等方面): MPI_Isend with buffer 然后 MPI_Iprobe & MPI_Recv 一旦接收器准备好,或者 带缓冲区的
我正在开发一个应用程序,其中每个处理器使用 MPI_Isend 向其他一些处理器发送一堆消息,然后接收一些未知数量的消息。 在我的小示例程序(下面的代码)中,我有 4 个处理器向其余 3 个处理器中的
我有以下带有 Microsoft MPI 的 c/c++ 代码 #include #include #include "mpi.h" int main (int argc, char *argv[
我已经阅读了所有 MPI 文档和教程以及我能找到的与此相关的 Stack Overflow 问题,但我仍然不完全理解 MPI_Wait 在“完成”MPI_Isend 时的行为方式。能简单概括一下吗?是
我创建了一个数组,我想用 MPI 发送它。第一部分运行良好(我认为?)但第二部分有问题。我想这是接收部分以及我如何分配数组?请看一下: if (myrank > 1) { //first pa
我是 MPI 编程新手!我尝试测量点对点通信带宽 介于实用的处理器之间。但是现在我遇到了段错误!我不明白为什么会这样。我也在 ubuntu 上尝试过 valgrind,但是不知道。所以也许有人可以帮助
我有以下代码 int main(int argc, char* argv[]) { int rank, size; MPI_Init (&argc, &argv); MP
我想了解 MPI 如何处理发送和接收。假设我分配一个 [12][50] 元素的缓冲区,如下所示: int **buf= malloc(12 * sizeof(int *)); for (i = 0;
简单问题:由于性能要求,我需要能够在发送数据的同时进行后续计算。所以我需要使用 MPI_Isend。 这安全吗? //qtasks[][] is a 2d array and Im sending
我正在创建一个程序,其中来自数组的信息被传递到不同的处理器。在下面的代码中,我尝试使用 for 循环反复向处理器发送信息或从处理器发送信息。当我在 5 核和 2 核上运行程序时,所有打印语句都按预期在
我是一名优秀的程序员,十分优秀!