By Amanda K Sharp,
Published:11/25/2013 Last Updated:08/29/2014
Compiler Methodology for Intel® MIC Architecture
Getting Started with Intel Compiler Pragmas and Directives
Overview
Compiler options allow a user to control how source files are interpreted and control characteristics of the object files or executables. Compiler options are applied to an entire source file. So what do you do if there are particular loops, variables, functions, or procedures which you need to control? This is where compiler pragmas and directives are useful. In this chapter, we explain where to find documentation on pragmas and directives and highlight a subset of these that are most useful for performance on either Intel® Xeon® processors or the Intel® Xeon Phi™ coprocessor.
Topics
A C/C++ 'pragma' is a command to be interpreted by the Intel C++ compiler and helps guide the compiler actions during compilation. For Fortran, a 'directive' is a command to be interpreted by the Intel Fortran compile and helps guide compiler actions during compilation. Syntax is obviously different for C++ pragmas versus Fortran directives. However, the actions specified to the two Intel compilers is often equivalent.
C++ Pragmas: Pragmas are directives that provide instructions to the compiler for use in specific cases. For example, you can use the novector pragma to specify that a loop should never be vectorized. The keyword #pragma is standard in the C++ language, but individual pragmas are machine-specific or operating system-specific, and vary by compiler.
Some pragmas provide the same functionality as compiler options. Pragmas override behavior specified by compiler options.
Some pragmas are available for both Intel and non-Intel processors but they may perform additional optimizations for Intel® processors than they perform for non-Intel processors. Refer to the individual pragma page for detailed description.
Documentation on C++ pragmas recognized by the Intel® C/C++ Composer XE compiler: Pragmas are documented in the product documentation, the "Intel® C++ Compiler XE User and Reference Guides". If you have forgotten where to find your documentation, please review this information from the chapter "New User Compiler Basic Usage". From the Contents of the User and Reference Guide, open chapter "Compiler Reference", "Pragmas", "Overview/Intel® C++ Compiler Pragmas"
Fortran Directives: Compiler directives are special commands that direct the action of the compilation. The directives recognized by the Intel® Fortran Composer XE are unique to this compiler. Compiler directives override any compiler options.
Documentation on directives recognized by the Intel® Fortran Composer XE compiler: Directives are documented in the product documentation, the "Intel® Fortran Compiler XE User and Reference Guides". If you have forgotten where to find your documentation, please review this information from the chapter "New User Compiler Basic Usage". From the Contents of the User and Reference Guide, open chapter "Language Reference", "Directive Enhanced Compilation", "Directive Enhanced Compilation Overview"
The following pragmas/directives are common to C++ and Fortran and are essential to understand. Please open your browser window to the pragma/directive documentation as described above. Research each of these pragma/directives for your language. In the description below, both C++ and Fortran syntax is shown in the order C++/Fortran:
There are more pragmas/directives. The above are key optimization pragmas/directives with which every performance oriented programmer should be familiar. Again, take some time to become familiar with the set of pragmas/directives listed above.
Take Aways
SIMD directives allow programmers the most control on loop vectorization. IVDEP and VECTOR are a weaker and older options that provide a suggestion or hint to the compiler. However, the compiler may choose to ignore IVDEP and VECTOR if the compiler is certain that there is a dependency in a loop. You should have reviewed the presentation Vectorization: Pragma/Directive SIMD before leaving this chapter: it is key to vectorization and hence performance on the Intel® Xeon Phi™ coprocessor.
NEXT STEPS
It is essential that you read this guide from start to finish using the built-in hyperlinks to guide you along a path to a successful port and tuning of your application(s) on Intel® Xeon Phi™ coprocessors. The paths provided in this guide reflect the steps necessary to get best possible application performance.
Go back to chapter "New User Compiler Basic Usage"
Attachment | Size |
---|---|
simd-upate.pdf | 3.7 MB |
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