-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/src/ch3u_eager.c
-: 0:Graph:ch3u_eager.gcno
-: 0:Data:ch3u_eager.gcda
-: 0:Runs:4382
-: 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 "mpidimpl.h"
-: 8:
-: 9:/*
-: 10: * Send an eager message. To optimize for the important, short contiguous
-: 11: * message case, there are separate routines for the contig and non-contig
-: 12: * datatype cases.
-: 13: */
-: 14:
-: 15:#undef FUNCNAME
-: 16:#define FUNCNAME MPIDI_CH3_SendNoncontig_iov
-: 17:#undef FCNAME
-: 18:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 19:/* MPIDI_CH3_SendNoncontig_iov - Sends a message by loading an
-: 20: IOV and calling iSendv. The caller must initialize
-: 21: sreq->dev.segment as well as segment_first and segment_size. */
-: 22:int MPIDI_CH3_SendNoncontig_iov( MPIDI_VC_t *vc, MPID_Request *sreq,
-: 23: void *header, MPIDI_msg_sz_t hdr_sz )
436886: 24:{
436886: 25: int mpi_errno = MPI_SUCCESS;
-: 26: int iov_n;
-: 27: MPID_IOV iov[MPID_IOV_LIMIT];
-: 28: MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_SENDNONCONTIG_IOV);
-: 29:
-: 30: MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_SENDNONCONTIG_IOV);
-: 31:
436886: 32: iov[0].MPID_IOV_BUF = header;
436886: 33: iov[0].MPID_IOV_LEN = hdr_sz;
-: 34:
436886: 35: iov_n = MPID_IOV_LIMIT - 1;
-: 36:
436886: 37: mpi_errno = MPIDI_CH3U_Request_load_send_iov(sreq, &iov[1], &iov_n);
436886: 38: if (mpi_errno == MPI_SUCCESS)
-: 39: {
436886: 40: iov_n += 1;
-: 41:
-: 42: /* Note this routine is invoked withing a CH3 critical section */
-: 43: /* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
436886: 44: mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, sreq, iov, iov_n));
-: 45: /* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
|
-: 46: /* --BEGIN ERROR HANDLING-- */
436886: 47: if (mpi_errno != MPI_SUCCESS)
-: 48: {
#####: 49: MPIU_Object_set_ref(sreq, 0);
#####: 50: MPIDI_CH3_Request_destroy(sreq);
#####: 51: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL,
-: 52: FCNAME, __LINE__, MPI_ERR_OTHER, "**ch3|eagermsg", 0);
#####: 53: goto fn_fail;
-: 54: }
-: 55: /* --END ERROR HANDLING-- */
-: 56:
-: 57: /* Note that in the non-blocking case, we need to add a ref to the
-: 58: datatypes */
-: 59: }
-: 60: else
-: 61: {
-: 62: /* --BEGIN ERROR HANDLING-- */
#####: 63: MPIU_Object_set_ref(sreq, 0);
#####: 64: MPIDI_CH3_Request_destroy(sreq);
#####: 65: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
-: 66: FCNAME, __LINE__, MPI_ERR_OTHER, "**ch3|loadsendiov", 0);
#####: 67: goto fn_fail;
-: 68: /* --END ERROR HANDLING-- */
-: 69: }
-: 70:
-: 71:
|
436886: 72: fn_exit:
|
-: 73: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_SENDNONCONTIG_IOV);
|
436886: 74: return mpi_errno;
|
-: 75: fn_fail:
-: 76: goto fn_exit;
-: 77:}
-: 78:
-: 79:/* This function will allocate a segment. That segment must be freed when
-: 80: it is no longer needed */
-: 81:#undef FUNCNAME
-: 82:#define FUNCNAME MPIDI_EagerNoncontigSend
-: 83:#undef FCNAME
-: 84:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 85:/* MPIDI_CH3_EagerNoncontigSend - Eagerly send noncontiguous data */
-: 86:int MPIDI_CH3_EagerNoncontigSend( MPID_Request **sreq_p,
-: 87: MPIDI_CH3_Pkt_type_t reqtype,
-: 88: const void * buf, int count,
-: 89: MPI_Datatype datatype, MPIDI_msg_sz_t data_sz,
-: 90: int rank,
-: 91: int tag, MPID_Comm * comm,
-: 92: int context_offset )
|
420411: 93:{
420411: 94: int mpi_errno = MPI_SUCCESS;
-: 95: MPIDI_VC_t * vc;
420411: 96: MPID_Request *sreq = *sreq_p;
-: 97: MPIDI_CH3_Pkt_t upkt;
420411: 98: MPIDI_CH3_Pkt_eager_send_t * const eager_pkt = &upkt.eager_send;
-: 99:
-: 100: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 101: "sending non-contiguous eager message, data_sz=" MPIDI_MSG_SZ_FMT,
-: 102: data_sz));
420411: 103: sreq->dev.OnDataAvail = 0;
420411: 104: sreq->dev.OnFinal = 0;
-: 105:
420411: 106: MPIDI_Pkt_init(eager_pkt, reqtype);
420411: 107: eager_pkt->match.parts.rank = comm->rank;
420411: 108: eager_pkt->match.parts.tag = tag;
420411: 109: eager_pkt->match.parts.context_id = comm->context_id + context_offset;
420411: 110: eager_pkt->sender_req_id = MPI_REQUEST_NULL;
420411: 111: eager_pkt->data_sz = data_sz;
-: 112:
420411: 113: MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
-: 114:
-: 115: MPIDI_VC_FAI_send_seqnum(vc, seqnum);
-: 116: MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
-: 117: MPIDI_Request_set_seqnum(sreq, seqnum);
-: 118:
-: 119: MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,
-: 120: "Eager");
-: 121:
420411: 122: sreq->dev.segment_ptr = MPID_Segment_alloc( );
420411: 123: MPIU_ERR_CHKANDJUMP1((sreq->dev.segment_ptr == NULL), mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s", "MPID_Segment_alloc");
-: 124:
420411: 125: MPID_Segment_init(buf, count, datatype, sreq->dev.segment_ptr, 0);
420411: 126: sreq->dev.segment_first = 0;
420411: 127: sreq->dev.segment_size = data_sz;
-: 128:
-: 129: MPIU_THREAD_CS_ENTER(CH3COMM,vc);
420411: 130: mpi_errno = vc->sendNoncontig_fn(vc, sreq, eager_pkt,
-: 131: sizeof(MPIDI_CH3_Pkt_eager_send_t));
-: 132: MPIU_THREAD_CS_EXIT(CH3COMM,vc);
|
420411: 133: if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-: 134:
|
420411: 135: fn_exit:
420411: 136: return mpi_errno;
|
#####: 137: fn_fail:
|
#####: 138: *sreq_p = NULL;
#####: 139: goto fn_exit;
-: 140:}
-: 141:
-: 142:/* Send a contiguous eager message. We'll want to optimize (and possibly
-: 143: inline) this.
-: 144:
-: 145: Make sure that buf is at the beginning of the data to send;
-: 146: adjust by adding dt_true_lb if necessary
-: 147:*/
-: 148:#undef FUNCNAME
-: 149:#define FUNCNAME MPIDI_EagerContigSend
-: 150:#undef FCNAME
-: 151:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 152:int MPIDI_CH3_EagerContigSend( MPID_Request **sreq_p,
-: 153: MPIDI_CH3_Pkt_type_t reqtype,
-: 154: const void * buf, MPIDI_msg_sz_t data_sz, int rank,
-: 155: int tag, MPID_Comm * comm, int context_offset )
|
2695581: 156:{
2695581: 157: int mpi_errno = MPI_SUCCESS;
-: 158: MPIDI_VC_t * vc;
-: 159: MPIDI_CH3_Pkt_t upkt;
2695581: 160: MPIDI_CH3_Pkt_eager_send_t * const eager_pkt = &upkt.eager_send;
2695581: 161: MPID_Request *sreq = *sreq_p;
-: 162: MPID_IOV iov[2];
-: 163:
2695581: 164: MPIDI_Pkt_init(eager_pkt, reqtype);
2695581: 165: eager_pkt->match.parts.rank = comm->rank;
2695581: 166: eager_pkt->match.parts.tag = tag;
2695581: 167: eager_pkt->match.parts.context_id = comm->context_id + context_offset;
2695581: 168: eager_pkt->sender_req_id = MPI_REQUEST_NULL;
2695581: 169: eager_pkt->data_sz = data_sz;
-: 170:
2695581: 171: iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)eager_pkt;
2695581: 172: iov[0].MPID_IOV_LEN = sizeof(*eager_pkt);
-: 173:
-: 174: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 175: "sending contiguous eager message, data_sz=" MPIDI_MSG_SZ_FMT,
-: 176: data_sz));
-: 177:
2695581: 178: iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) buf;
2695581: 179: iov[1].MPID_IOV_LEN = data_sz;
-: 180:
2695581: 181: MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
-: 182: MPIDI_VC_FAI_send_seqnum(vc, seqnum);
-: 183: MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
-: 184:
-: 185: MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,"EagerContig");
-: 186: MPIU_THREAD_CS_ENTER(CH3COMM,vc);
2695581: 187: mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, 2, sreq_p));
-: 188: MPIU_THREAD_CS_EXIT(CH3COMM,vc);
2695581: 189: if (mpi_errno != MPI_SUCCESS) {
|
#####: 190: MPIU_ERR_SETFATALANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|eagermsg");
-: 191: }
-: 192:
|
2695581: 193: sreq = *sreq_p;
2695581: 194: if (sreq != NULL)
-: 195: {
-: 196: MPIDI_Request_set_seqnum(sreq, seqnum);
11007: 197: MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_SEND);
-: 198: }
-: 199:
|
2695581: 200: fn_fail:
|
2695581: 201: return mpi_errno;
-: 202:}
-: 203:
-: 204:#ifdef USE_EAGER_SHORT
-: 205:/* Send a short contiguous eager message. We'll want to optimize (and possibly
-: 206: inline) this
-: 207:
-: 208: Make sure that buf is at the beginning of the data to send;
-: 209: adjust by adding dt_true_lb if necessary
-: 210:
-: 211: We may need a nonblocking (cancellable) version of this, which will
-: 212: have a smaller payload.
-: 213:*/
-: 214:#undef FUNCNAME
-: 215:#define FUNCNAME MPIDI_EagerContigShortSend
-: 216:#undef FCNAME
-: 217:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 218:int MPIDI_CH3_EagerContigShortSend( MPID_Request **sreq_p,
-: 219: MPIDI_CH3_Pkt_type_t reqtype,
-: 220: const void * buf, MPIDI_msg_sz_t data_sz, int rank,
-: 221: int tag, MPID_Comm * comm,
-: 222: int context_offset )
2755049: 223:{
2755049: 224: int mpi_errno = MPI_SUCCESS;
-: 225: MPIDI_VC_t * vc;
-: 226: MPIDI_CH3_Pkt_t upkt;
-: 227: MPIDI_CH3_Pkt_eagershort_send_t * const eagershort_pkt =
2755049: 228: &upkt.eagershort_send;
2755049: 229: MPID_Request *sreq = *sreq_p;
-: 230:
-: 231: /* printf( "Sending short eager\n"); fflush(stdout); */
2755049: 232: MPIDI_Pkt_init(eagershort_pkt, reqtype);
2755049: 233: eagershort_pkt->match.parts.rank = comm->rank;
2755049: 234: eagershort_pkt->match.parts.tag = tag;
2755049: 235: eagershort_pkt->match.parts.context_id = comm->context_id + context_offset;
2755049: 236: eagershort_pkt->data_sz = data_sz;
-: 237:
-: 238: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 239: "sending contiguous short eager message, data_sz=" MPIDI_MSG_SZ_FMT,
-: 240: data_sz));
-: 241:
2755049: 242: MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
-: 243: MPIDI_VC_FAI_send_seqnum(vc, seqnum);
-: 244: MPIDI_Pkt_set_seqnum(eagershort_pkt, seqnum);
-: 245:
-: 246: /* Copy the payload. We could optimize this if data_sz & 0x3 == 0
-: 247: (copy (data_sz >> 2) ints, inline that since data size is
-: 248: currently limited to 4 ints */
-: 249: {
-: 250: unsigned char * restrict p =
2755049: 251: (unsigned char *)eagershort_pkt->data;
2755049: 252: unsigned char const * restrict bufp = (unsigned char *)buf;
-: 253: int i;
26561769: 254: for (i=0; i<data_sz; i++) {
23806720: 255: *p++ = *bufp++;
-: 256: }
-: 257: }
-: 258:
-: 259: MPIU_DBG_MSGPKT(vc,tag,eagershort_pkt->match.parts.context_id,rank,data_sz,
-: 260: "EagerShort");
-: 261: MPIU_THREAD_CS_ENTER(CH3COMM,vc);
2755049: 262: mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, eagershort_pkt,
-: 263: sizeof(*eagershort_pkt), sreq_p ));
-: 264: MPIU_THREAD_CS_EXIT(CH3COMM,vc);
2755049: 265: if (mpi_errno != MPI_SUCCESS) {
|
#####: 266: MPIU_ERR_SETFATALANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|eagermsg");
-: 267: }
|
2755049: 268: sreq = *sreq_p;
2755049: 269: if (sreq != NULL) {
-: 270: /*printf( "Surprise, did not complete send of eagershort (starting connection?)\n" );
-: 271: fflush(stdout); */
-: 272: MPIDI_Request_set_seqnum(sreq, seqnum);
1683: 273: MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_SEND);
-: 274: }
-: 275:
|
2755049: 276: fn_fail:
|
2755049: 277: return mpi_errno;
-: 278:}
-: 279:
-: 280:/* This is the matching handler for the EagerShort message defined above */
-: 281:
-: 282:#undef FUNCNAME
-: 283:#define FUNCNAME MPIDI_CH3_PktHandler_EagerShortSend
-: 284:#undef FCNAME
-: 285:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 286:int MPIDI_CH3_PktHandler_EagerShortSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
-: 287: MPIDI_msg_sz_t *buflen, MPID_Request **rreqp )
2755049: 288:{
2755049: 289: MPIDI_CH3_Pkt_eagershort_send_t * eagershort_pkt = &pkt->eagershort_send;
-: 290: MPID_Request * rreq;
-: 291: int found;
2755049: 292: int mpi_errno = MPI_SUCCESS;
-: 293:
-: 294: /* printf( "Receiving short eager!\n" ); fflush(stdout); */
-: 295: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 296: "received eagershort send pkt, rank=%d, tag=%d, context=%d",
-: 297: eagershort_pkt->match.parts.rank,
-: 298: eagershort_pkt->match.parts.tag,
-: 299: eagershort_pkt->match.parts.context_id));
-: 300:
-: 301: MPIU_DBG_MSGPKT(vc,eagershort_pkt->match.parts.tag,
-: 302: eagershort_pkt->match.parts.context_id,
-: 303: eagershort_pkt->match.parts.rank,eagershort_pkt->data_sz,
-: 304: "ReceivedEagerShort");
2755049: 305: rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&eagershort_pkt->match, &found);
2755049: 306: MPIU_ERR_CHKANDJUMP1(!rreq, mpi_errno,MPI_ERR_OTHER, "**nomemreq", "**nomemuereq %d", MPIDI_CH3U_Recvq_count_unexp());
-: 307:
2755049: 308: (rreq)->status.MPI_SOURCE = (eagershort_pkt)->match.parts.rank;
2755049: 309: (rreq)->status.MPI_TAG = (eagershort_pkt)->match.parts.tag;
2755049: 310: (rreq)->status.count = (eagershort_pkt)->data_sz;
2755049: 311: (rreq)->dev.recv_data_sz = (eagershort_pkt)->data_sz;
-: 312: MPIDI_Request_set_seqnum((rreq), (eagershort_pkt)->seqnum);
-: 313: /* FIXME: Why do we set the message type? */
2755049: 314: MPIDI_Request_set_msg_type((rreq), MPIDI_REQUEST_EAGER_MSG);
-: 315: /* The request is still complete (in the sense of
-: 316: having all data) */
2755049: 317: MPIDI_CH3U_Request_complete(rreq);
-: 318:
-: 319: /* This packed completes the reception of the indicated data.
-: 320: The packet handler returns null for a request that requires
-: 321: no further communication */
2755049: 322: *rreqp = NULL;
2755049: 323: *buflen = sizeof(MPIDI_CH3_Pkt_t);
-: 324:
-: 325: /* Extract the data from the packet */
-: 326: /* Note that if the data size if zero, we're already done */
2755049: 327: if (rreq->dev.recv_data_sz > 0) {
2755049: 328: if (found) {
-: 329: int dt_contig;
-: 330: MPI_Aint dt_true_lb;
-: 331: MPIDI_msg_sz_t userbuf_sz;
-: 332: MPID_Datatype *dt_ptr;
-: 333: MPIDI_msg_sz_t data_sz;
-: 334:
-: 335: /* Make sure that we handle the general (non-contiguous)
-: 336: datatypes correctly while optimizing for the
-: 337: special case */
2431364: 338: MPIDI_Datatype_get_info(rreq->dev.user_count, rreq->dev.datatype,
-: 339: dt_contig, userbuf_sz, dt_ptr, dt_true_lb);
-: 340:
2431364: 341: if (rreq->dev.recv_data_sz <= userbuf_sz) {
2431359: 342: data_sz = rreq->dev.recv_data_sz;
-: 343: }
-: 344: else {
-: 345: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 346: "receive buffer too small; message truncated, msg_sz="
-: 347: MPIDI_MSG_SZ_FMT ", userbuf_sz="
-: 348: MPIDI_MSG_SZ_FMT,
-: 349: rreq->dev.recv_data_sz, userbuf_sz));
|
5: 350: rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS,
-: 351: MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_TRUNCATE,
-: 352: "**truncate", "**truncate %d %d %d %d",
-: 353: rreq->status.MPI_SOURCE, rreq->status.MPI_TAG,
-: 354: rreq->dev.recv_data_sz, userbuf_sz );
|
5: 355: rreq->status.count = userbuf_sz;
5: 356: data_sz = userbuf_sz;
-: 357: }
-: 358:
4862710: 359: if (dt_contig && data_sz == rreq->dev.recv_data_sz) {
-: 360: /* user buffer is contiguous and large enough to store the
-: 361: entire message. We can just copy the code */
-: 362:
-: 363: /* Copy the payload. We could optimize this
-: 364: if data_sz & 0x3 == 0
-: 365: (copy (data_sz >> 2) ints, inline that since data size is
-: 366: currently limited to 4 ints */
-: 367: {
-: 368: unsigned char const * restrict p =
2431346: 369: (unsigned char *)eagershort_pkt->data;
-: 370: unsigned char * restrict bufp =
-: 371: (unsigned char *)(char*)(rreq->dev.user_buf) +
2431346: 372: dt_true_lb;
-: 373: int i;
22670154: 374: for (i=0; i<data_sz; i++) {
20238808: 375: *bufp++ = *p++;
-: 376: }
-: 377: }
-: 378: /* FIXME: We want to set the OnDataAvail to the appropriate
-: 379: function, which depends on whether this is an RMA
-: 380: request or a pt-to-pt request. */
2431346: 381: rreq->dev.OnDataAvail = 0;
-: 382: /* The recv_pending_count must be one here (!) because of
-: 383: the way the pending count is queried. We may want
-: 384: to fix this, but it will require a sweep of the code */
-: 385: }
-: 386: else {
-: 387: MPIDI_msg_sz_t recv_data_sz;
-: 388: MPI_Aint last;
-: 389: /* user buffer is not contiguous. Use the segment
-: 390: code to unpack it, handling various errors and
-: 391: exceptional cases */
-: 392: /* FIXME: The MPICH2 tests do not exercise this branch */
-: 393: /* printf( "Surprise!\n" ); fflush(stdout);*/
18: 394: rreq->dev.segment_ptr = MPID_Segment_alloc( );
18: 395: MPIU_ERR_CHKANDJUMP1((rreq->dev.segment_ptr == NULL), mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s", "MPID_Segment_alloc");
-: 396:
18: 397: MPID_Segment_init(rreq->dev.user_buf, rreq->dev.user_count,
-: 398: rreq->dev.datatype, rreq->dev.segment_ptr, 0);
-: 399:
18: 400: recv_data_sz = rreq->dev.recv_data_sz;
18: 401: last = recv_data_sz;
18: 402: MPID_Segment_unpack( rreq->dev.segment_ptr, 0,
-: 403: &last, eagershort_pkt->data );
18: 404: if (last != recv_data_sz) {
|
-: 405: /* --BEGIN ERROR HANDLING-- */
-: 406: /* There are two cases: a datatype mismatch (could
-: 407: not consume all data) or a too-short buffer. We
-: 408: need to distinguish between these two types. */
5: 409: rreq->status.count = (int)last;
5: 410: if (rreq->dev.recv_data_sz <= userbuf_sz) {
#####: 411: MPIU_ERR_SETSIMPLE(rreq->status.MPI_ERROR,MPI_ERR_TYPE,
-: 412: "**dtypemismatch");
-: 413: }
-: 414: /* --END ERROR HANDLING-- */
-: 415: }
|
18: 416: rreq->dev.OnDataAvail = 0;
-: 417: }
-: 418: }
-: 419: else {
-: 420: MPIDI_msg_sz_t recv_data_sz;
-: 421: /* This is easy; copy the data into a temporary buffer.
-: 422: To begin with, we use the same temporary location as
-: 423: is used in receiving eager unexpected data.
-: 424: */
-: 425: /* FIXME: When eagershort is enabled, provide a preallocated
-: 426: space for short messages (which is used even if eager short
-: 427: is not used), since we don't want to have a separate check
-: 428: to figure out which buffer we're using (or perhaps we should
-: 429: have a free-buffer-pointer, which can be null if it isn't
-: 430: a buffer that we've allocated). */
-: 431: /* printf( "Allocating into tmp\n" ); fflush(stdout); */
323685: 432: recv_data_sz = rreq->dev.recv_data_sz;
323685: 433: rreq->dev.tmpbuf = MPIU_Malloc(recv_data_sz);
323685: 434: if (!rreq->dev.tmpbuf) {
|
#####: 435: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 436: }
|
323685: 437: rreq->dev.tmpbuf_sz = recv_data_sz;
-: 438: /* Copy the payload. We could optimize this if recv_data_sz & 0x3 == 0
-: 439: (copy (recv_data_sz >> 2) ints, inline that since data size is
-: 440: currently limited to 4 ints */
-: 441: {
-: 442: unsigned char const * restrict p =
323685: 443: (unsigned char *)eagershort_pkt->data;
-: 444: unsigned char * restrict bufp =
323685: 445: (unsigned char *)rreq->dev.tmpbuf;
-: 446: int i;
3891445: 447: for (i=0; i<recv_data_sz; i++) {
3567760: 448: *bufp++ = *p++;
-: 449: }
-: 450: }
-: 451: /* printf( "Unexpected eager short\n" ); fflush(stdout); */
-: 452: /* These next two indicate that once matched, there is
-: 453: one more step (the unpack into the user buffer) to perform. */
323685: 454: rreq->dev.OnDataAvail = MPIDI_CH3_ReqHandler_UnpackUEBufComplete;
323685: 455: rreq->dev.recv_pending_count = 1;
-: 456: }
-: 457:
2755049: 458: if (mpi_errno != MPI_SUCCESS) {
|
#####: 459: MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**ch3|postrecv",
-: 460: "**ch3|postrecv %s", "MPIDI_CH3_PKT_EAGERSHORT_SEND");
-: 461: }
-: 462: }
-: 463:
-: 464: /* The semantics of the packet handlers is that a returned request
-: 465: means that additional actions are required on the request */
-: 466: /* We also signal completion (without this, the progress engine
-: 467: may fail to return from a Progress_wait; the probe-unexp test
-: 468: failed without this Progress_signal_completion call) */
|
2755049: 469: MPIDI_CH3_Progress_signal_completion();
-: 470:
|
2755049: 471: fn_fail:
|
2755049: 472: return mpi_errno;
-: 473:}
-: 474:
-: 475:#endif
-: 476:
-: 477:/* Send a contiguous eager message that can be cancelled (e.g.,
-: 478: a nonblocking eager send). We'll want to optimize (and possibly
-: 479: inline) this
-: 480:
-: 481: Make sure that buf is at the beginning of the data to send;
-: 482: adjust by adding dt_true_lb if necessary
-: 483:*/
-: 484:#undef FUNCNAME
-: 485:#define FUNCNAME MPIDI_EagerContigIsend
-: 486:#undef FCNAME
-: 487:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 488:int MPIDI_CH3_EagerContigIsend( MPID_Request **sreq_p,
-: 489: MPIDI_CH3_Pkt_type_t reqtype,
-: 490: const void * buf, MPIDI_msg_sz_t data_sz, int rank,
-: 491: int tag, MPID_Comm * comm, int context_offset )
6843904: 492:{
6843904: 493: int mpi_errno = MPI_SUCCESS;
-: 494: MPIDI_VC_t * vc;
-: 495: MPIDI_CH3_Pkt_t upkt;
6843904: 496: MPIDI_CH3_Pkt_eager_send_t * const eager_pkt = &upkt.eager_send;
6843904: 497: MPID_Request *sreq = *sreq_p;
-: 498: MPID_IOV iov[MPID_IOV_LIMIT];
-: 499:
-: 500: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 501: "sending contiguous eager message, data_sz=" MPIDI_MSG_SZ_FMT,
-: 502: data_sz));
-: 503:
6843904: 504: sreq->dev.OnDataAvail = 0;
-: 505:
6843904: 506: MPIDI_Pkt_init(eager_pkt, reqtype);
6843904: 507: eager_pkt->match.parts.rank = comm->rank;
6843904: 508: eager_pkt->match.parts.tag = tag;
6843904: 509: eager_pkt->match.parts.context_id = comm->context_id + context_offset;
6843904: 510: eager_pkt->sender_req_id = sreq->handle;
6843904: 511: eager_pkt->data_sz = data_sz;
-: 512:
6843904: 513: iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)eager_pkt;
6843904: 514: iov[0].MPID_IOV_LEN = sizeof(*eager_pkt);
-: 515:
6843904: 516: iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) buf;
6843904: 517: iov[1].MPID_IOV_LEN = data_sz;
-: 518:
6843904: 519: MPIDI_Comm_get_vc_set_active(comm, rank, &vc);
-: 520: MPIDI_VC_FAI_send_seqnum(vc, seqnum);
-: 521: MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
-: 522: MPIDI_Request_set_seqnum(sreq, seqnum);
-: 523:
-: 524: MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,"EagerIsend");
-: 525: MPIU_THREAD_CS_ENTER(CH3COMM,vc);
6843904: 526: mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, sreq, iov, 2 ));
-: 527: MPIU_THREAD_CS_EXIT(CH3COMM,vc);
|
-: 528: /* --BEGIN ERROR HANDLING-- */
6843904: 529: if (mpi_errno != MPI_SUCCESS)
-: 530: {
#####: 531: MPIU_Object_set_ref(sreq, 0);
#####: 532: MPIDI_CH3_Request_destroy(sreq);
#####: 533: *sreq_p = NULL;
#####: 534: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME,
-: 535: __LINE__, MPI_ERR_OTHER, "**ch3|eagermsg", 0);
#####: 536: goto fn_exit;
-: 537: }
-: 538: /* --END ERROR HANDLING-- */
-: 539:
|
6843904: 540: fn_exit:
6843904: 541: return mpi_errno;
-: 542:}
-: 543:
-: 544:/*
-: 545: * Here are the routines that are called by the progress engine to handle
-: 546: * the various rendezvous message requests (cancel of sends is in
-: 547: * mpid_cancel_send.c).
-: 548: */
-: 549:
-: 550:#define set_request_info(rreq_, pkt_, msg_type_) \
-: 551:{ \
-: 552: (rreq_)->status.MPI_SOURCE = (pkt_)->match.parts.rank; \
-: 553: (rreq_)->status.MPI_TAG = (pkt_)->match.parts.tag; \
-: 554: (rreq_)->status.count = (pkt_)->data_sz; \
-: 555: (rreq_)->dev.sender_req_id = (pkt_)->sender_req_id; \
-: 556: (rreq_)->dev.recv_data_sz = (pkt_)->data_sz; \
-: 557: MPIDI_Request_set_seqnum((rreq_), (pkt_)->seqnum); \
-: 558: MPIDI_Request_set_msg_type((rreq_), (msg_type_)); \
-: 559:}
-: 560:
-: 561:/* FIXME: This is not optimized for short messages, which
-: 562: should have the data in the same packet when the data is
-: 563: particularly short (e.g., one 8 byte long word) */
-: 564:#undef FUNCNAME
-: 565:#define FUNCNAME MPIDI_CH3_PktHandler_EagerSend
-: 566:#undef FCNAME
-: 567:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 568:int MPIDI_CH3_PktHandler_EagerSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
-: 569: MPIDI_msg_sz_t *buflen, MPID_Request **rreqp )
12214393: 570:{
12214393: 571: MPIDI_CH3_Pkt_eager_send_t * eager_pkt = &pkt->eager_send;
-: 572: MPID_Request * rreq;
-: 573: int found;
-: 574: int complete;
-: 575: char *data_buf;
-: 576: MPIDI_msg_sz_t data_len;
12214393: 577: int mpi_errno = MPI_SUCCESS;
-: 578:
-: 579: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 580: "received eager send pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d",
-: 581: eager_pkt->sender_req_id, eager_pkt->match.parts.rank,
-: 582: eager_pkt->match.parts.tag, eager_pkt->match.parts.context_id));
-: 583: MPIU_DBG_MSGPKT(vc,eager_pkt->match.parts.tag,
-: 584: eager_pkt->match.parts.context_id,
-: 585: eager_pkt->match.parts.rank,eager_pkt->data_sz,
-: 586: "ReceivedEager");
-: 587:
12214393: 588: rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&eager_pkt->match, &found);
12214393: 589: MPIU_ERR_CHKANDJUMP1(!rreq, mpi_errno,MPI_ERR_OTHER, "**nomemreq", "**nomemuereq %d", MPIDI_CH3U_Recvq_count_unexp());
-: 590:
12214393: 591: set_request_info(rreq, eager_pkt, MPIDI_REQUEST_EAGER_MSG);
-: 592:
12214393: 593: data_len = ((*buflen - sizeof(MPIDI_CH3_Pkt_t) >= rreq->dev.recv_data_sz)
-: 594: ? rreq->dev.recv_data_sz : *buflen - sizeof(MPIDI_CH3_Pkt_t));
12214393: 595: data_buf = (char *)pkt + sizeof(MPIDI_CH3_Pkt_t);
-: 596:
12214393: 597: if (rreq->dev.recv_data_sz == 0) {
-: 598: /* return the number of bytes processed in this function */
2325808: 599: *buflen = sizeof(MPIDI_CH3_Pkt_t);
2325808: 600: MPIDI_CH3U_Request_complete(rreq);
2325808: 601: *rreqp = NULL;
-: 602: }
-: 603: else {
9888585: 604: if (found) {
8995551: 605: mpi_errno = MPIDI_CH3U_Receive_data_found( rreq, data_buf,
-: 606: &data_len, &complete );
-: 607: }
-: 608: else {
893034: 609: mpi_errno = MPIDI_CH3U_Receive_data_unexpected( rreq, data_buf,
-: 610: &data_len, &complete );
-: 611: }
-: 612:
9888585: 613: if (mpi_errno != MPI_SUCCESS) {
|
#####: 614: MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**ch3|postrecv",
-: 615: "**ch3|postrecv %s", "MPIDI_CH3_PKT_EAGER_SEND");
-: 616: }
-: 617:
-: 618: /* return the number of bytes processed in this function */
|
9888585: 619: *buflen = sizeof(MPIDI_CH3_Pkt_t) + data_len;
-: 620:
9888585: 621: if (complete)
-: 622: {
|
#####: 623: MPIDI_CH3U_Request_complete(rreq);
#####: 624: *rreqp = NULL;
-: 625: }
-: 626: else
-: 627: {
|
9888585: 628: *rreqp = rreq;
-: 629: }
-: 630: }
-: 631:
|
12214393: 632: fn_fail:
|
12214393: 633: return mpi_errno;
-: 634:}
-: 635:
-: 636:
-: 637:#undef FUNCNAME
-: 638:#define FUNCNAME MPIDI_CH3_PktHandler_ReadySend
-: 639:#undef FCNAME
-: 640:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 641:int MPIDI_CH3_PktHandler_ReadySend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
-: 642: MPIDI_msg_sz_t *buflen, MPID_Request **rreqp )
77485: 643:{
77485: 644: MPIDI_CH3_Pkt_ready_send_t * ready_pkt = &pkt->ready_send;
-: 645: MPID_Request * rreq;
-: 646: int found;
-: 647: int complete;
-: 648: char *data_buf;
-: 649: MPIDI_msg_sz_t data_len;
77485: 650: int mpi_errno = MPI_SUCCESS;
-: 651:
-: 652: MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
-: 653: "received ready send pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d",
-: 654: ready_pkt->sender_req_id,
-: 655: ready_pkt->match.parts.rank,
-: 656: ready_pkt->match.parts.tag,
-: 657: ready_pkt->match.parts.context_id));
-: 658: MPIU_DBG_MSGPKT(vc,ready_pkt->match.parts.tag,
-: 659: ready_pkt->match.parts.context_id,
-: 660: ready_pkt->match.parts.rank,ready_pkt->data_sz,
-: 661: "ReceivedReady");
-: 662:
77485: 663: rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&ready_pkt->match, &found);
77485: 664: MPIU_ERR_CHKANDJUMP1(!rreq, mpi_errno,MPI_ERR_OTHER, "**nomemreq", "**nomemuereq %d", MPIDI_CH3U_Recvq_count_unexp());
-: 665:
77485: 666: set_request_info(rreq, ready_pkt, MPIDI_REQUEST_EAGER_MSG);
-: 667:
77485: 668: data_len = ((*buflen - sizeof(MPIDI_CH3_Pkt_t) >= rreq->dev.recv_data_sz)
-: 669: ? rreq->dev.recv_data_sz : *buflen - sizeof(MPIDI_CH3_Pkt_t));
77485: 670: data_buf = (char *)pkt + sizeof(MPIDI_CH3_Pkt_t);
-: 671:
77485: 672: if (found) {
77485: 673: if (rreq->dev.recv_data_sz == 0) {
-: 674: /* return the number of bytes processed in this function */
6174: 675: *buflen = sizeof(MPIDI_CH3_Pkt_t) + data_len;;
6174: 676: MPIDI_CH3U_Request_complete(rreq);
6174: 677: *rreqp = NULL;
-: 678: }
-: 679: else {
71311: 680: mpi_errno = MPIDI_CH3U_Receive_data_found(rreq, data_buf, &data_len,
-: 681: &complete);
71311: 682: if (mpi_errno != MPI_SUCCESS) {
|
#####: 683: MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER,
-: 684: "**ch3|postrecv",
-: 685: "**ch3|postrecv %s",
-: 686: "MPIDI_CH3_PKT_READY_SEND");
-: 687: }
-: 688:
-: 689: /* return the number of bytes processed in this function */
|
71311: 690: *buflen = sizeof(MPIDI_CH3_Pkt_t) + data_len;
-: 691:
71311: 692: if (complete)
-: 693: {
|
#####: 694: MPIDI_CH3U_Request_complete(rreq);
#####: 695: *rreqp = NULL;
-: 696: }
-: 697: else
-: 698: {
|
71311: 699: *rreqp = rreq;
-: 700: }
-: 701: }
-: 702: }
-: 703: else
-: 704: {
-: 705: /* FIXME: an error packet should be sent back to the sender
-: 706: indicating that the ready-send failed. On the send
-: 707: side, the error handler for the communicator can be invoked
-: 708: even if the ready-send request has already
-: 709: completed. */
-: 710:
-: 711: /* We need to consume any outstanding associated data and
-: 712: mark the request with an error. */
-: 713:
|
#####: 714: rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS,
-: 715: MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
-: 716: MPI_ERR_OTHER, "**rsendnomatch",
-: 717: "**rsendnomatch %d %d",
-: 718: ready_pkt->match.parts.rank,
-: 719: ready_pkt->match.parts.tag);
|
#####: 720: rreq->status.count = 0;
#####: 721: if (rreq->dev.recv_data_sz > 0)
-: 722: {
-: 723: /* force read of extra data */
#####: 724: *rreqp = rreq;
#####: 725: rreq->dev.segment_first = 0;
#####: 726: rreq->dev.segment_size = 0;
#####: 727: mpi_errno = MPIDI_CH3U_Request_load_recv_iov(rreq);
#####: 728: if (mpi_errno != MPI_SUCCESS) {
|
#####: 729: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,
-: 730: "**ch3|loadrecviov");
-: 731: }
-: 732: }
-: 733: else
-: 734: {
-: 735: /* mark data transfer as complete and decrement CC */
|
#####: 736: MPIDI_CH3U_Request_complete(rreq);
#####: 737: *rreqp = NULL;
-: 738: }
-: 739: /* we didn't process anything but the header in this case */
#####: 740: *buflen = sizeof(MPIDI_CH3_Pkt_t);
-: 741: }
|
77485: 742: fn_fail:
|
77485: 743: return mpi_errno;
-: 744:}
-: 745:
-: 746:
-: 747:/*
-: 748: * Define the routines that can print out the cancel packets if
-: 749: * debugging is enabled.
-: 750: */
-: 751:#ifdef MPICH_DBG_OUTPUT
-: 752:int MPIDI_CH3_PktPrint_EagerSend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
-: 753:{
-: 754: MPIU_DBG_PRINTF((" type ......... EAGER_SEND\n"));
-: 755: MPIU_DBG_PRINTF((" sender_reqid . 0x%08X\n", pkt->eager_send.sender_req_id));
-: 756: MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eager_send.match.parts.context_id));
-: 757: MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eager_send.match.parts.tag));
-: 758: MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eager_send.match.parts.rank));
-: 759: MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->eager_send.data_sz));
-: 760:#ifdef MPID_USE_SEQUENCE_NUMBERS
-: 761: MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->eager_send.seqnum));
-: 762:#endif
-: 763:}
-: 764:
-: 765:#if defined(USE_EAGER_SHORT)
-: 766:int MPIDI_CH3_PktPrint_EagerShortSend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
-: 767:{
-: 768: int datalen;
-: 769: unsigned char *p = (unsigned char *)pkt->eagershort_send.data;
-: 770: MPIU_DBG_PRINTF((" type ......... EAGERSHORT_SEND\n"));
-: 771: MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eagershort_send.match.parts.context_id));
-: 772: MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eagershort_send.match.parts.tag));
-: 773: MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eagershort_send.match.parts.rank));
-: 774: MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->eagershort_send.data_sz));
-: 775:#ifdef MPID_USE_SEQUENCE_NUMBERS
-: 776: MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->eagershort_send.seqnum));
-: 777:#endif
-: 778: datalen = pkt->eagershort_send.data_sz;
-: 779: if (datalen > 0) {
-: 780: char databytes[64+1];
-: 781: int i;
-: 782: if (datalen > 32) datalen = 32;
-: 783: for (i=0; i<datalen; i++) {
-: 784: MPIU_Snprintf( &databytes[2*i], 64 - 2*i, "%2x", p[i] );
-: 785: }
-: 786: MPIU_DBG_PRINTF((" data ......... %s\n", databytes));
-: 787: }
-: 788:}
-: 789:#endif /* defined(USE_EAGER_SHORT) */
-: 790:
-: 791:int MPIDI_CH3_PktPrint_ReadySend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
-: 792:{
-: 793: MPIU_DBG_PRINTF((" type ......... READY_SEND\n"));
-: 794: MPIU_DBG_PRINTF((" sender_reqid . 0x%08X\n", pkt->ready_send.sender_req_id));
-: 795: MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->ready_send.match.parts.context_id));
-: 796: MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->ready_send.match.parts.tag));
-: 797: MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->ready_send.match.parts.rank));
-: 798: MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->ready_send.data_sz));
-: 799:#ifdef MPID_USE_SEQUENCE_NUMBERS
-: 800: MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->ready_send.seqnum));
-: 801:#endif
-: 802:}
-: 803:
-: 804:#endif /* MPICH_DBG_OUTPUT */
|