📄 mpid_recvq.c
字号:
/* (C)Copyright IBM Corp. 2007, 2008 *//** * \file src/impl/mpid_recvq.c * \brief Functions to manage the Receive Queues *//* -*- Mode: C; c-basic-offset:4 ; -*- *//* * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */#include "mpidimpl.h"/** * \defgroup MPID_RECVQ MPID Receive Queue management * * Functions to manage the Receive Queues *//** \brief Unused lock macro to protect the receive queues */#define MPIDI_Recvq_lock() // MPID_Thread_lock(&MPIDI_Process.recvq_mutex)/** \brief Unused unlock macro to protect the receive queues */#define MPIDI_Recvq_unlock() // MPID_Thread_unlock(&MPIDI_Process.recvq_mutex)/** \brief Structure to group the common recvq pointers */static struct MPIDID_Recvq_t{ struct MPID_Request * posted_head; /**< \brief The Head of the Posted queue */ struct MPID_Request * posted_tail; /**< \brief The Tail of the Posted queue */ struct MPID_Request * unexpected_head; /**< \brief The Head of the Unexpected queue */ struct MPID_Request * unexpected_tail; /**< \brief The Tail of the Unexpected queue */} recvq;/** * \brief Set up the request queues */void MPIDI_Recvq_init(){ recvq.posted_head = NULL; recvq.posted_tail = NULL; recvq.unexpected_head = NULL; recvq.unexpected_tail = NULL;}/** * \brief Tear down the request queues */void MPIDI_Recvq_finalize(){ MPIDI_Recvq_DumpQueues(MPIDI_Process.verbose);}/** * \brief Find a request in the unexpected queue * \param [in] source Find by Sender * \param [in] tag Find by Tag * \param [in] context_id Find by Context ID (communicator) * \return The matching UE request or NULL */MPID_Request * MPIDI_Recvq_FU(int source, int tag, int context_id){ MPID_Request * rreq;#ifdef USE_STATISTICS unsigned search_length = 0;#endif if (tag != MPI_ANY_TAG && source != MPI_ANY_SOURCE) { MPIDI_Recvq_lock(); { rreq = recvq.unexpected_head; while(rreq != NULL) {#ifdef USE_STATISTICS ++search_length;#endif if ( (rreq->dcmf.msginfo.msginfo.MPIctxt == context_id) && (rreq->dcmf.msginfo.msginfo.MPIrank == source ) && (rreq->dcmf.msginfo.msginfo.MPItag == tag ) ) { MPID_Request_add_ref(rreq); break; } rreq = rreq->dcmf.next; } } MPIDI_Recvq_unlock(); } 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; } MPIDI_Recvq_lock(); { rreq = recvq.unexpected_head; while (rreq != NULL) {#ifdef USE_STATISTICS ++search_length;#endif if ( ( rreq->dcmf.msginfo.msginfo.MPIctxt == match.context_id) && ( (rreq->dcmf.msginfo.msginfo.MPIrank & mask.rank) == match.rank ) && ( (rreq->dcmf.msginfo.msginfo.MPItag & mask.tag ) == match.tag ) ) { MPID_Request_add_ref(rreq); break; } rreq = rreq->dcmf.next; } } MPIDI_Recvq_unlock(); }#ifdef USE_STATISTICS MPIDI_Statistics_time(MPIDI_Statistics.recvq.unexpected_search, search_length);#endif return rreq;}/** * \brief Find a request in the unexpected queue and dequeue it * \param [in] req Find by address of request object on sender * \param [in] source Find by Sender * \param [in] tag Find by Tag * \param [in] context_id Find by Context ID (communicator) * \return The matching UE request or NULL */MPID_Request * MPIDI_Recvq_FDURSTC (MPID_Request * req, int source, int tag, int context_id){ MPID_Request * prev_rreq = NULL; /* previous request in queue */ MPID_Request * cur_rreq = NULL; /* current request in queue */ MPID_Request * matching_cur_rreq = NULL; /* matching request in queue */ MPID_Request * matching_prev_rreq = NULL; /* previous in queue to match */#ifdef USE_STATISTICS unsigned search_length = 0;#endif /* ----------------------- */ /* first we do the finding */ /* ----------------------- */ MPIDI_Recvq_lock(); { cur_rreq = recvq.unexpected_head; while(cur_rreq != NULL) {#ifdef USE_STATISTICS ++search_length;#endif if (cur_rreq->dcmf.msginfo.msginfo.req == req && cur_rreq->dcmf.msginfo.msginfo.MPIctxt == context_id && cur_rreq->dcmf.msginfo.msginfo.MPIrank == source && cur_rreq->dcmf.msginfo.msginfo.MPItag == tag) { matching_prev_rreq = prev_rreq; matching_cur_rreq = cur_rreq; break; } prev_rreq = cur_rreq; cur_rreq = cur_rreq->dcmf.next; } /* ----------------------- */ /* found nothing; return */ /* ----------------------- */ if (matching_cur_rreq == NULL) goto fn_exit; /* --------------------------------------------------------------------- */ /* adjust the "next" pointer of the request previous to the matching one */ /* --------------------------------------------------------------------- */ if (matching_prev_rreq != NULL) matching_prev_rreq->dcmf.next = matching_cur_rreq->dcmf.next; else recvq.unexpected_head = matching_cur_rreq->dcmf.next; /* --------------------------------------- */ /* adjust the request queue's tail pointer */ /* --------------------------------------- */ if (matching_cur_rreq->dcmf.next == NULL) recvq.unexpected_tail = matching_prev_rreq; } fn_exit: MPIDI_Recvq_unlock();#ifdef USE_STATISTICS MPIDI_Statistics_time(MPIDI_Statistics.recvq.unexpected_search, search_length);#endif return (matching_cur_rreq);}/** * \brief Find a request in the unexpected queue and dequeue it * \param [in] req Find by address of request object on sender * \return The matching UE request or NULL */MPID_Request * MPIDI_Recvq_FDUR (MPID_Request * req){ MPID_Request * prev_rreq = NULL; /* previous request in queue */ MPID_Request * cur_rreq = NULL; /* current request in queue */ MPID_Request * matching_cur_rreq = NULL; /* matching request in queue */ MPID_Request * matching_prev_rreq = NULL; /* previous in queue to match */#ifdef USE_STATISTICS unsigned search_length = 0;#endif /* ----------------------- */ /* first we do the finding */ /* ----------------------- */ MPIDI_Recvq_lock(); { cur_rreq = recvq.unexpected_head; while(cur_rreq != NULL) {#ifdef USE_STATISTICS ++search_length;#endif if (cur_rreq->dcmf.msginfo.msginfo.req == req) { matching_prev_rreq = prev_rreq; matching_cur_rreq = cur_rreq; break; } prev_rreq = cur_rreq; cur_rreq = cur_rreq->dcmf.next; } /* ----------------------- */ /* found nothing; return */ /* ----------------------- */ if (matching_cur_rreq == NULL) goto fn_exit; /* --------------------------------------------------------------------- */ /* adjust the "next" pointer of the request previous to the matching one */ /* --------------------------------------------------------------------- */ if (matching_prev_rreq != NULL) matching_prev_rreq->dcmf.next = matching_cur_rreq->dcmf.next; else recvq.unexpected_head = matching_cur_rreq->dcmf.next; /* --------------------------------------- */ /* adjust the request queue's tail pointer */ /* --------------------------------------- */ if (matching_cur_rreq->dcmf.next == NULL) recvq.unexpected_tail = matching_prev_rreq; } fn_exit: MPIDI_Recvq_unlock();#ifdef USE_STATISTICS MPIDI_Statistics_time(MPIDI_Statistics.recvq.unexpected_search, search_length);#endif return (matching_cur_rreq);}/** * \brief Find a request in the unexpected queue and dequeue it, or allocate a new request and enqueue it in the posted queue * \param [in] source Find by Sender * \param [in] tag Find by Tag * \param [in] context_id Find by Context ID (communicator) * \param [out] foundp TRUE iff the request was found * \return The matching UE request or the new posted request */MPID_Request * MPIDI_Recvq_FDU_or_AEP(int source, int tag, int context_id, int * foundp){ int found; MPID_Request * rreq; MPID_Request * prev_rreq;#ifdef USE_STATISTICS unsigned search_length = 0;#endif MPIDI_Recvq_lock(); { if (tag != MPI_ANY_TAG && source != MPI_ANY_SOURCE) { prev_rreq = NULL; rreq = recvq.unexpected_head; while(rreq != NULL) {#ifdef USE_STATISTICS ++search_length;#endif if ( (rreq->dcmf.msginfo.msginfo.MPIctxt == context_id) && (rreq->dcmf.msginfo.msginfo.MPIrank == source ) && (rreq->dcmf.msginfo.msginfo.MPItag == tag )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -