⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch3u_handle_recv_pkt.c

📁 刚才是说明 现在是安装程序在 LINUX环境下进行编程的MPICH安装文件
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* *  (C) 2001 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include "mpidimpl.h"static void post_data_receive(MPIDI_VC * vc, MPID_Request * rreq, int found);#define set_request_info(_rreq, _pkt, _msg_type)		\{								\    (_rreq)->status.MPI_SOURCE = (_pkt)->match.rank;		\    (_rreq)->status.MPI_TAG = (_pkt)->match.tag;		\    (_rreq)->status.count = (_pkt)->data_sz;			\    (_rreq)->ch3.sender_req_id = (_pkt)->sender_req_id;		\    (_rreq)->ch3.recv_data_sz = (_pkt)->data_sz;		\    MPIDI_CH3U_Request_set_seqnum((_rreq), (_pkt)->seqnum);	\    MPIDI_Request_set_msg_type((_rreq), (_msg_type));		\}/* * MPIDI_CH3U_Handle_recv_pkt() * * NOTE: This routine must be reentrant.  Routines like MPIDI_CH3_iRead() are allowed to perform additional up-calls if they * complete the requested work immediately. *** Care must be take to avoid deep recursion.  With some thread packages, exceeding * the stack space allocated to a thread can result in overwriting the stack of another thread. *** */void MPIDI_CH3U_Handle_unordered_recv_pkt(MPIDI_VC * vc, MPIDI_CH3_Pkt_t * pkt);void MPIDI_CH3U_Handle_ordered_recv_pkt(MPIDI_VC * vc, MPIDI_CH3_Pkt_t * pkt);#if defined(MPIDI_CH3_MSGS_UNORDERED)#define MPIDI_CH3U_Handle_unordered_recv_pkt MPIDI_CH3U_Handle_recv_pkt#else#define MPIDI_CH3U_Handle_ordered_recv_pkt MPIDI_CH3U_Handle_recv_pkt #endif#if defined(MPIDI_CH3_MSGS_UNORDERED)#define MPIDI_CH3U_Pkt_send_container_alloc() (MPIU_Malloc(sizeof(MPIDI_CH3_Pkt_send_container_t)))#define MPIDI_CH3U_Pkt_send_container_free(pc) MPIU_Free(pc)#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Handle_unordered_recv_pkt#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)void MPIDI_CH3U_Handle_unordered_recv_pkt(MPIDI_VC * vc, MPIDI_CH3_Pkt_t * pkt){    MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_HANDLE_UNORDERED_RECV_PKT);    MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_HANDLE_UNORDERED_RECV_PKT);        switch(pkt->type)    {	case MPIDI_CH3_PKT_EAGER_SEND:	case MPIDI_CH3_PKT_EAGER_SYNC_SEND:	case MPIDI_CH3_PKT_READY_SEND:	case MPIDI_CH3_PKT_RNDV_REQ_TO_SEND:	{	    MPIDI_CH3_Pkt_send_t * send_pkt = (MPIDI_CH3_Pkt_send_t *) pkt;	    MPIDI_CH3_Pkt_send_container_t * pc_cur;	    MPIDI_CH3_Pkt_send_container_t * pc_last;	    	    MPIDI_DBG_PRINTF((30, FCNAME, "received (potentially) out-of-order send pkt"));	    MPIDI_DBG_PRINTF((30, FCNAME, "rank=%d, tag=%d, context=%d seqnum=%d",			      send_pkt->match.rank, send_pkt->match.tag, send_pkt->match.context_id, send_pkt->seqnum));	    	    /* MT - Need to lock VC !!! */	    	    MPIDI_DBG_PRINTF((30, FCNAME, "vc - seqnum_send=%d seqnum_recv=%d reorder_msg_queue=0x%08lx",			      vc->seqnum_send, vc->seqnum_recv, (unsigned long) vc->msg_reorder_queue));	    	    if (send_pkt->seqnum == vc->seqnum_recv)	    {		MPIDI_CH3U_Handle_ordered_recv_pkt(vc, pkt);		vc->seqnum_recv++;		pc_cur = vc->msg_reorder_queue;		while(pc_cur != NULL && vc->seqnum_recv == pc_cur->pkt.seqnum)		{		    pkt = (MPIDI_CH3_Pkt_t *) &pc_cur->pkt;		    MPIDI_CH3U_Handle_ordered_recv_pkt(vc, pkt);		    vc->seqnum_recv++;		    pc_last = pc_cur;		    pc_cur = pc_cur->next;		    MPIDI_CH3U_Pkt_send_container_free(pc_last);		}		vc->msg_reorder_queue = pc_cur;	    }	    else	    {		MPIDI_CH3_Pkt_send_container_t * pc_new;			/* allocate container and copy packet */		pc_new = MPIDI_CH3U_Pkt_send_container_alloc();		pc_new->pkt = *send_pkt;		/* insert packet into reorder queue */		pc_last = NULL;		pc_cur = vc->msg_reorder_queue;		while (pc_cur != NULL)		{		    /* the current recv seqnum is subtracted from both the seqnums prior to comparision so as to remove any wrap		       around effects. */		    if (pc_new->pkt.seqnum - vc->seqnum_recv < pc_cur->pkt.seqnum - vc->seqnum_recv)		    {			break;		    }		    pc_last = pc_cur;		    pc_cur = pc_cur->next;		}		if (pc_last == NULL)		{		    pc_new->next = pc_cur;		    vc->msg_reorder_queue = pc_new;		}		else		{		    pc_new->next = pc_cur;		    pc_last->next = pc_new;		}	    }	    break;	}	case MPIDI_CH3_PKT_CANCEL_SEND_REQ:	{	    /* FIXME: processing send cancel requests requires that we be aware               of pkts in the reorder queue */	    abort();	    break;	}		default:	{	    MPIDI_CH3U_Handle_ordered_recv_pkt(vc, pkt);	    break;	}    }        MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_HANDLE_UNORDERED_RECV_PKT);}#endif#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Handle_ordered_recv_pkt#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)void MPIDI_CH3U_Handle_ordered_recv_pkt(MPIDI_VC * vc, MPIDI_CH3_Pkt_t * pkt){    MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_HANDLE_ORDERED_RECV_PKT);    MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_HANDLE_ORDERED_RECV_PKT);    assert(pkt->type < MPIDI_CH3_PKT_END_CH3);        switch(pkt->type)    {	case MPIDI_CH3_PKT_EAGER_SEND:	{	    MPIDI_CH3_Pkt_eager_send_t * eager_pkt = &pkt->eager_send;	    MPID_Request * rreq;	    int found;	    MPIDI_DBG_PRINTF((30, FCNAME, "received eager send pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d",			      eager_pkt->sender_req_id, eager_pkt->match.rank, eager_pkt->match.tag, eager_pkt->match.context_id));	    	    rreq = MPIDI_CH3U_Request_FDP_or_AEU(&eager_pkt->match, &found);	    if (rreq == NULL)	    {		/* FIXME - need to handle memory allocation problems */		assert(rreq != NULL);		abort();	    }	    	    set_request_info(rreq, eager_pkt, MPIDI_REQUEST_EAGER_MSG);	    post_data_receive(vc, rreq, found);	    break;	}		case MPIDI_CH3_PKT_READY_SEND:	{	    MPIDI_CH3_Pkt_ready_send_t * ready_pkt = &pkt->ready_send;	    MPID_Request * rreq;	    int found;	    	    MPIDI_DBG_PRINTF((30, FCNAME, "received ready send pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d",			      ready_pkt->sender_req_id, ready_pkt->match.rank, ready_pkt->match.tag, ready_pkt->match.context_id));	    	    rreq = MPIDI_CH3U_Request_FDP_or_AEU(&ready_pkt->match, &found);	    if (rreq == NULL)	    {		/* FIXME - need to handle memory allocation problems */		assert(rreq != NULL);		abort();	    }	    	    set_request_info(rreq, ready_pkt, MPIDI_REQUEST_EAGER_MSG);	    if (found)	    {		post_data_receive(vc, rreq, TRUE);	    }	    else	    {		/* FIXME: an error packet should be sent back to the sender indicating that the ready-send failed.  On the send                   side, the error handler for the communicator can be invoked even if the ready-send request has already                   completed. */		/* We need to consume any outstanding associated data and mark the request with an error. */		int rc;		rreq->status.MPI_ERROR = MPI_ERR_UNKNOWN;		rreq->status.count = 0;		if (rreq->ch3.recv_data_sz > 0)		{		     /* force read of extra data */		    rreq->ch3.segment_first = 0;		    rreq->ch3.segment_size = 0;		    rc = MPIDI_CH3U_Request_load_recv_iov(rreq);		    if (rc != MPI_SUCCESS)		    {			/* FIXME - need to handle buffer allocation problems */			assert(rc == MPI_SUCCESS);			abort();		    }		    MPIDI_CH3_iRead(vc, rreq);		}		else		{		    /* mark data transfer as complete adn decrment CC */		    rreq->ch3.iov_count = 0;		    MPIDI_CH3U_Request_complete(rreq);		}	    }	    break;	}		case MPIDI_CH3_PKT_EAGER_SYNC_SEND:	{	    MPIDI_CH3_Pkt_eager_send_t * es_pkt = &pkt->eager_send;	    MPID_Request * rreq;	    int found;	    MPIDI_DBG_PRINTF((30, FCNAME, "received eager sync send pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d",			      es_pkt->sender_req_id, es_pkt->match.rank, es_pkt->match.tag, es_pkt->match.context_id));	    	    rreq = MPIDI_CH3U_Request_FDP_or_AEU(&es_pkt->match, &found);	    if (rreq == NULL)	    {		/* FIXME - need to handle memory allocation problems */		assert(rreq != NULL);		abort();	    }	    	    set_request_info(rreq, es_pkt, MPIDI_REQUEST_EAGER_MSG);	    post_data_receive(vc, rreq, found);	    	    if (found)	    {		MPIDI_CH3_Pkt_t upkt;		MPIDI_CH3_Pkt_eager_sync_ack_t * const esa_pkt = &upkt.eager_sync_ack;		MPID_Request * esa_req;		    		MPIDI_DBG_PRINTF((30, FCNAME, "sending eager sync ack"));					esa_pkt->type = MPIDI_CH3_PKT_EAGER_SYNC_ACK;		esa_pkt->sender_req_id = es_pkt->sender_req_id;		esa_req = MPIDI_CH3_iStartMsg(vc, esa_pkt, sizeof(*esa_pkt));		if (esa_req != NULL)		{		    MPID_Request_release(esa_req);		}	    }	    else	    {		MPIDI_Request_set_sync_send_flag(rreq, TRUE);	    }	    	    break;	}	case MPIDI_CH3_PKT_EAGER_SYNC_ACK:	{	    MPIDI_CH3_Pkt_eager_sync_ack_t * esa_pkt = &pkt->eager_sync_ack;	    MPID_Request * sreq;	    	    MPIDI_DBG_PRINTF((30, FCNAME, "received eager sync ack pkt, sreq=0x%08x", esa_pkt->sender_req_id));	    	    MPID_Request_get_ptr(esa_pkt->sender_req_id, sreq);	    /* decrement CC (but don't mark data transfer as complete since the transfer could still be in progress) */	    MPIDI_CH3U_Request_complete(sreq);	    break;	}		case MPIDI_CH3_PKT_RNDV_REQ_TO_SEND:	{	    MPIDI_CH3_Pkt_rndv_req_to_send_t * rts_pkt = &pkt->rndv_req_to_send;	    MPID_Request * rreq;	    int found;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -