User and Reference Guide for the Intel® Fortran Compiler 14.0
This topic presents specific Fortran language features that better help to vectorize code.
The SIMD vectorization feature is available for both Intel® microprocessors and non-Intel microprocessors. Vectorization may call library routines that can result in additional performance gain on Intel® microprocessors than on non-Intel microprocessors. The vectorization can also be affected by certain options, such as /arch (Windows*), -m (Linux* and OS X*), or [Q]x.
The !DIR$ ATTRIBUTES ALIGN:N declaration enables you to overcome hardware alignment constraints. The restrict qualifier and the auto-vectorization hints address the stylistic issues due to lexical scope, data dependency, and ambiguity resolution. The SIMD feature's directive allows you to enforce vectorization of loops.
The !DIR$ ATTRIBUTES VECTOR::FUNCTION-NAME-LIST and the !DIR$ ATTRIBUTES VECTOR[:CLAUSES]::FUNCTION-NAME-LIST directives can be used to vectorize user-defined functions and loops. For SIMD usage, the vector function is called from a loop that is being vectorized. The function must be implemented in vector operations as part of the loop.
The usage model of the VECTOR directive option is that the code generated for the function actually takes a small section ( VECTORLENGTH ) of the array, by value, and exploits SIMD parallelism, whereas the implementation of task parallelism is done at the call site.
The following table summarizes the language features that help vectorize code.
|
Language Feature |
Description |
|---|---|
|
!DIR$ ATTRIBUTES ALIGN : n :: var |
Directs the compiler to align the variable to an n-byte boundary. Address of the variable is address mod n=0. |
|
!DIR$ ATTRIBUTES ALIGN : n :: off |
Directs the compiler to align the variable to an n-byte boundary with offset off within each n-byte boundary. Address of the variable is address mod n=off. |
|
!DIR$ ATTRIBUTES VECTOR::FUNCTION-NAME-LIST |
Combines with the map operation at the call site to provide the data parallel semantics. When multiple instances of the vector declaration are invoked in a parallel context, the execution order among them is not sequenced. |
|
!DIR$ ATTRIBUTES VECTOR |
Provides data parallel semantics by combining with the vectorized operations or loops at the call site. When multiple instances of the vector declaration are invoked in a parallel context, the execution order among them is not sequenced. |
| Auto-vectorization Hints | |
|
!DIR$ IVDEP |
Instructs the compiler to ignore assumed vector dependencies. |
|
!DIR$ VECTOR [ALWAYS] |
Specifies how to vectorize the loop and indicates that efficiency heuristics should be ignored. Using the ASSERT keyword with the VECTOR [ALWAYS] directive generates an error-level assertion message saying that the compiler efficiency heuristics indicate that the loop cannot be vectorized. Use DIR$ IVDEP to ignore the assumed dependencies. |
|
!DIR$ NOVECTOR |
Specifies that the loop should never be vectorized. |
Some directives are available for both Intel® microprocessors and non-Intel microprocessors, but may perform additional optimizations for Intel® microprocessors than for non-Intel microprocessors.
| User-mandated directive | |
|---|---|
|
!DIR$ SIMD |
Enforces vectorization of loops. |