"Pinned" allocate

Thomas Koenig tkoenig@netcologne.de
Thu Jan 3 10:12:00 GMT 2013


Hello Al,

> Is there a way to do a "pinned" (i.e. page-locked in physical memory) allocate in gfortran?
> If not, I suggest an extension to the ALLOCATE statement with an option PINNED='YES' or 'NO'.

Gfortran currently does not have such a functionality.  If you have a
system which supports this, you can do it yourself using mlock and
the C interoperability feature.  Example (untested):

program main
   use iso_c_binding
   implicit none
   integer (kind=c_size_t) :: locklen
   integer (kind=c_int) :: retval
   integer, allocatable, target :: x(:)
   interface
      function mlock (addr, locklen) bind(c)
        use, intrinsic :: iso_c_binding
        type(c_ptr), value :: addr
        integer(c_size_t), value :: locklen
      end function mlock
   end interface
   locklen = 4096
   allocate(x(locklen))
   x = 0
   retval = mlock (c_loc(x(1)), locklen)
   print *,retval
end program main



More information about the Fortran mailing list