Visible to Intel only — GUID: GUID-38C9CE7E-26DF-4F81-A0AC-B4CEDF284781
Visible to Intel only — GUID: GUID-38C9CE7E-26DF-4F81-A0AC-B4CEDF284781
Function Annotations and the SIMD Directive for Vectorization
Certain Fortran language features provide help when vectorizing 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 !DIR$ ATTRIBUTES ALIGN directive lets you overcome hardware alignment constraints. The auto-vectorization hints address the stylistic issues caused by lexical scope, data dependency, and ambiguity resolution. The SIMD feature's directive lets you enforce vectorization of loops.
You can use the !DIR$ ATTRIBUTES VECTOR directive to vectorize user-defined functions and loops. For SIMD usage, a function with the VECTOR attribute is called from a loop that is being vectorized.
The usage model of the VECTOR attribute takes a small section of code (indicated by the VECTORLENGTH clause in the ATTRIBUTES VECTOR directive) generated for the function of the array and exploits SIMD parallelism.
The following table summarizes the language features that help vectorize your code:
Language Feature |
Description |
---|---|
!DIR$ ATTRIBUTES ALIGN : n :: obj |
Directs the compiler to align an object to an n-byte boundary. Address of the variable is address mod n=0. |
!DIR$ ATTRIBUTES VECTOR [: clauses] :: routine-name-list |
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. The clauses are:
|
!DIR$ ASSUME_ALIGNED a:n |
Instructs the compiler to assume that array a is aligned on an n-byte boundary; used in cases where the compiler has failed to obtain alignment information. |
!DIR$ ASSUME (scalar-logical-expression)) |
Instructs the compiler to assume that the condition represented by scalar-logical-expression is true where the keyword appears. This is typically used to convey properties that the compiler can take advantage of for generating more efficient code, such as alignment information. |
The following table summarizes the auto-vectorization hints that help vectorize your code:
Hint |
Description |
---|---|
!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 in an ALWAYS clause of a VECTOR directive generates an error-level assertion message if 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.
The following table summarizes the user-mandated directives that help vectorize your code:
User-Mandated Directive |
Description |
---|---|
Requires and controls SIMD vectorization of loops. |