| June 13, 2010 9:00 PM PDT | |
Intel(R) 20 Questions Contest: Question #4
Question:
Intel® Parallel Composer: Extract project and source files from <Intel Parallel Studio directory>\Composer\Samples\en_US\C++\vec_samples.zip and study the sample code. What prevents the innermost for-loop in function novec_cse from getting vectorized?
Hint: Compile project with Intel® C++ Compiler using compiler's option which enables generation of optimization reports.
Correct Answer:
"existence of vector dependence"
Details:
Intel(R) C++ Compiler, a part of Intel(R) Parallel Composer, has a capability to vectorize code automatically. The goal of vectorization is to speed up the code by applying single instruction to multiple data (SIMD). When you use Intel(R) Compilers with Intel(R) Parallel Composer, you can rely on the fact that auto-vectorization is enabled by default when you set optimization level to /O2 or higher. However, there are two more ways to enable vectorization:
- Compiler option /Qvec enables vectorization (/Qvec- disables vectorization)
- Compiler pragmas: #pragma vector [argument] indicates that the loop should be vectorized according to one of the argument words; #pragma ivdep instructs the compiler to ignore assumed vector dependencies
Intel(R) Compiler is very conservative when trying to vectorize the code. If there is a slight chance of introducing an error into the code by vectorizing it, compiler would simply not do it. To make more of your code vectorizable, you will often need to make some changes (in some cases even your coding style might prevent compiler from vectorizing the code). Please read Programming Guidelines for Vectorization to learn more.
If compiler by any reason decided not to vectorize some of the loops, the best way to learn why that happened is to re-build your application with /Qvec-report:[level] option (see Fgiure 1) and compiler will show you a list of diagnostic info reported by vectorizer (see Figure 2). Now, when you know which loops could not be vecotorized and why, you can change your code to help compiler auto-vectorize it or optimize it in some other way.
To learn more about compiler options, please see the Intel® Parallel Composer documentation or visit this page.
Figure 1:
Figure 2:
For more complete information about compiler optimizations, see our Optimization Notice.

