void *omp_alloc(size_t size, omp_allocator_handle_t allocator);
void *omp_aligned_alloc(
size_t alignment,
size_t size,
omp_allocator_handle_t allocator);
Summary The omp_alloc and omp_aligned_alloc routines request a memory allocation from a memory allocator.
type(c_ptr) function omp_alloc(size, allocator) bind(c)
use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t
integer(c_size_t), value :: size
integer(omp_allocator_handle_kind), value :: allocator
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
Constraints on Arguments Unless dynamic_allocators appears on a requires directive in the same compilation unit, omp_alloc and omp_aligned_alloc invocations that appear in target regions must not pass omp_null_allocator as the allocator argument, which must be a constant expression that evaluates to one of the predefined memory allocator values.
The alignment argument to omp_aligned_alloc must be a power of two and the size argument must be a multiple of alignment.
Binding The binding task set for an omp_alloc or omp_aligned_alloc region is the generating task.
Effect The omp_alloc and omp_aligned_alloc routines request a memory allocation of size bytes from the specified memory allocator. If the allocator argument is omp_null_allocator the memory allocator used by the routines will be the one specified by the def-allocator-var ICV of the binding implicit task. Upon success they return a pointer to the allocated memory. Otherwise, the behavior that the fallback trait of the allocator specifies will be followed.
If size is 0, omp_alloc and omp_aligned_alloc will return NULL (or, C_NULL_PTR, for Fortran).
Memory allocated by omp_alloc will be byte-aligned to at least the maximum of the alignment required by malloc and the alignment trait of the allocator.
Memory allocated by omp_aligned_alloc will be byte-aligned to at least the maximum of the alignment required by malloc, the alignment trait of the allocator and the alignment argument value.
The omp_alloc and omp_aligned_alloc routines require an explicit interface and so might not be provided in omp_lib.h.