Commit 55589398 authored by James Dinan's avatar James Dinan
Browse files

[svn-r10115] New CH3 window functions interface.

This adds the win_fns table to ch3, which allows the channel to override the
default implementation of window creation routines provided by ch3.  This also
pushes the implementation of shared memory windows down into Nemesis, includes
window functions for sock, and contains multiple improvements to the window
creation functions code.

Reviewer: buntinas
parent 52d980d7
......@@ -185,6 +185,7 @@ MPI_TYPECLASS_INTEGER, or MPI_TYPECLASS_COMPLEX
**rmatypenotatomic: Datatype not permitted for atomic operations
**rmatypenotatomic %D: Datatype (%D) not permitted for atomic operations
**winflavor: Window flavor is not compatible with the given operation
**typenotpredefined: Datatype must be predefined
......
......@@ -11,5 +11,14 @@
#include "mpid_nem_defs.h"
#include "mpid_nem_memdefs.h"
#define MPIDI_CH3_WIN_DECL \
int shm_allocated; /* flag: TRUE iff this window has a shared memory \
region associated with it */ \
void *shm_base_addr; /* base address of shared memory region */ \
MPI_Aint shm_segment_len; /* size of shared memory region */ \
void **shm_base_addrs; /* array of base addresses of the windows of \
all processes in this process's address space */ \
MPIU_SHMW_Hnd_t shm_segment_handle; /* handle to shared memory region */ \
#endif /* MPID_NEM_PRE_H */
......@@ -168,5 +168,8 @@ typedef struct MPIDI_CH3I_VC
void *sendq_head;
} MPIDI_CH3I_VC;
/* Nemesis-provided RMA implementation */
int MPIDI_CH3_SHM_Win_shared_query(MPID_Win *win_ptr, int target_rank, MPI_Aint *size, int *disp_unit, void *baseptr);
int MPIDI_CH3_SHM_Win_free(MPID_Win **win_ptr);
#endif /* !defined(MPICH_MPIDI_CH3_IMPL_H_INCLUDED) */
......@@ -14,6 +14,8 @@ lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/channels/nemesis/src/ch3_istartmsgv.c \
src/mpid/ch3/channels/nemesis/src/ch3_progress.c \
src/mpid/ch3/channels/nemesis/src/ch3_abort.c \
src/mpid/ch3/channels/nemesis/src/ch3_rma_shm.c \
src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c \
src/mpid/ch3/channels/nemesis/src/ch3i_comm.c \
src/mpid/ch3/channels/nemesis/src/ch3i_eagernoncontig.c \
src/mpid/ch3/channels/nemesis/src/mpid_nem_alloc.c \
......
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpidi_ch3_impl.h"
#include "mpidrma.h"
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_shared_query
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_SHM_Win_shared_query(MPID_Win *win_ptr, int target_rank, MPI_Aint *size, int *disp_unit, void *baseptr)
{
int comm_size;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY);
comm_size = win_ptr->comm_ptr->local_size;
if (win_ptr->create_flavor != MPIX_WIN_FLAVOR_SHARED) {
MPIU_ERR_SETANDJUMP(mpi_errno, MPIX_ERR_RMA_WRONG_FLAVOR, "**winflavor");
}
/* Scan the sizes to locate the first process that allocated a nonzero
* amount of space */
if (target_rank == MPI_PROC_NULL) {
int i;
/* Default, if no processes have size > 0. */
*size = 0;
*((void**) baseptr) = NULL;
for (i = 0; i < comm_size; i++) {
if (win_ptr->sizes[i] > 0) {
*size = win_ptr->sizes[i];
*((void**) baseptr) = win_ptr->shm_base_addrs[i];
break;
}
}
} else {
*size = win_ptr->sizes[target_rank];
*((void**) baseptr) = win_ptr->shm_base_addrs[target_rank];
}
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY);
return mpi_errno;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_SHM_Win_free
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_SHM_Win_free(MPID_Win **win_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_SHM_WIN_FREE);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_SHM_WIN_FREE);
/* Free shared memory region */
if ((*win_ptr)->shm_allocated) {
/* free shm_base_addrs that's only used for shared memory windows */
MPIU_Free((*win_ptr)->shm_base_addrs);
/* detach from shared memory segment */
mpi_errno = MPIU_SHMW_Seg_detach((*win_ptr)->shm_segment_handle, (char **)&(*win_ptr)->shm_base_addr,
(*win_ptr)->shm_segment_len);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_SHMW_Hnd_finalize(&(*win_ptr)->shm_segment_handle);
}
mpi_errno = MPIDI_Win_free(win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_SHM_WIN_FREE);
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpid_nem_impl.h"
#include "mpidimpl.h"
/* FIXME: get this from OS */
#define MPIDI_CH3_PAGESIZE ((MPI_Aint)4096)
#define MPIDI_CH3_PAGESIZE_MASK (~(MPIDI_CH3_PAGESIZE-1))
#define MPIDI_CH3_ROUND_UP_PAGESIZE(x) ((((MPI_Aint)x)+(~MPIDI_CH3_PAGESIZE_MASK)) & MPIDI_CH3_PAGESIZE_MASK)
#ifdef USE_MPIU_INSTR
MPIU_INSTR_DURATION_EXTERN_DECL(wincreate_allgather);
#endif
static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr,
void **base_ptr, MPID_Win **win_ptr);
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_fns_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_Win_fns_init(MPIDI_CH3U_Win_fns_t *win_fns)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
win_fns->allocate_shared = MPIDI_CH3I_Win_allocate_shared;
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
return mpi_errno;
}
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_allocate_shared
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int MPIDI_CH3I_Win_allocate_shared(MPI_Aint size, MPID_Info *info, MPID_Comm *comm_ptr,
void **base_ptr, MPID_Win **win_ptr)
{
int mpi_errno = MPI_SUCCESS;
int i, k, comm_size, rank;
MPI_Aint *tmp_buf;
int errflag = FALSE;
int noncontig = FALSE;
char key[] = "alloc_shared_noncontig";
MPIU_CHKPMEM_DECL(6);
MPIU_CHKLMEM_DECL(1);
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_WIN_ALLOCATE_SHARED);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_WIN_ALLOCATE_SHARED);
/* see if we can allocate all windows contiguously */
if (info)
MPIR_Info_get_impl(info, key, 0, NULL, &noncontig);
(*win_ptr)->shm_allocated = TRUE;
comm_size = (*win_ptr)->comm_ptr->local_size;
rank = (*win_ptr)->comm_ptr->rank;
MPIU_INSTR_DURATION_START(wincreate_allgather);
/* allocate memory for the base addresses, disp_units, and
completion counters of all processes */
MPIU_CHKPMEM_MALLOC((*win_ptr)->base_addrs, void **,
comm_size*sizeof(void *),
mpi_errno, "(*win_ptr)->base_addrs");
MPIU_CHKPMEM_MALLOC((*win_ptr)->shm_base_addrs, void **,
comm_size*sizeof(void *),
mpi_errno, "(*win_ptr)->shm_base_addrs");
MPIU_CHKPMEM_MALLOC((*win_ptr)->sizes, MPI_Aint *, comm_size*sizeof(MPI_Aint),
mpi_errno, "(*win_ptr)->sizes");
MPIU_CHKPMEM_MALLOC((*win_ptr)->disp_units, int *, comm_size*sizeof(int),
mpi_errno, "(*win_ptr)->disp_units");
for (i=0; i<comm_size; i++) (*win_ptr)->disp_units[i] = 1;
MPIU_CHKPMEM_MALLOC((*win_ptr)->all_win_handles, MPI_Win *,
comm_size*sizeof(MPI_Win),
mpi_errno, "(*win_ptr)->all_win_handles");
MPIU_CHKPMEM_MALLOC((*win_ptr)->pt_rma_puts_accs, int *,
comm_size*sizeof(int),
mpi_errno, "(*win_ptr)->pt_rma_puts_accs");
for (i=0; i<comm_size; i++) (*win_ptr)->pt_rma_puts_accs[i] = 0;
/* get the sizes of the windows and window objectsof
all processes. allocate temp. buffer for communication */
MPIU_CHKLMEM_MALLOC(tmp_buf, MPI_Aint *, 2*comm_size*sizeof(MPI_Aint), mpi_errno, "tmp_buf");
/* FIXME: This needs to be fixed for heterogeneous systems */
tmp_buf[2*rank] = (MPI_Aint) size;
tmp_buf[2*rank+1] = (MPI_Aint) (*win_ptr)->handle;
mpi_errno = MPIR_Allgather_impl(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
tmp_buf, 2 * sizeof(MPI_Aint), MPI_BYTE,
(*win_ptr)->comm_ptr, &errflag);
MPIU_INSTR_DURATION_END(wincreate_allgather);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
(*win_ptr)->shm_segment_len = 0;
k = 0;
for (i = 0; i < comm_size; ++i) {
(*win_ptr)->sizes[i] = tmp_buf[k++];
(*win_ptr)->all_win_handles[i] = (MPI_Win) tmp_buf[k++];
if (noncontig)
/* Round up to next page size */
(*win_ptr)->shm_segment_len += MPIDI_CH3_ROUND_UP_PAGESIZE((*win_ptr)->sizes[i]);
else
(*win_ptr)->shm_segment_len += (*win_ptr)->sizes[i];
}
mpi_errno = MPIU_SHMW_Hnd_init(&(*win_ptr)->shm_segment_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (rank == 0) {
char *serialized_hnd_ptr = NULL;
/* create shared memory region for all processes in win and map */
mpi_errno = MPIU_SHMW_Seg_create_and_attach((*win_ptr)->shm_segment_handle, (*win_ptr)->shm_segment_len,
(char **)&(*win_ptr)->shm_base_addr, 0);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* serialize handle and broadcast it to the other processes in win */
mpi_errno = MPIU_SHMW_Hnd_get_serialized_by_ref((*win_ptr)->shm_segment_handle, &serialized_hnd_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Bcast_impl(serialized_hnd_ptr, MPIU_SHMW_GHND_SZ, MPI_CHAR, 0, (*win_ptr)->comm_ptr, &errflag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
/* wait for other processes to attach to win */
mpi_errno = MPIR_Barrier_impl((*win_ptr)->comm_ptr, &errflag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
/* unlink shared memory region so it gets deleted when all processes exit */
mpi_errno = MPIU_SHMW_Seg_remove((*win_ptr)->shm_segment_handle);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
} else {
char serialized_hnd[MPIU_SHMW_GHND_SZ] = {0};
/* get serialized handle from rank 0 and deserialize it */
mpi_errno = MPIR_Bcast_impl(serialized_hnd, MPIU_SHMW_GHND_SZ, MPI_CHAR, 0, (*win_ptr)->comm_ptr, &errflag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
mpi_errno = MPIU_SHMW_Hnd_deserialize((*win_ptr)->shm_segment_handle, serialized_hnd, strlen(serialized_hnd));
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* attach to shared memory region created by rank 0 */
mpi_errno = MPIU_SHMW_Seg_attach((*win_ptr)->shm_segment_handle, (*win_ptr)->shm_segment_len,
(char **)&(*win_ptr)->shm_base_addr, 0);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Barrier_impl((*win_ptr)->comm_ptr, &errflag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
}
/* compute the base addresses of each process within the shared memory segment */
(*win_ptr)->shm_base_addrs[0] = (*win_ptr)->shm_base_addr;
for (i = 1; i < comm_size; ++i) {
if ((*win_ptr)->sizes[i]) {
if (noncontig)
(*win_ptr)->shm_base_addrs[i] = (char *)(*win_ptr)->shm_base_addrs[i-1] +
MPIDI_CH3_ROUND_UP_PAGESIZE((*win_ptr)->sizes[i-1]);
else
(*win_ptr)->shm_base_addrs[i] = (char *)(*win_ptr)->shm_base_addrs[i-1] + (*win_ptr)->sizes[i-1];
} else {
(*win_ptr)->shm_base_addrs[i] = NULL; /* FIXME: Is this right? */
}
}
(*win_ptr)->base = (*win_ptr)->shm_base_addrs[rank];
/* get the base addresses of the windows. Note we reuse tmp_buf from above
since it's at least as large as we need it for this allgather. */
/* FIXME: This needs to be fixed for heterogeneous systems */
tmp_buf[rank] = (MPI_Aint) (*win_ptr)->base;
mpi_errno = MPIR_Allgather_impl(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
tmp_buf, sizeof(MPI_Aint), MPI_BYTE,
(*win_ptr)->comm_ptr, &errflag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
for (i = 0; i < comm_size; ++i)
(*win_ptr)->base_addrs[i] = (void *)(tmp_buf[i]);
*base_ptr = (*win_ptr)->base;
/* Provide operation overrides for this window flavor */
(*win_ptr)->RMAFns.Win_shared_query = MPIDI_CH3_SHM_Win_shared_query;
(*win_ptr)->RMAFns.Win_free = MPIDI_CH3_SHM_Win_free;
fn_exit:
MPIU_CHKLMEM_FREEALL();
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_WIN_ALLOCATE_SHARED);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
/* --END ERROR HANDLING-- */
}
......@@ -18,7 +18,8 @@ lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/channels/sock/src/ch3_isendv.c \
src/mpid/ch3/channels/sock/src/ch3_istartmsg.c \
src/mpid/ch3/channels/sock/src/ch3_istartmsgv.c \
src/mpid/ch3/channels/sock/src/ch3_progress.c
src/mpid/ch3/channels/sock/src/ch3_progress.c \
src/mpid/ch3/channels/sock/src/ch3_win_fns.c
endif BUILD_CH3_SOCK
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpidimpl.h"
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3_Win_fns_init
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_Win_fns_init(MPIDI_CH3U_Win_fns_t *win_fns)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
/* Sock doesn't override any of the default Window functions */
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_FNS_INIT);
return mpi_errno;
}
......@@ -1114,6 +1114,34 @@ int MPIDI_CH3U_Comm_FinishPending( MPID_Comm * );
/* mpirma.h (in src/mpi/rma?) */
/* ------------------------------------------------------------------------- */
/* The Win_fns table contains pointers to the channel's implementation of the
* RMA window creation routines. The channel must provide the init function,
* which can optionally override any defaults already set by CH3.
*/
typedef struct MPIDI_CH3U_Win_fns_s {
int (*create)(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *, MPID_Win **);
int (*allocate)(MPI_Aint, int, MPID_Info *, MPID_Comm *, void *, MPID_Win **);
int (*allocate_shared)(MPI_Aint, MPID_Info *, MPID_Comm *, void **, MPID_Win **);
int (*create_dynamic)(MPID_Info *, MPID_Comm *, MPID_Win **);
} MPIDI_CH3U_Win_fns_t;
extern MPIDI_CH3U_Win_fns_t MPIDI_CH3U_Win_fns;
/* 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);
/* Default window creation functions provided by CH3 */
int MPIDI_CH3U_Win_create(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *,
MPID_Win **);
int MPIDI_CH3U_Win_allocate(MPI_Aint size, int disp_unit, MPID_Info *info,
MPID_Comm *comm, void *baseptr, MPID_Win **win);
int MPIDI_CH3U_Win_allocate_shared(MPI_Aint size, MPID_Info *info_ptr, MPID_Comm *comm_ptr,
void **baseptr, MPID_Win **win_ptr);
int MPIDI_CH3U_Win_create_dynamic(MPID_Info *info, MPID_Comm *comm, MPID_Win **win);
/* FIXME: These are specific to the RMA code and should be in the RMA
header file. */
#define MPIDI_RMA_PUT 23
......@@ -1130,6 +1158,12 @@ int MPIDI_CH3U_Comm_FinishPending( MPID_Comm * );
#define MPID_LOCK_NONE 0
#define MPID_LOCK_SHARED_ALL 1
/* MPI RMA Utility functions */
int MPIDI_CH3U_Win_create_gather(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *,
MPID_Win **);
/* MPI-2 RMA Routines */
int MPIDI_Win_create(void *, MPI_Aint, int, MPID_Info *, MPID_Comm *,
......
......@@ -26,9 +26,6 @@ typedef MPIR_Pint MPIDI_msg_sz_t;
/* FIXME: Include here? */
#include "opa_primitives.h"
/* For shared memory window support in MPID_Win */
#include "mpiu_os_wrappers_pre.h"
/* Include definitions from the channel which must exist before items in this
file (mpidpre.h) or the file it includes (mpiimpl.h) can be defined. */
#include "mpidi_ch3_pre.h"
......@@ -211,13 +208,6 @@ typedef struct MPIDI_VC * MPID_VCR;
that this process has \
completed as target */ \
MPI_Aint *sizes; /* array of sizes of all windows */ \
int shm_allocated; /* flag: TRUE iff this window has a shared memory \
region associated with it */ \
void *shm_base_addr; /* base address of shared memory region */ \
MPI_Aint shm_segment_len; /* size of shared memory region */ \
void **shm_base_addrs; /* array of base addresses of the windows of \
all processes in this process's address space */ \
MPIU_SHMW_Hnd_t shm_segment_handle; /* handle to shared memory region */
#ifdef MPIDI_CH3_WIN_DECL
#define MPID_DEV_WIN_DECL \
......
......@@ -26,6 +26,7 @@ lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/src/ch3u_rndv.c \
src/mpid/ch3/src/ch3u_eager.c \
src/mpid/ch3/src/ch3u_eagersync.c \
src/mpid/ch3/src/ch3u_win_fns.c \
src/mpid/ch3/src/mpid_abort.c \
src/mpid/ch3/src/mpid_cancel_recv.c \
src/mpid/ch3/src/mpid_cancel_send.c \
......
......@@ -176,3 +176,13 @@ int MPIDI_Win_flush_local_all(MPID_Win *win)
{
MPIDI_FUNC_NOTIMPL(WIN_FLUSH_LOCAL_ALL)
}
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_shared_query
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_shared_query(MPID_Win *win_ptr, int target_rank, MPI_Aint *size, int *disp_unit, void *baseptr)
{
MPIDI_FUNC_NOTIMPL(WIN_FLUSH_LOCAL_ALL)
}
......@@ -7,21 +7,14 @@
#include "mpidi_ch3_impl.h"
#include "mpidrma.h"
/* FIXME: get this from OS */
#define MPIDI_PAGESIZE ((MPI_Aint)4096)
#define MPIDI_PAGESIZE_MASK (~(MPIDI_PAGESIZE-1))
#define MPIDI_ROUND_UP_PAGESIZE(x) ((((MPI_Aint)x)+(~MPIDI_PAGESIZE_MASK)) & MPIDI_PAGESIZE_MASK)
static int enableShortACC=1;
MPIU_THREADSAFE_INIT_DECL(initRMAoptions);
#ifdef USE_MPIU_INSTR
MPIU_INSTR_DURATION_DECL(wincreate_allgather);
MPIU_INSTR_DURATION_DECL(winfree_rs);
MPIU_INSTR_DURATION_DECL(winfree_complete);
MPIU_INSTR_DURATION_DECL(rmaqueue_alloc);
MPIU_INSTR_DURATION_DECL(rmaqueue_set);
MPIU_INSTR_DURATION_EXTERN_DECL(wincreate_allgather);
MPIU_INSTR_DURATION_EXTERN_DECL(winfree_rs);
MPIU_INSTR_DURATION_EXTERN_DECL(winfree_complete);
MPIU_INSTR_DURATION_EXTERN_DECL(rmaqueue_alloc);
MPIU_INSTR_DURATION_EXTERN_DECL(rmaqueue_set);
extern void MPIDI_CH3_RMA_InitInstr(void);
#endif
......@@ -45,424 +38,6 @@ extern void MPIDI_CH3_RMA_InitInstr(void);
* return value is error code (e.g., allocation failure).
*/
#undef FUNCNAME
#define FUNCNAME win_init
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
static int 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;
MPID_Comm *win_comm_ptr;
MPIDI_STATE_DECL(MPID_STATE_WIN_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_WIN_INIT);
/* FIXME: There should be no unreferenced args */
MPIU_UNREFERENCED_ARG(info);
if(initRMAoptions) {
MPIU_THREADSAFE_INIT_BLOCK_BEGIN(initRMAoptions);
#ifdef USE_MPIU_INSTR
/* Define all instrumentation handles used in the CH3 RMA here*/
MPIU_INSTR_DURATION_INIT(wincreate_allgather,0,"WIN_CREATE:Allgather");
MPIU_INSTR_DURATION_INIT(winfree_rs,0,"WIN_FREE:ReduceScatterBlock");
MPIU_INSTR_DURATION_INIT(winfree_complete,0,"WIN_FREE:Complete");
MPIU_INSTR_DURATION_INIT(rmaqueue_alloc,0,"Allocate RMA Queue element");
MPIU_INSTR_DURATION_INIT(rmaqueue_set,0,"Set fields in RMA Queue element");
MPIDI_CH3_RMA_InitInstr();
#endif
MPIU_THREADSAFE_INIT_CLEAR(initRMAoptions);
MPIU_THREADSAFE_INIT_BLOCK_END(initRMAoptions);
}
*win_ptr = (MPID_Win *)MPIU_Handle_obj_alloc( &MPID_Win_mem );
MPIU_ERR_CHKANDJUMP1(!(*win_ptr),mpi_errno,MPI_ERR_OTHER,"**nomem",
"**nomem %s","MPID_Win_mem");
mpi_errno = MPIR_Comm_dup_impl(comm_ptr, &win_comm_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_Object_set_ref(*win_ptr, 1);
(*win_ptr)->fence_cnt = 0;
/* (*win_ptr)->errhandler is set by upper level; */
/* (*win_ptr)->base is set by caller; */
(*win_ptr)->size = size;
(*win_ptr)->disp_unit = disp_unit;
(*win_ptr)->create_flavor = create_flavor;
(*win_ptr)->model = model;
(*win_ptr)->attributes = NULL;
(*win_ptr)->start_group_ptr = NULL;
(*win_ptr)->start_assert = 0;
(*win_ptr)->comm_ptr = win_comm_ptr;
(*win_ptr)->myrank = comm_ptr->rank;
/* (*win_ptr)->lockRank is initizlized when window is locked*/
(*win_ptr)->my_counter = 0;
/* (*win_ptr)->base_addrs[] is set by caller; */
/* (*win_ptr)->sizes[] is set by caller; */
/* (*win_ptr)->disp_units[] is set by caller; */
/* (*win_ptr)->all_win_handles[] is set by caller; */
(*win_ptr)->rma_ops_list_head = NULL;
(*win_ptr)->rma_ops_list_tail = NULL;
(*win_ptr)->lock_granted = 0;
(*win_ptr)->current_lock_type = MPID_LOCK_NONE;
(*win_ptr)->shared_lock_ref_cnt = 0;
(*win_ptr)->lock_queue = NULL;
(*win_ptr)->pt_rma_puts_accs = NULL;
(*win_ptr)->my_pt_rma_puts_accs = 0;
/* (*win_ptr)->shm_allocated is set by caller; */
/* (*win_ptr)->shm_base_addr is set by caller; */
/* (*win_ptr)->shm_segment_len is set by caller; */
/* (*win_ptr)->shm_base_addrs[] is set by caller; */
/* (*win_ptr)->shm_segment_handle is set by caller; */
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_WIN_INIT);
return mpi_errno;