Commit 7c1a8fb1 authored by Xin Zhao's avatar Xin Zhao
Browse files

Add a function hook to initialize window attributes in channel layer.



There are some window attributes in the channel layer that
needs to be initialized during window creation. In this
patch, we first add a win_hooks table that contains pointers
to the channel's implementation of the function hooks. Secondly,
we add a function hook 'win_init' to allow the channel layer to
initialize its own attributes. The hook is called from the
CH3 win_init function.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent eddd8b91
......@@ -18,6 +18,9 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_wincreate_allgather);
MPIDI_SHM_Wins_list_t shm_wins_list;
static int MPIDI_CH3I_Win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
MPID_Info * info, MPID_Comm * comm_ptr, MPID_Win ** win_ptr);
static int MPIDI_CH3I_Win_allocate_shm(MPI_Aint size, int disp_unit, MPID_Info * info,
MPID_Comm * comm_ptr, void *base_ptr, MPID_Win ** win_ptr);
......@@ -44,6 +47,54 @@ int MPIDI_CH3_Win_fns_init(MPIDI_CH3U_Win_fns_t * win_fns)
return mpi_errno;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_hooks_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_Win_hooks_init(MPIDI_CH3U_Win_hooks_t * win_hooks)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
if (MPIDI_CH3I_Shm_supported()) {
win_hooks->win_init = MPIDI_CH3I_Win_init;
}
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
return mpi_errno;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int MPIDI_CH3I_Win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
MPID_Info * info, MPID_Comm * comm_ptr, MPID_Win ** win_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_WIN_INIT);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_WIN_INIT);
(*win_ptr)->shm_base_addr = NULL;
(*win_ptr)->shm_segment_len = 0;
(*win_ptr)->shm_segment_handle = 0;
(*win_ptr)->shm_mutex = NULL;
(*win_ptr)->shm_mutex_segment_handle = 0;
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_WIN_INIT);
return mpi_errno;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_SHM_Wins_match
#undef FCNAME
......
......@@ -25,3 +25,21 @@ int MPIDI_CH3_Win_fns_init(MPIDI_CH3U_Win_fns_t *win_fns)
return mpi_errno;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_hooks_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_Win_hooks_init(MPIDI_CH3U_Win_hooks_t *win_hooks)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
/* Sock doesn't implement any of the Window hooks */
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_HOOKS_INIT);
return mpi_errno;
}
......@@ -1129,10 +1129,19 @@ typedef struct {
extern MPIDI_CH3U_Win_fns_t MPIDI_CH3U_Win_fns;
typedef struct {
int (*win_init)(MPI_Aint, int, int, int, MPID_Info *, MPID_Comm *, MPID_Win **);
} MPIDI_CH3U_Win_hooks_t;
extern MPIDI_CH3U_Win_hooks_t MPIDI_CH3U_Win_hooks;
/* CH3 and Channel window functions initializers */
int MPIDI_Win_fns_init(MPIDI_CH3U_Win_fns_t *win_fns);
int MPIDI_CH3_Win_fns_init(MPIDI_CH3U_Win_fns_t *win_fns);
/* Channel window hooks initializer */
int MPIDI_CH3_Win_hooks_init(MPIDI_CH3U_Win_hooks_t *win_hooks);
/* Default window creation functions provided by CH3 */
int MPIDI_CH3U_Win_create(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *,
MPID_Win **);
......
......@@ -40,6 +40,7 @@ static int set_eager_threshold(MPID_Comm *comm_ptr, MPID_Info *info, void *state
MPIDI_Process_t MPIDI_Process = { NULL };
MPIDI_CH3U_SRBuf_element_t * MPIDI_CH3U_SRBuf_pool = NULL;
MPIDI_CH3U_Win_fns_t MPIDI_CH3U_Win_fns = { NULL };
MPIDI_CH3U_Win_hooks_t MPIDI_CH3U_Win_hooks = { NULL };
#undef FUNCNAME
......@@ -175,6 +176,7 @@ int MPID_Init(int *argc, char ***argv, int requested, int *provided,
init function. */
MPIDI_Win_fns_init(&MPIDI_CH3U_Win_fns);
MPIDI_CH3_Win_fns_init(&MPIDI_CH3U_Win_fns);
MPIDI_CH3_Win_hooks_init(&MPIDI_CH3U_Win_hooks);
/*
* Let the channel perform any necessary initialization
......
......@@ -394,6 +394,14 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
win_elem->win_ptr = *win_ptr;
MPL_LL_APPEND(MPIDI_RMA_Win_list, MPIDI_RMA_Win_list_tail, win_elem);
if (MPIDI_CH3U_Win_hooks.win_init != NULL) {
mpi_errno =
MPIDI_CH3U_Win_hooks.win_init(size, disp_unit, create_flavor, model, info, comm_ptr,
win_ptr);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_WIN_INIT);
return 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