Why can't you use cprofile? Have you tried?
For MPICH, I ran like this:
$ mpiexec -l -np 4 python -m cProfile ./simple-io.py doodad
This gives me 4 sets of output, but the '-l' argument lists the MPI rank in front of each bit of output. Note: that '-l' argument is MPICH specific. OpenMPI uses --tag-output
. Other implementations might use something else.
I see cprofile can take a file name argument. make a per-rank output file and then process it with the Stats
% 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()
gives me lots of cprofile information... but my toy program was too tiny to give me anything useful.