18.2.105. MPI_F_sync_reg
MPI_F_sync_reg — Prevent invalid register optimization of a Fortran buffer
18.2.105.1. SYNTAX
18.2.105.1.1. Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_F_SYNC_REG(BUF)
<type> BUF(*)
18.2.105.1.2. Fortran 2008 Syntax
USE mpi_f08
MPI_F_sync_reg(buf)
TYPE(*), DIMENSION(..), ASYNCHRONOUS :: buf
18.2.105.2. INPUT/OUTPUT PARAMETERS
buf: Initial address of the buffer (choice).
18.2.105.3. DESCRIPTION
MPI_F_sync_reg has no executable statements; it exists only to prevent a Fortran compiler from making invalid assumptions about the contents of a buffer across an operation that the compiler cannot see. Passing buf to this routine forces the compiler, when necessary, to flush a cached register copy of the buffer back to memory, or to invalidate a cached register copy so that the buffer is reloaded from memory on its next use.
This is needed in Fortran code that aggressively optimizes register usage around nonblocking or one-sided operations, whose completion — and therefore whose effect on the buffer — is not visible to the compiler from the surrounding code.
18.2.105.4. NOTES
This routine is provided only in the Fortran bindings; it has no C binding because it would serve no purpose in C. It also has no ierror argument because there is no operation that can fail.
For example, after an MPI_Wait that completes a nonblocking receive
into buf, a call to MPI_F_sync_reg(buf) ensures that the compiler
reloads buf from memory rather than reusing a stale register copy that
predates the receive.
See also