Hello everyone,
I was dabbling with OpenMPI and decided to have a little fun by
modding a piece of sample code.

#include <stdio.h>
#include <mpi.h>

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);
        }
   }
   MPI_Finalize();                         /* Terminate MPI        */
}

This code looks harmless at first glance, but turns out it is idiotic,
however it took me a full on hour to figure out why.
Anyone wanna guess whats wrong?

Oh and yeah, don't try to compile this one at home. :)

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to