1

我正在做 MPI 编程,使用它的功能对我来说有点不清楚。假设我有 4 个处理器,每个处理器都知道一个数组:

P0 : iarr{a0, a1, a2, a3}
P1 : iarr{b0, b1, b2, b3}
P2 : iarr{c0, c1, c2, c3}
P3 : iarr{d0, d1, d2, d3}

我想要另一个数组(oarr)获取这些值:

P0 : oarr{a0, b0, c0, d0}
P1 : oarr{a1, b1, c1, d1}
P2 : oarr{a2, b2, c2, d2}
P3 : oarr{a3, b3, c3, d3}

我知道这是一个经典示例或 MPI_Alltoall(),但我的代码不起作用。它会生成一些内存映射信息作为错误结果。

我正在用 C 编写代码,我的代码如下所示:

int *iarr = NULL, *oarr = NULL;
....
MPI_Alltoall(&iarr, P, MPI_INT, &oarr, P, MPI_INT, MPI_COMM_WORLD);

iarr 有一些值,而 oarr ahs 只有 0。我做对了吗?!http://stackoverflow.com/questions/ask

部分错误输出:

[NYPC:20583] *** Process received signal ***
[NYPC:20583] Signal: Segmentation fault (11)
[NYPC:20583] Signal code: Address not mapped (1)
[NYPC:20583] Failing at address: 0x2
[NYPC:20582] *** Process received signal ***
[NYPC:20582] Signal: Aborted (6)
[NYPC:20582] Signal code:  (-6)
[NYPC:20583] [ 0] [0xb77d940c]
[NYPC:20583] [ 1] ./ex31(votes_mpi+0x18e) [0x8048e38]
[NYPC:20583] [ 2] ./ex31(main+0x1c0) [0x8048b6c]
[NYPC:20583] [ 3] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb75684d3]
[NYPC:20582] [ 0] [0xb771740c]
[NYPC:20582] [ 1] [0xb7717424]
[NYPC:20582] [ 2] /lib/i386-linux-gnu/libc.so.6(gsignal+0x4f) [0xb74bb1df]
[NYPC:20582] [ 3] /lib/i386-linux-gnu/libc.so.6(abort+0x175) [0xb74be825]
[NYPC:20582] [ 4] /lib/i386-linux-gnu/libc.so.6(+0x6b39a) [0xb74f839a]
[NYPC:20582] [ 5] /lib/i386-linux-gnu/libc.so.6(+0x75ee2) [0xb7502ee2]
4

0 回答 0