Hi guys.

I am interested in an example from OpenMPI, as  attachment: 
singleton_client_server.c.
So, I wrote another example. And some error happened.
My example includes two servers and one client. 
First, server1 runs. Second, client runs. server1 and client merge an new 
intra-comm. Next, server2 runs. server2 open a port, server1 and client want to 
connect server2. At the moment, some error happen. client and server2 block, 
and server1 has errors as following:


[datanode-2:06824] [[53818,0],0]:route_callback tried routing message from 
[[53818,1],0] to [[53822,1],0]:16, can't find route
[0] func:/usr/lib/libopen-pal.so.0(opal_backtrace_print+0x30) [0xb769fbc0]
[1] func:/usr/lib/openmpi/lib/openmpi/mca_rml_oob.so(+0x1bfd) [0xb748fbfd]
[2] func:/usr/lib/openmpi/lib/openmpi/mca_oob_tcp.so(+0x6cfa) [0xb7484cfa]
[3] func:/usr/lib/openmpi/lib/openmpi/mca_oob_tcp.so(+0x81c2) [0xb74861c2]
[4] func:/usr/lib/libopen-pal.so.0(+0x1aca4) [0xb7688ca4]
[5] func:/usr/lib/libopen-pal.so.0(opal_event_loop+0x25) [0xb7688ea5]
[6] func:/usr/lib/libopen-pal.so.0(opal_event_dispatch+0x1b) [0xb7688ecb]
[7] func:mpiexec() [0x804ac0a]
[8] func:mpiexec() [0x8049f4f]
[9] func:/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb74c14d3]
[10] func:mpiexec() [0x8049ea1] 


My code is attached.


Regards.
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "mpi.h"

int main( int argc, char **argv )
{
        MPI_Comm server,server2,newcomm,newcomm2,client2;
        FILE *fp ;
        char port_name[MPI_MAX_PORT_NAME];
        char port_name2[MPI_MAX_PORT_NAME];
        int size,rank;

        MPI_Init( &argc, &argv );
        
        fp = fopen("port_name.txt", "r") ;
        if(fp == NULL)
        {
        fprintf(stderr, "fopen failed: %s\n", strerror(errno)) ;
        exit(1) ;
        }
        fscanf(fp, "%s", port_name) ;
        fclose(fp) ;    
        
        printf("server port name:%s\n",port_name);
        
        MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&server );

        MPI_Intercomm_merge(server,11,&newcomm);
        MPI_Comm_rank(newcomm, &rank);
        MPI_Comm_size(newcomm, &size);
        printf("At client %d, newcomm_size=%d\n",rank,size);

        MPI_Barrier(newcomm);
        
        fp = fopen("port_name.txt", "r") ;
        if(fp == NULL)
        {
        fprintf(stderr, "fopen failed: %s\n", strerror(errno)) ;
        exit(1) ;
        }
        fscanf(fp, "%s", port_name2) ;
        fclose(fp) ;    
        
        printf("server port name:%s\n",port_name2);
        
        MPI_Comm_connect( port_name2, MPI_INFO_NULL, 0, newcomm,&server2 
);//BLOCK here!!!

        MPI_Intercomm_merge(server2,12,&newcomm2);
        MPI_Comm_rank(newcomm2, &rank);
        MPI_Comm_size(newcomm2, &size);
        printf("At client %d, newcomm_size=%d\n",rank,size);

sleep(10);
        MPI_Comm_disconnect( &server );
        MPI_Finalize();
        return 0;
}


#include "mpi.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
        MPI_Comm client, client2, newcomm, newcomm2;
        MPI_Status status;
        FILE *fp ;
        char port_name[MPI_MAX_PORT_NAME];
        char port_name2[MPI_MAX_PORT_NAME];
        int size, again, rank, myrank;

        MPI_Init(&argc, &argv);
        MPI_Comm_rank(MPI_COMM_WORLD,&myrank);

        MPI_Open_port(MPI_INFO_NULL, port_name);
        printf("At server %d, port_name is %s\n\n",myrank, port_name);
        
        /* store the port name */
        fp = fopen("port_name.txt", "w") ;
        if(fp == NULL)
        {
                fprintf(stderr, "fopen failed: %s\n", strerror(errno)) ;
                exit(1) ;
        }
        fprintf(fp, "%s", port_name) ;
        fclose(fp) ;    
        
        MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD,&client);
        
        MPI_Intercomm_merge(client,11,&newcomm);
        MPI_Comm_rank(newcomm, &rank);
        MPI_Comm_size(newcomm, &size);
        printf("At server %d, newcomm_size=%d\n",rank,size);

    sleep(10);    
        MPI_Barrier(newcomm);   
        
        fp = fopen("port_name.txt", "r") ;
        if(fp == NULL)
        {
                fprintf(stderr, "fopen failed: %s\n", strerror(errno)) ;
                exit(1) ;
        }
        fscanf(fp, "%s", port_name2) ;
        fclose(fp) ;    
        
        printf("At server %d, port_name is %s\n\n",rank, port_name2);
        
        MPI_Comm_connect(port_name2, MPI_INFO_NULL, 0, 
newcomm,&client2);//Error happenned !!!

        MPI_Intercomm_merge(client2,12,&newcomm2);
        MPI_Comm_rank(newcomm2, &rank);
        MPI_Comm_size(newcomm2, &size);
        printf("At server %d, newcomm_size=%d\n",rank,size);
        
        MPI_Barrier(newcomm2);

        MPI_Close_port(port_name);
        MPI_Comm_disconnect(&client);
        MPI_Close_port(port_name2);
        MPI_Comm_disconnect(&client2);

        MPI_Finalize();
        return 0;
}
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "mpi.h"

int main( int argc, char **argv )
{
        MPI_Comm client,newcomm;
        FILE *fp;
        char port_name[MPI_MAX_PORT_NAME];
        int size,rank,myrank;
        int e;

        MPI_Init( &argc, &argv );
        MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
        
        e=MPI_Open_port(MPI_INFO_NULL, port_name);
        printf("At server2 %d, MPI_MAX_PORT_NAME=%d, port_name is 
%s\n\n",myrank,MPI_MAX_PORT_NAME, port_name);
                
        /* store the port name */
        fp = fopen("port_name.txt", "w") ;
        if(fp == NULL)
        {
                fprintf(stderr, "fopen failed: %s\n", strerror(errno)) ;
                exit(1) ;
        }
        fprintf(fp, "%s", port_name) ;
        fclose(fp) ;    
                
        
        MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, 
MPI_COMM_WORLD,&client);//BLOCK here!!!

        MPI_Intercomm_merge(client,12,&newcomm);

sleep(10);
        MPI_Barrier(newcomm);
        
        MPI_Close_port(port_name);
        MPI_Comm_disconnect( &client );
        MPI_Finalize();
        return 0;
}


Reply via email to