-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/src/mpid_issend.c
        -:    0:Graph:mpid_issend.gcno
        -:    0:Data:mpid_issend.gcda
        -:    0:Runs:559
        -:    0:Programs:89
        -:    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 "mpidimpl.h"
        -:    8:
        -:    9:/* FIXME: HOMOGENEOUS SYSTEMS ONLY -- no data conversion is performed */
        -:   10:
        -:   11:/*
        -:   12: * MPID_Issend()
        -:   13: */
        -:   14:#undef FUNCNAME
        -:   15:#define FUNCNAME MPID_Issend
        -:   16:#undef FCNAME
        -:   17:#define FCNAME MPIDI_QUOTE(FUNCNAME)
        -:   18:int MPID_Issend(const void * buf, int count, MPI_Datatype datatype, int rank, int tag, MPID_Comm * comm, int context_offset,
        -:   19:		MPID_Request ** request)
      179:   20:{
        -:   21:    MPIDI_msg_sz_t data_sz;
        -:   22:    int dt_contig;
        -:   23:    MPI_Aint dt_true_lb;
        -:   24:    MPID_Datatype * dt_ptr;
        -:   25:    MPID_Request * sreq;
      179:   26:    MPIDI_VC_t * vc=0;
        -:   27:#if defined(MPID_USE_SEQUENCE_NUMBERS)
        -:   28:    MPID_Seqnum_t seqnum;
        -:   29:#endif    
      179:   30:    int mpi_errno = MPI_SUCCESS;
        -:   31:    MPIDI_STATE_DECL(MPID_STATE_MPID_ISSEND);
        -:   32:
        -:   33:    MPIDI_FUNC_ENTER(MPID_STATE_MPID_ISSEND);
        -:   34:
        -:   35:    MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
        -:   36:                 "rank=%d, tag=%d, context=%d", 
        -:   37:                 rank, tag, comm->context_id + context_offset));
        -:   38:    
      179:   39:    if (rank == comm->rank && comm->comm_kind != MPID_INTERCOMM)
        -:   40:    {
       12:   41:	mpi_errno = MPIDI_Isend_self(buf, count, datatype, rank, tag, comm, context_offset, MPIDI_REQUEST_TYPE_SSEND, &sreq);
       12:   42:	goto fn_exit;
        -:   43:    }
        -:   44:
      167:   45:    if (rank != MPI_PROC_NULL)
        -:   46:    {
      167:   47:       MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
        -:   48:        /* this needs to come before the sreq is created, since the override */
        -:   49:        /* function is responsible for creating its own request */       
        -:   50:#ifdef ENABLE_COMM_OVERRIDES
        -:   51:       if (vc->comm_ops && vc->comm_ops->issend)
        -:   52:       {
        -:   53:	  mpi_errno = vc->comm_ops->issend( vc, buf, count, datatype, rank, tag, comm, context_offset, &sreq);
        -:   54:	  goto fn_exit;
        -:   55:       }
        -:   56:#endif
        -:   57:    }   
        -:   58:   
      167:   59:    MPIDI_Request_create_sreq(sreq, mpi_errno, goto fn_exit);
      167:   60:    MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_SSEND);
        -:   61:    
      167:   62:    if (rank == MPI_PROC_NULL)
        -:   63:    {
    #####:   64:	MPIU_Object_set_ref(sreq, 1);
    #####:   65:	sreq->cc = 0;
    #####:   66:	goto fn_exit;
        -:   67:    }
        -:   68:    
      167:   69:    MPIDI_Datatype_get_info(count, datatype, dt_contig, data_sz, dt_ptr, dt_true_lb);
        -:   70:    
      167:   71:    if (data_sz == 0)
        -:   72:    {
    #####:   73:	mpi_errno = MPIDI_CH3_EagerSyncZero( &sreq, rank, tag, comm, 
        -:   74:					     context_offset );
    #####:   75:	goto fn_exit;
        -:   76:    }
        -:   77:    
      167:   78:    if (data_sz + sizeof(MPIDI_CH3_Pkt_eager_sync_send_t) <= vc->eager_max_msg_sz)
        -:   79:    {
      164:   80:	mpi_errno = MPIDI_CH3_EagerSyncNoncontigSend( &sreq, buf, count,
        -:   81:                                                      datatype, data_sz, 
        -:   82:                                                      dt_contig, dt_true_lb,
        -:   83:                                                      rank, tag, comm, 
        -:   84:                                                      context_offset );
        -:   85:	/* If we're not complete, then add a reference to the datatype */
      164:   86:	if (sreq && sreq->dev.OnDataAvail) {
    #####:   87:	    sreq->dev.datatype_ptr = dt_ptr;
    #####:   88:	    MPID_Datatype_add_ref(dt_ptr);
        -:   89:	}
        -:   90:    }
        -:   91:    else
        -:   92:    {
        -:   93:	/* Note that the sreq was created above */
        3:   94:	MPIDI_Request_set_msg_type(sreq, MPIDI_REQUEST_RNDV_MSG);
        3:   95:	mpi_errno = vc->rndvSend_fn( &sreq, buf, count, datatype, dt_contig,
        -:   96:                                     data_sz, dt_true_lb, rank, tag, comm, 
        -:   97:                                     context_offset );
        -:   98:	
        -:   99:	/* FIXME: fill temporary IOV or pack temporary buffer after send to 
        -:  100:	   hide some latency.  This requires synchronization
        -:  101:           because the CTS packet could arrive and be processed before the 
        -:  102:	   above iStartmsg completes (depending on the progress
        -:  103:           engine, threads, etc.). */
        -:  104:	
        3:  105:	if (sreq && dt_ptr != NULL)
        -:  106:	{
    #####:  107:	    sreq->dev.datatype_ptr = dt_ptr;
    #####:  108:	    MPID_Datatype_add_ref(dt_ptr);
        -:  109:	}
        -:  110:    }
        -:  111:
      179:  112:  fn_exit:
      179:  113:    *request = sreq;
        -:  114:    
        -:  115:    MPIU_DBG_STMT(CH3_OTHER,VERBOSE,
        -:  116:    {
        -:  117:	if (sreq != NULL) {
        -:  118:	    MPIU_DBG_MSG_P(CH3_OTHER,VERBOSE,
        -:  119:			   "request allocated, handle=0x%08x", sreq->handle);
        -:  120:	}
        -:  121:    }
        -:  122:		  )
        -:  123:    
        -:  124:    MPIDI_FUNC_EXIT(MPID_STATE_MPID_ISSEND);
      179:  125:    return mpi_errno;
        -:  126:}