On Thu, 2006-10-19 at 11:55 -0600, Jacob Fugal wrote:
> void main (int argc, char *argv[])
> {
> int myrank, size,x;
>
> MPI_Init(&argc, &argv); /* Initialize MPI */
>
> for(x = 0; x < 10; x++){
> if(fork() > 0){
> MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* Get my rank
> */
> MPI_Comm_size(MPI_COMM_WORLD, &size); /* Get the
> total number of
> processors */
> printf("Processor %d of %d: Running!\n", myrank, size);
> return;
> }
> }
> MPI_Finalize(); /* Terminate MPI */
> }
>
> There's no need for a parent flag because each child terminates
> immediately after doing its chores. And only the parent will ever make
> it all the way through the for loop and execute the MPI_Finalize call.That depends on what exactly MPI is. From the code I get the impression that it's a library that handles parallel execution, in which case the whole point is to have multiple processes fork off and remain running. If that's the case I believe my code is correct. It could also be that each child is supposed to run MPI_Finalize, signalling that it has exited and should no longer be included in the process pool. Googling around for MPI seems to indicate something along those lines. In the general case, you are correct. Corey
signature.asc
Description: This is a digitally signed message part
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
