Hello All, <br><br>Thank you <span class="gD">Rajeev </span> for your e-mail. <br><br>My question is how to call mpi_spawn with a specific communicator. I dont know how to call it with comm? and I am not sure if it is possible. <br>
<br>If you mean changeing the parameter "&intercomm" with "&comm" in mpi_comm_spawn. It doesnt help. This parameter is not the name of calling communicator. It is the intercommunicator between original group and the
newly spawned group.I have to change the name of original group. <br><br>I even tried it and it did not help. Please tell me if I am doing something wrong. Here is <b>the new code and output:</b><br><br>#include "mpi.h"<br>
#include <stdio.h><br>#include <stdlib.h><br>#include <string.h><br>#include <stdint.h><br><br>#define NUM_SPAWNS 4<br> MPI_Comm comm, comm1;<br> MPI_Comm parentcomm, intercomm;<br> int np = NUM_SPAWNS; <br>
int errcodes[4];<br> char argv[1]; <br> int rank; <br>int main( int argc, char *argv[] )<br>{<br> MPI_Init( &argc, &argv );<br> MPI_Comm_get_parent( &parentcomm );<br> int i = atoi(argv[1]);<br>
<br> if (i==2){<br> MPI_Intercomm_merge( parentcomm, 1, &comm1 ); <br> goto jump; ///Here secondly spawned processes jump. <br> }<br><br> if (parentcomm == MPI_COMM_NULL)<br> {<br> argv[0] = "1"; <br>
MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );<br> MPI_Intercomm_merge( intercomm, 0, &comm );<br> } <br> else <br>
{<br> MPI_Intercomm_merge( parentcomm, 1, &comm ); <br> }<br> argv[0] = "2"; <br> MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &comm, errcodes );<br>
MPI_Intercomm_merge( comm, 0, &comm1 );<br><br> jump:<br> MPI_Comm_rank (comm1, &rank); <br> printf("I created at %d. call my rank is %d \n", i, rank);<br> <br> MPI_Finalize();<br> return 0;<br>
}<br><br><b>output:<br></b>umit@ubuntu:~/Desktop/merge$ mpirun -np 4 ./a.out 0<br>I created at 2. call my rank is 4 <br>I created at 0. call my rank is 0 <br>I created at 2. call my rank is 6 <br>I created at 0. call my rank is 2 <br>
I created at 2. call my rank is 5 <br>I created at 2. call my rank is 7 <br>I created at 0. call my rank is 3 <br>I created at 0. call my rank is 1 <br>I created at 1. call my rank is 3 <br>I created at 2. call my rank is 4 <br>
I created at 1. call my rank is 1 <br>I created at 1. call my rank is 0 <br>I created at 2. call my rank is 7 <br>I created at 2. call my rank is 6 <br>I created at 1. call my rank is 2 <br>I created at 2. call my rank is 5 <br>
<b><br></b>Best Regards, <br><br><br><br><br><br><br><div class="gmail_quote">On 22 February 2012 19:22, Rajeev Thakur <span dir="ltr"><<a href="mailto:thakur@mcs.anl.gov">thakur@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You need to call the second spawn with comm instead of intercomm.<br>
<div><div class="h5"><br>
On Feb 22, 2012, at 12:05 PM, Umit wrote:<br>
<br>
> Hello All,<br>
><br>
><br>
><br>
> I am running a mpi program with 4 processes and I am spawning 4 more processes and adding them in a new intracommunicator with mpi_intercomm_merge and having a intracommunicator with 8 processes. I am successful until this point.<br>
><br>
> And then I want to call with these 8 processes 4 new processes and add them in a new communicator and get 12 processes in my intracommunicator. But I couldn’t spawn the new processes with these 8 processes.<br>
><br>
> Spawned processes and other processes are calling mpi_comm_spawn separately. At first 4 processes are calling mpi_comm_spawn and then first spawned processes are calling mpi_comm_spawn and I am getting two intracommunicatiors each with 8 processes.<br>
><br>
> How can I make mpi_comm_spawn to call the new processes with new crated intracommunicator? Is this possible?<br>
><br>
><br>
><br>
> Here is my code and the output of my program:<br>
><br>
><br>
><br>
> Code:<br>
><br>
> #include "mpi.h"<br>
><br>
> #include <stdio.h><br>
><br>
> #include <stdlib.h><br>
><br>
> #include <string.h><br>
><br>
> #include <stdint.h><br>
><br>
><br>
> #define NUM_SPAWNS 4<br>
><br>
> MPI_Comm comm;<br>
><br>
> MPI_Comm parentcomm, intercomm;<br>
><br>
> int np = NUM_SPAWNS;<br>
><br>
> int errcodes[4];<br>
><br>
> char argv[1];<br>
><br>
> int rank;<br>
><br>
> int main( int argc, char *argv[] )<br>
><br>
> {<br>
><br>
> MPI_Init( &argc, &argv );<br>
><br>
> MPI_Comm_get_parent( &parentcomm );<br>
><br>
> int i = atoi(argv[1]);<br>
><br>
> if (parentcomm == MPI_COMM_NULL)<br>
><br>
> {<br>
><br>
> argv[0] = "1";<br>
><br>
> MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );<br>
><br>
> MPI_Intercomm_merge( intercomm, 0, &comm );<br>
><br>
> MPI_Comm_rank (comm, &rank);<br>
><br>
> printf("I am not spawned my rank is %d \n", rank);<br>
><br>
> }<br>
><br>
> else<br>
><br>
> {<br>
><br>
> MPI_Intercomm_merge( parentcomm, 1, &comm );<br>
><br>
> MPI_Comm_rank (comm, &rank);<br>
><br>
> printf("I am spawned at %d. call my rank is %d \n", i, rank);<br>
><br>
><br>
> if (i==2) goto jump; ///Here secondly spawned processes jump.<br>
><br>
> }<br>
><br>
> argv[0] = "2";<br>
><br>
> MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );<br>
><br>
> MPI_Intercomm_merge( intercomm, 0, &comm );<br>
><br>
> MPI_Comm_rank (comm, &rank);<br>
><br>
> jump:<br>
><br>
> MPI_Finalize();<br>
><br>
> return 0;<br>
><br>
> }<br>
><br>
><br>
> Output is:<br>
><br>
> umit@ubuntu:~/Desktop/merge$ mpirun -np 4 ./a.out 0<br>
><br>
> I am spawned at 1. call my rank is 7<br>
><br>
> I am not spawned my rank is 3<br>
><br>
> I am spawned at 1. call my rank is 5<br>
><br>
> I am not spawned my rank is 1<br>
><br>
> I am spawned at 1. call my rank is 4<br>
><br>
> I am not spawned my rank is 2<br>
><br>
> I am spawned at 1. call my rank is 6<br>
><br>
> I am not spawned my rank is 0<br>
><br>
> I am spawned at 2. call my rank is 4<br>
><br>
> I am spawned at 2. call my rank is 6<br>
><br>
> I am spawned at 2. call my rank is 7<br>
><br>
> I am spawned at 2. call my rank is 5<br>
><br>
> I am spawned at 2. call my rank is 5<br>
><br>
> I am spawned at 2. call my rank is 4<br>
><br>
> I am spawned at 2. call my rank is 6<br>
><br>
> I am spawned at 2. call my rank is 7<br>
><br>
><br>
><br>
><br>
> Best Regards,<br>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> mpich-discuss mailing list <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
<br>
_______________________________________________<br>
mpich-discuss mailing list <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
</blockquote></div><br>