【问题标题】:`MPI_ERR_TRUNCATE: message truncated` error [closed]`MPI_ERR_TRUNCATE:消息被截断`错误[关闭]
【发布时间】:2016-04-22 20:13:47
【问题描述】:

我遇到了一个类似于in this topic 讨论的问题,我有一个 MPI 代码,它对具有特定行数的向量的行求和。我附上the code here

当我尝试用一​​个核心在线编译mpirun -n 1 ./program时,我得到:

500000 sum 125000250000.00000 calculated by root process. The grand total is: 125000250000.00000 因为我只有一个计算总和的核心,所以看起来没问题。但是当我尝试使用多核 mpirun -n 4 ./program 时,我得到:

please enter the number of numbers to sum:
500000
[federico-C660:9540] *** An error occurred in MPI_Recv
[federico-C660:9540] *** on communicator MPI_COMM_WORLD
[federico-C660:9540] *** MPI_ERR_TRUNCATE: message truncated
[federico-C660:9540] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
 sum    7812562500.0000000       calculated by root process.
--------------------------------------------------------------------------
mpirun has exited due to process rank 1 with PID 9539 on
node XXXXX1 exiting without calling "finalize".

我也为 C 程序 here 红色了类似的问题。 2 和 3 处理器也是如此。

有人可以帮我找出问题所在吗?我的猜测是我在与“发送者”相关的 MPI_RECV 调用中犯了一个错误。

【问题讨论】:

  • 请在此处内联您的代码。如果它是 MCVE,它应该很容易适应。

标签: fortran mpi fortran90 gfortran openmpi


【解决方案1】:

代码中有几个问题;

  1. 最明显的问题是接收变量 num_rows_to_receive 的语法错误。您在 num_rows_to_received 中收到了由 root_process 计算的行,但使用变量 num_rows_to_receive 来实际接收向量。 CALL mpi_recv (num_rows_to_receive, 1 , mpi_integer, root_process, mpi_any_tag, mpi_comm_world, STATUS, ierr) CALL mpi_recv (vector2, num_rows_to_receive, mpi_real8, root_process, mpi_any_tag, mpi_comm_world, STATUS, ierr)

这应该可以解决错误。

  1. 第二个问题(至少我可以在我的系统上看到)是 MPI_REAL 数据类型默认为 MPI_REAL4 并且向量的大小被截断。所以我们将无法收到所有元素的实际总和。将 mpi_real 更改为 MPI_REAL8 将解决求和问题,您可以获得所有任意数量等级的准确求和值。 ~/temp$ mpirun -n 8 ./a.out please enter the number of numbers to sum: 500000 sum 1953156250.0000000 calculated by root process. partial sum 5859406250.0000000 returned from process 1 partial sum 9765656250.0000000 returned from process 2 partial sum 17578156250.000000 returned from process 4 partial sum 21484406250.000000 returned from process 5 partial sum 13671906250.000000 returned from process 3 partial sum 25390656250.000000 returned from process 6 partial sum 29296906250.000000 returned from process 7 The grand total is: 125000250000.00000

【讨论】:

  • 给我答案。非常感谢。我很感激。我可以说这个问题可以关闭,因为我收到了答案。非常感谢大家。
猜你喜欢
  • 2017-02-24
  • 2019-08-23
  • 2016-07-10
  • 1970-01-01
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
  • 1970-01-01
  • 2017-04-30
相关资源
最近更新 更多