Commit 079a516b authored by Xin Zhao's avatar Xin Zhao
Browse files

Add routine to enqueue op to RMA slots.



Given an RMA op, finding the correct slot and target,
enqueue op to the pending op list in that target object.
If the target is not existed, create one in that slot.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 0f596c48
......@@ -210,6 +210,57 @@ static inline int MPIDI_CH3I_Win_find_target(MPID_Win * win_ptr, int target_rank
goto fn_exit;
}
/* MPIDI_CH3I_Win_enqueue_op(): given an operation, enqueue it to the
* corresponding operation lists in corresponding target element. This
* routines is only called from operation routines. */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_enqueue_op
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_Win_enqueue_op(MPID_Win * win_ptr,
MPIDI_RMA_Op_t * op)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_RMA_Target_t *target = NULL;
mpi_errno = MPIDI_CH3I_Win_find_target(win_ptr, op->target_rank, &target);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
if (target == NULL) {
mpi_errno = MPIDI_CH3I_Win_create_target(win_ptr, op->target_rank, &target);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
if (win_ptr->states.access_state == MPIDI_RMA_PER_TARGET ||
win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_GRANTED) {
/* If global state is MPIDI_RMA_PER_TARGET, this must not
* be the first time to create this target (The first time
* is in Win_lock). Here we recreated it and set the access
* state to LOCK_GRANTED because before we free the previous
* one, the lock should already be granted. */
/* If global state is MPIDI_RMA_LOCK_ALL_GRANTED, all locks
* should already be granted. So the access state for this
* target is also set to MPIDI_RMA_LOCK_GRANTED. */
target->access_state = MPIDI_RMA_LOCK_GRANTED;
}
else if (win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_CALLED) {
/* If global state is MPIDI_RMA_LOCK_ALL_CALLED, this must
the first time to create this target, set its access state
to MPIDI_RMA_LOCK_CALLED. */
target->access_state = MPIDI_RMA_LOCK_CALLED;
target->lock_type = MPI_LOCK_SHARED;
}
}
/* Enqueue operation into pending list. */
MPL_LL_APPEND(target->pending_op_list, target->pending_op_list_tail, op);
if (target->next_op_to_issue == NULL)
target->next_op_to_issue = op;
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* MPIDI_CH3I_Win_target_dequeue_and_free(): dequeue and free
* the target in RMA slots. */
......
......@@ -72,16 +72,12 @@ int MPIDI_Put(const void *origin_addr, int origin_count, MPI_Datatype
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
MPIDI_CH3_Pkt_put_t *put_pkt = NULL;
/* queue it up */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
put_pkt = &(new_ptr->pkt.put);
MPIDI_Pkt_init(put_pkt, MPIDI_CH3_PKT_PUT);
......@@ -99,6 +95,10 @@ int MPIDI_Put(const void *origin_addr, int origin_count, MPI_Datatype
new_ptr->origin_datatype = origin_datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
/* if source or target datatypes are derived, increment their
* reference counts */
if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
......@@ -184,16 +184,12 @@ int MPIDI_Get(void *origin_addr, int origin_count, MPI_Datatype
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
MPIDI_CH3_Pkt_get_t *get_pkt = NULL;
/* queue it up */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
get_pkt = &(new_ptr->pkt.get);
MPIDI_Pkt_init(get_pkt, MPIDI_CH3_PKT_GET);
......@@ -211,6 +207,10 @@ int MPIDI_Get(void *origin_addr, int origin_count, MPI_Datatype
new_ptr->origin_datatype = origin_datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
/* if source or target datatypes are derived, increment their
* reference counts */
if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
......@@ -297,16 +297,12 @@ int MPIDI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
MPIDI_CH3_Pkt_accum_t *accum_pkt = NULL;
/* queue it up */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
/* If predefined and contiguous, use a simplified element */
if (MPIR_DATATYPE_IS_PREDEFINED(origin_datatype) &&
......@@ -333,6 +329,11 @@ int MPIDI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype
new_ptr->origin_count = origin_count;
new_ptr->origin_datatype = origin_datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
goto fn_exit;
}
}
......@@ -354,6 +355,10 @@ int MPIDI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype
new_ptr->origin_datatype = origin_datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
/* if source or target datatypes are derived, increment their
* reference counts */
if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
......@@ -443,15 +448,11 @@ int MPIDI_Get_accumulate(const void *origin_addr, int origin_count,
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
/* Append the operation to the window's RMA ops queue */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
/* TODO: Can we use the MPIDI_RMA_ACC_CONTIG optimization? */
......@@ -494,6 +495,10 @@ int MPIDI_Get_accumulate(const void *origin_addr, int origin_count,
new_ptr->target_rank = target_rank;
}
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
/* if source or target datatypes are derived, increment their
* reference counts */
if (op != MPI_NO_OP && !MPIR_DATATYPE_IS_PREDEFINED(origin_datatype)) {
......@@ -578,16 +583,12 @@ int MPIDI_Compare_and_swap(const void *origin_addr, const void *compare_addr,
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
MPIDI_CH3_Pkt_cas_t *cas_pkt = NULL;
/* Append this operation to the RMA ops queue */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
cas_pkt = &(new_ptr->pkt.cas);
MPIDI_Pkt_init(cas_pkt, MPIDI_CH3_PKT_CAS);
......@@ -605,6 +606,10 @@ int MPIDI_Compare_and_swap(const void *origin_addr, const void *compare_addr,
new_ptr->compare_addr = (void *) compare_addr;
new_ptr->compare_datatype = datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
}
fn_exit:
......@@ -673,16 +678,12 @@ int MPIDI_Fetch_and_op(const void *origin_addr, void *result_addr,
MPIU_ERR_POP(mpi_errno);
}
else {
MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
MPIDI_RMA_Ops_list_t *ops_list_tail = MPIDI_CH3I_RMA_Get_ops_list_tail(win_ptr, target_rank);
MPIDI_RMA_Op_t *new_ptr = NULL;
MPIDI_CH3_Pkt_fop_t *fop_pkt = NULL;
/* Append this operation to the RMA ops queue */
mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(win_ptr, ops_list, ops_list_tail, &new_ptr);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(new_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
fop_pkt = &(new_ptr->pkt.fop);
MPIDI_Pkt_init(fop_pkt, MPIDI_CH3_PKT_FOP);
......@@ -699,6 +700,10 @@ int MPIDI_Fetch_and_op(const void *origin_addr, void *result_addr,
new_ptr->result_addr = result_addr;
new_ptr->result_datatype = datatype;
new_ptr->target_rank = target_rank;
mpi_errno = MPIDI_CH3I_Win_enqueue_op(win_ptr, new_ptr);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
}
fn_exit:
......
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