Shared memory windows

MPI-3 has introduced the ability to create windows with shared memory:

int MPI_Win_allocate_shared(MPI_Aint size, int disp_unit, \
     MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win)

It is up to the user to ensure that the process group associated with comm can allocate a shared memory segment, but as with MPI_Win_allocate, if the criteria are met, the allocation is handled automatically by MPI_Win_allocate_shared. Such criteria would typically include something like making sure the processes are all running locally on the same node, or if the processes are on different nodes, making certain the hardware (like Omni-Path or InfiniBand) and/or software environment (e.g., OpenSHMEM) natively support RMA operations.

Memory allocated in this fashion will be contiguous across process ranks unless alloc_shared_noncontig is set to true in the info argument. Contiguous across ranks means that the first address of the memory segment for process i+1 occurs immediately after the last address in the memory segment of process i. This has the notable advantage of allowing the user to calculate remote addresses in the window's buffer with only local information. However, note that symmetry is not required as the size argument may be different for each process, and it may even be zero for some processes in the communicator. The downside to using this contiguous-across-ranks shared memory segment is that padding memory for efficient access may not be possible, so setting alloc_shared_noncontig to true can be beneficial on some architectures. Note that MPI only guarantees consistent memory for shared memory windows using the unified memory model and only when using window synchronization functions.

The following function is used to get the local size, local displacement size, and local base address for a given window and rank:

int MPI_Win_shared_query(MPI_Win win, int rank, MPI_Aint *size,
     int *disp_unit, void *base)
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement