- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
据我所知,MPI_Sendrecv
需要两个不同的缓冲区用于发送和接收。我的以下代码将 (N/P) 行 block 发送到 P-1 处理器,但它不起作用并给我一个卡住的屏幕。我试图确保一切正确,但我不知道问题出在哪里(我省略了变量声明以使其简短)
int **M, **FinalM, **M0;
M = malloc(N * sizeof (int *));
for (i = 0; i < N; i++) {
M[i] = malloc(N * sizeof (int));
}
FinalM = malloc(N * sizeof (int *));
for (i = 0; i < N; i++) {
FinalM[i] = malloc(n * sizeof (int));
}
M0 = malloc(N/P * sizeof (int *));
for (i = 0; i < N/P; i++) {
M0[i] = malloc(N * sizeof (int));
}
c = N/P; // P is Number of Processors and N rows
if (rank == 0) {
for (i = 0; i < P; i++) {
k = i*c;
k1 = (i + 1) * c;
for (j = k; j < k1; j++) {
MPI_Sendrecv(M[j], N, MPI_INT, i, TAG, FinalM[j], N, MPI_INT, i, TAG, MPI_COMM_WORLD, &status[d]);
}
}
} else {
for (i = 0; i < (N / P); i++) {
MPI_Recv(M0[i], N, MPI_INT, 0, TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
}
请问有人可以给我一个解决这个问题的提示吗?谢谢。
最佳答案
来自 https://www.open-mpi.org/doc/v1.8/man3/MPI_Sendrecv.3.php#toc7 的文档:
MPI_Sendrecv executes a blocking send and receive operation.
在您的情况下,主循环将矩阵的一部分发送到第一个工作程序并阻塞,等待工作程序响应。没有响应,因此它永远挂起。您需要在主循环中仅使用 MPI_Send
,然后再使用 MPI_Recv
循环。工作人员必须使用 MPI_Send
发回一些内容。
关于c - 使用 2D 矩阵的 MPI_Sendrecv 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33503503/
我想使用 MPI_Sendrecv MPI_Sendrecv(&ballPos, 2, MPI_INT, FIELD, NEW_BALL_POS_TAG, &ballPos, 2, MPI_INT,
我想使用 MPI_Sendrecv 执行矩阵转置,但在运行时,它等待并且程序没有结束。这是我的代码: ... void sendrecvelem(int **A, int **R, int p, in
我的问题很简单。使用 MPI_Sendrecv 时,它会系统地生成段错误。我之前在使用 2D 数组和基本 MPI_Send 时遇到了同样的问题,但最终解决了。当我尝试在最后一个案例中使用相同的解决方案
假设我有 n 个进程,每个进程都拥有一个本地数据,比如说一个 int。 现在我想重新实现 MPI_Allreduce() 函数,即计算所有这些 int 的全局总和,然后将结果总和广播回进程。 我试着像
尝试进行“halo/ghost”行交换时,我被死锁难住了(在图片下方的代码片段中)。要交换的“光环”行表示为深灰色线(在图片中)以及 hp[0] 和 hp[M-1](在代码)。 [不能发图片;声望不够
我使用 MPI_Sendrecv MPI 函数在进程之间传递数据数组。我使用 mpi4py 在 Python 中执行此操作,但我很确定我的问题与使用的语言无关。 我真正想要的是将驻留在另一个进程上的数
据我所知,MPI_Sendrecv 需要两个不同的缓冲区用于发送和接收。我的以下代码将 (N/P) 行 block 发送到 P-1 处理器,但它不起作用并给我一个卡住的屏幕。我试图确保一切正确,但我不
我正在尝试编写康威生命游戏的代码,模式是兔子。我使用笛卡尔2D方法构建了一个进程组,它们之间的通信是MPI_Sendrecv。但是这段代码不起作用,当我运行它时它只是卡在那里没有任何响应。我花了很长时
我是一名优秀的程序员,十分优秀!