-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/src/mpid_rsend.c
        -:    0:Graph:mpid_rsend.gcno
        -:    0:Data:mpid_rsend.gcda
        -:    0:Runs:538
        -:    0:Programs:84
        -:    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:/* FIXME: How does this differ from eager send?  It should differ in 
        -:   12:   only a few bits (e.g., indicate that the send is ready and should
        -:   13:   fail if there is no matching receive) */
        -:   14:
        -:   15:/*
        -:   16: * MPID_Rsend()
        -:   17: */
        -:   18:#undef FUNCNAME
        -:   19:#define FUNCNAME MPID_Rsend
        -:   20:#undef FCNAME
        -:   21:#define FCNAME MPIDI_QUOTE(FUNCNAME)
        -:   22:int MPID_Rsend(const void * buf, int count, MPI_Datatype datatype, int rank, int tag, MPID_Comm * comm, int context_offset,
        -:   23:	       MPID_Request ** request)
     5210:   24:{
        -:   25:    MPIDI_msg_sz_t data_sz;
        -:   26:    int dt_contig;
        -:   27:    MPI_Aint dt_true_lb;
        -:   28:    MPID_Datatype * dt_ptr;
     5210:   29:    MPID_Request * sreq = NULL;
        -:   30:    MPIDI_VC_t * vc;
        -:   31:#if defined(MPID_USE_SEQUENCE_NUMBERS)
        -:   32:    MPID_Seqnum_t seqnum;
        -:   33:#endif    
     5210:   34:    int mpi_errno = MPI_SUCCESS;    
        -:   35:    MPIDI_STATE_DECL(MPID_STATE_MPID_RSEND);
        -:   36:
        -:   37:    MPIDI_FUNC_ENTER(MPID_STATE_MPID_RSEND);
        -:   38:
        -:   39:    MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
        -:   40:					"rank=%d, tag=%d, context=%d", 
        -:   41:                              rank, tag, comm->context_id + context_offset));
        -:   42:    
     5210:   43:    if (rank == comm->rank && comm->comm_kind != MPID_INTERCOMM)
        -:   44:    {
      144:   45:	mpi_errno = MPIDI_Isend_self(buf, count, datatype, rank, tag, comm, context_offset, MPIDI_REQUEST_TYPE_RSEND, &sreq);
      144:   46:	goto fn_exit;
        -:   47:    }
        -:   48:
     5066:   49:    if (rank == MPI_PROC_NULL)
        -:   50:    {
     3024:   51:	goto fn_exit;
        -:   52:    }
        -:   53:
     2042:   54:    MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
        -:   55:
        -:   56:#ifdef ENABLE_COMM_OVERRIDES
        -:   57:    if (vc->comm_ops && vc->comm_ops->rsend)
        -:   58:    {
        -:   59:	mpi_errno = vc->comm_ops->rsend( vc, buf, count, datatype, rank, tag, comm, context_offset, &sreq);
        -:   60:	goto fn_exit;
        -:   61:    }
        -:   62:#endif
        -:   63:
     2042:   64:    MPIDI_Datatype_get_info(count, datatype, dt_contig, data_sz, dt_ptr, dt_true_lb);
        -:   65:
     2042:   66:    if (data_sz == 0)
        -:   67:    {
        -:   68:	MPIDI_CH3_Pkt_t upkt;
      168:   69:	MPIDI_CH3_Pkt_ready_send_t * const ready_pkt = &upkt.ready_send;
        -:   70:
        -:   71:	MPIU_DBG_MSG(CH3_OTHER,VERBOSE,"sending zero length message");
        -:   72:    
      168:   73:	MPIDI_Pkt_init(ready_pkt, MPIDI_CH3_PKT_READY_SEND);
      168:   74:	ready_pkt->match.parts.rank = comm->rank;
      168:   75:	ready_pkt->match.parts.tag = tag;
      168:   76:	ready_pkt->match.parts.context_id = comm->context_id + context_offset;
      168:   77:	ready_pkt->sender_req_id = MPI_REQUEST_NULL;
      168:   78:	ready_pkt->data_sz = data_sz;
        -:   79:
        -:   80:	MPIDI_VC_FAI_send_seqnum(vc, seqnum);
        -:   81:	MPIDI_Pkt_set_seqnum(ready_pkt, seqnum);
        -:   82:	
        -:   83:	MPIU_THREAD_CS_ENTER(CH3COMM,vc);
      168:   84:	mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, ready_pkt, 
        -:   85:						  sizeof(*ready_pkt), &sreq));
        -:   86:	MPIU_THREAD_CS_EXIT(CH3COMM,vc);
        -:   87:	/* --BEGIN ERROR HANDLING-- */
      168:   88:	if (mpi_errno != MPI_SUCCESS)
        -:   89:	{
    #####:   90:	    mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPI_ERR_OTHER, "**ch3|eagermsg", 0);
    #####:   91:	    goto fn_exit;
        -:   92:	}
        -:   93:	/* --END ERROR HANDLING-- */
      168:   94:	if (sreq != NULL)
        -:   95:	{
        -:   96:	    MPIDI_Request_set_seqnum(sreq, seqnum);
    #####:   97:	    MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_RSEND);
        -:   98:	    /* sreq->comm = comm;
        -:   99:	       MPIR_Comm_add_ref(comm); -- not needed for blocking operations */
        -:  100:	}
        -:  101:
        -:  102:	goto fn_exit;
        -:  103:    }
        -:  104:    
     1874:  105:    if (dt_contig)
        -:  106:    {
     1650:  107:	mpi_errno = MPIDI_CH3_EagerContigSend( &sreq, 
        -:  108:					       MPIDI_CH3_PKT_READY_SEND,
        -:  109:					       (char *)buf + dt_true_lb,
        -:  110:					       data_sz, rank, tag, comm, 
        -:  111:					       context_offset );
        -:  112:    }
        -:  113:    else
        -:  114:    {
      224:  115:	MPIDI_Request_create_sreq(sreq, mpi_errno, goto fn_exit);
      224:  116:	MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_SEND);
      224:  117:	mpi_errno = MPIDI_CH3_EagerNoncontigSend( &sreq, 
        -:  118:                                                  MPIDI_CH3_PKT_READY_SEND,
        -:  119:                                                  buf, count, datatype,
        -:  120:                                                  data_sz, rank, tag, 
        -:  121:                                                  comm, context_offset );
        -:  122:    }
        -:  123:
     5210:  124:  fn_exit:
     5210:  125:    *request = sreq;
        -:  126:
        -:  127:    MPIU_DBG_STMT(CH3_OTHER,VERBOSE,
        -:  128:    {
        -:  129:	if (mpi_errno == MPI_SUCCESS) {
        -:  130:	    if (sreq) {
        -:  131:		MPIU_DBG_MSG_P(CH3_OTHER,VERBOSE,"request allocated, handle=0x%08x", sreq->handle);
        -:  132:	    }
        -:  133:	    else
        -:  134:	    {
        -:  135:		MPIU_DBG_MSG(CH3_OTHER,VERBOSE,"operation complete, no requests allocated");
        -:  136:	    }
        -:  137:	}
        -:  138:    }
        -:  139:		  );
        -:  140:    
        -:  141:    MPIDI_FUNC_EXIT(MPID_STATE_MPID_RSEND);
     5210:  142:    return mpi_errno;
        -:  143:}