Dear all,
I'm using the lam-6.5.9-3 (under Fedora core), and I'm trying to
make a program, that needs uses MPI_Comm_spawn (the program is just
below). But what I constated, is that it successfully create the first
process (under the rank 0, I think...) and the other processes created
under the others ranks, don't do anything. What I want exactly, is
create a program with some nodes (in the begin) and after that, every
process creates a child and every new process can act in the
MPI_COMM_WORLD, how can I do that ?
Thanks,
Gabriel
--
int main(int argc,char *argv[])
{
int myrank;
double starttime,endtime;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
switch(myrank) {
case 0:
slave(1);
break;
case 1:
slave(2);
break;
case 2:
slave(3);
break;
}
MPI_Finalize();
exit(0);
}
int slave (int number)
{
char command[] = "Program...";
char **argv;
int my_rank,ntasks;
int *errors;
char *lam_spawn_sched_round_robin
=(char*)"lam_spawn_sched_round_robin";
MPI_Comm child_communicator;
MPI_Info info;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size (MPI_COMM_WORLD, &ntasks);
MPI_Info_create(&info);
MPI_Info_set(info,"lam_spawn_sched_round_robin","n1");
/* I tried with info and MPI_INFO_NULL */
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
errors=(int *)malloc(sizeof(int)*ntasks );
memset(errors, -1, ntasks);
argv=(char **)malloc(2*sizeof(char *));
argv[0]=(char*)malloc(10*sizeof(char));
sprintf(argv[0],"%d",another_argument);
argv[1] = NULL;
MPI_Comm_spawn(command,MPI_ARGV_NULL,1,info,0,MPI_COMM_WORLD,&child_communicator,errors);
return(0);
}
and the Program called by the MPI_Comm_spawn is:
int main(int argc,char *argv[])
{
int my_rank;
MPI_Comm parent;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_get_parent(&parent);
//MPI_Intercomm_merge(MPI_COMM_WORLD,0,&parent);
/* I forgot, I tried to merged the communicators, father and child,
but didn't work */
exit(0);
}
|