20.1.20. Comparison with C

PreviousUpNext
Up: Support for Fortran Next: Support for Large Count and Large Byte Displacement in MPI Language Bindings Previous: Permanent Data Movement

In C, subroutines that modify variables that are not in the argument list will not cause register optimization problems. This is because taking pointers to storage objects by using the & operator and later referencing the objects by indirection on the pointer is an integral part of the language. A C compiler understands the implications, so that the problem should not occur, in general. However, some compilers do offer optional aggressive optimization levels that may not be safe. Problems due to temporary memory modifications can also occur in C. As above, the best advice is to avoid the problem: use different variables for buffers in nonblocking MPI operations and computation that is executed while a nonblocking communication operation is pending.


Example Protecting GPU optimizations with the ASYNCHRONOUS attribute.

USE mpi_f08 
REAL :: buf(100,100) 
CALL separated_sections(buf(1:1,1:100), buf(2:100,1:100)) 
END 
 
SUBROUTINE separated_sections(buf_halo, buf_inner) 
REAL, ASYNCHRONOUS :: buf_halo(1:1,1:100) 
REAL :: buf_inner(2:100,1:100) 
REAL :: local_buf(2:100,100) 
 
CALL MPI_Irecv(buf_halo(1,1:100),..., req,...) 
local_buf = buf_inner 
DO j=1,100 
  DO i=2,100 
    local_buf(i,j)=... 
  END DO 
END DO 
buf_inner = local_buf ! buf_halo is not touched!!! 
 
CALL MPI_Wait(req,...) 


PreviousUpNext
Up: Support for Fortran Next: Support for Large Count and Large Byte Displacement in MPI Language Bindings Previous: Permanent Data Movement


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

(Unofficial) MPI-5.0 of June 9, 2025
HTML Generated on March 2, 2025