[MPICH2-dev] Publish/Lookup

Denis Lima denisvl at uol.com.br
Tue May 16 15:54:12 CDT 2006


Hey Rob,

I'm running the following code, and the client does not find the service name "SERVER".
Thanks
Denis

//SERVER
#include <mpi.h>
#include <stdio.h>
int main ( int argc, char * argv[] )
{
 MPI_Comm newcomm; 
 char port_name [MPI_MAX_PORT_NAME];
 int test = 0;
 MPI_Status status;
 MPI_Init ( &argc, &argv );
 MPI_Open_port ( MPI_INFO_NULL, port_name ); 
 
 MPI_Publish_name ( "SERVER", MPI_INFO_NULL, port_name ); 
 
 MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &newcomm );
 MPI_Recv ( &test, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, &status );
 printf ( "%d", test );
 MPI_Unpublish_name ( "SERVER", MPI_INFO_NULL, port_name );
 MPI_Close_port ( port_name );
 
 MPI_Finalize ( );
 return 0;
}

//CLIENT
#include <mpi.h>
#include <stdio.h>
int main ( int argc, char * argv[] )
{
 MPI_Comm newcomm; 
 char port_name [MPI_MAX_PORT_NAME];
 int test = 1234; 
 MPI_Init ( &argc, &argv );
 MPI_Lookup_name ( "SERVER", MPI_INFO_NULL, port_name ); 
 MPI_Comm_connect ( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &newcomm ); 
 
 MPI_Send ( &test, 1, MPI_INT, 0, 1, MPI_COMM_WORLD );
 MPI_Comm_disconnect ( &newcomm );
 MPI_Close_port ( port_name );
 
 MPI_Finalize ( );
 return 0;
}
 



> On Tue, May 16, 2006 at 04:07:22PM -0300, Denis Lima wrote: 
> > Hello guys, 
> > 
> > I'm not been able to use the Publish_name/LookUp_name functions in 
> > MPICH2. Do you have any sample c code that works? 
> 
> 
> The 'server' has to do something like this: 
> 
> MPI_Comm newcomm; 
> char port_name[MPI_MAX_PORT_NAME]; 
> 
> MPI_Open_port(MPI_INFO_NULL, port_name); 
> MPI_Publish_name("port_name", MPI_INFO_NULL, port_name); 
> MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, comm, &newcomm); 
> 
> 
> And the 'client': 
> 
> MPI_Comm newcomm; 
> char port_name[MPI_MAX_PORT_NAME]; 
> 
> MPI_Lookup_name("port_name", MPI_INFO_NULL, port_name); 
> MPI_Comm_connect(port_name, MPI_INFO_NULL, 0, comm, &newcomm); 
> 
> 
> Naturally, use whatever you like instead of "port_name". Also, i've 
> omitted checking return values. You'll need an MPD ring up and running 
> for this to work. Can you elaborate on what is not working for you? 
> 
> ==rob 
> 
> -- 
> Rob Latham 
> Mathematics and Computer Science Division A215 0178 EA2D B059 8CDF 
> Argonne National Labs, IL USA B29D F333 664A 4280 315B 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mcs.anl.gov/mailman/private/mpich2-dev/attachments/20060516/08fbb4a2/attachment.htm>


More information about the mpich2-dev mailing list