Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating child process with MPI_Comm_spawn

Tags:

c

spawn

mpi

openmpi

Can someone explain why even when I set the number of process to more than 1 only two process child are created in the code below. Each MPI_Comm_spawn can create two child process using the code below, in the code used each process created with mpirun will call MPI_Comm_spawn once and will create 2 (#define NUM_SPAWNS 2) child process, so if I call N process then childs 2*N process child must be created. But this does not happen.

In the example below the number of the children must be 4 * 2 = 8. But...

for example:

:~$ mpirun -np 4 ./spawn_example

output:

I'm the parent.

I'm the parent.

I'm the parent.

I'm the parent.

I'm the spawned.

I'm the spawned.

The following sample code illustrates MPI_Comm_spawn.

like image 238
ericmoraess Avatar asked Aug 14 '26 11:08

ericmoraess


1 Answers

You seem to misunderstand what MPI_Comm_spawn does. It is a collective call and it does not spawn n additional processes per rank but rather it spawns a child MPI job with n processes, therefore adding n to the total number of processes. When called with n = 2, it spawn a child job with 2 processes and that's exactly what you observe in the output.

like image 164
Hristo Iliev Avatar answered Aug 17 '26 00:08

Hristo Iliev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!