LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2003-04-16 07:31:51


On Tue, 15 Apr 2003 seberino_at_[hidden] wrote:

> Thanks for your answers. I took careful notes.

:-)

> Can I ask you another question???

It'll cost you; I assume you have my Swiss bank account numbers. ;-)

> I have old MPI code hardwired for 4 node computers.

A common mistake: ensure that you distinguish between "nodes" and "MPI
processes". You can have more than one MPI process on a given node.
Hence, I'd be willing to bet that you really meant that your code was
hardwired to run on 4 processes...?

> If I define a couple of new "communicators" of 4 nodes each, can I run
> lots of 4 node runs simultaneously by just replacing mpi_comm_world with
> the new communicators?
>
> e.g. mpirun -np 12 new_program
>
> I can get 3 independent "4 node calculations" from this command line by
> just changing mpi_comm argument in the old MPI commands!!!

Let me ensure that I understand what you're asking:

- old_program is hardwired to work for 4 processes
- old_program uses MPI_COMM_WORLD for all comm arguments
- you want to slightly change old_program (into new_program) to take a
  variable argument for comm arguments (i.e., not MPI_COMM_WORLD)
- then use "mpirun -np 12 new_program" to effectively run 3 sets of the
  old_program

Yes, this is certainly do-able. You could use MPI_COMM_SPLIT to split
MPI_COMM_WORLD into 3 sub-communicators.

However, to do this, you'll need to add a little additional book-keeping
in your code. i.e., stuff like:

- each rank in MPI_COMM_WORLD needs to figure out which set it is in
  (pretty easy, actually, it's just size_of_comm_world / 4)
- do an MPI_COMM_SPLIT with that number as the color
- the harder part: figure out the input/output for that set. i.e., I
  guess/assume that you have inputs and outputs for the program. With
  old_program, there was simply one set of input/output. With
  new_program, you need to multiplex somehow such that MPI_COMM_WORLD
  ranks 0-3 get the first set of input and generate the first set of
  output, MCW ranks 4-7 get the second set of input and generate the
  second set of output, etc.

None of this is particularly hard to do, but it is additional
complexity that you'll need to add to your program. And while you do
get a slightly more generalized program as a result, it isn't really
much value-added, actually -- you can effect the same thing with:

    mpirun c0-3 old_program ...args...
    mpirun c4-7 old_program ...args...
    mpirun c8-11 old_program ...args...

You might want to look at the MPI tutorials that are available on the
web. We have a decent one on the LAM/MPI web site; NCSA has an
*excellent* one on their web site. Both are available under
http://www.lam-mpi.org/tutorials/.

Hope this helps.

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/