I’m practicing with mpi exercises. In this one I must separate the static processes in two groups, odds and even. Then each group should create 2 processes. The thing is that if I only do that with one group (odd parents or even parents) it does work, but not with both of them. This is the fragment that is giving me trouble:
color = my_world_rank % 2;
// Creación de dos intracomunicadores: padres pares, padres impares
if (color == 0)
{
MPI_Comm_split(MPI_COMM_WORLD, color, my_world_rank, &intracom_padres_par);
MPI_Comm_rank(intracom_padres_par, &rank1);
// Creación dinámica de procesos hijos
MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 2, MPI_INFO_NULL, 0, intracom_padres_par, &intercom_padreshijos_pares, MPI_ERRCODES_IGNORE);
printf("Soy proceso %d global, dentro de los padres pares soy %d, en el intracomunicador de padres soy %d n", my_world_rank, rank1, rank2);
}
else
{
MPI_Comm_split(MPI_COMM_WORLD, color, my_world_rank, &intracom_padres_impar);
MPI_Comm_rank(intracom_padres_impar, &rank1);
// Creación dinámica de procesos hijos
MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 2, MPI_INFO_NULL, 0, intracom_padres_impar, &intercom_padreshijos_impares, MPI_ERRCODES_IGNORE);
printf("Soy proceso %d global, dentro de los padres impares soy %d, en el intracomunicador de padres soy %d n", my_world_rank, rank1, rank2);```
I've tried the code without the spawning and it works fine. I've read the documentation and it should be working but the program just freezes. With only one of the calls it works though ...
New contributor
Guille Luengo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.