【发布时间】:2016-02-12 14:10:17
【问题描述】:
我有一个 MPI proc 的周期性笛卡尔网格,对于 4 个 proc,布局看起来像这样
__________________________
| | | |
| 0 | 1 | 2 |
|_______|________|_______ |
| | | |
| 3 | 4 | 5 |
|_______|________|________|
其中的数字是 proc 在通信器中的等级。 在计算过程中,所有proc'必须向其左邻居发送一个数字,并且该数字应与左邻居已经拥有的数字相加:
int a[2];
a[0] = calculateSomething1();
a[1] = calculateSomething2();
int tempA;
MPI_Request recv_request, send_request;
//Revceive from the right neighbour
MPI_Irecv(&tempA, 1, MPI_INT, myMPI.getRightNeigh(), 0, Cart_comm, &recv_request);
//Send to the left neighbour
MPI_Isend(&a[0], 1, MPI_INT, myMPI.getLeftNeigh(), 0, Cart_comm, &send_request);
MPI_Status status;
MPI_Wait(&recv_request, &status);
MPI_Wait(&send_request, &status);
//now I have to do something like this
a[1] += tempA;
我想知道是否有一种“本地”缩减操作仅适用于一对发送者-接收者,或者唯一的解决方案是拥有“本地”通信器并在那里使用集体操作?
【问题讨论】:
-
MPI-3 引入了邻居(稀疏)集合,但不包括归约。无论如何,这是一个使用
MPI_Sendrecv简单实现的操作。