Commit 0f596c48 authored by Xin Zhao's avatar Xin Zhao
Browse files

Add RMA slots and related APIs.



We allocate a fixed size of targets array on window
during window creation. The size can be configured
by the user via CVAR. Each slot entry contains a list
of target elements.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 5dd8a0a4
......@@ -142,6 +142,104 @@ static inline int MPIDI_CH3I_Win_target_free(MPID_Win * win_ptr, MPIDI_RMA_Targe
return mpi_errno;
}
/* MPIDI_CH3I_Win_create_target(): given a rank, create
* corresponding target in RMA slots. */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_create_target
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_Win_create_target(MPID_Win * win_ptr, int target_rank,
MPIDI_RMA_Target_t **e)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_RMA_Slot_t *slot = NULL;
MPIDI_RMA_Target_t *t = NULL;
if (win_ptr->num_slots < win_ptr->comm_ptr->local_size)
slot = &(win_ptr->slots[target_rank % win_ptr->num_slots]);
else
slot = &(win_ptr->slots[target_rank]);
t = MPIDI_CH3I_Win_target_alloc(win_ptr);
MPIU_ERR_CHKANDJUMP(t == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem");
t->target_rank = target_rank;
/* Enqueue target into target list. */
MPL_LL_APPEND(slot->target_list, slot->target_list_tail, t);
assert(t != NULL);
(*e) = t;
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* MPIDI_CH3I_Win_find_target(): given a rank, find
* corresponding target in RMA slots. */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_find_target
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_Win_find_target(MPID_Win * win_ptr, int target_rank,
MPIDI_RMA_Target_t **e)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_RMA_Slot_t *slot = NULL;
MPIDI_RMA_Target_t *t = NULL;
if (win_ptr->num_slots < win_ptr->comm_ptr->local_size)
slot = &(win_ptr->slots[target_rank % win_ptr->num_slots]);
else
slot = &(win_ptr->slots[target_rank]);
t = slot->target_list;
while (t != NULL) {
if (t->target_rank == target_rank)
break;
}
(*e) = t;
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. */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_target_dequeue_and_free
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static inline int MPIDI_CH3I_Win_target_dequeue_and_free(MPID_Win * win_ptr,
MPIDI_RMA_Target_t * e)
{
int mpi_errno = MPI_SUCCESS;
int target_rank = e->target_rank;
MPIDI_RMA_Slot_t *slot;
if (win_ptr->num_slots < win_ptr->comm_ptr->local_size)
slot = &(win_ptr->slots[target_rank % win_ptr->num_slots]);
else
slot = &(win_ptr->slots[target_rank]);
MPL_LL_DELETE(slot->target_list, slot->target_list_tail, e);
mpi_errno = MPIDI_CH3I_Win_target_free(win_ptr, e);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* Return nonzero if the RMA operations list is empty.
*/
#undef FUNCNAME
......
......@@ -119,6 +119,11 @@ typedef struct MPIDI_RMA_Target {
MPIDI_RMA_Pool_type_t pool_type;
} MPIDI_RMA_Target_t;
typedef struct MPIDI_RMA_Slot {
struct MPIDI_RMA_Target *target_list;
struct MPIDI_RMA_Target *target_list_tail;
} MPIDI_RMA_Slot_t;
typedef struct MPIDI_PT_single_op {
MPIDI_CH3_Pkt_type_t type; /* put, get, or accum. */
void *addr;
......
......@@ -339,6 +339,8 @@ struct MPIDI_Win_target_state {
struct MPIDI_RMA_Target *target_pool_start; /* start pointer used for freeing */\
struct MPIDI_RMA_Target *target_pool; /* pool of targets */ \
struct MPIDI_RMA_Target *target_pool_tail; /* tail pointer to pool of targets */\
struct MPIDI_RMA_Slot *slots; \
int num_slots; \
#ifdef MPIDI_CH3_WIN_DECL
#define MPID_DEV_WIN_DECL \
......
......@@ -7,6 +7,25 @@
#include "mpidimpl.h"
#include "mpidrma.h"
/*
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
cvars:
- name : MPIR_CVAR_CH3_RMA_SLOTS_SIZE
category : CH3
type : int
default : 262144
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : >-
Number of RMA slots during window creation. Each slot contains
a linked list of target elements. The distribution of ranks among
slots follows a round-robin pattern. Requires a positive value.
=== END_MPI_T_CVAR_INFO_BLOCK ===
*/
MPIU_THREADSAFE_INIT_DECL(initRMAoptions);
......@@ -258,7 +277,7 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
int i;
MPID_Comm *win_comm_ptr;
int win_target_pool_size;
MPIU_CHKPMEM_DECL(3);
MPIU_CHKPMEM_DECL(4);
MPIDI_STATE_DECL(MPID_STATE_WIN_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_WIN_INIT);
......@@ -349,6 +368,14 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
MPL_LL_APPEND((*win_ptr)->target_pool, (*win_ptr)->target_pool_tail, &((*win_ptr)->target_pool_start[i]));
}
(*win_ptr)->num_slots = MPIR_MIN(MPIR_CVAR_CH3_RMA_SLOTS_SIZE, MPIR_Comm_size(win_comm_ptr));
MPIU_CHKPMEM_MALLOC((*win_ptr)->slots, struct MPIDI_RMA_Slot *,
sizeof(MPIDI_RMA_Slot_t) * (*win_ptr)->num_slots, mpi_errno, "RMA slots");
for (i = 0; i < (*win_ptr)->num_slots; i++) {
(*win_ptr)->slots[i].target_list = NULL;
(*win_ptr)->slots[i].target_list_tail = NULL;
}
MPID_WIN_FTABLE_SET_DEFAULTS(win_ptr);
fn_exit:
......
......@@ -160,6 +160,7 @@ int MPIDI_Win_free(MPID_Win ** win_ptr)
MPIU_Free((*win_ptr)->all_win_handles);
MPIU_Free((*win_ptr)->op_pool_start);
MPIU_Free((*win_ptr)->target_pool_start);
MPIU_Free((*win_ptr)->slots);
/* Free the attached buffer for windows created with MPI_Win_allocate() */
if ((*win_ptr)->create_flavor == MPI_WIN_FLAVOR_ALLOCATE ||
......
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