hi!
I have a problem spawning processes. In MPI standerd it mentioned that
MPI_Comm_spawn is a collective operation. so as I understand all the parent
group should call MPI_Comm_spawn. I want to create one process at a time.
but when th parents group call the spawn function. a number of processes is
created not one. is it a bug or I am doing something wrong. Please advice it
is very urgent for me. here is the result of my code followed with the code.
/***** Result section **************/
beolinc1 ~/MPI> mpirun -v -c 4 master
18943 master running on n0 (o)
18944 master running on n0 (o)
20015 master running on n1
20016 master running on n1
the process have been created
size 2
the master exit
the slave are exiting, my rank 1 the world size 2
the process have been created
size 2
the master exit
the process have been created
size 2
the slave are exiting, my rank 1 the world size 2
the master exit
the process have been created
size 2
the master exit
/***************************************/
/**************Code *********************/
/* manager */
#include "mpi.h"
int main(int argc, char *argv[])
{
char * myargv[6];
char processor_name[MPI_MAX_PROCESSOR_NAME],controlmsg[CMDSIZE];
int namelen,rank, world_size, universe_size, *universe_sizep, flag;
MPI_Comm everyone; /* intercommunicator */
MPI_Comm Simulation;
int size;
char worker_program[100];
MPI_Init(&argc, &argv);
strcpy( worker_program, "/home/abdelmss/MPI/slave" );
MPI_Comm_spawn(worker_program,MPI_ARGV_NULL,1 ,
MPI_INFO_NULL, 0, MPI_COMM_SELF, &everyone,
MPI_ERRCODES_IGNORE);
printf ("the process have been created\n");
MPI_Intercomm_merge(everyone,0,&Simulation);
MPI_Comm_size( Simulation, &size );
printf ("size %d \n ",size);
printf ("the master exit\n");
MPI_Finalize();
return 0;
}
/* worker */
#include "mpi.h"
#define CMDSIZE 80
#include <lam_ksignal.h>
int main(int argc, char *argv[])
{ int namelen,i;
char processor_name[MPI_MAX_PROCESSOR_NAME];
int size,rank;
MPI_Comm parent;
MPI_Comm Simulation;
char worker_program[100];
MPI_Init(&argc, &argv);
MPI_Comm_get_parent(&parent);
MPI_Intercomm_merge(parent,1,&Simulation);
MPI_Comm_size(Simulation, &size);
MPI_Comm_rank( Simulation, &rank );
printf ("the slave are exiting, my rank %d the world size %d
\n",rank,size);
MPI_Finalize();
return 0;
}
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
|