SIMD
7. SIMD#
Single instruction, multiple data (SIMD) is a form of parallel execution in which the same operation is performed on multiple data elements independently in hardware vector processing units (VPU), also called SIMD units. The addition of two vectors to form a third vector is a SIMD operation. Many processors have SIMD (vector) units that can perform simultaneously 2, 4, 8 or more executions of the same operation (by a single SIMD unit).
Loops without loop-carried backward dependency (or with dependency preserved using ordered simd) are candidates for vectorization by the compiler for execution with SIMD units. In addition, with state-of-the-art vectorization technology and declare simd directive extensions for function vectorization in the OpenMP 4.5 specification, loops with function calls can be vectorized as well. The basic idea is that a scalar function call in a loop can be replaced by a vector version of the function, and the loop can be vectorized simultaneously by combining a loop vectorization (simd directive on the loop) and a function vectorization (declare simd directive on the function).
A simd construct states that SIMD operations be performed on the data within the loop. A number of clauses are available to provide data-sharing attributes (private, linear, reduction and lastprivate). Other clauses provide vector length preference/restrictions (simdlen / safelen), loop fusion (collapse), and data alignment (aligned).
The declare simd directive designates that a vector version of the function should also be constructed for execution within loops that contain the function and have a simd directive. Clauses provide argument specifications (linear, uniform, and aligned), a requested vector length (simdlen), and designate whether the function is always/never called conditionally in a loop (notinbranch/inbranch). The latter is for optimizing performance.
Also, the simd construct has been combined with the worksharing loop constructs (for simd and do simd) to enable simultaneous thread execution in different SIMD units.