13.7.4. Registers and Compiler Optimizations

PreviousUpNext
Up: Semantics and Correctness Next: Examples Previous: Progress


Advice to users.

All the material in this section is an advice to users. ( End of advice to users.)
A coherence problem exists between variables kept in registers and the memory values of these variables. An RMA call may access a variable in memory (or cache), while the up-to-date value of this variable is in register. A get will not return the latest variable value, and a put may be overwritten when the register is stored back in memory. Note that these issues are unrelated to the RMA memory model; that is, these issues apply even if the memory model is MPI_WIN_UNIFIED.

The problem is illustrated in Example Registers and Compiler Optimizations.


Example In this example, variable buff is allocated in the register reg_A and therefore ccc will have the old value of buff and not the new value 777.

Image file

This problem, which also afflicts in some cases send/receive communication, is discussed more at length in Section Optimization Problems, an Overview.

Programs written in C avoid this problem, because of the semantics of C. Many Fortran compilers will avoid this problem, without disabling compiler optimizations. However, in order to avoid register coherence problems in a completely portable manner, users should restrict their use of RMA windows to variables stored in modules or COMMON blocks. To prevent problems with the argument copying and register optimization done by Fortran compilers, please note the hints in Sections Problems With Fortran Bindings for MPI--Comparison with C. Sections Solutions to The (Poorly Performing) Fortran VOLATILE Attribute discuss several solutions for the problem in this example.


PreviousUpNext
Up: Semantics and Correctness Next: Examples Previous: Progress


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