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 AOBench 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* Binomial Lattice 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* Mandelbrot 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* RTM Stencil 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 Averaging Filter 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 NotationDesktop Windows*; Linux*; OS X* Black-Scholes Equation 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 NotationDesktop Windows*; Linux*; OS X* Discrete Cosine Transforms (DCT) Image Processing DCT and Quantization are the first two steps in the JPEG compression standard.
Usage of Intel® Cilk™ Plus:cilk_for
and Array NotationDesktop Windows*; Linux*; OS X* Fluid Animate 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 NotationDesktop Windows*; Linux*; OS X* Monte Carlo Finance Utilizes Monte Carlo simulation to estimate the valuation of a swaption portfolio.
Usage of Intel® Cilk™ Plus:cilk_for
and Array NotationDesktop Windows*; Linux*; OS X* Sepia Filter 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 NotationDesktop Windows*; Linux*; OS X* Shortest Path 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 NotationDesktop Windows*; Linux*; OS X*