使用mpi4py配置并行化的python脚本

我有一个使用mpi4py的
python脚本,名为main_parallel.py.我可以使用时间来测量cli的时间,但是,我如何制作类似于cProfile的配置文件?我想看看代码的每个部分的调用次数.我不能使用cProfile,因为它只用于串行代码.

谢谢!

最佳答案 你为什么不能使用cprofile?你有没有尝试过?

对于MPICH,我这样运行:

$mpiexec -l -np 4 python -m cProfile ./simple-io.py doodad 

这给了我4组输出,但’-l’参数列出了每个输出位前面的MPI排名.注意:’-l’参数是MPICH特定的. OpenMPI使用–tag-output.其他实现可能会使用其他东西.

我看到cprofile可以采用文件名参数.制作每个排名的输出文件,然后使用统计数据处理它

% python 
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pstats
>>> pstats.Stats("simple-io.cprofile").sort_stats('cumulative').print_stats()

给了我很多cprofile信息…但我的玩具程序太小了,不能给我任何有用的东西.

点赞