On Thursday 19 October 2006 11:30, Alex Esplin wrote:
> Eh? Somebody wanna enlighten a confused young whippersnapper that has
> no clue what is going on here but would like to learn something?
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);
}
}
- The 1st process will execute the loop 10 times, spawning 10 children. Call
them generation 1.
- Each of the 10 generation-1 children continue executing the loop, which at
this point has 9 iterations left to go, and thus they each spawn 9 children.
Call them generation 2.
- Each of the 90 generation-2 children continue executing the loop, which at
this point now has 8 iterations left to go, and thus they each spawn 8
children.
- etc.
gen. #-in-gen. each_spawn total-spawned total
0 1 10 10 11
1 10 9 90 101
2 90 8 270 371
3 270 7 1890 2261
4 1890 6 11340 13601
5 11340 5 56700 70301
6 56700 4 170100 240401
7 170100 3 340200 580601
8 340200 2 1360800 1941401
9 1360800 1 0
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/