c++ - 我自己的 MPI_Gather 实现
问题描述
我正在尝试编写自己的 MPI_Gather 实现,但输入的数组并没有随着输出而改变。正常的 MPI_gather 工作正常。
编码:
void My_MPI_Gather(int* sendbuf, int sendcount, MPI_Datatype d1, int* recvbuf, int recvcount, MPI_Datatype d2, int root, MPI_Comm comm)
{
int numprocs, myid;
int *temp = new int[sendcount];
int temp2;
MPI_Status status;
MPI_Comm_size(comm, &numprocs);
MPI_Comm_rank(comm, &myid);
if (myid == root)
{
for (int i = 0; i < numprocs; i++)
{
if (i != root)
{
MPI_Recv(sendbuf, recvcount, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, *sendbuf, &status);
for (int j = 0; j < recvcount; j++)
{
recvbuf[recvcount*i + j] = *temp;
}
}
recvbuf[root*recvcount] = *sendbuf;
}
}
else
{
MPI_Send(temp, sendcount, d1, root, 99, *recvbuf);
}
}
MPI 中最糟糕的事情是我无法调试这个函数,所以我会很感激任何建议 :)
解决方案
推荐阅读
- python - 不能禁止用户名中包含字母字符的数字
- html - 为什么有时需要使用 CSS 硬件加速来防止文本闪烁?
- twitter-bootstrap - 单击时更改引导下拉链接的背景颜色
- java - Java 2d 更改用户输入的值
- php - 使用 php 和 ajax 在 mysql 中更新 div,无需通过 timmer 重新加载
- python - 我的 guizero 代码的背景颜色没有更新
- reactjs - console.error:“使用有效负载导航的操作...未处理...”
- java - Java Stax如何仅获取特定子节点的值
- html - 引导滚动显示没有发生
- apache-spark - Spark Streaming 数据集