Немања Илић (Nemanja Ilic) wrote:
> Dear Sir or Madam,
> 
> I am about to start a project that includes MPI communication. My question 
> is: "Is there a way to debug parallel OpenMPI applications on linux in 
> console mode on one computer using gdb?"
> 

Yes, you can run MPI programs with numproc > 1 on a single node. After
the job starts, you can then use gdb to attach one of the running
processes by specifying the processID of the process you want to attach to:

gdb <PID>

If you want to know which PID corresponds to which rank, it can be
helpful to have each rank print their rank and PID to STDOUT as soon as
they startup, then have them sleep for a little while so have time to
attach the debugger to the process before the fun starts.

You can do this for every MPI process you want to watch how they
interact. However, if you are working on the console, you'll be limited
to the number of virtual consoles.

And while we're talkingdebugging, never underestimate the power of the
printf command. printf works great for MPI programs, too. You just need
to specify the rank of the process in the printf string so you can keep
track of who's doing what when the error occurs.

I use something like this:

#ifdef DEBUG
        printf("Rank %i: sending to rank %i\n", my_rank, other_rank);
#endif

MPI_Send(arg1 arg2,,,,);


It's not fancy, it's not high-tech, but it works.

-- 
Prentice

Reply via email to