📄 ch3u_request.c
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */#include "mpidimpl.h"/* * MPIDI_CH3U_Request_FU() * * Find a request in the unexpected queue; or return NULL. */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_FU#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_Request * MPIDI_CH3U_Request_FU(int source, int tag, int context_id){ MPID_Request * rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_FU); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_FU); if (tag != MPI_ANY_TAG && source != MPI_ANY_SOURCE) { rreq = MPIDI_Process.recv_unexpected_head; while(rreq != NULL) { if (rreq->ch3.match.context_id == context_id && rreq->ch3.match.rank == source && rreq->ch3.match.tag == tag) { MPIDI_CH3_Request_add_ref(rreq); break; } rreq = rreq->ch3.next; } } else { MPIDI_Message_match match; MPIDI_Message_match mask; match.context_id = context_id; mask.context_id = ~0; if (tag == MPI_ANY_TAG) { match.tag = 0; mask.tag = 0; } else { match.tag = tag; mask.tag = ~0; } if (source == MPI_ANY_SOURCE) { match.rank = 0; mask.rank = 0; } else { match.rank = source; mask.rank = ~0; } rreq = MPIDI_Process.recv_unexpected_head; while (rreq != NULL) { if (rreq->ch3.match.context_id == match.context_id && (rreq->ch3.match.rank & mask.rank) == match.rank && (rreq->ch3.match.tag & mask.tag) == match.tag) { MPIDI_CH3_Request_add_ref(rreq); break; } rreq = rreq->ch3.next; } } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_REQUEST_FU); return rreq;}/* * MPIDI_CH3U_Request_FDU() * * Find a request in the unexpected queue and dequeue it; otherwise return NULL. */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_FDU#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_Request * MPIDI_CH3U_Request_FDU(MPI_Request sreq_id, MPIDI_Message_match * match){ MPID_Request * rreq; MPID_Request * prev_rreq; MPID_Request * cur_rreq; MPID_Request * matching_prev_rreq; MPID_Request * matching_cur_rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_FDU); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_FDU); matching_prev_rreq = NULL; matching_cur_rreq = NULL; prev_rreq = NULL; cur_rreq = MPIDI_Process.recv_unexpected_head; while(cur_rreq != NULL) { if (cur_rreq->ch3.sender_req_id == sreq_id && cur_rreq->ch3.match.context_id == match->context_id && cur_rreq->ch3.match.rank == match->rank && cur_rreq->ch3.match.tag == match->tag) { matching_prev_rreq = prev_rreq; matching_cur_rreq = cur_rreq; } prev_rreq = cur_rreq; cur_rreq = cur_rreq->ch3.next; } if (matching_cur_rreq != NULL) { if (matching_prev_rreq != NULL) { matching_prev_rreq->ch3.next = matching_cur_rreq->ch3.next; } else { MPIDI_Process.recv_unexpected_head = matching_cur_rreq->ch3.next; } if (matching_cur_rreq->ch3.next == NULL) { MPIDI_Process.recv_unexpected_tail = matching_prev_rreq; } rreq = matching_cur_rreq; } else { rreq = NULL; } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_REQUEST_FDU); return rreq;}/* * MPIDI_CH3U_Request_FDU_or_AEP() * * Atomically find a request in the unexpected queue and dequeue it, or allocate a new request and enqueue it in the posted queue */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_FDU_or_AEP#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_Request * MPIDI_CH3U_Request_FDU_or_AEP(int source, int tag, int context_id, int * found){ MPID_Request * rreq; MPID_Request * prev_rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_FDU_OR_AEP); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_FDU_OR_AEP); if (tag != MPI_ANY_TAG && source != MPI_ANY_SOURCE) { prev_rreq = NULL; rreq = MPIDI_Process.recv_unexpected_head; while(rreq != NULL) { if (rreq->ch3.match.context_id == context_id && rreq->ch3.match.rank == source && rreq->ch3.match.tag == tag) { if (prev_rreq != NULL) { prev_rreq->ch3.next = rreq->ch3.next; } else { MPIDI_Process.recv_unexpected_head = rreq->ch3.next; } if (rreq->ch3.next == NULL) { MPIDI_Process.recv_unexpected_tail = prev_rreq; } *found = TRUE; goto fn_exit; } prev_rreq = rreq; rreq = rreq->ch3.next; } } else { MPIDI_Message_match match; MPIDI_Message_match mask; match.context_id = context_id; mask.context_id = ~0; if (tag == MPI_ANY_TAG) { match.tag = 0; mask.tag = 0; } else { match.tag = tag; mask.tag = ~0; } if (source == MPI_ANY_SOURCE) { match.rank = 0; mask.rank = 0; } else { match.rank = source; mask.rank = ~0; } prev_rreq = NULL; rreq = MPIDI_Process.recv_unexpected_head; while (rreq != NULL) { if (rreq->ch3.match.context_id == match.context_id && (rreq->ch3.match.rank & mask.rank) == match.rank && (rreq->ch3.match.tag & mask.tag) == match.tag) { if (prev_rreq != NULL) { prev_rreq->ch3.next = rreq->ch3.next; } else { MPIDI_Process.recv_unexpected_head = rreq->ch3.next; } if (rreq->ch3.next == NULL) { MPIDI_Process.recv_unexpected_tail = prev_rreq; } *found = TRUE; goto fn_exit; } prev_rreq = rreq; rreq = rreq->ch3.next; } } /* A matching request was not found in the unexpected queue, so we need to allocate a new request and add it to the posted queue */ rreq = MPIDI_CH3_Request_create(); if (rreq != NULL) { MPIU_Object_set_ref(rreq, 2); rreq->kind = MPID_REQUEST_RECV; rreq->ch3.match.tag = tag; rreq->ch3.match.rank = source; rreq->ch3.match.context_id = context_id; rreq->ch3.next = NULL; if (MPIDI_Process.recv_posted_tail != NULL) { MPIDI_Process.recv_posted_tail->ch3.next = rreq; } else { MPIDI_Process.recv_posted_head = rreq; } MPIDI_Process.recv_posted_tail = rreq; } *found = FALSE; fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_REQUEST_FDU_OR_AEP); return rreq;}/* * MPIDI_CH3U_Request_DP() * * Given an existing request, dequeue that request from the posted queue, or return NULL if the request was not in the posted * queued */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_DP#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)int MPIDI_CH3U_Request_DP(MPID_Request * rreq){ int found; MPID_Request * cur_rreq; MPID_Request * prev_rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_DP); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_DP); prev_rreq = NULL; cur_rreq = MPIDI_Process.recv_posted_head; found = FALSE; while (rreq != NULL) { if (cur_rreq == rreq) { if (prev_rreq != NULL) { prev_rreq->ch3.next = cur_rreq->ch3.next; } else { MPIDI_Process.recv_posted_head = cur_rreq->ch3.next; } if (cur_rreq->ch3.next == NULL) { MPIDI_Process.recv_posted_tail = prev_rreq; } found = TRUE; break; } prev_rreq = rreq; rreq = rreq->ch3.next; } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_REQUEST_DP); return found;}/* * MPIDI_CH3U_Request_FDP * * Locate a request in the posted queue and dequeue it, or return NULL. */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_FDP#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_Request * MPIDI_CH3U_Request_FDP(MPIDI_Message_match * match){ MPID_Request * rreq; MPID_Request * prev_rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_FDP_OR_AEU); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_FDP_OR_AEU); prev_rreq = NULL; rreq = MPIDI_Process.recv_posted_head; while (rreq != NULL) { if ((rreq->ch3.match.context_id == match->context_id) && (rreq->ch3.match.rank == match->rank || rreq->ch3.match.rank == MPI_ANY_SOURCE) && (rreq->ch3.match.tag == match->tag || rreq->ch3.match.tag == MPI_ANY_TAG)) { if (prev_rreq != NULL) { prev_rreq->ch3.next = rreq->ch3.next; } else { MPIDI_Process.recv_posted_head = rreq->ch3.next; } if (rreq->ch3.next == NULL) { MPIDI_Process.recv_posted_tail = prev_rreq; } break; } prev_rreq = rreq; rreq = rreq->ch3.next; } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_REQUEST_FDP_OR_AEU); return rreq;}/* * MPIDI_CH3U_Request_FDP_or_AEU() * * Locate a request in the posted queue and dequeue it, or allocate a new request and enqueue it in the unexpected queue */#undef FUNCNAME#define FUNCNAME MPIDI_CH3U_Request_FDP_or_AEU#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_Request * MPIDI_CH3U_Request_FDP_or_AEU(MPIDI_Message_match * match, int * found){ MPID_Request * rreq; MPID_Request * prev_rreq; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_REQUEST_FDP_OR_AEU); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_REQUEST_FDP_OR_AEU); prev_rreq = NULL; rreq = MPIDI_Process.recv_posted_head; while (rreq != NULL) { if ((rreq->ch3.match.context_id == match->context_id) && (rreq->ch3.match.rank == match->rank || rreq->ch3.match.rank == MPI_ANY_SOURCE) && (rreq->ch3.match.tag == match->tag || rreq->ch3.match.tag == MPI_ANY_TAG)) { if (prev_rreq != NULL) { prev_rreq->ch3.next = rreq->ch3.next; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -