Commit 03ebc97b authored by Xin Zhao's avatar Xin Zhao
Browse files

Modify ACK of op with both LOCK and UNLOCK (FLUSH) flags

No reviewer.
parent 01679120
......@@ -654,7 +654,6 @@ typedef struct MPIDI_CH3_Pkt_lock_ack {
typedef struct MPIDI_CH3_Pkt_flush_ack {
MPIDI_CH3_Pkt_type_t type;
MPIDI_CH3_Pkt_flags_t flags;
MPI_Win source_win_handle;
int target_rank;
} MPIDI_CH3_Pkt_flush_ack_t;
......
......@@ -148,7 +148,6 @@ static inline int MPIDI_CH3I_Send_lock_ack_pkt(MPIDI_VC_t * vc, MPID_Win * win_p
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_Send_flush_ack_pkt(MPIDI_VC_t *vc, MPID_Win *win_ptr,
MPIDI_CH3_Pkt_flags_t flags,
MPI_Win source_win_handle)
{
MPIDI_CH3_Pkt_t upkt;
......@@ -162,9 +161,6 @@ static inline int MPIDI_CH3I_Send_flush_ack_pkt(MPIDI_VC_t *vc, MPID_Win *win_pt
MPIDI_Pkt_init(flush_ack_pkt, MPIDI_CH3_PKT_FLUSH_ACK);
flush_ack_pkt->source_win_handle = source_win_handle;
flush_ack_pkt->target_rank = win_ptr->comm_ptr->rank;
flush_ack_pkt->flags = MPIDI_CH3_PKT_FLAG_NONE;
if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK)
flush_ack_pkt->flags |= MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED;
/* Because this is in a packet handler, it is already within a critical section */
/* MPIU_THREAD_CS_ENTER(CH3COMM,vc); */
......@@ -633,19 +629,25 @@ static inline int finish_op_on_target(MPID_Win *win_ptr, MPIDI_VC_t *vc,
if (type == MPIDI_CH3_PKT_PUT || type == MPIDI_CH3_PKT_ACCUMULATE) {
/* This is PUT or ACC */
if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK) {
if (!(flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) &&
!(flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)) {
mpi_errno = MPIDI_CH3I_Send_lock_ack_pkt(vc, win_ptr,
MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED,
source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
MPIDI_CH3_Pkt_flags_t pkt_flags = MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED;
if (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH)
pkt_flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK;
if (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)
pkt_flags |= MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_ACK;
mpi_errno = MPIDI_CH3I_Send_lock_ack_pkt(vc, win_ptr,
pkt_flags,
source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, flags,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (!(flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK)) {
/* If op is piggybacked with both LOCK and FLUSH,
we only send LOCK ACK back, do not send FLUSH ACK. */
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER) {
......@@ -656,9 +658,13 @@ static inline int finish_op_on_target(MPID_Win *win_ptr, MPIDI_VC_t *vc,
MPIDI_CH3_Progress_signal_completion();
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, flags,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (!(flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK)) {
/* If op is piggybacked with both LOCK and UNLOCK,
we only send LOCK ACK back, do not send FLUSH (UNLOCK) ACK. */
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr,
source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
mpi_errno = MPIDI_CH3I_Release_lock(win_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIDI_CH3_Progress_signal_completion();
......
......@@ -1451,6 +1451,7 @@ int MPIDI_CH3_PktHandler_LockAck(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
MPIDI_CH3_Pkt_lock_ack_t *lock_ack_pkt = &pkt->lock_ack;
MPID_Win *win_ptr = NULL;
int target_rank = lock_ack_pkt->target_rank;
MPIDI_CH3_Pkt_flags_t flags = lock_ack_pkt->flags;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_LOCKACK);
......@@ -1467,6 +1468,17 @@ int MPIDI_CH3_PktHandler_LockAck(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
mpi_errno = set_lock_sync_counter(win_ptr, target_rank);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK) {
MPIU_Assert(flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED);
mpi_errno = MPIDI_CH3I_RMA_Handle_flush_ack(win_ptr, target_rank);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
}
if (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_ACK) {
MPIU_Assert(flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED);
mpi_errno = MPIDI_CH3I_RMA_Handle_flush_ack(win_ptr, target_rank);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
}
*rreqp = NULL;
MPIDI_CH3_Progress_signal_completion();
......@@ -1501,11 +1513,6 @@ int MPIDI_CH3_PktHandler_FlushAck(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
MPID_Win_get_ptr(flush_ack_pkt->source_win_handle, win_ptr);
if (flush_ack_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
mpi_errno = set_lock_sync_counter(win_ptr, target_rank);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
/* decrement ack_counter on target */
mpi_errno = MPIDI_CH3I_RMA_Handle_flush_ack(win_ptr, target_rank);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
......@@ -1583,7 +1590,7 @@ int MPIDI_CH3_PktHandler_Unlock(MPIDI_VC_t * vc ATTRIBUTE((unused)),
MPIU_ERR_CHKANDJUMP(mpi_errno != MPI_SUCCESS, mpi_errno, MPI_ERR_OTHER, "**ch3|rma_msg");
if (!(unlock_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_NO_ACK)) {
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, MPIDI_CH3_PKT_FLAG_NONE,
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr,
unlock_pkt->source_win_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
......@@ -1623,7 +1630,7 @@ int MPIDI_CH3_PktHandler_Flush(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
MPID_Win_get_ptr(flush_pkt->target_win_handle, win_ptr);
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr, MPIDI_CH3_PKT_FLAG_NONE,
mpi_errno = MPIDI_CH3I_Send_flush_ack_pkt(vc, win_ptr,
flush_pkt->source_win_handle);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment