Building a Pinned Memory Pool in FORTRAN¶
In this recipe, we show you how to build a pool in pinned memory using Umpire’s FORTRAN API. These kinds of pools can be useful for allocating buffers to be used in communication routines in various scientific applications.
Building the pool takes two steps: 1) getting a base “PINNED” allocator, and 2) creating the pool:
base_allocator = rm%get_allocator_by_name("PINNED")
pinned_pool = rm%make_allocator_pool("PINNED_POOL", &
base_allocator, &
512_8*1024_8, &
1024_8)
The complete example is included below:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Copyright (c) 2016-19, Lawrence Livermore National Security, LLC and Umpire
! project contributors. See the COPYRIGHT file for details.
!
! SPDX-License-Identifier: (MIT)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
program umpire_f_pinned_pool
use umpire_mod
implicit none
logical ok
integer(C_INT), pointer, dimension(:) :: array(:)
type(UmpireAllocator) base_allocator
type(UmpireAllocator) pinned_pool
type(UmpireResourceManager) rm
rm = rm%get_instance()
base_allocator = rm%get_allocator_by_name("PINNED")
pinned_pool = rm%make_allocator_pool("PINNED_POOL", &
base_allocator, &
512_8*1024_8, &
1024_8)
call pinned_pool%allocate(array, [10])
end program umpire_f_pinned_pool