Commit fce285fc authored by William Gropp's avatar William Gropp
Browse files

[svn-r3275] Updates for brief-global thread cs support (still requires updates...

[svn-r3275] Updates for brief-global thread cs support (still requires updates to MPIR_Localcopy) and for new match structure defintion where used within debugging statements
parent e33bee98
......@@ -23,7 +23,7 @@
*/
#define MPIDI_CH3_Progress_start(progress_state_) \
{ \
MPIU_THREAD_CS_ENTER(MPIDCOMM,);\
MPIU_THREAD_CS_ENTER(MPIDCOMM,);\
(progress_state_)->ch.completion_count = MPIDI_CH3I_progress_completion_count;\
}
#define MPIDI_CH3_Progress_end(progress_state_) MPIU_THREAD_CS_EXIT(MPIDCOMM,)
......
......@@ -226,10 +226,50 @@ extern MPIDI_Process_t MPIDI_Process;
* completion state
* cancelled state
*/
#define MPIU_HANDLE_ALLOCATION_MUTEX 0
#define MPIU_HANDLE_ALLOCATION_THREAD_LOCAL 1
/* XXX DJG for TLS hack */
#define MPID_REQUEST_TLS_MAX 128
#if MPIU_HANDLE_ALLOCATION_METHOD == MPIU_HANDLE_ALLOCATION_THREAD_LOCAL
# define MPIDI_Request_tls_alloc(req) \
do { \
int i; \
MPIU_THREADPRIV_DECL; \
MPIU_THREADPRIV_GET; \
if (!MPIU_THREADPRIV_FIELD(request_handles)) { \
MPID_Request *prev, *cur; \
/* batch allocate a linked list of requests */ \
MPIU_THREAD_CS_ENTER(HANDLEALLOC,); \
prev = MPIU_Handle_obj_alloc_unsafe(&MPID_Request_mem); \
prev->next = NULL; \
assert(prev); \
for (i = 1; i < MPID_REQUEST_TLS_MAX; ++i) { \
cur = MPIU_Handle_obj_alloc_unsafe(&MPID_Request_mem); \
assert(cur); \
cur->next = prev; \
prev = cur; \
} \
MPIU_THREAD_CS_EXIT(HANDLEALLOC,); \
MPIU_THREADPRIV_FIELD(request_handles) = cur; \
MPIU_THREADPRIV_FIELD(request_handle_count) += MPID_REQUEST_TLS_MAX; \
} \
(req) = MPIU_THREADPRIV_FIELD(request_handles); \
MPIU_THREADPRIV_FIELD(request_handles) = req->next; \
MPIU_THREADPRIV_FIELD(request_handle_count) -= 1; \
} while (0)
#elif MPIU_HANDLE_ALLOCATION_METHOD == MPIU_HANDLE_ALLOCATION_MUTEX
# define MPIDI_Request_tls_alloc(req) (req) = MPIU_Handle_obj_alloc(&MPID_Request_mem)
#else
# error MPIU_HANDLE_ALLOCATION_METHOD not defined
#endif
/* FIXME: This must be used within an MPIDCOMM critical section. */
#define MPIDI_CH3U_Request_complete(req_) \
{ \
int incomplete__; \
MPIU_THREAD_CS_ENTER(MPIDCOMM,); \
\
MPIDI_CH3U_Request_decrement_cc((req_), &incomplete__); \
if (!incomplete__) \
......@@ -237,7 +277,6 @@ extern MPIDI_Process_t MPIDI_Process;
MPID_Request_release(req_); \
MPIDI_CH3_Progress_signal_completion(); \
} \
MPIU_THREAD_CS_EXIT(MPIDCOMM,); \
}
......@@ -409,6 +448,7 @@ extern MPIDI_Process_t MPIDI_Process;
(sreq_)->partner_request = NULL; \
}
/* FIXME: We've moved to allow finer-grain critical sections... */
/* Note: In the current implementation, the mpid_xsend.c routines that
make use of MPIDI_VC_FAI_send_seqnum are all protected by the
SINGLE_CS_ENTER/EXIT macros, so all uses of this macro are
......@@ -1306,13 +1346,6 @@ int MPIDI_CH3U_Recvq_DP(MPID_Request * rreq);
MPID_Request * MPIDI_CH3U_Recvq_FDP_or_AEU(MPIDI_Message_match * match,
int * found);
#if 0
/* FIXME: These are macros! Why do they have prototypes */
void MPIDI_CH3U_Request_complete(MPID_Request * req);
void MPIDI_CH3U_Request_increment_cc(MPID_Request * req, int * was_incomplete);
void MPIDI_CH3U_Request_decrement_cc(MPID_Request * req, int * incomplete);
#endif
int MPIDI_CH3U_Request_load_send_iov(MPID_Request * const sreq,
MPID_IOV * const iov, int * const iov_n);
int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq);
......
......@@ -39,7 +39,10 @@ int MPIDI_CH3_SendNoncontig_iov( MPIDI_VC_t *vc, MPID_Request *sreq,
{
iov_n += 1;
/* Note this routine is invoked withing a CH3 critical section */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, sreq, iov, iov_n));
/* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -113,7 +116,7 @@ int MPIDI_CH3_EagerNoncontigSend( MPID_Request **sreq_p,
MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
MPIDI_Request_set_seqnum(sreq, seqnum);
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.context_id,rank,data_sz,
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,
"Eager");
sreq->dev.segment_ptr = MPID_Segment_alloc( );
......@@ -123,8 +126,10 @@ int MPIDI_CH3_EagerNoncontigSend( MPID_Request **sreq_p,
sreq->dev.segment_first = 0;
sreq->dev.segment_size = data_sz;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = vc->sendNoncontig_fn(vc, sreq, eager_pkt,
sizeof(MPIDI_CH3_Pkt_eager_send_t));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
fn_exit:
......@@ -177,8 +182,10 @@ int MPIDI_CH3_EagerContigSend( MPID_Request **sreq_p,
MPIDI_VC_FAI_send_seqnum(vc, seqnum);
MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.context_id,rank,data_sz,"EagerContig");
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,"EagerContig");
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, 2, sreq_p));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETFATALANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|eagermsg");
}
......@@ -249,10 +256,12 @@ int MPIDI_CH3_EagerContigShortSend( MPID_Request **sreq_p,
}
}
MPIU_DBG_MSGPKT(vc,tag,eagershort_pkt->match.context_id,rank,data_sz,
MPIU_DBG_MSGPKT(vc,tag,eagershort_pkt->match.parts.context_id,rank,data_sz,
"EagerShort");
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, eagershort_pkt,
sizeof(*eagershort_pkt), sreq_p ));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETFATALANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|eagermsg");
}
......@@ -285,12 +294,13 @@ int MPIDI_CH3_PktHandler_EagerShortSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
/* printf( "Receiving short eager!\n" ); fflush(stdout); */
MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
"received eagershort send pkt, rank=%d, tag=%d, context=%d",
eagershort_pkt->match.rank,
eagershort_pkt->match.tag, eagershort_pkt->match.context_id));
eagershort_pkt->match.parts.rank,
eagershort_pkt->match.parts.tag,
eagershort_pkt->match.parts.context_id));
MPIU_DBG_MSGPKT(vc,eagershort_pkt->match.tag,
eagershort_pkt->match.context_id,
eagershort_pkt->match.rank,eagershort_pkt->data_sz,
MPIU_DBG_MSGPKT(vc,eagershort_pkt->match.parts.tag,
eagershort_pkt->match.parts.context_id,
eagershort_pkt->match.parts.rank,eagershort_pkt->data_sz,
"ReceivedEagerShort");
rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&eagershort_pkt->match, &found);
if (rreq == NULL) {
......@@ -512,8 +522,10 @@ int MPIDI_CH3_EagerContigIsend( MPID_Request **sreq_p,
MPIDI_Pkt_set_seqnum(eager_pkt, seqnum);
MPIDI_Request_set_seqnum(sreq, seqnum);
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.context_id,rank,data_sz,"EagerIsend");
MPIU_DBG_MSGPKT(vc,tag,eager_pkt->match.parts.context_id,rank,data_sz,"EagerIsend");
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, sreq, iov, 2 ));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -563,10 +575,11 @@ int MPIDI_CH3_PktHandler_EagerSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
"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));
MPIU_DBG_MSGPKT(vc,eager_pkt->match.tag,eager_pkt->match.context_id,
eager_pkt->match.rank,eager_pkt->data_sz,
eager_pkt->sender_req_id, eager_pkt->match.parts.rank,
eager_pkt->match.parts.tag, eager_pkt->match.parts.context_id));
MPIU_DBG_MSGPKT(vc,eager_pkt->match.parts.tag,
eager_pkt->match.parts.context_id,
eager_pkt->match.parts.rank,eager_pkt->data_sz,
"ReceivedEager");
rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&eager_pkt->match, &found);
......@@ -633,10 +646,13 @@ int MPIDI_CH3_PktHandler_ReadySend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
"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));
MPIU_DBG_MSGPKT(vc,ready_pkt->match.tag,ready_pkt->match.context_id,
ready_pkt->match.rank,ready_pkt->data_sz,
ready_pkt->sender_req_id,
ready_pkt->match.parts.rank,
ready_pkt->match.parts.tag,
ready_pkt->match.parts.context_id));
MPIU_DBG_MSGPKT(vc,ready_pkt->match.parts.tag,
ready_pkt->match.parts.context_id,
ready_pkt->match.parts.rank,ready_pkt->data_sz,
"ReceivedReady");
rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&ready_pkt->match, &found);
......@@ -734,9 +750,9 @@ int MPIDI_CH3_PktPrint_EagerSend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
{
MPIU_DBG_PRINTF((" type ......... EAGER_SEND\n"));
MPIU_DBG_PRINTF((" sender_reqid . 0x%08X\n", pkt->eager_send.sender_req_id));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eager_send.match.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eager_send.match.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eager_send.match.rank));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eager_send.match.parts.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eager_send.match.parts.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eager_send.match.parts.rank));
MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->eager_send.data_sz));
#ifdef MPID_USE_SEQUENCE_NUMBERS
MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->eager_send.seqnum));
......@@ -749,9 +765,9 @@ int MPIDI_CH3_PktPrint_EagerShortSend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
int datalen;
unsigned char *p = (unsigned char *)pkt->eagershort_send.data;
MPIU_DBG_PRINTF((" type ......... EAGERSHORT_SEND\n"));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eagershort_send.match.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eagershort_send.match.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eagershort_send.match.rank));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eagershort_send.match.parts.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eagershort_send.match.parts.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eagershort_send.match.parts.rank));
MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->eagershort_send.data_sz));
#ifdef MPID_USE_SEQUENCE_NUMBERS
MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->eagershort_send.seqnum));
......@@ -773,9 +789,9 @@ int MPIDI_CH3_PktPrint_ReadySend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
{
MPIU_DBG_PRINTF((" type ......... READY_SEND\n"));
MPIU_DBG_PRINTF((" sender_reqid . 0x%08X\n", pkt->ready_send.sender_req_id));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->ready_send.match.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->ready_send.match.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->ready_send.match.rank));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->ready_send.match.parts.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->ready_send.match.parts.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->ready_send.match.parts.rank));
MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->ready_send.data_sz));
#ifdef MPID_USE_SEQUENCE_NUMBERS
MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->ready_send.seqnum));
......
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
......@@ -56,7 +57,7 @@ int MPIDI_CH3_EagerSyncNoncontigSend( MPID_Request **sreq_p,
MPIDI_Pkt_set_seqnum(es_pkt, seqnum);
MPIDI_Request_set_seqnum(sreq, seqnum);
MPIU_DBG_MSGPKT(vc,tag,es_pkt->match.context_id,rank,data_sz,"EagerSync");
MPIU_DBG_MSGPKT(vc,tag,es_pkt->match.parts.context_id,rank,data_sz,"EagerSync");
if (dt_contig)
{
......@@ -70,7 +71,9 @@ int MPIDI_CH3_EagerSyncNoncontigSend( MPID_Request **sreq_p,
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST) ((char *)buf + dt_true_lb);
iov[1].MPID_IOV_LEN = data_sz;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, sreq, iov, 2));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -95,7 +98,9 @@ int MPIDI_CH3_EagerSyncNoncontigSend( MPID_Request **sreq_p,
sreq->dev.segment_first = 0;
sreq->dev.segment_size = data_sz;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = vc->sendNoncontig_fn(vc, sreq, es_pkt, sizeof(MPIDI_CH3_Pkt_eager_sync_send_t));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
......@@ -136,8 +141,10 @@ int MPIDI_CH3_EagerSyncZero(MPID_Request **sreq_p, int rank, int tag,
MPIDI_Pkt_set_seqnum(es_pkt, seqnum);
MPIDI_Request_set_seqnum(sreq, seqnum);
MPIU_DBG_MSGPKT(vc,tag,es_pkt->match.context_id,rank,(MPIDI_msg_sz_t)0,"EagerSync0");
MPIU_DBG_MSGPKT(vc,tag,es_pkt->match.parts.context_id,rank,(MPIDI_msg_sz_t)0,"EagerSync0");
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iSend(vc, sreq, es_pkt, sizeof(*es_pkt)));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -166,8 +173,10 @@ int MPIDI_CH3_EagerSyncAck( MPIDI_VC_t *vc, MPID_Request *rreq )
MPIU_DBG_MSG(CH3_OTHER,VERBOSE,"sending eager sync ack");
MPIDI_Pkt_init(esa_pkt, MPIDI_CH3_PKT_EAGER_SYNC_ACK);
esa_pkt->sender_req_id = rreq->dev.sender_req_id;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, esa_pkt, sizeof(*esa_pkt),
&esa_req));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_POP(mpi_errno);
}
......@@ -209,10 +218,11 @@ int MPIDI_CH3_PktHandler_EagerSyncSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
"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));
MPIU_DBG_MSGPKT(vc,es_pkt->match.tag,es_pkt->match.context_id,
es_pkt->match.rank,es_pkt->data_sz,
es_pkt->sender_req_id, es_pkt->match.parts.rank,
es_pkt->match.parts.tag,
es_pkt->match.parts.context_id));
MPIU_DBG_MSGPKT(vc,es_pkt->match.parts.tag,es_pkt->match.parts.context_id,
es_pkt->match.parts.rank,es_pkt->data_sz,
"ReceivedEagerSync");
rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&es_pkt->match, &found);
......@@ -261,8 +271,11 @@ int MPIDI_CH3_PktHandler_EagerSyncSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIDI_Pkt_init(esa_pkt, MPIDI_CH3_PKT_EAGER_SYNC_ACK);
esa_pkt->sender_req_id = rreq->dev.sender_req_id;
/* Because this is a packet handler, it is already within a CH3 CS */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, esa_pkt,
sizeof(*esa_pkt), &esa_req));
/* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,
"**ch3|syncack");
......@@ -318,8 +331,7 @@ int MPIDI_CH3_PktHandler_EagerSyncAck( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
transfer could still be in progress) */
/* FIXME: This sometimes segfaults */
MPIDI_CH3U_Request_complete(sreq); /* brad : seen this segfault in ssm
dynamic process...? */
MPIDI_CH3U_Request_complete(sreq);
*buflen = sizeof(MPIDI_CH3_Pkt_t);
*rreqp = NULL;
......@@ -331,9 +343,9 @@ int MPIDI_CH3_PktPrint_EagerSyncSend( FILE *fp, MPIDI_CH3_Pkt_t *pkt )
{
MPIU_DBG_PRINTF((" type ......... EAGER_SYNC_SEND\n"));
MPIU_DBG_PRINTF((" sender_reqid . 0x%08X\n", pkt->eager_sync_send.sender_req_id));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eager_sync_send.match.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eager_sync_send.match.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eager_sync_send.match.rank));
MPIU_DBG_PRINTF((" context_id ... %d\n", pkt->eager_sync_send.match.parts.context_id));
MPIU_DBG_PRINTF((" tag .......... %d\n", pkt->eager_sync_send.match.parts.tag));
MPIU_DBG_PRINTF((" rank ......... %d\n", pkt->eager_sync_send.match.parts.rank));
MPIU_DBG_PRINTF((" data_sz ...... %d\n", pkt->eager_sync_send.data_sz));
#ifdef MPID_USE_SEQUENCE_NUMBERS
MPIU_DBG_PRINTF((" seqnum ....... %d\n", pkt->eager_sync_send.seqnum));
......
......@@ -314,7 +314,10 @@ int MPIDI_CH3_ReqHandler_GetRespDerivedDTComplete( MPIDI_VC_t *vc,
sreq->dev.segment_first = 0;
sreq->dev.segment_size = new_dtp->size * sreq->dev.user_count;
/* Because this is in a packet handler, it is already within a critical section */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
mpi_errno = vc->sendNoncontig_fn(vc, sreq, get_resp_pkt, sizeof(*get_resp_pkt));
/* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -921,8 +924,11 @@ int MPIDI_CH3I_Send_pt_rma_done_pkt(MPIDI_VC_t *vc, MPI_Win source_win_handle)
MPIDI_Pkt_init(pt_rma_done_pkt, MPIDI_CH3_PKT_PT_RMA_DONE);
pt_rma_done_pkt->source_win_handle = source_win_handle;
/* Because this is in a packet handler, it is already within a critical section */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, pt_rma_done_pkt,
sizeof(*pt_rma_done_pkt), &req));
/* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETFATALANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|rmamsg");
}
......@@ -1025,7 +1031,10 @@ static int do_simple_get(MPID_Win *win_ptr, MPIDI_Win_lock_queue *lock_queue)
MPID_Datatype_get_size_macro(lock_queue->pt_single_op->datatype, type_size);
iov[1].MPID_IOV_LEN = lock_queue->pt_single_op->count * type_size;
/* Because this is in a packet handler, it is already within a critical section */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(lock_queue->vc, req, iov, 2));
/* MPIU_THREAD_CS_EXIT(CH3COMM,vc); */
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......
......@@ -90,6 +90,16 @@ MPID_Request ** const MPID_Recvq_unexpected_head_ptr = &recvq_unexpected_head;
* not MPI_STATUS_IGNORE, return information about the request in that
* parameter. This routine is used by mpid_probe and mpid_iprobe.
*
* Multithread - As this is a read-only routine, it need not
* require an external critical section (careful organization of the
* queue updates would not even require a critical section within this
* routine). However, this routine is used both from within the progress
* engine and from without it. To make that work with the current
* design for MSGQUEUE and the brief-global mode, the critical section
* is *outside* of this routine.
*
* This routine is used only in mpid_iprobe and mpid_probe
*
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Recvq_FU
......@@ -153,7 +163,12 @@ int MPIDI_CH3U_Recvq_FU(int source, int tag, int context_id, MPI_Status *s)
*
* Find a request in the unexpected queue and dequeue it; otherwise return NULL.
*
* This routine is used only in the case of send_cancel
* Multithread - This routine must be atomic (since it dequeues a
* request). However, once the request is dequeued, no other thread can
* see it, so this routine provides its own atomicity.
*
* This routine is used only in the case of send_cancel. However, it is used both
* within mpid_send_cancel and within a packet handler.
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Recvq_FDU
......@@ -177,6 +192,7 @@ MPID_Request * MPIDI_CH3U_Recvq_FDU(MPI_Request sreq_id,
/* Note that since this routine is used only in the case of send_cancel,
there can be only one match if at all. */
/* FIXME: Why doesn't this exit after it finds the first match? */
cur_rreq = recvq_unexpected_head;
while (cur_rreq != NULL) {
if (cur_rreq->dev.sender_req_id == sreq_id &&
......@@ -216,6 +232,14 @@ MPID_Request * MPIDI_CH3U_Recvq_FDU(MPI_Request sreq_id,
*
* Atomically find a request in the unexpected queue and dequeue it, or
* allocate a new request and enqueue it in the posted queue
*
* Multithread - This routine must be called from within a MSGQUEUE
* critical section. If a request is allocated, it must not release
* the MSGQUEUE until the request is completely valid, as another thread
* may then find it and dequeue it.
*
* This routine is used in mpid_irecv and mpid_recv.
*
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Recvq_FDU_or_AEP
......@@ -355,6 +379,8 @@ MPID_Request * MPIDI_CH3U_Recvq_FDU_or_AEP(int source, int tag,
*
* Given an existing request, dequeue that request from the posted queue, or
* return NULL if the request was not in the posted queued
*
* Multithread - This routine is atomic
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Recvq_DP
......@@ -372,6 +398,7 @@ int MPIDI_CH3U_Recvq_DP(MPID_Request * rreq)
found = FALSE;
prev_rreq = NULL;
MPIU_THREAD_CS_ENTER(MSGQUEUE,);
cur_rreq = recvq_posted_head;
while (cur_rreq != NULL) {
if (cur_rreq == rreq) {
......@@ -394,6 +421,8 @@ int MPIDI_CH3U_Recvq_DP(MPID_Request * rreq)
cur_rreq = cur_rreq->dev.next;
}
MPIU_THREAD_CS_EXIT(MSGQUEUE,);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_RECVQ_DP);
return found;
}
......@@ -403,6 +432,19 @@ int MPIDI_CH3U_Recvq_DP(MPID_Request * rreq)
*
* Locate a request in the posted queue and dequeue it, or allocate a new
* request and enqueue it in the unexpected queue
*
* Multithread - This routine must be called from within a MSGQUEUE
* critical section. If a request is allocated, it must not release
* the MSGQUEUE until the request is completely valid, as another thread
* may then find it and dequeue it.
*
* This routine is used in ch3u_eager, ch3u_eagersync, ch3u_handle_recv_pkt,
* ch3u_rndv, and mpidi_isend_self. Routines within the progress engine
* will need to be careful to avoid nested critical sections.
*
* FIXME: Currently, the routines called from within the progress engine
* do not use the MSGQUEUE CS, because in the brief-global mode, that
* simply uses the global_mutex .
*/
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3U_Recvq_FDP_or_AEU
......
......@@ -537,8 +537,6 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
MPID_Datatype_get_size_macro(rma_op->origin_datatype, origin_type_size);
if (!target_dt_derived)
{
/* basic datatype on target */
......@@ -548,7 +546,9 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)rma_op->origin_addr;
iov[1].MPID_IOV_LEN = rma_op->origin_count * origin_type_size;
iovcnt = 2;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, iovcnt, request));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
MPIU_ERR_CHKANDJUMP(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**ch3|rmamsg");
}
else
......@@ -575,7 +575,9 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
(*request)->dev.OnFinal = 0;
(*request)->dev.OnDataAvail = 0;
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
mpi_errno = vc->sendNoncontig_fn(vc, *request, iov[0].MPID_IOV_BUF, iov[0].MPID_IOV_LEN);
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
MPIU_ERR_CHKANDJUMP(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**ch3|rmamsg");
}
}
......@@ -612,7 +614,9 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
(*request)->dev.OnFinal = 0;
(*request)->dev.OnDataAvail = 0;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = vc->sendNoncontig_fn(vc, *request, iov[0].MPID_IOV_BUF, iov[0].MPID_IOV_LEN);
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
MPIU_ERR_CHKANDJUMP(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**ch3|rmamsg");
/* we're done with the datatypes */
......@@ -713,7 +717,9 @@ static int MPIDI_CH3I_Recv_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
if (predefined)
{
/* basic datatype on target. simply send the get_pkt. */
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, get_pkt, sizeof(*get_pkt), &req));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
}
else
{
......@@ -752,7 +758,9 @@ static int MPIDI_CH3I_Recv_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
iov[2].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)*dataloop;
iov[2].MPID_IOV_LEN = dtp->dataloop_size;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, 3, &req));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
/* release the target datatype */
MPID_Datatype_release(dtp);
......@@ -1147,9 +1155,11 @@ int MPIDI_Win_complete(MPID_Win *win_ptr)
MPIDI_Comm_get_vc(comm_ptr, dst, &vc);
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, put_pkt,
sizeof(*put_pkt),
&requests[j]));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|rmamsg" );
}
......@@ -1486,7 +1496,9 @@ int MPIDI_Win_unlock(int dest, MPID_Win *win_ptr)
/* Set the lock granted flag to 0 */
win_ptr->lock_granted = 0;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, lock_pkt, sizeof(*lock_pkt), &req));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**winRMAmessage");
}
......@@ -1869,7 +1881,9 @@ static int MPIDI_CH3I_Send_lock_put_or_acc(MPID_Win *win_ptr)
iov[1].MPID_IOV_LEN = rma_op->origin_count * origin_type_size;
iovcnt = 2;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, iovcnt, &request));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**ch3|rmamsg");
}
......@@ -2336,7 +2350,8 @@ int MPIDI_CH3_PktHandler_Get( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
iov[1].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)get_pkt->addr;
MPID_Datatype_get_size_macro(get_pkt->datatype, type_size);
iov[1].MPID_IOV_LEN = get_pkt->count * type_size;
/* Because this is in a packet handler, it is already within a critical section */
mpi_errno = MPIU_CALL(MPIDI_CH3,iSendv(vc, req, iov, 2));
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
......
......@@ -48,10 +48,12 @@ int MPIDI_CH3_RndvSend( MPID_Request **sreq_p, const void * buf, int count,
MPIDI_Pkt_set_seqnum(rts_pkt, seqnum);
MPIDI_Request_set_seqnum(sreq, seqnum);
MPIU_DBG_MSGPKT(vc,tag,rts_pkt->match.context_id,rank,data_sz,"Rndv");
MPIU_DBG_MSGPKT(vc,tag,rts_pkt->match.parts.context_id,rank,data_sz,"Rndv");
MPIU_THREAD_CS_ENTER(CH3COMM,);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsg(vc, rts_pkt, sizeof(*rts_pkt),
&rts_sreq));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
{
......@@ -114,10 +116,11 @@ int MPIDI_CH3_PktHandler_RndvReqToSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
MPIU_DBG_MSG_FMT(CH3_OTHER,VERBOSE,(MPIU_DBG_FDEST,
"received rndv RTS pkt, sreq=0x%08x, rank=%d, tag=%d, context=%d, data_sz=" MPIDI_MSG_SZ_FMT,
rts_pkt->sender_req_id, rts_pkt->match.rank, rts_pkt->match.tag,
rts_pkt->match.context_id, rts_pkt->data_sz));
MPIU_DBG_MSGPKT(vc,rts_pkt->match.tag,rts_pkt->match.context_id,
rts_pkt->match.rank,rts_pkt->data_sz,
rts_pkt->sender_req_id, rts_pkt->match.parts.rank,
rts_pkt->match.parts.tag,
rts_pkt->match.parts.context_id, rts_pkt->data_sz));
MPIU_DBG_MSGPKT(vc,rts_pkt->match.parts.tag,rts_pkt->match.parts.context_id,
rts_pkt->match.parts.rank,rts_pkt->data_sz,
"ReceivedRndv");
rreq = MPIDI_CH3U_Recvq_FDP_or_AEU(&rts_pkt->match, &found);
...<