Intel® Fortran Compiler 16.0 User and Reference Guide

VECTOR and NOVECTOR

General Compiler Directive: Overrides default heuristics for vectorization of DO loops. It can also affect certain optimizations.

!DIR$ VECTOR [clause[[,] clause]...]

!DIR$ NOVECTOR

clause

Is an optional vectorization or optimizer clause. It can be one or more of the following:

  • ALWAYS [ASSERT]

    Enables or disables vectorization of a DO loop. The ALWAYS clause overrides efficiency heuristics of the vectorizer, but it only works if the loop can actually be vectorized. If the ASSERT keyword is added, the compiler will generate an error-level assertion message saying that the compiler efficiency heuristics indicate that the loop cannot be vectorized. You should use the IVDEP directive to ignore assumed dependences.

  • ALIGNED | UNALIGNED

    Specifies that all data is aligned or no data is aligned in a DO loop. These clauses override efficiency heuristics in the optimizer. The clause ALIGNED instructs the compiler to use aligned data movement instructions for all array references. The clause UNALIGNED instructs the compiler to avoid dynamic or static loop peeling transformation as an alignment optimization; the compiler can still use available alignment information. These clauses disable all the advanced alignment optimizations of the compiler, such as determining alignment properties from the program context or using dynamic loop peeling to make references aligned.

    Be careful when using the ALIGNED clause. Instructing the compiler to implement all array references with aligned data movement instructions will cause a runtime exception if some of the access patterns are actually unaligned.

  • G2S or NOG2S

    Disables or enables the use of gather/scatter instructions in the lexically next loop.

    G2S tells the optimizer to disable the generation of gather/scatter and to transform gather/scatter into unit-strided loads/stores plus a set of shuffles wherever possible.

    NOG2S tells the optimizer to enable the generation of gather/scatter instructions and not to transform gather/scatter into unit-strided loads/stores.

    This clause does not affect loops nested in the specified loop.

  • TEMPORAL | NONTEMPORAL [(var1 [, var2]...)]

    var

    Is an optional memory reference in the form of a variable name.

    Controls how the "stores" of register contents to storage are performed (streaming versus non-streaming).

    The TEMPORAL clause directs the compiler to use temporal (that is, non-streaming) stores.

    The NONTEMPORAL clause directs the compiler to use non-temporal (that is, streaming) stores. On Intel® 64 architecture targeting the Intel® Xeon Phi™ coprocessor x100 product family (formerly code name Knights Corner), the compiler generates clevict (cache-line-evict) instructions after the stores based on the non-temporal directive when the compiler knows that the store addresses are aligned.

    By default, the compiler automatically determines whether a streaming store should be used for each variable.

    Streaming stores may cause significant performance improvements over non-streaming stores for large numbers on certain processors. However, the misuse of streaming stores can significantly degrade performance.

  • VECREMAINDER | NOVECREMAINDER

    Directs the compiler to vectorize (or not to vectorize) the remainder loop when the original loop is vectorized.

    If !DIR$ VECTOR ALWAYS is specified, the following occurs:

    • If neither the VECREMAINDER or NOVECREMAINDER clause is specified, the compiler overrides efficiency heuristics of the vectorizer and it determines whether the loop can be vectorized.

    • If VECREMAINDER is specified, the compiler vectorizes remainder loops when the original main loop is vectorized.

    • If NOVECREMAINDER is specified, the compiler does not vectorize the remainder loop when the original main loop is vectorized.

The VECTOR and NOVECTOR directives control vectorization of the DO loop that directly follows the directive.

Caution

The VECTOR directive should be used with care. Overriding the efficiency heuristics of the compiler should only be done if you are absolutely sure the vectorization will improve performance.

Example

The compiler normally does not vectorize DO loops that have a large number of non-unit stride references (compared to the number of unit stride references).

In the following example, vectorization would be disabled by default, but the directive overrides this behavior:

!DIR$ VECTOR ALWAYS
  do i = 1, 100, 2
    ! two references with stride 2 follow
    a(i) = b(i)
  enddo

There may be cases where you want to explicitly avoid vectorization of a loop; for example, if vectorization would result in a performance regression rather than an improvement. In these cases, you can use the NOVECTOR directive to disable vectorization of the loop.

In the following example, vectorization would be performed by default, but the directive overrides this behavior:

!DIR$ NOVECTOR
  do i = 1, 100
    a(i) = b(i) + c(i)
  enddo

See Also