Visible to Intel only — GUID: GUID-A522C810-5780-4373-920E-04AB4D082C6C
Visible to Intel only — GUID: GUID-A522C810-5780-4373-920E-04AB4D082C6C
SIMD Loop Directive
General Compiler Directive: Requires and controls SIMD vectorization of loops. This directive is deprecated and will be removed in a future release.This feature is only available for ifort.
!DIR$ SIMD [clause[[,] clause]...]
clause |
Is an optional vectorization clause. It can be one or more of the following:
|
If you specify the SIMD directive with no clause, default rules are in effect for variable attributes, vector length, and so forth.
If you do not explicitly specify a VECTORLENGTH clause, the compiler will choose a VECTORLENGTH using its own cost model. Misclassification of variables into PRIVATE, FIRSTPRIVATE, LASTPRIVATE, LINEAR, and REDUCTION, or the lack of appropriate classification of variables, may lead to unintended consequences such as runtime failures and/or incorrect results.
You can only specify a particular variable in at most one instance of a PRIVATE, LINEAR, or REDUCTION clause.
If the compiler is unable to vectorize a loop, a warning occurs by default. However, if ASSERT is specified, an error occurs instead.
If the vectorizer has to stop vectorizing a loop for some reason, the fast floating-point model is used for the SIMD loop.
A SIMD loop may contain one or more nested loops or be contained in a loop nest. Only the loop preceded by the SIMD directive is processed for SIMD vectorization.
The vectorization performed on this loop by the SIMD directive overrides any setting you may specify for options -fp-model (Linux* and macOS) and /fp (Windows*) for this loop.
Note that the SIMD directive may not affect all auto-vectorizable loops. Some of these loops do not have a way to describe the SIMD vector semantics.
The following restrictions apply to the SIMD directive:
The countable loop for the SIMD directive has to conform to the DO-loop style of an OpenMP worksharing loop construct. Additionally, the loop control variable must be a signed integer type.
The vector values must be signed 8-, 16-, 32-, or 64-bit integers, single or double-precision floating-point numbers, or single- or double-precision complex numbers.
A SIMD directive loop performs memory references unconditionally. Therefore, all address computations must result in valid memory addresses, even though such locations may not be accessed if the loop is executed sequentially.
To disable the SIMD transformations for vectorization, specify option -no-simd (Linux* and macOS) or /Qsimd- (Windows*).
To disable transformations that enable more vectorization, specify options -no-vec-no-simd (Linux and macOS) or /Qvec-/Qsimd- (Windows).
Consider the following:
...
subroutine add(A, N, X)
integer N, X
real A(N)
cDIR$ SIMD
DO I=X+1, N
A(I) = A(I) + A(I-X)
ENDDO
end
...
When the program containing this subroutine is compiled, the DO loop will be vectorized.
Because no optional clause was specified for the directive, default rules will apply for variable attributes, vector length, and so forth.