Commit 384d96b7 authored by Xin Zhao's avatar Xin Zhao Committed by Pavan Balaji
Browse files

Add "alloc_shm" info to MPI_Win_allocate.



Add "alloc_shm" to window's info arguments and initialize it to FALSE.
In MPID_Win_allocate, if "alloc_shm" is set to true, call ALLOCATE_SHARED,
otherwise call ALLOCATE.

Free window memory only when SHM region is not allocated, therwise it is
already freed in MPIDI_CH3I_SHM_Win_free.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@mcs.anl.gov>
parent 44d9c98d
......@@ -244,6 +244,7 @@ struct MPIDI_Win_info_args {
int accumulate_ops;
int same_size; /* valid flavor = allocate */
int alloc_shared_noncontig; /* valid flavor = allocate shared */
int alloc_shm; /* valid flavor = allocate */
};
struct MPIDI_RMA_op; /* forward decl from mpidrma.h */
......
......@@ -67,7 +67,8 @@ int MPIDI_Win_free(MPID_Win **win_ptr)
/* Free the attached buffer for windows created with MPI_Win_allocate() */
if ((*win_ptr)->create_flavor == MPI_WIN_FLAVOR_ALLOCATE && (*win_ptr)->size > 0) {
MPIU_Free((*win_ptr)->base);
if ((*win_ptr)->shm_allocated != TRUE)
MPIU_Free((*win_ptr)->base);
}
MPIU_Object_release_ref(*win_ptr, &in_use);
......
......@@ -109,8 +109,22 @@ int MPID_Win_allocate(MPI_Aint size, int disp_unit, MPID_Info *info,
mpi_errno = win_init(size, disp_unit, MPI_WIN_FLAVOR_ALLOCATE, MPI_WIN_UNIFIED, comm_ptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
mpi_errno = MPIDI_CH3U_Win_fns.allocate(size, disp_unit, info, comm_ptr, baseptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
if (info != NULL) {
int alloc_shm_flag = 0;
char shm_alloc_value[MPI_MAX_INFO_VAL+1];
MPIR_Info_get_impl(info, "alloc_shm", MPI_MAX_INFO_VAL, shm_alloc_value, &alloc_shm_flag);
if ((alloc_shm_flag == 1) && (!strncmp(shm_alloc_value, "true", sizeof("true"))))
(*win_ptr)->info_args.alloc_shm = TRUE;
}
if((*win_ptr)->info_args.alloc_shm == TRUE) {
mpi_errno = MPIDI_CH3U_Win_fns.allocate_shared(size, disp_unit, info, comm_ptr, baseptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
}
else {
mpi_errno = MPIDI_CH3U_Win_fns.allocate(size, disp_unit, info, comm_ptr, baseptr, win_ptr);
if (mpi_errno != MPI_SUCCESS) { MPIU_ERR_POP(mpi_errno); }
}
fn_fail:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_WIN_ALLOCATE);
......@@ -298,6 +312,7 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
(*win_ptr)->info_args.accumulate_ops = MPIDI_ACC_OPS_SAME_OP_NO_OP;
(*win_ptr)->info_args.same_size = 0;
(*win_ptr)->info_args.alloc_shared_noncontig = 0;
(*win_ptr)->info_args.alloc_shm = FALSE;
MPID_WIN_FTABLE_SET_DEFAULTS(win_ptr);
......
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