-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/coll/helper_fns.c
        -:    0:Graph:helper_fns.gcno
        -:    0:Data:helper_fns.gcda
        -:    0:Runs:4383
        -:    0:Programs:1376
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    2:/*
        -:    3: *
        -:    4: *  (C) 2001 by Argonne National Laboratory.
        -:    5: *      See COPYRIGHT in top-level directory.
        -:    6: */
        -:    7:
        -:    8:#include "mpiimpl.h"
        -:    9:#include "datatype.h"
        -:   10:
        -:   11:#define COPY_BUFFER_SZ 16384
        -:   12:
        -:   13:/* These functions are used in the implementation of collective
        -:   14:   operations. They are wrappers around MPID send/recv functions. They do
        -:   15:   sends/receives by setting the context offset to
        -:   16:   MPID_CONTEXT_INTRA_COLL or MPID_CONTEXT_INTER_COLL. */
        -:   17:
        -:   18:#undef FUNCNAME
        -:   19:#define FUNCNAME MPIC_Send
        -:   20:#undef FCNAME
        -:   21:#define FCNAME "MPIC_Send"
        -:   22:int MPIC_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag,
        -:   23:              MPI_Comm comm)
  2149664:   24:{
        -:   25:    int mpi_errno, context_id;
  2149664:   26:    MPID_Request *request_ptr=NULL;
  2149664:   27:    MPID_Comm *comm_ptr=NULL;
        -:   28:    MPIDI_STATE_DECL(MPID_STATE_MPIC_SEND);
        -:   29:
        -:   30:    MPIDI_PT2PT_FUNC_ENTER_FRONT(MPID_STATE_MPIC_SEND);
        -:   31:
  2149664:   32:    MPID_Comm_get_ptr( comm, comm_ptr );
  2149664:   33:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:   34:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:   35:
  2149664:   36:    mpi_errno = MPID_Send(buf, count, datatype, dest, tag, comm_ptr,
        -:   37:                          context_id, &request_ptr); 
  2149664:   38:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
  2149664:   39:    if (request_ptr) {
    11715:   40:        mpi_errno = MPIC_Wait(request_ptr);
    11715:   41:	if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
    11715:   42:	MPID_Request_release(request_ptr);
        -:   43:    }
  2149664:   44: fn_exit:
        -:   45:    MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_SEND);
  2149664:   46:    return mpi_errno;
    #####:   47: fn_fail:
    #####:   48:    if (request_ptr) {
    #####:   49:        MPID_Request_release(request_ptr);
        -:   50:    }
        -:   51:    goto fn_exit;
        -:   52:}
        -:   53:
        -:   54:#undef FUNCNAME
        -:   55:#define FUNCNAME MPIC_Recv
        -:   56:#undef FCNAME
        -:   57:#define FCNAME "MPIC_Recv"
        -:   58:int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
        -:   59:	     MPI_Comm comm, MPI_Status *status)
  2146979:   60:{
        -:   61:    int mpi_errno, context_id;
  2146979:   62:    MPID_Request *request_ptr=NULL;
  2146979:   63:    MPID_Comm *comm_ptr = NULL;
        -:   64:    MPIDI_STATE_DECL(MPID_STATE_MPIC_RECV);
        -:   65:
        -:   66:    MPIDI_PT2PT_FUNC_ENTER_BACK(MPID_STATE_MPIC_RECV);
        -:   67:
  2146979:   68:    MPID_Comm_get_ptr( comm, comm_ptr );
  2146979:   69:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:   70:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:   71:
  2146979:   72:    mpi_errno = MPID_Recv(buf, count, datatype, source, tag, comm_ptr,
        -:   73:                          context_id, status, &request_ptr); 
  2146979:   74:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
  2146979:   75:    if (request_ptr) {
  2048557:   76:        mpi_errno = MPIC_Wait(request_ptr);
  2048557:   77:	if (mpi_errno == MPI_SUCCESS) {
  2048556:   78:	    if (status != MPI_STATUS_IGNORE) {
   719329:   79:		*status = request_ptr->status;
        -:   80:	    }
  2048556:   81:	    mpi_errno = request_ptr->status.MPI_ERROR;
        -:   82:	}
        1:   83:	else { MPIU_ERR_POP(mpi_errno); }
        -:   84:
  2048556:   85:        MPID_Request_release(request_ptr);
        -:   86:    }
  2146979:   87: fn_exit:
        -:   88:    MPIDI_PT2PT_FUNC_EXIT_BACK(MPID_STATE_MPIC_RECV);
  2146979:   89:    return mpi_errno;
        1:   90: fn_fail:
        1:   91:    if (request_ptr) { 
        1:   92:	MPID_Request_release(request_ptr);
        -:   93:    }
        -:   94:    goto fn_exit;
        -:   95:}
        -:   96:
        -:   97:#undef FUNCNAME
        -:   98:#define FUNCNAME MPIC_Ssend
        -:   99:#undef FCNAME
        -:  100:#define FCNAME "MPIC_Ssend"
        -:  101:int MPIC_Ssend(void *buf, int count, MPI_Datatype datatype, int dest, int tag,
        -:  102:               MPI_Comm comm)
    #####:  103:{
        -:  104:    int mpi_errno, context_id;
    #####:  105:    MPID_Request *request_ptr=NULL;
    #####:  106:    MPID_Comm *comm_ptr=NULL;
        -:  107:    MPIDI_STATE_DECL(MPID_STATE_MPIC_SSEND);
        -:  108:
        -:  109:    MPIDI_PT2PT_FUNC_ENTER_FRONT(MPID_STATE_MPIC_SSEND);
        -:  110:
    #####:  111:    MPID_Comm_get_ptr( comm, comm_ptr );
    #####:  112:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:  113:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:  114:
    #####:  115:    mpi_errno = MPID_Ssend(buf, count, datatype, dest, tag, comm_ptr,
        -:  116:                           context_id, &request_ptr); 
    #####:  117:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
    #####:  118:    if (request_ptr) {
    #####:  119:        mpi_errno = MPIC_Wait(request_ptr);
    #####:  120:	if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
    #####:  121:	MPID_Request_release(request_ptr);
        -:  122:    }
    #####:  123: fn_exit:
        -:  124:    MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_SSEND);
    #####:  125:    return mpi_errno;
    #####:  126: fn_fail:
    #####:  127:    if (request_ptr) {
    #####:  128:        MPID_Request_release(request_ptr);
        -:  129:    }
        -:  130:    goto fn_exit;
        -:  131:}
        -:  132:
        -:  133:#undef FUNCNAME
        -:  134:#define FUNCNAME MPIC_Sendrecv
        -:  135:#undef FCNAME
        -:  136:#define FCNAME "MPIC_Sendrecv"
        -:  137:int MPIC_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
        -:  138:                  int dest, int sendtag, void *recvbuf, int recvcount,
        -:  139:                  MPI_Datatype recvtype, int source, int recvtag,
        -:  140:                  MPI_Comm comm, MPI_Status *status) 
  7179565:  141:{
  7179565:  142:    MPID_Request *recv_req_ptr=NULL, *send_req_ptr=NULL;
        -:  143:    int mpi_errno, context_id;
  7179565:  144:    MPID_Comm *comm_ptr = NULL;
        -:  145:    MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV);
        -:  146:
        -:  147:    MPIDI_PT2PT_FUNC_ENTER_BOTH(MPID_STATE_MPIC_SENDRECV);
        -:  148:
  7179565:  149:    MPID_Comm_get_ptr( comm, comm_ptr );
  7179565:  150:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:  151:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:  152:
  7179565:  153:    mpi_errno = MPID_Irecv(recvbuf, recvcount, recvtype, source, recvtag,
        -:  154:                           comm_ptr, context_id, &recv_req_ptr);
  7179565:  155:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
  7179565:  156:    mpi_errno = MPID_Isend(sendbuf, sendcount, sendtype, dest, sendtag, 
        -:  157:                           comm_ptr, context_id, &send_req_ptr); 
  7179565:  158:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  159:
  7179565:  160:    mpi_errno = MPIC_Wait(send_req_ptr); 
  7179565:  161:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  162:    
  7179565:  163:    mpi_errno = MPIC_Wait(recv_req_ptr);
  7179565:  164:    if (mpi_errno) { MPIU_ERR_POPFATAL(mpi_errno); }
  7179563:  165:    if (status != MPI_STATUS_IGNORE)
  4012168:  166:        *status = recv_req_ptr->status;
  7179563:  167:    mpi_errno = recv_req_ptr->status.MPI_ERROR;
        -:  168:
  7179563:  169:    MPID_Request_release(send_req_ptr);
  7179563:  170:    MPID_Request_release(recv_req_ptr);
  7179565:  171: fn_fail:
        -:  172:    MPIDI_PT2PT_FUNC_EXIT_BOTH(MPID_STATE_MPIC_SENDRECV);
  7179565:  173:    return mpi_errno;
        -:  174:}
        -:  175:
        -:  176:/* NOTE: for regular collectives (as opposed to irregular collectives) calling
        -:  177: * this function repeatedly will almost always be slower than performing the
        -:  178: * equivalent inline because of the overhead of the repeated malloc/free */
        -:  179:#undef FUNCNAME
        -:  180:#define FUNCNAME MPIC_Sendrecv_replace
        -:  181:#undef FCNAME
        -:  182:#define FCNAME MPIU_QUOTE(FUNCNAME)
        -:  183:int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
        -:  184:                          int dest, int sendtag,
        -:  185:                          int source, int recvtag,
        -:  186:                          MPI_Comm comm, MPI_Status *status)
     6642:  187:{
     6642:  188:    int mpi_errno = MPI_SUCCESS;
        -:  189:    MPIR_Context_id_t context_id_offset;
        -:  190:    MPID_Request *sreq;
        -:  191:    MPID_Request *rreq;
     6642:  192:    void *tmpbuf = NULL;
     6642:  193:    int tmpbuf_size = 0;
     6642:  194:    int tmpbuf_count = 0;
        -:  195:    MPID_Comm *comm_ptr;
     6642:  196:    MPIU_THREADPRIV_DECL;
     6642:  197:    MPIU_CHKLMEM_DECL(1);
        -:  198:    MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV_REPLACE);
        -:  199:#ifdef MPID_LOG_ARROWS
        -:  200:    /* The logging macros log sendcount and recvcount */
        -:  201:    int sendcount = count, recvcount = count;
        -:  202:#endif
        -:  203:
        -:  204:    MPIDI_PT2PT_FUNC_ENTER_BOTH(MPID_STATE_MPIC_SENDRECV_REPLACE);
        -:  205:
     6642:  206:    MPIU_THREADPRIV_GET;
        -:  207:
     6642:  208:    MPID_Comm_get_ptr( comm, comm_ptr );
     6642:  209:    context_id_offset = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:  210:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:  211:
     6642:  212:    if (count > 0 && dest != MPI_PROC_NULL)
        -:  213:    {
     6538:  214:        MPIR_Nest_incr();
     6538:  215:        mpi_errno = NMPI_Pack_size(count, datatype, comm, &tmpbuf_size);
     6538:  216:        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        -:  217:
     6538:  218:        MPIU_CHKLMEM_MALLOC(tmpbuf, void *, tmpbuf_size, mpi_errno, "temporary send buffer");
        -:  219:
     6538:  220:        mpi_errno = NMPI_Pack(buf, count, datatype, tmpbuf, tmpbuf_size, &tmpbuf_count, comm);
     6538:  221:        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     6538:  222:        MPIR_Nest_decr();
        -:  223:    }
        -:  224:
     6642:  225:    mpi_errno = MPID_Irecv(buf, count, datatype, source, recvtag,
        -:  226:                           comm_ptr, context_id_offset, &rreq);
     6642:  227:    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        -:  228:
     6642:  229:    mpi_errno = MPID_Isend(tmpbuf, tmpbuf_count, MPI_PACKED, dest,
        -:  230:                           sendtag, comm_ptr, context_id_offset,
        -:  231:                           &sreq);
     6642:  232:    if (mpi_errno != MPI_SUCCESS)
        -:  233:    {
        -:  234:        /* --BEGIN ERROR HANDLING-- */
        -:  235:        /* FIXME: should we cancel the pending (possibly completed) receive request or wait for it to complete? */
    #####:  236:        MPID_Request_release(rreq);
    #####:  237:        MPIU_ERR_POP(mpi_errno);
        -:  238:        /* --END ERROR HANDLING-- */
        -:  239:    }
        -:  240:
     6642:  241:    if (*sreq->cc_ptr != 0 || *rreq->cc_ptr != 0)
        -:  242:    {
        -:  243:        MPID_Progress_state progress_state;
        -:  244:
     3709:  245:        MPID_Progress_start(&progress_state);
    13578:  246:        while (*sreq->cc_ptr != 0 || *rreq->cc_ptr != 0)
        -:  247:        {
     6160:  248:            mpi_errno = MPID_Progress_wait(&progress_state);
     6160:  249:            if (mpi_errno != MPI_SUCCESS)
        -:  250:            {
        -:  251:                /* --BEGIN ERROR HANDLING-- */
        -:  252:                MPID_Progress_end(&progress_state);
    #####:  253:                MPIU_ERR_POP(mpi_errno);
        -:  254:                /* --END ERROR HANDLING-- */
        -:  255:            }
        -:  256:        }
        -:  257:        MPID_Progress_end(&progress_state);
        -:  258:    }
        -:  259:
     6642:  260:    if (status != MPI_STATUS_IGNORE) {
     6642:  261:        *status = rreq->status;
        -:  262:    }
        -:  263:
     6642:  264:    if (mpi_errno == MPI_SUCCESS) {
     6642:  265:        mpi_errno = rreq->status.MPI_ERROR;
        -:  266:
     6642:  267:        if (mpi_errno == MPI_SUCCESS) {
     6642:  268:            mpi_errno = sreq->status.MPI_ERROR;
        -:  269:        }
        -:  270:    }
        -:  271:
     6642:  272:    MPID_Request_release(sreq);
     6642:  273:    MPID_Request_release(rreq);
        -:  274:
     6642:  275:    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        -:  276:
        -:  277:fn_exit:
     6538:  278:    MPIU_CHKLMEM_FREEALL();
        -:  279:    MPIDI_PT2PT_FUNC_EXIT_BOTH(MPID_STATE_MPIC_SENDRECV_REPLACE);
     6642:  280:    return mpi_errno;
        -:  281:fn_fail:
        -:  282:    goto fn_exit;
        -:  283:}
        -:  284:
        -:  285:#undef FUNCNAME
        -:  286:#define FUNCNAME MPIR_Localcopy
        -:  287:#undef FCNAME
        -:  288:#define FCNAME "MPIR_Localcopy"
        -:  289:int MPIR_Localcopy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
        -:  290:                   void *recvbuf, int recvcount, MPI_Datatype recvtype)
  4195595:  291:{
  4195595:  292:    int mpi_errno = MPI_SUCCESS;
        -:  293:    int sendtype_iscontig, recvtype_iscontig;
        -:  294:    MPI_Aint sendsize, recvsize, sdata_sz, rdata_sz, copy_sz;
        -:  295:    MPI_Aint true_extent, sendtype_true_lb, recvtype_true_lb;
  4195595:  296:    MPIU_CHKLMEM_DECL(1);
  4195595:  297:    MPIU_THREADPRIV_DECL;
        -:  298:    MPID_MPI_STATE_DECL(MPID_STATE_MPIR_LOCALCOPY);
        -:  299:
        -:  300:    MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_LOCALCOPY);
        -:  301:
  4195595:  302:    MPIU_THREADPRIV_GET;
        -:  303:
  4195595:  304:    MPIR_Nest_incr();
        -:  305:    
  4195595:  306:    MPIR_Datatype_iscontig(sendtype, &sendtype_iscontig);
  4195595:  307:    MPIR_Datatype_iscontig(recvtype, &recvtype_iscontig);
        -:  308:
  4195595:  309:    MPID_Datatype_get_size_macro(sendtype, sendsize);
  4195595:  310:    MPID_Datatype_get_size_macro(recvtype, recvsize);
  4195595:  311:    sdata_sz = sendsize * sendcount;
  4195595:  312:    rdata_sz = recvsize * recvcount;
        -:  313:
  4195595:  314:    if (!sdata_sz || !rdata_sz)
    15592:  315:        goto fn_exit;
        -:  316:    
  4180003:  317:    if (sdata_sz > rdata_sz)
        -:  318:    {
    #####:  319:        MPIU_ERR_SET2(mpi_errno, MPI_ERR_TRUNCATE, "**truncate", "**truncate %d %d", sdata_sz, rdata_sz);
    #####:  320:        copy_sz = rdata_sz;
        -:  321:    }
        -:  322:    else
        -:  323:    {
  4180003:  324:        copy_sz = sdata_sz;
        -:  325:    }
        -:  326:
  4180003:  327:    mpi_errno = NMPI_Type_get_true_extent(sendtype, &sendtype_true_lb, &true_extent);
  4180003:  328:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  329:    
  4180003:  330:    mpi_errno = NMPI_Type_get_true_extent(recvtype, &recvtype_true_lb, &true_extent);
  4180003:  331:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  332:
  8352569:  333:    if (sendtype_iscontig && recvtype_iscontig)
        -:  334:    {    
  4172566:  335:        MPIU_Memcpy(((char *) recvbuf + recvtype_true_lb), 
        -:  336:               ((char *) sendbuf + sendtype_true_lb), 
        -:  337:               copy_sz);
        -:  338:    }
     7437:  339:    else if (sendtype_iscontig)
        -:  340:    {
        -:  341:        MPID_Segment seg;
        -:  342:	MPI_Aint last;
        -:  343:
       89:  344:	MPID_Segment_init(recvbuf, recvcount, recvtype, &seg, 0);
       89:  345:	last = copy_sz;
       89:  346:	MPID_Segment_unpack(&seg, 0, &last, (char*)sendbuf + sendtype_true_lb);
       89:  347:        MPIU_ERR_CHKANDJUMP(last != copy_sz, mpi_errno, MPI_ERR_TYPE, "**dtypemismatch");
        -:  348:    }
     7348:  349:    else if (recvtype_iscontig)
        -:  350:    {
        -:  351:        MPID_Segment seg;
        -:  352:	MPI_Aint last;
        -:  353:
     2109:  354:	MPID_Segment_init(sendbuf, sendcount, sendtype, &seg, 0);
     2109:  355:	last = copy_sz;
     2109:  356:	MPID_Segment_pack(&seg, 0, &last, (char*)recvbuf + recvtype_true_lb);
     2109:  357:        MPIU_ERR_CHKANDJUMP(last != copy_sz, mpi_errno, MPI_ERR_TYPE, "**dtypemismatch");
        -:  358:    }
        -:  359:    else
        -:  360:    {
        -:  361:	char * buf;
        -:  362:	MPIDI_msg_sz_t buf_off;
        -:  363:	MPID_Segment sseg;
        -:  364:	MPIDI_msg_sz_t sfirst;
        -:  365:	MPID_Segment rseg;
        -:  366:	MPIDI_msg_sz_t rfirst;
        -:  367:
     5239:  368:        MPIU_CHKLMEM_MALLOC(buf, char *, COPY_BUFFER_SZ, mpi_errno, "buf");
        -:  369:
     5239:  370:	MPID_Segment_init(sendbuf, sendcount, sendtype, &sseg, 0);
     5239:  371:	MPID_Segment_init(recvbuf, recvcount, recvtype, &rseg, 0);
        -:  372:
     5239:  373:	sfirst = 0;
     5239:  374:	rfirst = 0;
     5239:  375:	buf_off = 0;
        -:  376:	
        -:  377:	while (1)
        -:  378:	{
        -:  379:	    MPI_Aint last;
        -:  380:	    char * buf_end;
        -:  381:
     5853:  382:	    if (copy_sz - sfirst > COPY_BUFFER_SZ - buf_off)
        -:  383:	    {
      614:  384:		last = sfirst + (COPY_BUFFER_SZ - buf_off);
        -:  385:	    }
        -:  386:	    else
        -:  387:	    {
     5239:  388:		last = copy_sz;
        -:  389:	    }
        -:  390:	    
     5853:  391:	    MPID_Segment_pack(&sseg, sfirst, &last, buf + buf_off);
     5853:  392:	    MPIU_Assert(last > sfirst);
        -:  393:	    
     5853:  394:	    buf_end = buf + buf_off + (last - sfirst);
     5853:  395:	    sfirst = last;
        -:  396:	    
     5853:  397:	    MPID_Segment_unpack(&rseg, rfirst, &last, buf);
     5853:  398:	    MPIU_Assert(last > rfirst);
        -:  399:
     5853:  400:	    rfirst = last;
        -:  401:
     5853:  402:	    if (rfirst == copy_sz)
        -:  403:	    {
        -:  404:		/* successful completion */
     5239:  405:		break;
        -:  406:	    }
        -:  407:
        -:  408:            /* if the send side finished, but the recv side couldn't unpack it, there's a datatype mismatch */
      614:  409:            MPIU_ERR_CHKANDJUMP(sfirst == copy_sz, mpi_errno, MPI_ERR_TYPE, "**dtypemismatch");        
        -:  410:
        -:  411:            /* if not all data was unpacked, copy it to the front of the buffer for next time */
      614:  412:	    buf_off = sfirst - rfirst;
      614:  413:	    if (buf_off > 0)
        -:  414:	    {
    #####:  415:		memmove(buf, buf_end - buf_off, buf_off);
        -:  416:	    }
        -:  417:	}
        -:  418:    }
        -:  419:    
        -:  420:    
        -:  421:  fn_exit:
     5239:  422:    MPIU_CHKLMEM_FREEALL();
  4195595:  423:    MPIR_Nest_decr();
        -:  424:    MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_LOCALCOPY);
  4195595:  425:    return mpi_errno;
        -:  426:
        -:  427:  fn_fail:
        -:  428:    goto fn_exit;
        -:  429:}
        -:  430:
        -:  431:
        -:  432:#undef FUNCNAME
        -:  433:#define FUNCNAME MPIC_Isend
        -:  434:#undef FCNAME
        -:  435:#define FCNAME "MPIC_Isend"
        -:  436:int MPIC_Isend(void *buf, int count, MPI_Datatype datatype, int dest, int tag,
        -:  437:              MPI_Comm comm, MPI_Request *request)
    18517:  438:{
        -:  439:    int mpi_errno, context_id;
    18517:  440:    MPID_Request *request_ptr=NULL;
    18517:  441:    MPID_Comm *comm_ptr=NULL;
        -:  442:    MPIDI_STATE_DECL(MPID_STATE_MPIC_ISEND);
        -:  443:
        -:  444:    MPIDI_PT2PT_FUNC_ENTER_FRONT(MPID_STATE_MPIC_ISEND);
        -:  445:
    18517:  446:    MPID_Comm_get_ptr( comm, comm_ptr );
    18517:  447:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:  448:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:  449:
    18517:  450:    mpi_errno = MPID_Isend(buf, count, datatype, dest, tag, comm_ptr,
        -:  451:                          context_id, &request_ptr); 
    18517:  452:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); } 
        -:  453:
    18517:  454:    *request = request_ptr->handle;
        -:  455:
    18517:  456: fn_fail:
        -:  457:    MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_ISEND);
    18517:  458:    return mpi_errno;
        -:  459:}
        -:  460:
        -:  461:
        -:  462:#undef FUNCNAME
        -:  463:#define FUNCNAME MPIC_Irecv
        -:  464:#undef FCNAME
        -:  465:#define FCNAME "MPIC_Irecv"
        -:  466:int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int
        -:  467:               source, int tag, MPI_Comm comm, MPI_Request *request)
    21202:  468:{
        -:  469:    int mpi_errno, context_id;
    21202:  470:    MPID_Request *request_ptr=NULL;
    21202:  471:    MPID_Comm *comm_ptr = NULL;
        -:  472:    MPIDI_STATE_DECL(MPID_STATE_MPIC_IRECV);
        -:  473:
        -:  474:    MPIDI_PT2PT_FUNC_ENTER_BACK(MPID_STATE_MPIC_IRECV);
        -:  475:
    21202:  476:    MPID_Comm_get_ptr( comm, comm_ptr );
    21202:  477:    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
        -:  478:        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
        -:  479:
    21202:  480:    mpi_errno = MPID_Irecv(buf, count, datatype, source, tag, comm_ptr,
        -:  481:                          context_id, &request_ptr); 
    21202:  482:    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  483:
    21202:  484:    *request = request_ptr->handle;
        -:  485:
    21202:  486: fn_fail:
        -:  487:    MPIDI_PT2PT_FUNC_EXIT_BACK(MPID_STATE_MPIC_IRECV);
    21202:  488:    return mpi_errno;
        -:  489:}
        -:  490:
        -:  491:/* FIXME: For the brief-global and finer-grain control, we must ensure that
        -:  492:   the global lock is *not* held when this routine is called. (unless we change
        -:  493:   progress_start/end to grab the lock, in which case we must *still* make
        -:  494:   sure that the lock is not held when this routine is called). */
        -:  495:#undef FUNCNAME
        -:  496:#define FUNCNAME MPIC_Wait
        -:  497:#undef FCNAME
        -:  498:#define FCNAME "MPIC_Wait"
        -:  499:int MPIC_Wait(MPID_Request * request_ptr)
 16419402:  500:{
 16419402:  501:    int mpi_errno = MPI_SUCCESS;
        -:  502:    MPIDI_STATE_DECL(MPID_STATE_MPIC_WAIT);
        -:  503:
        -:  504:    MPIDI_PT2PT_FUNC_ENTER(MPID_STATE_MPIC_WAIT);
 16419402:  505:    if ((*(request_ptr)->cc_ptr) != 0)
        -:  506:    {
        -:  507:	MPID_Progress_state progress_state;
        -:  508:	
  8071684:  509:	MPID_Progress_start(&progress_state);
 25523378:  510:	while((*(request_ptr)->cc_ptr) != 0)
        -:  511:	{
  9380013:  512:	    mpi_errno = MPID_Progress_wait(&progress_state);
  9380013:  513:	    if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
        -:  514:	}
        -:  515:	MPID_Progress_end(&progress_state);
        -:  516:    }
        -:  517:
 16419402:  518: fn_fail:
        -:  519:    MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_WAIT);
 16419402:  520:    return mpi_errno;
        -:  521:}