Newsgroups: comp.parallel.mpi
From: eddemain@neumann.uwaterloo.ca (Erik Demaine)
Subject: Re: Killing MPI processes
Organization: University of Waterloo
Date: Wed, 6 Mar 1996 14:40:39 GMT
Message-ID: <Dnuors.Dzw@undergrad.math.uwaterloo.ca>

Peter Lindstrom (lindstro@cc.gatech.edu) wrote:
: I've got a scenario where I don't know at startup how many processes I need.
: Hence, I have to run a large number of processes, and later exclude some
: of these in the computation. Is there an elegant way of killing off these
: processes? If not, how do I put them to sleep indefinitely without having
: them eat up a lot of cycles (I'm running part of my program on an smp)?

: In order for MPI_Bcast() to work, I assume that I have to create a new
: process group (communicator) for the processes that are part of the computation
: (i.e. with the sleeping processes excluded). Is this the case, or is there a
: way to get around this?

You will have to create a new communicator, I imagine (I'm not sure how
MPI_Abort() will affect communicators) for doing collective communication.
This is not difficult at all!  Suppose each process has a flag should_die,
which is true iff the process wants to exit.  Then do this:

	MPI_Comm_split (MPI_COMM_WORLD, (should_die ? 1 : 0), 0, &comm);
	if (should_die)
	{
	   MPI_Abort (&comm, 0);
	   /* this may not work, depending on your implementation of MPI.
	    * you may want to try: MPI_Finalize ();
	    */
	}
	/* in the future, use comm instead of MPI_COMM_WORLD */

Good luck,
Erik
--
Erik Demaine                 \/  e-mail: eddemain@neumann.uwaterloo.ca
Dept. of Computer Science    /\  URL   : http://barrow.uwaterloo.ca/~eddemain/
University of Waterloo       \/  Most jugglers do poorly while drunk, especially
Waterloo, ON Canada N2L 3G1  /\  in a large wavelength gravity field.

