Commit f8e7f47f authored by Pavan Balaji's avatar Pavan Balaji
Browse files

Simplify checks for shared memory windows.



We already do a check for shared memory before calling the
shared-memory specific functions.  This patch simplifies some of those
redundant checks.
Signed-off-by: default avatarXin Zhao <xinzhao3@illinois.edu>
parent 833f2e3e
......@@ -327,20 +327,11 @@ static inline int MPIDI_CH3I_Shm_put_op(const void *origin_addr, int origin_coun
int mpi_errno = MPI_SUCCESS;
void *base = NULL;
int disp_unit;
MPIDI_VC_t *orig_vc, *target_vc;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_PUT_OP);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SHM_PUT_OP);
/* FIXME: Here we decide whether to perform SHM operations by checking if origin and target are on
the same node. However, in ch3:sock, even if origin and target are on the same node, they do
not within the same SHM region. Here we filter out ch3:sock by checking shm_allocated flag first,
which is only set to TRUE when SHM region is allocated in nemesis.
In future we need to figure out a way to check if origin and target are in the same "SHM comm".
*/
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
}
......@@ -378,7 +369,6 @@ static inline int MPIDI_CH3I_Shm_acc_op(const void *origin_addr, int origin_coun
int origin_predefined, target_predefined;
MPI_User_function *uop = NULL;
MPID_Datatype *dtp;
MPIDI_VC_t *orig_vc, *target_vc;
int mpi_errno = MPI_SUCCESS;
MPIU_CHKLMEM_DECL(2);
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_ACC_OP);
......@@ -388,10 +378,7 @@ static inline int MPIDI_CH3I_Shm_acc_op(const void *origin_addr, int origin_coun
MPIDI_CH3I_DATATYPE_IS_PREDEFINED(origin_datatype, origin_predefined);
MPIDI_CH3I_DATATYPE_IS_PREDEFINED(target_datatype, target_predefined);
/* FIXME: refer to FIXME in MPIDI_CH3I_Shm_put_op */
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
shm_op = 1;
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
......@@ -534,7 +521,6 @@ static inline int MPIDI_CH3I_Shm_get_acc_op(const void *origin_addr, int origin_
MPI_User_function *uop = NULL;
MPID_Datatype *dtp;
int origin_predefined, target_predefined;
MPIDI_VC_t *orig_vc, *target_vc;
int mpi_errno = MPI_SUCCESS;
MPIU_CHKLMEM_DECL(2);
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_GET_ACC_OP);
......@@ -547,10 +533,7 @@ static inline int MPIDI_CH3I_Shm_get_acc_op(const void *origin_addr, int origin_
}
MPIDI_CH3I_DATATYPE_IS_PREDEFINED(target_datatype, target_predefined);
/* FIXME: refer to FIXME in MPIDI_CH3I_Shm_put_op */
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
......@@ -706,16 +689,12 @@ static inline int MPIDI_CH3I_Shm_get_op(void *origin_addr, int origin_count, MPI
{
void *base = NULL;
int disp_unit;
MPIDI_VC_t *orig_vc, *target_vc;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_GET_OP);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SHM_GET_OP);
/* FIXME: refer to FIXME in MPIDI_CH3I_Shm_put_op */
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
}
......@@ -751,15 +730,11 @@ static inline int MPIDI_CH3I_Shm_cas_op(const void *origin_addr, const void *com
int disp_unit;
int len, shm_locked = 0;
int mpi_errno = MPI_SUCCESS;
MPIDI_VC_t *orig_vc, *target_vc;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_CAS_OP);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SHM_CAS_OP);
/* FIXME: refer to FIXME in MPIDI_CH3I_Shm_put_op */
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
......@@ -810,16 +785,12 @@ static inline int MPIDI_CH3I_Shm_fop_op(const void *origin_addr, void *result_ad
MPI_User_function *uop = NULL;
int disp_unit;
int len, one, shm_locked = 0;
MPIDI_VC_t *orig_vc, *target_vc;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_FOP_OP);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SHM_FOP_OP);
/* FIXME: refer to FIXME in MPIDI_CH3I_Shm_put_op */
MPIDI_Comm_get_vc(win_ptr->comm_ptr, win_ptr->comm_ptr->rank, &orig_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
if (win_ptr->shm_allocated == TRUE) {
base = win_ptr->shm_base_addrs[target_rank];
disp_unit = win_ptr->disp_units[target_rank];
......
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