ALIGN

Purpose

You can use the ALIGN directive to specify the alignment of variables in memory. This can improve performance when the alignment allows the use of the vector facilities.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-ALIGN--(--alignment_boundary--, -var_list--)----------------><

alignment_boundary
The alignment boundary in bytes. It must be a constant scalar integer expression whose value is a power of 2, in the range 1 - 1, 048, 576.
var_list
A comma-separated list of variable names to align on the specified boundary.

Rules

You can use the ALIGN directive only in the specification part of a compilation unit. In addition, the directive must be in the same scoping unit in which var is declared.

The ALIGN directive can only specify the alignment of variables. Therefore, the ALIGN directive must not be specified in derived type declarations.

You must not specify the same variable name in multiple ALIGN directives.

The ALIGN directive must not be specified for the following objects:
  • Subobjects
  • Use-associated variables
  • Host-associated variables
  • Record structures
  • Common block names and objects
  • Dummy arguments
  • Named constants
  • Variables that have VECTOR types
  • Variables that are part of an equivalence group

The ALIGN directive has precedence over the -qalign option.

Examples

Example 1:

In the following example, the optimizer can use SIMD instructions to do the array add operation:
REAL x(4), y(4), z(4) 
!IBM* ALIGN(16, x, y, z) 
! Code to initialize x and y
z = x + y 
END

Example 2:

In the following example, specifying the alignment of an allocatable variable determines the alignment of the target data.
REAL, ALLOCATABLE :: x(:) 
!IBM* ALIGN(16, x) 
ALLOCATE(x(20)) 
PRINT *, MOD(LOC(x(1)), 16) ! Prints 0 
END

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us