Closed
Description
Here is the issue I encountered.
In the git main
branch, using ompi-tests-public/singleton
I got:
x@x:~/github/test/ompi-tests-public/singleton$ make
mpicc hello_c.c -Wall -g -O0 -o hello_c
mpicc simple_spawn.c -Wall -g -O0 -o simple_spawn
mpicc simple_spawn_multiple.c -Wall -g -O0 -o simple_spawn_multiple
x@x:~/github/test/ompi-tests-public/singleton$ ompi_info --version
Open MPI v5.1.0a1
https://www.open-mpi.org/community/help/
x@x:~/github/test/ompi-tests-public/singleton$ ./run.sh
=====================
Testing: Hello with mpirun
=====================
0/ 1) [x] 548449 Hello, world!
=====================
Testing: Hello as a singleton
=====================
0/ 1) [x] 548451 Hello, world!
=====================
Testing: MPI_Comm_spawn with mpirun
=====================
Spawning './simple_spawn' ... OK
=====================
Testing: MPI_Comm_spawn as a singleton
=====================
Spawning './simple_spawn' ... OK
=====================
Testing: MPI_Comm_spawn_multiple with mpirun
=====================
Hello from a Child (B)
Hello from a Child (A)
Hello from a Child (B)
Spawning Multiple './simple_spawn_multiple' ... OK
=====================
Testing: MPI_Comm_spawn_multiple as a singleton
=====================
Spawning Multiple './simple_spawn_multiple' ... OK
=====================
Success
=====================
Note that the output of MPI_Comm_spawn_multiple
singleton
is different from mpirun
.
Further testing
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
MPI_Comm parent_comm, intercomm;
int world_rank, world_size;
MPI_Init(&argc, &argv);
MPI_Comm_get_parent(&parent_comm);
if (parent_comm == MPI_COMM_NULL) {
// I am the parent
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
printf("Parent: rank %d out of %d\n", world_rank, world_size);
// Spawn a child processes
MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, 1,
MPI_INFO_NULL, 0, MPI_COMM_WORLD,
&intercomm, MPI_ERRCODES_IGNORE);
// Receive message from child rank 0
char buf[128];
MPI_Recv(buf, 128, MPI_CHAR, 0, 0, intercomm, MPI_STATUS_IGNORE);
printf("Parent: received message: %s\n", buf);
} else {
// I am the child
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
printf("Child: rank %d out of %d\n", world_rank, world_size);
char msg[128];
snprintf(msg, sizeof(msg), "Hello from child rank %d!", world_rank);
// Send message to parent (rank 0 in parent group)
MPI_Send(msg, strlen(msg) + 1, MPI_CHAR, 0, 0, parent_comm);
printf("Child rank %d sent message\n", world_rank);
}
MPI_Finalize();
return 0;
}
Output of the above program:
Parent: rank 0 out of 1
Parent: received message: Hello from child rank 0!
I suspect that IO forwarding may not be functioning as expected in the above scenario, and further testing is needed.
Metadata
Metadata
Assignees
Labels
No labels