[MPI3 Fortran] Effect of volatile

Craig Rasmussen crasmussen at lanl.gov
Thu Dec 18 12:49:51 CST 2008


At the MPI Forum meeting this week there was a discussion on the  
effects of volatile (the subject has come up on the WG5 list as well)  
on performance.  MPI users are very concerned about performance and  
are worried that providing the volatile attribute to an array will  
substantially affect performance.  However, I think the following  
should work with minimal  performance implications:

---------------------

     buf(1) = 1
     call MPI_Irecv(buf, ...., request,...)

     ! .... do work without buf

     BLOCK
         volatile :: buf
         call MPI_Wait(request, ...)
     END BLOCK

    ! now buf is ready to use

    x = buf(1)

---------------------

I believe that the effects of the volatile statement within the block  
is AS IF MPI_Wait were called with buf as a parameter and the dummy  
variable was INTENT(INOUT): any registers containing values associated  
with buf will be flushed and code motion will be restricted.  Volatile  
would only be in effect within the block construct and would not have  
any performance implications otherwise.  At the assignment statement,  
x = buf(1), the value assigned to x would have to be retrieved from  
memory and could not be obtained from a register.

I should note that buf can't actually be passed as a parameter to  
MPI_Wait as the request handle could be associated with any number of  
variables, not just buf.

Regards,
Craig







  
    



More information about the mpiwg-fortran mailing list