HOME
| OPENMP API Specification: Version 5.1 November 2020

2.13.3  allocate Directive

Summary The allocate directive specifies how to allocate the specified variables. The allocate directive is a declarative directive if it is not associated with an allocation statement.

Syntax

SVG-Viewer needed.

The syntax of the allocate directive is as follows:  

 
#pragma omp allocate(list) [clause[ [,] clause] ... ] new-line  

where clause is one of the following:  

 
allocator(allocator) 
align(alignment)  

where allocator is an expression of omp_allocator_handle_t type and alignment is a constant positive integer expression with a value that is a power of two.

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the allocate directive is as follows:  

 
!$omp allocate(list) [clause[ [,] clause] ... ]  

or  

 
!$omp allocate[(list)] [clause[ [,] clause] ... ] 
[!$omp allocate[(list)] [clause[ [,] clause] ... ] 
[...]] 
   allocate-stmt  

where allocate-stmt is a Fortran ALLOCATE statement and clause is one of the following:  

 
allocator(allocator) 
align(alignment)  

where allocator is an integer expression of omp_allocator_handle_kindkind and alignment is a constant scalar positive integer expression with a value that is a power of two.

SVG-Viewer needed.

Description The storage for each list item that appears in the allocate directive is provided by an allocation through a memory allocator. If no allocator clause is specified then the memory allocator specified by the def-allocator-var ICV is used. If the allocator clause is specified, the memory allocator specified in the clause is used. If the align clause is specified then the allocation of each list item is byte aligned to at least the maximum of the alignment required by the base language for the type of that list item, the alignment trait of the allocator and the alignment value of the align clause. If the align clause is not specified then the allocation of each list item is byte aligned to at least the maximum of the alignment required by the base language for the type of that list item and the alignment trait of the allocator.

The scope of this allocation is that of the list item in the base language. At the end of the scope for a given list item the memory allocator used to allocate that list item deallocates the storage.

SVG-Viewer needed.

If the directive is associated with an allocate-stmt, the allocate-stmt allocates all list items that appear in the directive list using the specified memory allocator. If no list items are specified then all variables that are listed by the allocate-stmt and are not listed in an allocate directive associated with the statement are allocated with the specified memory allocator.

SVG-Viewer needed.

For allocations that arise from this directive the null_fb value of the fallback allocator trait behaves as if the abort_fb had been specified.

Restrictions Restrictions to the allocate directive are as follows:

Cross References