• 09/03/2020
  • Public Content

Explicit Vector Programming

Auto-vectorization has its limitations. The compiler must be conservative, and not make any assumptions or optimizations that could lead to different results from unoptimized code for any possible input data.
The auto-vectorizer can be more effective if the compiler is given hints through compiler directives, but whether or not a loop is vectorized still depends on the compiler’s internal analysis and the information available to it. Explicit Vector Programming is an attempt to remove that uncertainty: the programmer, using his knowledge of the application, can instruct the compiler to vectorize a loop.
The main features of explicit vector programming in Intel® Cilk™ Plus are array notation, SIMD enabled functions and the #pragma SIMD. OpenMP* 4.0 contains similar functionality, except for array notation.
To quickly learn Intel® Cilk™ Plus from a series of short videos, please see Vectorization Essentials. You may also find the article Explicit Vector Programming in Fortran useful.
  • pragma SIMD and SIMD-enabled function samples
  • Click on the sample name to see an in-depth description and source code.
    Sample Name
    Program Domain/Area
    Description
    Target Platforms
    OSes
    Rendering
    Approximates the reflection of light off non-reflective surfaces by ray-casting into the scene from the screen, and the once again from a collision point. Usage of Intel® Cilk™ Plus:
    cilk_for
    and
    #pragma simd
    Desktop
    Windows*; Linux*; OS X*
    Finance
    Used to evaluate an American option, which can be redeemed any time between two dates. Usage of Intel® Cilk™ Plus:
    cilk_for
    and
    #pragma simd
    Desktop
    Windows*; Linux*; OS X*
    Image Processing
    A visually impressive iterative algorithm that checks the bounds of a complex (imaginary) number over iterations and plots the depth (number of iterations) on a complex plane. Usage of Intel® Cilk™ Plus:
    cilk_for
    and
    #pragma simd
    Desktop
    Windows*; Linux*; OS X*
    Stencil
    Solve the wave equation using the finite difference method. This sample computes a 3-D 25-point stencil. Usage of Intel® Cilk™ Plus:
    cilk_spawn
    and
    #pragma simd
    Desktop
    Windows*; Linux*; OS X*
  • Array notation samples
  • Click on the sample name to see an in-depth description and source code.
    Sample Name
    Program Domain/Area
    Description
    Target Platforms
    OSes
    Image Processing
    A commonly used filter in the field of image processing and is mainly used for removing any noise in a given image. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Finance
    Estimates the price of an option over time. Can be used to smartly hedge the option on its underlying assets, among many other applications. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Image Processing
    DCT and Quantization are the first two steps in the JPEG compression standard. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Computational Fluid Dynamics
    Simulate the flow of fluid in a container using the Smoothed-Particle Hydrodynamics model. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Finance
    Utilizes Monte Carlo simulation to estimate the valuation of a swaption portfolio. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Image Processing
    Converts a color image to a duotone image with a dark Brown-Gray color. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
    Classic Algorithms
    Dijkstra algorithm is a graph search algorithm that solves the single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree. Usage of Intel® Cilk™ Plus:
    cilk_for
    and Array Notation
    Desktop
    Windows*; Linux*; OS X*
1

Product and Performance Information

1

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 reserverd 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