13.2.2. Window That Allocates Memory

PreviousUpNext
Up: Initialization Next: Window That Allocates Shared Memory Previous: Window Creation

MPI_WIN_ALLOCATE(size, disp_unit, info, comm, baseptr, win)
IN sizesize of window in bytes (non-negative integer)
IN disp_unitlocal unit size for displacements, in bytes (positive integer)
IN infoinfo argument (handle)
IN commintra-communicator (handle)
OUT baseptrinitial address of window (choice)
OUT winwindow object (handle)
C binding
int MPI_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *baseptr, MPI_Win *win)
int MPI_Win_allocate_c(MPI_Aint size, MPI_Aint disp_unit, MPI_Info info, MPI_Comm comm, void *baseptr, MPI_Win *win)
Fortran 2008 binding
MPI_Win_allocate(size, disp_unit, info, comm, baseptr, win, ierror)

USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: size
INTEGER, INTENT(IN) :: disp_unit
TYPE(MPI_Info), INTENT(IN) :: info
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(C_PTR), INTENT(OUT) :: baseptr
TYPE(MPI_Win), INTENT(OUT) :: win
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Win_allocate(size, disp_unit, info, comm, baseptr, win, ierror) !(_c)

USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: size, disp_unit
TYPE(MPI_Info), INTENT(IN) :: info
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(C_PTR), INTENT(OUT) :: baseptr
TYPE(MPI_Win), INTENT(OUT) :: win
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_WIN_ALLOCATE(SIZE, DISP_UNIT, INFO, COMM, BASEPTR, WIN, IERROR)

INTEGER(KIND=MPI_ADDRESS_KIND) SIZE, BASEPTR
INTEGER DISP_UNIT, INFO, COMM, WIN, IERROR

This procedure is collective over the group of comm. On each MPI process, it allocates memory of at least size bytes and returns a pointer to it along with a handle to a new window that can be used by all MPI processes in the group of comm to perform RMA operations. The returned memory consists of size bytes local to each MPI process, starting at address baseptr and is associated with the window as if the user called MPI_WIN_CREATE on existing memory. The size argument may be different at each MPI process and size = 0 is valid; however, a library might allocate and expose more memory in order to create a fast, globally symmetric allocation. The discussion of and rationales for MPI_ALLOC_MEM and MPI_FREE_MEM in Section Memory Allocation also apply to MPI_WIN_ALLOCATE; in particular, see the rationale in Section Memory Allocation for an explanation of the type used for baseptr.

Implementations may make allocated memory available for load/store accesses by MPI processes in the same shared memory domain. A communicator of such processes can be constructed as described in Section Communicator Constructors using MPI_COMM_SPLIT_TYPE. Pointers to access a shared memory segment can be queried using MPI_WIN_SHARED_QUERY. If shared memory is available it is not guaranteed to be contiguous (see Section Window That Allocates Shared Memory).

If the Fortran compiler provides TYPE(C_PTR), then the following generic interface must be provided in the mpi module and should be provided in the (deprecated) mpif.h include file through overloading, i.e., with the same routine name as the routine with INTEGER(KIND=MPI_ADDRESS_KIND) BASEPTR, but with a different specific procedure name:


INTERFACE MPI_WIN_ALLOCATE 
    SUBROUTINE MPI_WIN_ALLOCATE(SIZE, DISP_UNIT, INFO, COMM, BASEPTR, & 
            WIN, IERROR) 
        IMPORT :: MPI_ADDRESS_KIND 
        INTEGER :: DISP_UNIT, INFO, COMM, WIN, IERROR 
        INTEGER(KIND=MPI_ADDRESS_KIND) :: SIZE, BASEPTR 
    END SUBROUTINE 
    SUBROUTINE MPI_WIN_ALLOCATE_CPTR(SIZE, DISP_UNIT, INFO, COMM, BASEPTR, & 
            WIN, IERROR) 
        USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR 
        IMPORT :: MPI_ADDRESS_KIND 
        INTEGER :: DISP_UNIT, INFO, COMM, WIN, IERROR 
        INTEGER(KIND=MPI_ADDRESS_KIND) :: SIZE 
        TYPE(C_PTR) :: BASEPTR 
    END SUBROUTINE 
END INTERFACE 
The base procedure name of this overloaded function is MPI_WIN_ALLOCATE_CPTR. The implied specific procedure names are described in Section Interface Specifications, Procedure Names, and the Profiling Interface.


Rationale.

By allocating (potentially aligned) memory instead of allowing the user to pass in an arbitrary buffer, this call can improve the performance for systems with remote direct memory access. This also permits the collective allocation of memory and supports what is sometimes called the ``symmetric allocation'' model that can be more scalable (for example, the implementation can arrange to return an address for the allocated memory that is the same on all MPI processes). ( End of rationale.)
The info argument can be used to specify hints similar to the info argument for MPI_WIN_CREATE and MPI_ALLOC_MEM.

The default memory alignment requirements and the mpi_minimum_memory_alignment info key described for MPI_ALLOC_MEM in Section Memory Allocation apply to all MPI processes with nonzero size argument.


PreviousUpNext
Up: Initialization Next: Window That Allocates Shared Memory Previous: Window Creation


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023