OpenMP* Memory Spaces and Allocators

For storage and retrieval variables, OpenMP* provides memory known as memory spaces. Different memory spaces have different traits. Depending on how a variable is to be used and accessed determines which memory space is appropriate for allocation of the variable.

Each memory space has a unique allocator that is used to allocate and deallocate memory in that space. The allocators allocate variables in contiguous space that does not overlap any other allocation in the memory space. Multiple memory spaces with different traits may map to a single memory resource.

The behavior of the allocator is affected by the allocator traits that you specify. The allocator traits, their possible values, and their default values are shown in the following table:

Allocator Trait

Values That Can Be Specified

Default Value

access

  • all
  • cgroup
  • pteam
  • thread

All

alignment

A positive integer value that is a power of 2 specifying number of bytes

1 byte

fallback

  • abort_fb
  • allocator_fb
  • default_mem_fb
  • null_fb

default_mem_fb

fb_data

An allocator handle

None

partition

  • blocked
  • environment
  • interleaved
  • nearest

environment

pinned

  • true
  • false

false

pool_size

a positive integer value

Implementation defined

sync_hint

  • contended
  • uncontended
  • private
  • serialized

contended

The access trait specifies the accessibility of the allocated memory. The following are values you can specify for access:

The alignment trait specifies how allocated variables will be aligned. Variables will be byte-aligned to at least the value specified for this trait. The default setting is 1 byte. Alignment can also be affected by directives and OpenMP runtime allocator routines that specify alignment requirements.

The fallback trait indicates how an allocator behaves if it is unable to satisfy an allocation request. The following are values you can specify for fallback:

The fb_data trait lets you specify a fall back allocator to be used if the requested allocator fails to satisfy the allocation request. The fallback trait of the failing allocator must be set to allocator_fb in order for the allocator specified by the fb_data trait to be used.

The partition trait describes the partitioning of allocated memory over the storage resources represented by the memory space of the allocator. The following are values you can specify for partition:

If the pinned trait has the value true, the allocator ensures each allocation made by the allocator will remain in the storage resource at the same location where it was allocated until it is deallocated. The default setting is false.

The value of pool_size is the total number of bytes of storage available to an allocator when there have been no allocations. The following affect pool_size:

The sync_hint trait describes the way that multiple threads can access an allocator. The following are values you can specify for sync_hint:

There are five predefined memory spaces in OpenMP:

There are three additional predefined memory spaces that are extensions to the OpenMP standard:

The following table shows the predefined memory allocators, the memory space they are associated with, and the non-default memory trait values they possess.

Allocator Name

Associated Memory Space

Non-Default Trait Values

omp_default_mem_alloc

omp_default_mem_space

fallback=null_fb

omp_large_cap_mem_alloc

omp_large_cap_mem_space

none

omp_low_lat_mem_alloc

omp_low_lat_mem_space

none

omp_high_bw_mem_alloc

omp_high_bw_mem_space

none

omp_const_mem_alloc

omp_const_mem_space

none

omp_cgroup_mem_alloc

implementation/system defined

access=cgroup

omp_pteam_mem_alloc

implementation/system defined

access=pteam

omp_thread_mem_alloc

implementation/system defined

access=thread

omp_target_host_mem_alloc

omp_target_host_mem_space

none

omp_target_shared_mem_alloc

omp_target_shared_mem_space

none

omp_target_device_mem_alloc

omp_target_device_mem_space

none

See Also