インテル® Fortran コンパイラー 14.0 ユーザー・リファレンス・ガイド
The ATTRIBUTES directive option VECTOR tells the compiler to vectorize the specified function or subroutine.
!DIR$ ATTRIBUTES [att,] VECTOR [:clause] [, att]... :: routine-name
!DIR$ ATTRIBUTES [att,] VECTOR :(clause [, clause]...) [, att] :: routine-name
If you specify more than one clause, they must be separated by commas and enclosed in parentheses.
When you specify the 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 the ATTRIBUTES VECTOR directive with no VECTORLENGTH clause, a default VECTORLENGTH is computed based on efficiency heuristics of the vectorizer and the following:
The return type of the function, if the function has a return type.
The data type of the first non-scalar argument (that is, the first argument that is specified in the scalar clause), if any.
Default integer type, if neither of the above is supplied.
If you do not explicitly specify a VECTORLENGTH clause, the compiler will choose a VECTORLENGTH using its own cost model.
If you specify the ATTRIBUTES VECTOR directive with no clause, the compiler will generate vector code based on compiler efficiency heuristics and whatever processor compiler options are specified.
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.
The Fortran Standard keyword ELEMENTAL specifies that a procedure written with scalar arguments can be extended to conforming array arguments by processing the array elements one at a time in any order. The ATTRIBUTES VECTOR directive tells the optimizer to produce versions of the procedure routine-name that execute with contiguous slices of the array arguments as defined by the VECTORLENGTH clause in an "elemental" fashion. routine-name does not need to be defined as ELEMENTAL to be given the VECTOR attribute.
The VECTOR attribute causes the compiler to generate a short vector form of the procedure, which can perform the procedure's operation on multiple elements of its array arguments in a single invocation. The short vector version may be able to perform multiple operations as fast as the regular implementation performs a single operation by using the vector instruction set in the CPU.
In addition, when invoked from an OMP construct, the compiler may assign different copies of the elemental procedures to different threads, executing them concurrently. The end result is that your data parallel operation executes on the CPU using both the parallelism available in the multiple cores and the parallelism available in the vector instruction set. If the short vector procedure is called inside a parallel loop or an auto-parallelized loop that is vectorized, you can achieve both vector-level and thread-level parallelism.
The INTENT(OUT) or INTENT(INOUT) attribute is not allowed for arguments of a procedure with the VECTOR attribute since the VECTOR attribute forces the procedure to receive its arguments by value.
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 |
The ATTRIBUTES VECTOR directive must be accessible in the caller, either via an INTERFACE block or by USE association.
The following shows an example of an external function with an INTERFACE block:
!... function definition
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
! attribute vector explicit in calling procedure using an INTERFACE
interface
function f(x)
!dir$ attributes vector :: f
real :: f, x
end
end interface
...
do i=1,n
z(i) = f( x(i) )
end do
The ATTRIBUTES VECTOR directive can be brought into the caller by USE association if the vector function is a module procedure; for example:
! attribute vector in definition of module procedure
module use_vect
contains
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
end function
end module use_vect
! USE and call of f(x) from another procedure with a module USE statement
USE use_vect !brings in ATTRIBUTE VECTOR for f(x)
...
! now simply call f(x)
do i=1,n
z(i) = f( x(i) )
end do
You can also specify this directive with other ATTRIBUTE settings; for example:
!DIR$ ATTRIBUTES VECTOR, C :: F
This sets both the VECTOR and C attributes for routine F.
You can specify more than one SCALAR or LINEAR clause in an ATTRIBUTES VECTOR directive. For example, all of the following are valid:
!DIR$ ATTRIBUTES VECTOR:PROCESSOR(atom) :: f
!DIR$ ATTRIBUTES VECTOR:(SCALAR(a), SCALAR(b)) :: f
!DIR$ 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:
!DIR$ ATTRIBUTES VECTOR:( PROCESSOR(atom),
!DIR$& SCALAR(a, b),
!DIR$& LINEAR(x:1, y:1) ) :: f