-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/channels/sock/src/ch3_init.c
        -:    0:Graph:ch3_init.gcno
        -:    0:Data:ch3_init.gcda
        -:    0:Runs:4381
        -:    0:Programs:1376
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    2:/*
        -:    3: *  (C) 2001 by Argonne National Laboratory.
        -:    4: *      See COPYRIGHT in top-level directory.
        -:    5: */
        -:    6:
        -:    7:#include "mpidi_ch3_impl.h"
        -:    8:
        -:    9:/* Define the ABI version of this channel.  Change this if the channel
        -:   10:   interface (not just the implementation of that interface) changes */
        -:   11:char MPIDI_CH3_ABIVersion[] = "1.1";
        -:   12:
        -:   13:/*
        -:   14: *  MPIDI_CH3_Init  - makes socket specific initializations.  Most of this 
        -:   15: *                    functionality is in the MPIDI_CH3U_Init_sock upcall 
        -:   16: *                    because the same tasks need to be done for the ssh 
        -:   17: *                    (sock + shm) channel.  
        -:   18: */
        -:   19:
        -:   20:#undef FUNCNAME
        -:   21:#define FUNCNAME MPIDI_CH3_Init
        -:   22:#undef FCNAME
        -:   23:#define FCNAME MPIDI_QUOTE(FUNCNAME)
        -:   24:int MPIDI_CH3_Init(int has_parent, MPIDI_PG_t * pg_p, int pg_rank )
     4381:   25:{
     4381:   26:    int mpi_errno = MPI_SUCCESS;
     4381:   27:    char *publish_bc_orig = NULL;
     4381:   28:    char *bc_val = NULL;
        -:   29:    int val_max_remaining;
        -:   30:    MPIDI_STATE_DECL(MPID_STATE_MPID_CH3_INIT);
        -:   31:
        -:   32:    MPIDI_FUNC_ENTER(MPID_STATE_MPID_CH3_INIT);
        -:   33:
     4381:   34:    mpi_errno = MPIDI_CH3I_Progress_init();
     4381:   35:    if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
        -:   36:
        -:   37:    /* Initialize the business card */
     4381:   38:    mpi_errno = MPIDI_CH3I_BCInit( &bc_val, &val_max_remaining );
     4381:   39:    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     4381:   40:    publish_bc_orig = bc_val;
        -:   41:
        -:   42:    /* initialize aspects specific to sockets  */
     4381:   43:    mpi_errno = MPIDI_CH3U_Init_sock(has_parent, pg_p, pg_rank,
        -:   44:				     &bc_val, &val_max_remaining);
        -:   45:
        -:   46:    /* Set the connection information in our process group 
        -:   47:       (publish the business card ) */
     4381:   48:    MPIDI_PG_SetConnInfo( pg_rank, (const char *)publish_bc_orig );
        -:   49:
        -:   50:    /* Free the business card now that it is published
        -:   51:     (note that publish_bc_orig is the head of bc_val ) */
     4381:   52:    MPIDI_CH3I_BCFree( publish_bc_orig );
        -:   53:
     4381:   54:    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        -:   55:
     4381:   56: fn_exit:
        -:   57:    MPIDI_FUNC_EXIT(MPID_STATE_MPID_CH3_INIT);
     4381:   58:    return mpi_errno;
    #####:   59: fn_fail:
    #####:   60:    if (publish_bc_orig != NULL) {
    #####:   61:        MPIU_Free(publish_bc_orig);
        -:   62:    }           
        -:   63:    goto fn_exit;
        -:   64:}
        -:   65:
        -:   66:/* This function simply tells the CH3 device to use the defaults for the 
        -:   67:   MPI Port functions */
        -:   68:int MPIDI_CH3_PortFnsInit( MPIDI_PortFns *portFns ATTRIBUTE((unused)) ) 
      467:   69:{
        -:   70:    MPIU_UNREFERENCED_ARG(portFns);
      467:   71:    return 0;
        -:   72:}
        -:   73:
        -:   74:/* This function simply tells the CH3 device to use the defaults for the 
        -:   75:   MPI-2 RMA functions */
        -:   76:int MPIDI_CH3_RMAFnsInit( MPIDI_RMAFns *a ATTRIBUTE((unused)) ) 
    #####:   77:{
        -:   78:    MPIU_UNREFERENCED_ARG(a);
    #####:   79:    return 0;
        -:   80:}
        -:   81:
        -:   82:/* Perform the channel-specific vc initialization */
    25152:   83:int MPIDI_CH3_VC_Init( MPIDI_VC_t *vc ) {
    25152:   84:    MPIDI_CH3I_VC *vcch = (MPIDI_CH3I_VC *)vc->channel_private;
    25152:   85:    vcch->sendq_head         = NULL;
    25152:   86:    vcch->sendq_tail         = NULL;
    25152:   87:    vcch->state              = MPIDI_CH3I_VC_STATE_UNCONNECTED;
    25152:   88:    MPIDI_VC_InitSock( vc );
        -:   89:    MPIU_DBG_MSG_P(CH3_CONNECT,TYPICAL,"vc=%p: Setting state (ch) to VC_STATE_UNCONNECTED (Initialization)", vc );
    25152:   90:    return 0;
        -:   91:}
        -:   92:
        -:   93:const char * MPIDI_CH3_VC_GetStateString( struct MPIDI_VC *vc )
    #####:   94:{
        -:   95:#ifdef USE_DBG_LOGGING
        -:   96:    return MPIDI_CH3_VC_SockGetStateString( vc );
        -:   97:#else
    #####:   98:    return "unknown";
        -:   99:#endif
        -:  100:}
        -:  101:
        -:  102:/* Select the routine that uses sockets to connect two communicators
        -:  103:   using a socket */
        -:  104:int MPIDI_CH3_Connect_to_root(const char * port_name, 
        -:  105:			      MPIDI_VC_t ** new_vc)
      669:  106:{
      669:  107:    return MPIDI_CH3I_Connect_to_root_sock( port_name, new_vc );
        -:  108:}
        -:  109:
        -:  110:/* This routine is a hook for initializing information for a process
        -:  111:   group before the MPIDI_CH3_VC_Init routine is called */
        -:  112:int MPIDI_CH3_PG_Init( MPIDI_PG_t *pg ATTRIBUTE((unused)) )
     6367:  113:{
     6367:  114:    return MPI_SUCCESS;
        -:  115:}
        -:  116:
        -:  117:/* This routine is a hook for any operations that need to be performed before
        -:  118:   freeing a process group */
        -:  119:int MPIDI_CH3_PG_Destroy( struct MPIDI_PG *pg ATTRIBUTE((unused)) )
     6360:  120:{
     6360:  121:    return MPI_SUCCESS;
        -:  122:}
        -:  123:
        -:  124:/* This routine is a hook for any operations that need to be performed before
        -:  125:   freeing a virtual connection */
        -:  126:int MPIDI_CH3_VC_Destroy( struct MPIDI_VC *vc ATTRIBUTE((unused)) )
    25138:  127:{
    25138:  128:    return MPI_SUCCESS;
        -:  129:}
        -:  130:
        -:  131:/* A dummy function so that all channels provide the same set of functions, 
        -:  132:   enabling dll channels */
        -:  133:int MPIDI_CH3_InitCompleted( void )
     4381:  134:{
     4381:  135:    return MPI_SUCCESS;
        -:  136:}