next up previous contents
Next: Using logging and visualization Up: Debugging MPI programs Previous: Debugging MPI programs   Contents

Using print statements

Using print statements will work with a MPI program, as the output from all processes is sent back to the console. However, it can be hard to sort out the output from different processes. Using the -l option with mpiexec will tag each output line with the process number that it came from. See the example below.

[amit@node05 PBS ~/cs430/lab/MPI/parallel-sum]:mpiexec -n 4 spmd_sum_3 1000000
 I got 250000 from 0
Sending partial sum back: 250000
Sending partial sum back: 250000
Sending partial sum back: 250000
I got 250000 from 3
I got 250000 from 2
I got 250000 from 1
The total is 1000000. Time taken = 0.001284 seconds

[amit@node05 PBS ~/cs430/lab/MPI/parallel-sum]:mpiexec -l -n 4 spmd_sum_3 1000000
[2] Sending partial sum back: 250000
[3] Sending partial sum back: 250000
[1] Sending partial sum back: 250000
[0]  I got 250000 from 0
[0] I got 250000 from 2
[0] I got 250000 from 3
[0] I got 250000 from 1
[0] The total is 1000000. Time taken = 0.000842 seconds
[amit@node05 PBS ~/cs430/lab/MPI/parallel-sum]:



Amit Jain 2016-09-08