MPI_AllToAllV导致MPI_ERR_TRUNCATE

时间:2014-04-03 07:01:19

标签: c++ parallel-processing mpi

我有以下MPI_AllToAllv电话。所有变量都是向量

MPI_Alltoallv(
        &elements[0],
        &send_counts[0],
        &send_displacements[0],
        MPI_INT,
        &receiving_vector[0],
        &receiving_counts[0],
        &receiving_displacements[0],
        MPI_INT,
        MPI_COMM_WORLD
         );

以下是载体的内容:

Elements : [6, 5, 4, ]
 @ 0
Elements : [3, 2, 1, ]
 @ 1
send_counts : [3, 0, ]
 @ 1
send_displacements : [0, 3, ]
 @ 1
 receiving_vector  : [0, 0, 0, ]
 @ 0
elements : [6, 5, 4, ]
 @ 0
send_counts : [0, 3, ]
 @ 0
send_displacements : [0, 0, ]
 @ 0
 receiving_vector  : [0, 0, 0, ]
 @ 1
receiving_counts : [0, 3, ]
 @ 1
receiving_displacements : [0, 0, ]
 @ 1
[lawn-143-215-98-238:1182] *** An error occurred in MPI_Alltoallv
[lawn-143-215-98-238:1182] *** reported by process [2332229633,0]
[lawn-143-215-98-238:1182] *** on communicator MPI_COMM_WORLD
[lawn-143-215-98-238:1182] *** MPI_ERR_TRUNCATE: message truncated
[lawn-143-215-98-238:1182] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
[lawn-143-215-98-238:1182] ***    and potentially your MPI job)
receiving_counts : [3, 0, ]
 @ 0
receiving_displacements : [0, 0, ]
 @ 0

我不明白为什么会收到此错误。任何帮助都将深表感谢。

我已经搜索了这个错误,它可能是我接收到的矢量大小但是我已经尝试了很多尺寸并且无法获得任何地方。

1 个答案:

答案 0 :(得分:2)

发送的数据量和接收的数据量不匹配。由于您只有两个等级,因此很容易绘制一个表格,其中包含了多少人以及向谁发送数据。表格的每一行都是相应等级send_counts[]的内容:

      receiver
s    | 0 | 1 |
e ---+---+---+
n  0 | 0 | 3 |  (send_counts[] @ 0)
d ---+---+---+
e  1 | 3 | 0 |  (send_counts[] @ 1)
r ---+---+---+

要匹配发送的数据量,每个等级的接收计数应该等于上表中对应于该等级的列向量:

    {li>

    receiving_counts[] @ 0{ 0, 3 } [3, 0, ];

    当您拥有receiving_counts[] @ 1时,
  • { 3, 0 }应为[0, 3, ]

因此截断错误。