【发布时间】:2012-01-05 04:16:05
【问题描述】:
我目前正在为一个图论问题编写一些 MPI 代码,其中许多节点都可以包含一个答案和该答案的长度。为了让一切都回到主节点,我正在执行 MPI_Gather 以获得答案,并尝试使用 MPI_MINLOC 操作执行 MPI_Reduce 以确定谁拥有最短的解决方案。现在我存储长度和节点 ID 的数据类型被定义为(每个示例显示在许多网站上,如 http://www.open-mpi.org/doc/v1.4/man3/MPI_Reduce.3.php):
struct minType
{
float len;
int index;
};
在每个节点上,我以以下方式初始化此结构的本地副本:
int commRank;
MPI_Comm_rank (MPI_COMM_WORLD, &commRank);
minType solutionLen;
solutionLen.len = 1e37;
solutionLen.index = commRank;
在执行结束时,我有一个 MPI_Gather 调用,它成功提取了所有解决方案(我已从内存中将它们打印出来以验证它们),然后调用:
MPI_Reduce (&solutionLen, &solutionLen, 1, MPI_FLOAT_INT, MPI_MINLOC, 0, MPI_COMM_WORLD);
据我了解,论点应该是:
- 数据源
- 是结果的目标(仅在指定的根节点上有效)
- 每个节点发送的项目数
- 数据类型(MPI_FLOAT_INT 似乎是根据上面的链接定义的)
- 操作(似乎也定义了 MPI_MINLOC)
- 指定通讯组中根节点的ID
- 要等待的通信组。
当我的代码进入 reduce 操作时,我收到此错误:
[compute-2-19.local:9754] *** An error occurred in MPI_Reduce
[compute-2-19.local:9754] *** on communicator MPI_COMM_WORLD
[compute-2-19.local:9754] *** MPI_ERR_ARG: invalid argument of some other kind
[compute-2-19.local:9754] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
--------------------------------------------------------------------------
mpirun has exited due to process rank 0 with PID 9754 on
node compute-2-19.local exiting improperly. There are two reasons this could occur:
1. this process did not call "init" before exiting, but others in
the job did. This can cause a job to hang indefinitely while it waits
for all processes to call "init". By rule, if one process calls "init",
then ALL processes must call "init" prior to termination.
2. this process called "init", but exited without calling "finalize".
By rule, all processes that call "init" MUST call "finalize" prior to
exiting or it will be considered an "abnormal termination"
This may have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------
我承认我完全被这件事难住了。以防万一,我在基于 CentOS 5.5 的 Rocks 集群上使用 OpenMPI 1.5.3(使用 gcc 4.4 构建)进行编译。
【问题讨论】:
标签: c++ parallel-processing mpi