$subject_val = "Re: [OMPI users] Open specific port TCP/IP in MPI"; include("../../include/msg-header.inc"); ?>
Subject: Re: [OMPI users] Open specific port TCP/IP in MPI
From: Nulik Nol (nuliknol_at_[hidden])
Date: 2009-06-27 11:34:55
On Fri, Jun 26, 2009 at 6:25 PM, Ralph Castain<rhc_at_[hidden]> wrote:
> Not sure I understand the problem. Your server will have the ability to recv
this is what i wanted. feel free to add to the FAQ. In the TODO list
is still remove the step of copying of the URI from one machine to
another, but that can be done later. This works only from version 1.3
and up. Regards
[root_at_niko code]# cat server.c
#include <stdio.h>
#include <mpi.h>
int main(int argc,char *argv[]){
int size;
char port_name[MPI_MAX_PORT_NAME],data[256],message[5]="pong\0";
MPI_Comm client; MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size != 1) {printf("only one process is accepted\n"); return(1);}
MPI_Open_port(MPI_INFO_NULL, port_name);
printf("server: listening on port %s\n",port_name);
MPI_Publish_name("myserver", MPI_INFO_NULL, port_name);
MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&client );
MPI_Recv( data,256,MPI_CHAR,MPI_ANY_SOURCE, MPI_ANY_TAG, client, &status );
printf("server: %s\n",data);
MPI_Send(message,5,MPI_CHAR,0,2,client);
MPI_Comm_disconnect( &client );
MPI_Finalize();
}
[root_at_niko code]# cat client.c
#include <stdio.h>
#include "mpi.h"
int main( int argc, char **argv )
{
MPI_Comm server; MPI_Status status;
char port_name[MPI_MAX_PORT_NAME],data[256],message[5]="ping\0";
MPI_Init( &argc, &argv );
MPI_Lookup_name("myserver", MPI_INFO_NULL, port_name);
MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF,
&server);
MPI_Send( message, 5, MPI_CHAR, 0, 1, server );
MPI_Recv( data,256,MPI_CHAR,MPI_ANY_SOURCE, MPI_ANY_TAG, server, &status );
printf("client: %s\n",data);
MPI_Comm_disconnect( &server );
MPI_Finalize();
}
[root_at_niko code]# mpicc -I/usr/include/openmpi/1.2.4-gcc/
-L/usr/lib64/openmpi/1.2.4-gcc -lmpi -o server server.c
[root_at_niko code]# mpicc -I/usr/include/openmpi/1.2.4-gcc/
-L/usr/lib64/openmpi/1.2.4-gcc -lmpi -o client client.c
[root_at_niko code]# scp client root_at_192.168.1.63:/root
client 100%
9645 9.4KB/s 00:00
[root_at_niko code]# ompi-server -r ompi-server.uri
[root_at_niko code]# cat ompi-server.uri
258080768.0;tcp://192.168.1.64:48683
[root_at_niko code]# mpirun -np 1 -ompi-server $(cat ompi-server.uri) ./server &
[1] 24079
[root_at_niko code]# server: listening on port
257949696.0;tcp://192.168.1.64:58284+257949697.0;tcp://192.168.1.64:59326:300
[root_at_niko code]# ssh -l root 192.168.1.63
Last login: Sat Jun 27 23:17:24 Local time zone must be set--see zic
manual page 2009 from n64 on ssh
master ~ # mpirun -np 1 -ompi-server
'258080768.0;tcp://192.168.1.64:48683' ./client
server: ping
client: pong
master ~ #