如何与在发送侧位移MPI

如何与在发送侧位移MPI

本文介绍了如何与在发送侧位移MPI_Gatherv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重组子阵的没有的有 MPI_Gatherv 暗灰色行。图片的千言万语:

I'm trying to recombine sub-arrays without the dark-grey rows with MPI_Gatherv. Picture's worth a thousand words:

你会如何发送 * sendbuf (中的),以根进程(无其他结构的浪费改写,这次没有暗灰色行)?在 *位移(第4个参数)只对相关的 * recvbuf 根的过程。

How would you send only parts of *sendbuf (the first parameter in MPI_Gatherv manual) to the root process (without a wasteful rewriting in another structure, this time without the dark-grey rows)? The *displacements (the 4th parameter) is only relevant to the *recvbuf of the root process.

感谢您。

我想也派边界(浅灰色)细胞......不只是内部(白色)细胞。由于 osgx 正确地指出:在这种情况下, MPI_Gatherv 足以...一些有条件的数组索引会做

I wanted to also send the "boundary" (light-grey) cells ... not just the "interior" (white) cells. As osgx correctly pointed out: in this case the MPI_Gatherv suffices ... some conditional array indexing will do it.

推荐答案

怎么样构建一个数据类型,这将允许您发送只有白色(室内)细胞?

What about constructing a datatype, which will allow you to send only white (Interior) cells?

合并(来源)数据类型可以是。

The combined (derived) datatype can be a MPI_Type_indexed.

唯一的问题将是非常第一线,并在过程中P0和PN最后一行,因为P1和PN应该发送更多的数据,那么P2 .... PN-1

The only problem will be with very first line and very last line in processes P0 and PN, because P1 and PN should send more data then P2....PN-1

有关内饰+边界就可以构造一个行的数据类型,以

For Interior+Boundary you can construct datatype of single "line" with

MPI_Datatype LineType;
MPI_Type_vector (1, row_number, 0 , MPI_DOUBLE, &LineType)
MPI_Type_commit ( &LineType);

然后(对数组的大小[I] [J]分裂为 stripecount 条纹)

for (i=0; i< processes_number; ++i) {
    displs[i] = i*(I/stripecount)+1; // point to second line in each stripe
    rcounts[i] = (I/stripecount) -2 ;
}
rcounts[0] ++; // first and last processes must send one line more
rcounts[processes_number-1] ++;
displs[0] -= 1; // first process should send first line of stripe
// lastprocess displacement is ok, because it should send last line  of stripe

source_ptr = ARRAY[displs[rank]];

lines_to_send = rcounts[rank];

MPI_Gatherv( source_ptr, lines_to_send, LineType, recv_buf, rcounts, displs, LineType, root, comm);

这篇关于如何与在发送侧位移MPI_Gatherv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 02:18