-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/channels/sock/src/ch3_istartmsg.c
-: 0:Graph:ch3_istartmsg.gcno
-: 0:Data:ch3_istartmsg.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:#undef FUNCNAME
-: 10:#define FUNCNAME create_request
-: 11:#undef FCNAME
-: 12:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 13:static MPID_Request * create_request(void * hdr, MPIDI_msg_sz_t hdr_sz,
-: 14: MPIU_Size_t nb)
2705: 15:{
-: 16: MPID_Request * sreq;
-: 17: MPIDI_STATE_DECL(MPID_STATE_CREATE_REQUEST);
-: 18:
-: 19: MPIDI_FUNC_ENTER(MPID_STATE_CREATE_REQUEST);
-: 20:
2705: 21: sreq = MPID_Request_create();
|
-: 22: /* --BEGIN ERROR HANDLING-- */
2705: 23: if (sreq == NULL)
#####: 24: return NULL;
-: 25: /* --END ERROR HANDLING-- */
|
2705: 26: MPIU_Object_set_ref(sreq, 2);
2705: 27: sreq->kind = MPID_REQUEST_SEND;
2705: 28: MPIU_Assert(hdr_sz == sizeof(MPIDI_CH3_Pkt_t));
2705: 29: sreq->dev.pending_pkt = *(MPIDI_CH3_PktGeneric_t *) hdr;
2705: 30: sreq->dev.iov[0].MPID_IOV_BUF =
-: 31: (MPID_IOV_BUF_CAST)((char *) &sreq->dev.pending_pkt + nb);
2705: 32: sreq->dev.iov[0].MPID_IOV_LEN = hdr_sz - nb;
2705: 33: sreq->dev.iov_count = 1;
2705: 34: sreq->dev.OnDataAvail = 0;
-: 35:
|
-: 36: MPIDI_FUNC_EXIT(MPID_STATE_CREATE_REQUEST);
|
2705: 37: return sreq;
-: 38:}
-: 39:
-: 40:/*
-: 41: * MPIDI_CH3_iStartMsg() attempts to send the message immediately. If the
-: 42: * entire message is successfully sent, then NULL is
-: 43: * returned. Otherwise a request is allocated, the header is copied into the
-: 44: * request, and a pointer to the request is returned.
-: 45: * An error condition also results in a request be allocated and the errror
-: 46: * being returned in the status field of the request.
-: 47: */
-: 48:#undef FUNCNAME
-: 49:#define FUNCNAME MPIDI_CH3_iStartMsg
-: 50:#undef FCNAME
-: 51:#define FCNAME MPIDI_QUOTE(FUNCNAME)
-: 52:int MPIDI_CH3_iStartMsg(MPIDI_VC_t * vc, void * hdr, MPIDI_msg_sz_t hdr_sz,
-: 53: MPID_Request ** sreq_ptr)
3708645: 54:{
3708645: 55: MPID_Request * sreq = NULL;
3708645: 56: MPIDI_CH3I_VC *vcch = (MPIDI_CH3I_VC *)vc->channel_private;
3708645: 57: int mpi_errno = MPI_SUCCESS;
-: 58: MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_ISTARTMSG);
-: 59:
-: 60: MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_ISTARTMSG);
-: 61:
3708645: 62: MPIU_Assert( hdr_sz <= sizeof(MPIDI_CH3_Pkt_t));
-: 63:
-: 64: /* The SOCK channel uses a fixed length header, the size of which is the
-: 65: maximum of all possible packet headers */
3708645: 66: hdr_sz = sizeof(MPIDI_CH3_Pkt_t);
-: 67: MPIU_DBG_STMT(CH3_CHANNEL,VERBOSE,
-: 68: MPIDI_DBG_Print_packet((MPIDI_CH3_Pkt_t*)hdr));
-: 69:
3708645: 70: if (vcch->state == MPIDI_CH3I_VC_STATE_CONNECTED) /* MT */
-: 71: {
-: 72: /* Connection already formed. If send queue is empty attempt to send
-: 73: data, queuing any unsent data. */
3706653: 74: if (MPIDI_CH3I_SendQ_empty(vcch)) /* MT */
-: 75: {
-: 76: MPIU_Size_t nb;
-: 77: int rc;
-: 78:
-: 79: MPIU_DBG_MSG(CH3_CHANNEL,VERBOSE,
-: 80: "send queue empty, attempting to write");
-: 81:
-: 82: MPIU_DBG_PKT(vcch->conn,hdr,"istartmsg");
-: 83: /* MT: need some signalling to lock down our right to use the
-: 84: channel, thus insuring that the progress engine does
-: 85: not also try to write */
3705963: 86: rc = MPIDU_Sock_write(vcch->sock, hdr, hdr_sz, &nb);
3705963: 87: if (rc == MPI_SUCCESS)
-: 88: {
-: 89: MPIU_DBG_MSG_D(CH3_CHANNEL,VERBOSE,
-: 90: "wrote %ld bytes", (unsigned long) nb);
-: 91:
3705963: 92: if (nb == hdr_sz)
-: 93: {
-: 94: MPIU_DBG_MSG_D(CH3_CHANNEL,VERBOSE,
-: 95: "entire write complete, " MPIDI_MSG_SZ_FMT " bytes", nb);
-: 96: /* done. get us out of here as quickly as possible. */
-: 97: }
-: 98: else
-: 99: {
-: 100: MPIU_DBG_MSG_D(CH3_CHANNEL,VERBOSE,
-: 101: "partial write of " MPIDI_MSG_SZ_FMT " bytes, request enqueued at head", nb);
23: 102: sreq = create_request(hdr, hdr_sz, nb);
23: 103: if (!sreq) {
|
#####: 104: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 105: }
-: 106:
|
23: 107: MPIDI_CH3I_SendQ_enqueue_head(vcch, sreq);
-: 108: MPIU_DBG_MSG_FMT(CH3_CHANNEL,VERBOSE,
-: 109: (MPIU_DBG_FDEST,"posting write, vc=0x%p, sreq=0x%08x", vc, sreq->handle));
23: 110: vcch->conn->send_active = sreq;
23: 111: mpi_errno = MPIDU_Sock_post_write(vcch->conn->sock, sreq->dev.iov[0].MPID_IOV_BUF,
-: 112: sreq->dev.iov[0].MPID_IOV_LEN, sreq->dev.iov[0].MPID_IOV_LEN, NULL);
|
-: 113: /* --BEGIN ERROR HANDLING-- */
23: 114: if (mpi_errno != MPI_SUCCESS)
-: 115: {
#####: 116: mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_FATAL, FCNAME, __LINE__, MPI_ERR_OTHER,
-: 117: "**ch3|sock|postwrite", "ch3|sock|postwrite %p %p %p",
-: 118: sreq, vcch->conn, vc);
#####: 119: goto fn_fail;
-: 120: }
-: 121: /* --END ERROR HANDLING-- */
-: 122: }
-: 123: }
-: 124: /* --BEGIN ERROR HANDLING-- */
-: 125: else
-: 126: {
-: 127: MPIU_DBG_MSG_D(CH3_CHANNEL,TYPICAL,
-: 128: "ERROR - MPIDU_Sock_write failed, rc=%d", rc);
#####: 129: sreq = MPID_Request_create();
#####: 130: if (!sreq) {
#####: 131: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 132: }
#####: 133: sreq->kind = MPID_REQUEST_SEND;
#####: 134: sreq->cc = 0;
#####: 135: sreq->status.MPI_ERROR = MPIR_Err_create_code( rc,
-: 136: MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
-: 137: MPI_ERR_INTERN, "**ch3|sock|writefailed",
-: 138: "**ch3|sock|writefailed %d", rc );
-: 139: /* Make sure that the caller sees this error */
#####: 140: mpi_errno = sreq->status.MPI_ERROR;
-: 141: }
-: 142: /* --END ERROR HANDLING-- */
-: 143: }
-: 144: else
-: 145: {
-: 146: MPIU_DBG_MSG(CH3_CHANNEL,VERBOSE,
-: 147: "send in progress, request enqueued");
|
690: 148: sreq = create_request(hdr, hdr_sz, 0);
690: 149: if (!sreq) {
|
#####: 150: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 151: }
|
690: 152: MPIDI_CH3I_SendQ_enqueue(vcch, sreq);
-: 153: }
-: 154: }
1992: 155: else if (vcch->state == MPIDI_CH3I_VC_STATE_CONNECTING) /* MT */
-: 156: {
-: 157: MPIU_DBG_VCUSE(vc,
-: 158: "connecteding. enqueuing request");
-: 159:
-: 160: /* queue the data so it can be sent after the connection is formed */
10: 161: sreq = create_request(hdr, hdr_sz, 0);
10: 162: if (!sreq) {
|
#####: 163: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 164: }
|
10: 165: MPIDI_CH3I_SendQ_enqueue(vcch, sreq);
-: 166: }
1982: 167: else if (vcch->state == MPIDI_CH3I_VC_STATE_UNCONNECTED) /* MT */
-: 168: {
-: 169: MPIU_DBG_VCUSE(vc,
-: 170: "unconnected. posting connect and enqueuing request");
-: 171:
-: 172: /* queue the data so it can be sent after the connection is formed */
1982: 173: sreq = create_request(hdr, hdr_sz, 0);
1982: 174: if (!sreq) {
|
#####: 175: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 176: }
|
1982: 177: MPIDI_CH3I_SendQ_enqueue(vcch, sreq);
-: 178:
-: 179: /* Form a new connection */
1982: 180: MPIDI_CH3I_VC_post_connect(vc);
-: 181: }
|
#####: 182: else if (vcch->state != MPIDI_CH3I_VC_STATE_FAILED)
-: 183: {
-: 184: /* Unable to send data at the moment, so queue it for later */
-: 185: MPIU_DBG_VCUSE(vc,"forming connection, request enqueued");
#####: 186: sreq = create_request(hdr, hdr_sz, 0);
#####: 187: if (!sreq) {
|
#####: 188: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 189: }
|
#####: 190: MPIDI_CH3I_SendQ_enqueue(vcch, sreq);
-: 191: }
|
-: 192: /* --BEGIN ERROR HANDLING-- */
-: 193: else
-: 194: {
-: 195: /* Connection failed, so allocate a request and return an error. */
-: 196: MPIU_DBG_VCUSE(vc,"ERROR - connection failed");
#####: 197: sreq = MPID_Request_create();
#####: 198: if (!sreq) {
#####: 199: MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
-: 200: }
#####: 201: sreq->kind = MPID_REQUEST_SEND;
#####: 202: sreq->cc = 0;
-: 203:
#####: 204: sreq->status.MPI_ERROR = MPIR_Err_create_code( MPI_SUCCESS,
-: 205: MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
-: 206: MPI_ERR_INTERN, "**ch3|sock|connectionfailed",0 );
-: 207: /* Make sure that the caller sees this error */
#####: 208: mpi_errno = sreq->status.MPI_ERROR;
-: 209: }
-: 210: /* --END ERROR HANDLING-- */
-: 211:
3708645: 212: fn_fail:
|
3708645: 213: *sreq_ptr = sreq;
|
-: 214: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_ISTARTMSG);
|
3708645: 215: return mpi_errno;
-: 216:}
|