Intel® Fortran Compiler 18.0 Developer Guide and Reference

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.

  • MASK_READWRITE | NOMASK READWRITE

    Enables or disables the generation of masked load and store operations within conditional statements.

    The MASK_READWRITE clause directs the compiler to disable memory speculation, causing the generation of masked load and store operations within conditional statements.

    The NOMASK_READWRITE clause directs the compiler to enable memory speculation, causing the generation of unmasked loads and stores within conditional statements.

  • 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.

    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.

  • [NO]VECREMAINDER

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

If the MASK_READWRITE clause is specified, the compiler generates masked loads and stores within all conditional branches in the loop. If the NOMASK_READWRITE clause is specified, the compiler generates unmasked loads and stores for increased performance.

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