[mpich-discuss] mpi_comm_spawn problem
Umit
umitcanyilmaz at gmail.com
Wed Feb 22 12:05:04 CST 2012
Hello All,
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.
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.
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.
How can I make mpi_comm_spawn to call the new processes with new crated
intracommunicator? Is this possible?
Here is my code and the output of my program:
*Code:*
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define NUM_SPAWNS 4
MPI_Comm comm;
MPI_Comm parentcomm, intercomm;
int np = NUM_SPAWNS;
int errcodes[4];
char argv[1];
int rank;
int main( int argc, char *argv[] )
{
MPI_Init( &argc, &argv );
MPI_Comm_get_parent( &parentcomm );
int i = atoi(argv[1]);
if (parentcomm == MPI_COMM_NULL)
{
argv[0] = "1";
MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np,
MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );
MPI_Intercomm_merge( intercomm, 0, &comm );
MPI_Comm_rank (comm, &rank);
printf("I am not spawned my rank is %d \n", rank);
}
else
{
MPI_Intercomm_merge( parentcomm, 1, &comm );
MPI_Comm_rank (comm, &rank);
printf("I am spawned at %d. call my rank is %d \n", i,
rank);
if (i==2) goto jump; ///Here secondly spawned processes
jump.
}
argv[0] = "2";
MPI_Comm_spawn( "/home/umit/Desktop/merge/./a.out", argv, np,
MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );
MPI_Intercomm_merge( intercomm, 0, &comm );
MPI_Comm_rank (comm, &rank);
jump:
MPI_Finalize();
return 0;
}
*Output is:
*
umit at ubuntu:~/Desktop/merge$ mpirun -np 4 ./a.out 0
I am spawned at 1. call my rank is 7
I am not spawned my rank is 3
I am spawned at 1. call my rank is 5
I am not spawned my rank is 1
I am spawned at 1. call my rank is 4
I am not spawned my rank is 2
I am spawned at 1. call my rank is 6
I am not spawned my rank is 0
I am spawned at 2. call my rank is 4
I am spawned at 2. call my rank is 6
I am spawned at 2. call my rank is 7
I am spawned at 2. call my rank is 5
I am spawned at 2. call my rank is 5
I am spawned at 2. call my rank is 4
I am spawned at 2. call my rank is 6
I am spawned at 2. call my rank is 7
Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20120222/939a6ae7/attachment.htm>
More information about the mpich-discuss
mailing list