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

📄 mpid_cancel_send.c

📁 刚才是说明 现在是安装程序在 LINUX环境下进行编程的MPICH安装文件
💻 C
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* *  (C) 2001 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include "mpidimpl.h"#undef FUNCNAME#define FUNCNAME MPID_Cancel_send#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)void MPID_Cancel_send(MPID_Request * sreq){    MPIDI_VC * vc;    int proto;    int flag;    MPIDI_STATE_DECL(MPID_STATE_MPID_CANCEL_SEND);    MPIDI_FUNC_ENTER(MPID_STATE_MPID_CANCEL_SEND);    MPIDI_DBG_PRINTF((10, FCNAME, "entering"));        assert(sreq->kind == MPID_REQUEST_SEND);    MPIDI_Request_cancel_pending(sreq, &flag);    if (flag)    {	goto fn_exit;    }        vc = sreq->comm->vcr[sreq->ch3.match.rank];    proto = MPIDI_Request_get_msg_type(sreq);    if (proto == MPIDI_REQUEST_SELF_MSG)    {	MPID_Request * rreq;		MPIDI_DBG_PRINTF((15, FCNAME, "attempting to cancel message sent to self"));		rreq = MPIDI_CH3U_Request_FDU(sreq->handle, &sreq->ch3.match);	if (rreq)	{	    assert(rreq->partner_request == sreq);	    	    MPIDI_DBG_PRINTF((15, FCNAME, "send-to-self cancellation successful, sreq=0x%08x, rreq=0x%08x",			      sreq->handle, rreq->handle));	    	    MPIU_Object_set_ref(rreq, 0);	    MPIDI_CH3_Request_destroy(rreq);	    	    sreq->status.cancelled = TRUE;	    /* no other thread should be waiting on sreq, so it is safe to reset ref_count and cc */	    sreq->cc = 0;	    MPIU_Object_set_ref(sreq, 1);	}	else	{	    MPIDI_DBG_PRINTF((15, FCNAME, "send-to-self cancellation failed, sreq=0x%08x, rreq=0x%08x",			      sreq->handle, rreq->handle));	}		goto fn_exit;    }    /* Check to see if the send is still in the send queue.  If so, remove it, mark the request and cancelled and complete, and       release the device's reference to the request object.  QUESTION: what is the right interface for MPIDI_CH3_Send_cancel()?       It needs to be able to cancel requests to send a RTS packet for this request.  Perhaps we can use the partner request       field to track RTS requests. */    {	MPID_Request * sreq_cancel;		if (proto == MPIDI_REQUEST_RNDV_MSG)	{	    /* OPTIMIZATION: if clear-to-send has been received, then we already know that we cannot cancel the message. */	    	    /* FIXME - MT: cancellation of the RTS request needs to be atomic through the destruction of the RTS request to avoid               conflict with release of the RTS request if the CTS is received (see handling of a rendezvous CTS packet in               MPIDI_CH3U_Handle_recv_pkt()) */	    sreq_cancel = sreq->partner_request;	}	else	{	    sreq_cancel = sreq;	}		if (sreq_cancel != NULL && MPIDI_CH3_Cancel_send(vc, sreq_cancel))	{	    /* if we cancelled a RTS request, the release that request */	    if (sreq_cancel != sreq)	    {		MPIU_Object_set_ref(sreq_cancel, 0);		MPIDI_CH3_Request_destroy(sreq_cancel);	    }	    	    sreq->status.cancelled = TRUE;	    /* no other thread should be waiting on sreq, so it is safe to reset ref_count and cc */	    sreq->cc = 0;	    MPIU_Object_set_ref(sreq, 1);	    goto fn_exit;	}    }    /* Part or all of the message has already been sent, so we need to send a cancellation request to the receiver in an attempt       to catch the message before it is matched. */    {	int cc_was_zero;	MPIDI_CH3_Pkt_t upkt;	MPIDI_CH3_Pkt_cancel_send_req_t * const csr_pkt = &upkt.cancel_send_req;	MPID_Request * csr_sreq;		MPIDI_DBG_PRINTF((15, FCNAME, "sending cancel request to %d for 0x%08x", sreq->ch3.match.rank, sreq->handle));		/* The completion counter and reference count are incremented to keep the request around long enough to receive a	   response regardless of what the user does (free the request before waiting, etc.). */	cc_was_zero = (sreq->cc == 0);	MPIDI_CH3U_Request_increment_cc(sreq);	/* FIXME - MT: the reference count should only be incremented if the completion was zero before the increment.  This           requires an atomic test for zero and increment. */	if (cc_was_zero)	{	    MPIDI_CH3_Request_add_ref(sreq);	}	csr_pkt->type = MPIDI_CH3_PKT_CANCEL_SEND_REQ;	csr_pkt->match.rank = sreq->comm->rank;	csr_pkt->match.tag = sreq->ch3.match.tag;	csr_pkt->match.context_id = sreq->ch3.match.context_id;	csr_pkt->sender_req_id = sreq->handle;		csr_sreq = MPIDI_CH3_iStartMsg(vc, csr_pkt, sizeof(*csr_pkt));	if (csr_sreq != NULL)	{	    MPID_Request_release(csr_sreq);	}    }        /* FIXME: if send cancellation packets are allowed to arrive out-of-order with respect to send packets, then we need to       timestamp send and cancel packets to insure that a cancellation request does not bypass the send packet to be cancelled       and erroneously cancel a previously sent message with the same request handle. */  fn_exit:    MPIDI_DBG_PRINTF((10, FCNAME, "exiting"));    MPIDI_FUNC_EXIT(MPID_STATE_MPID_CANCEL_SEND);}

⌨️ 快捷键说明

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