3.11.6 omp_aligned_alloc – Memory allocation with an allocator and alignment

Description:

Allocate memory with the specified allocator, which can either be a predefined allocator, an allocator handle or omp_null_allocator. If the allocators is omp_null_allocator, the allocator specified by the def-allocator-var ICV is used. alignment must be a positive power of two and size must be a nonnegative number that is a multiple of the alignment and denotes the number of bytes to be allocated; if size is zero, omp_aligned_alloc will return a null pointer. The alignment will be at least the maximal value required by alignment trait of the allocator and the value of the passed alignment argument. If successful, a pointer to the allocated memory is returned, otherwise the fallback trait of the allocator determines the behavior. The content of the allocated memory is unspecified.

In target regions, either the dynamic_allocators clause must appear on a requires directive in the same compilation unit – or the allocator argument may only be a constant expression with the value of one of the predefined allocators and may not be omp_null_allocator.

Memory allocated by omp_aligned_alloc must be freed using omp_free.

C:
Prototype:void* omp_aligned_alloc(size_t alignment,
size_t size,
omp_allocator_handle_t allocator)
C++:
Prototype:void* omp_aligned_alloc(size_t alignment,
size_t size,
omp_allocator_handle_t allocator=omp_null_allocator)
Fortran:
Interface:type(c_ptr) function omp_aligned_alloc(alignment, size, allocator) bind(C)
use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
integer (c_size_t), value :: alignment, size
integer (omp_allocator_handle_kind), value :: allocator
See also:

OMP_ALLOCATOR – Set the default allocator, Memory allocation, omp_set_default_allocator – Set the default allocator, omp_free – Freeing memory allocated with OpenMP routines, omp_init_allocator – Create an allocator

Reference:

OpenMP specification v5.1, Section 3.13.6