ATTRIBUTES VECTOR

The ATTRIBUTES directive option VECTOR tells the compiler to vectorize the specified function or subroutine. It takes one of the following forms:

Syntax

cDEC$ ATTRIBUTES [att,] VECTOR [:clause] [, att]... :: routine-name

cDEC$ ATTRIBUTES [att,] VECTOR :(clause [, clause]...) [, att] :: routine-name

c

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

att

Is an ATTRIBUTES directive option. For a list of possible directive options, see the description of argument att in ATTRIBUTES.

clause

Is one or more of the following optional clauses:

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

    var

    Is a scalar variablethat is a dummy argument in the specified routine.

    step

    Is a compile-time positive, integer constant expression.

    Tells the compiler that for each consecutive invocation of the routine in a serial execution, the value of var1 is incremented by step1, var2 is incremented by step2, and so on.

    If more than one step is specified for a particular var, a compile-time error occurs.

    Multiple LINEAR clauses are merged as a union.

  • [NO]MASK

    Determines whether the compiler generates a masked vector version of the routine.

  • PROCESSOR (cpuid [, cpuid]…)

    cpuid

    Can be any of the following keywords:

    pentium_4

    pentium_m

    pentium_4_sse3

    core_2_duo_ssse3

    core_2_duo_sse4_1

    atom

    core_i7_sse4_2

    core_aes_pclmulqdq

    core_2nd_gen_avx

    lrb

    Tells the compiler to create a vector version of the routine for the specified processor.

    The vector version of the routine that is created by the compiler is not affected by processor options specified on the command line.

    When running on a processor that does not match cpuid, a scalar version will be invoked multiple times based on vector length.

    Multiple PROCESSOR clauses are merged as a union.

  • SCALAR (arg [, arg]…)

    arg

    Is a scalar variable that is a dummy argument in the specified routine.

    Tells the compiler that the values of the specified arguments can be broadcasted to all iterations as a performance optimization.

    Multiple SCALAR clauses are merged as a union.

  • VECTORLENGTH (n[, n]…)

    n

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

    Tells the compiler that each routine invocation at the call site should execute the computation equivalent to n times the scalar function execution.

    Multiple VECTORLENGTH clauses are merged as a union.

routine-name

Is the name of a routine (a function or subroutine). It must be the enclosing routine or the routine immediately following the directive.

If you specify more than one clause, they must be separated by commas and enclosed in parentheses.

When you specify the cDEC$ ATTRIBUTES VECTOR directive, the compiler 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. If you specify one or more clauses, they affect the data parallel semantics provided by the compiler.

If you specify thecDEC$ ATTRIBUTES VECTOR directive with no VECTORLENGTH clause, a default VECTORLENGTH is computed based on efficiency heuristics of the vectorizer and the following:

If you specify the cDEC$ ATTRIBUTES VECTOR directive with no clause, the compiler will generate vector code based on compiler efficiency heuristics and whatever processor compiler options are specified.

Note iconNote

You should ensure that any possible side effects for the specified routine-name are acceptable or expected, and the memory access interferences are properly synchronized.

Optimization Notice

Intel’s compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804

Example

The ATTRIBUTES VECTOR directive can appear in the declaration of the routine; for example:

   function f(x)
!DEC$ attributes vector :: f

The ATTRIBUTES VECTOR directive can also appear in the code of the caller; for example:

   main m
   integer f
   external f
!dec$ attributes vector :: f   ! or it can be in an interface block describing f
   ...
   print *, f(x)

You can also specify this directive with other ATTRIBUTE settings; for example:

!DEC$ ATTRIBUTES VECTOR, C :: F

This sets both the VECTOR and C attributes for routine F.

You can specify more than one PROCESSOR, SCALAR, or LINEAR clause in an ATTRIBUTES VECTOR directive. For example, all of the following are valid:

!DEC$ ATTRIBUTES VECTOR:PROCESSOR(atom) :: f
!DEC$ ATTRIBUTES VECTOR:(PROCESSOR(atom), PROCESSOR(core_i7_sse4_2)) :: f
 
!DEC$ ATTRIBUTES VECTOR:PROCESSOR(atom, core_i7_sse4_2) :: f
!DEC$ ATTRIBUTES VECTOR:(SCALAR(a), SCALAR(b)) :: f
!DEC$ ATTRIBUTES VECTOR:(LINEAR(x:1), LINEAR(y:1)) :: f

The three directives above are equivalent to specifying a single, continued, directive in fixed-form source, as follows:

!DEC$ ATTRIBUTES VECTOR:( PROCESSOR(atom, core_i7_sse4_2),
!DEC$& SCALAR(a, b), 
!DEC$& LINEAR(x:1, y:1) ) :: f

See Also


Submit feedback on this help topic

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