SIMD

General Compiler Directive: Controls SIMD vectorization of loops.

Syntax

cDEC$ SIMD [clause[, clause]...]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

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

  • VECTORLENGTH (n1 [, n2]...)

    n

    Is a vector length (VL). It must be an integer that is a power of 2; the value must be 2, 4, 8, or 16. If you specify more than one n, the vectorizor will choose the VL from the values specified.

    Causes each iteration in the vector loop to execute the computation equivalent to n iterations of scalar loop execution. Multiple VECTORLENGTH clauses are merged as a union.

  • PRIVATE (var1 [, var2]...)

    var

    Is a scalar variable

    Causes each variable to be private to each iteration of a loop. Unless the compiler can prove that the initial and last values are unused, the initial value is broadcast to all private instances, and the last value is copied out from the last iteration instance. Multiple PRIVATE clauses are merged as a union.

  • LINEAR (var1:step1 [, var2:step2]...)

    var

    Is a scalar variable.

    step

    Is a compile-time positive, integer constant expression.

    For each iteration of a scalar loop, var1 is incremented by step1, var2 is incremented by step2, and so on. Therefore, every iteration of the vector loop increments the variables by VL*step1, VL*step2, …, to VL*stepN, respectively. If more than one step is specified for a var, a compile-time error occurs. Multiple LINEAR clauses are merged as a union.

  • REDUCTION (oper:var1 [, var2]...)

    oper

    Is a reduction operator ( +, *, -, .AND., .OR., .EQV., or .NEQV.).

    var

    Is a scalar variable.

    Applies the vector reduction indicated by oper to var1, var2, …, varN. A SIMD directive can have multiple reduction clauses using the same or different operators. If more than one reduction operator is associated with a var, a compile-time error occurs.

  • [NO]ASSERT

    Directs the compiler to assert (produce an error) or not to assert (produce a warning) when the vectorization fails. The default is NOASSERT. If this clause is specified more than once, a compile-time error occurs.

If you specify the SIMD directive with no clause, default rules are in effect for variable attributes, vector length, and so forth.

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.

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:

To disable the SIMD transformations for vectorization, specify -no-simd (Linux and Mac OS X) or /Qsimd- (Windows).

To disable transformations that enable more vectorization, specify options -no-vec -no-simd (Linux and Mac OS X) or /Qvec- /Qsimd- (Windows).

Example

Consider the following:

  ...
subroutine add(A, N, X)
   integer N, X
   real    A(N)
cDEC$ 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.

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.