Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] MPI_Lookup_name error
From: Alberto Giannetti (albertogiannetti_at_[hidden])
Date: 2008-04-27 20:58:27


I am having error using MPI_Lookup_name. The same program works fine
when using MPICH:

/usr/local/bin/mpiexec -np 2 ./client myfriend
Processor 0 (662, Sender) initialized
Processor 0 looking for service myfriend-0
Processor 1 (664, Sender) initialized
Processor 1 looking for service myfriend-1
[local:00662] *** An error occurred in MPI_Lookup_name
[local:00662] *** on communicator MPI_COMM_WORLD
[local:00662] *** MPI_ERR_NAME: invalid name argument
[local:00662] *** MPI_ERRORS_ARE_FATAL (goodbye)
[local:00664] *** An error occurred in MPI_Lookup_name
[local:00664] *** on communicator MPI_COMM_WORLD
[local:00664] *** MPI_ERR_NAME: invalid name argument
[local:00664] *** MPI_ERRORS_ARE_FATAL (goodbye)

int main(int argc, char* argv[])
{
   int rank, i;
   float data[100];
   char cdata[64];
   char myport[MPI_MAX_PORT_NAME];
   char myservice[64];
   MPI_Comm intercomm;
   MPI_Status status;
   int intercomm_size;

   MPI_Init(&argc, &argv);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   printf("Processor %d (%d, Sender) initialized\n", rank, getpid());

   if( argc < 2 ) {
     fprintf(stderr, "Require server name\n");
     MPI_Finalize();
     exit(-1);
   }

   for( i = 0; i < 100; i++ )
     data[i] = i;

   sprintf(myservice, "%s-%d", argv[1], rank);
   printf("Processor %d looking for service %s\n", rank, myservice);
   MPI_Lookup_name(myservice, MPI_INFO_NULL, myport);
   printf("Processor %d found port %s looking for service %s\n",
rank, myport, myservice);

   while( 1 ) {
     printf("Processor %d connecting to '%s'\n", rank, myport);
     if( MPI_Comm_connect(myport, MPI_INFO_NULL, 0, MPI_COMM_SELF,
&intercomm) == MPI_SUCCESS )
       break;
     sleep(1);
   }
   printf("Processor %d connected\n", rank);

   MPI_Comm_remote_size(intercomm, &intercomm_size);
   printf("Processor %d remote comm size is %d\n", rank,
intercomm_size);

   printf("Processor %d sending data through intercomm to rank 0...
\n", rank);
   MPI_Send(data, 100, MPI_FLOAT, 0, rank, intercomm);
   printf("Processor %d data sent!\n", rank);
   MPI_Recv(cdata, 12, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG,
intercomm, &status);
   printf("Processor %d received string data '%s' from rank %d, tag %d
\n", rank, cdata, status.MPI_SOURCE, status.MPI_TAG);

   sleep(5);

   printf("Processor %d disconnecting communicator\n", rank);
   MPI_Comm_disconnect(&intercomm);
   printf("Processor %d finalizing\n", rank);

   MPI_Finalize();
   printf("Processor %d Goodbye!\n", rank);
}