如何在MPI程序中使用ltrace? [英] How to use ltrace for mpi programs?
问题描述
我想知道如何使用ltrace来获取mpi应用程序的库函数调用,但是ltrace无法正常工作,并且我的mpirun无法成功. 有什么主意吗?
I want to know how to use ltrace to get library function calls of mpi application but simply ltrace doesn't work and my mpirun cannot succeed. Any idea?
推荐答案
您应该能够简单地使用:
You should be able to simply use:
$ mpiexec -n 4 -other_mpiexec_options ltrace ./executable
但是这将造成巨大的混乱,因为来自不同等级的输出将合并.更好的选择是将ltrace
的输出重定向到每个等级的单独文件.通过一些MPI实现,获得排名很容易.例如,Open MPI导出环境变量OMPI_COMM_WORLD_RANK
中的世界排名.以下包装器脚本将有所帮助:
But that will create a huge mess since the outputs from the different ranks will merge. A much better option is to redirect the output of ltrace
to a separate file for each rank. Getting the rank is easy with some MPI implementations. For example, Open MPI exports the world rank in the environment variable OMPI_COMM_WORLD_RANK
. The following wrapper script would help:
#!/bin/sh
ltrace --output trace.$OMPI_COMM_WORLD_RANK $*
用法:
$ mpiexec -n 4 ... ltrace_wrapper ./executable
这将产生4个跟踪文件,每个级别对应一个文件:trace.0
,trace.1
,trace.2
和trace.3
.
This will produce 4 trace files, one for each rank: trace.0
, trace.1
, trace.2
, and trace.3
.
对于基于MPICH和基于它的Hydra PM导出PMI_RANK
的其他MPI实现,必须修改上述给定脚本,并用PMI_RANK
替换OMPI_COMM_WORLD_RANK
.也可以编写一个通用包装器,用于两个MPI实现系列.
For MPICH and other MPI implementations based on it and using the Hydra PM exports PMI_RANK
and the above given script has to be modified and OMPI_COMM_WORLD_RANK
replaced with PMI_RANK
. One could also write an universal wrapper that works with both families of MPI implementations.
这篇关于如何在MPI程序中使用ltrace?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!