LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Brian W. Barrett (brbarret_at_[hidden])
Date: 2003-04-15 10:43:38


You are calling Isend one to many times - you use MPI_Comm_spawn() to
start (universe_size - 1) processes, which will give you the
intercommunicator everyone with a remote group of (universe_size - 1)
ranks. You then try to call MPI_Isend() universe_size times on that
communicator. So you are trying to send to a rank that doesn't exist
(giving the error message below).

Hope this helps,

Brian

On Thu, 10 Apr 2003, Sherif Abd El-Momen wrote:

> Hi!
>
> I am spawning a 3 slaves from a master program. I a sending a message to the
> slaves. I just print the communicated message.
> I recived the following result, I don't think the master finish his job.
>
> beolinc1 ~/MPI> mpirun -v -c 1 master
> 28812 master running on n0 (o)
> This MPI does not support UNIVERSE_SIZE. How many
> processes total?4
> MPI_Isend: invalid rank (rank 0, comm 2)
> myrank is 0 my buffer is 100.000000
> Rank (0, MPI_COMM_WORLD): Call stack within LAM:
> Rank (0, MPI_COMM_WORLD): - MPI_Isend()
> myrank is 1 my buffer is 101.000000
> Rank (0, MPI_COMM_WORLD): - main()
> myrank is 2 my buffer is 103.000000
>
> /********************* manager *****************/
> #include "mpi.h"
> int main(int argc, char *argv[])
> {
> double flag_buffer =100;
> MPI_Request Reqs[3];
> int rank,i,j;
> int world_size, universe_size, *universe_sizep, flag;
> MPI_Comm everyone; /* intercommunicator */
> char worker_program[100];
> MPI_Status status;
> MPI_Init(&argc, &argv);
> MPI_Comm_size(MPI_COMM_WORLD, &world_size);
> MPI_Comm_rank(MPI_COMM_WORLD,&rank);
> if (world_size != 1)
> perror("Top heavy with management");
>
> MPI_Attr_get(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE,
> &universe_sizep, &flag);
> flag =0;
> if (!flag)
> {
> printf("This MPI does not support UNIVERSE_SIZE. How many\n\
> processes total?");
> scanf("%d", &universe_size);
>
> }
> else
> universe_size = *universe_sizep;
> // printf("Universe_size = %d ",universe_size);
> if (universe_size == 1)
> perror("No room to start workers");
>
> /* choose_worker_program(worker_program);*/
> strcpy( worker_program, "/home/abdelmss/MPI/slave" );
> MPI_Comm_spawn(worker_program, MPI_ARGV_NULL, universe_size-1,
> MPI_INFO_NULL, 0, MPI_COMM_SELF, &everyone,
> MPI_ERRCODES_IGNORE);
>
> /* communication to slaves */
> for (i=0; i< universe_size; i++){
> flag_buffer+=i;
> MPI_Isend(&flag_buffer,
> sizeof(flag_buffer),MPI_DOUBLE,i,1,everyone,&Reqs[i]);
> }
> /* wait for each messge to be recived */
> for ( j=0;j < universe_size;j++){
> MPI_Wait(&Reqs[i],&status);
> }
> printf("my rank is %d ", rank);
>
> MPI_Comm_free(&everyone);
> MPI_Finalize();
>
> return 0;
> }
> /******************** worker *******************/
>
> #include "mpi.h"
> int main(int argc, char *argv[])
> { double flag_buffer=0;
> MPI_Status status;
> MPI_Request req;
> int size, rank;
> MPI_Comm parent;
> MPI_Init(&argc, &argv);
> MPI_Comm_get_parent(&parent);
> if (parent == MPI_COMM_NULL)
> perror("No parent!");
> MPI_Comm_remote_size(parent, &size);
> if (size != 1)
> perror("Something's wrong with the parent");
>
> MPI_Comm_rank(MPI_COMM_WORLD,&rank);
> MPI_Irecv(&flag_buffer,sizeof(flag_buffer),MPI_DOUBLE,0,1,parent,&req);
> MPI_Wait (&req,&status);
> printf( "myrank is %d my buffer is %f\n",rank , flag_buffer );
> MPI_Finalize();
> return 0;
> }
>
>
>
>
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>

-- 
  Brian Barrett
  LAM/MPI developer and all around nice guy
  Have a LAM/MPI day: http://www.lam-mpi.org/