Guided Autoparallelism

Compiler Methodology for Intel® MIC Architecture

Guided Autoparallelism (GAP)

The Intel compiler includes the Guided Autoparallelism (GAP) tool. This tool is available for both Fortran and C/C++. This tool is designed to assist the programmer with vectorization and parallelization. This tool complements the -vec-report option (use -qopt-report with version 15.0 and later) provided by the compiler. GAP attempts to explain barriers to vectorization or parallelization in terms that a programmer can better understand.

NOTE: as of September 2012, the GAP tool only works with the host compiler. It is not available for the native compiler for Intel® MIC Architecture (when -mmic is used). The intent is that you use this tool on the host platform. The advice given, is also applicable to the vectorization and parallelization on Intel MIC Architecture. Use GAP on your source files with the host compilers, apply any suggestions, and verify those changes on the host. Changes will benefit the application when it is compiled for Intel MIC Architecture as well as when compiled for the host.


GAP is a feature of the Intel Compilers. This tool/feature is invoked with the compiler option family -guide (-guide -guide-vec -guide-par or -guide-data-trans). When using these options, the compiler does NOT compile your code. Instead, it analyzes your code for vectorization guidance (-guide-vec option ), parallelization guidance (-guide-par), or both (-guide). In addition, GAP can make suggestions on how to reorder your data structures for more optimal data access and performance (-guide-data-trans).

GAP differs from -vec-report or -opt-report in that it's goal is to help you get over vectorization or parallelization barriers. GAP analyzes your code and for each loop nest that is not vectorizing or parallelizing (via -parallel or -openmp) and it offers advice on how to possibly break the barriers to optimizing this particular loop nest. It offers three categories of guidance:

  1. Compiler options or pragmas to assist the compiler with vectorization or parallelization
  2. Code transformations or changes that will assist the compiler. Note it does NOT do these coding changes. That is left for the programmer to implement.
  3. Compiler options that will remove barriers to optimization.

Using GAP

For a quick overview of GAP, read the presentation "GAP - Guided Auto Parallelism"

Guided Auto-Parallel Overview
The guided auto-parallelization feature of the Intel® Compiler is a tool that offers selective advice resulting in better performance of serially coded applications.
The advice generated by the compiler typically falls under three broad categories: 

Advice On Code Changes: GAP may provide advice on simple code changes.  For example, the compiler may advise you to make simple source changes that are localized to a loop-nest or a routine. For example, you may receive advice to use a local-variable for the upper-bound of a loop (instead of a class member in C++ for example) OR to initialize a local variable unconditionally at the top of the loop-body OR (C/C++) to add restrict keyword to pointer-arguments of a function definition (if it is appropriate). 

Advice on Pragmas or Directives: GAP may advise you to apply a new pragma (C/C++) or directive (Fortran) on a certain loop-level if the pragma/directive semantics can be satisfied (in other words, if you the user verifies that the pragma/directive will not affect correct execution of the loop). In many cases, you may be able to apply the pragma/directive, thus explicitly asserting new program/loop properties.  These will help the compiler better optimize the loop for vectorization or parallelization.

Advice to Add Compiler Options: GAP may advise you to add new command-line options that assert new properties.  Compiler options apply to an entire source file, so the user should insure that the recommended compiler option is appropriate for all routines in the source files(s).

The advice given by GAP is merely advice.  GAP does NOT change your code or compiler options.  You, the programmer, can either implement suggestions or you may choose reject them. To receive this advice all you need to do is use the -guide [Linux* and Mac OS* X] or the /Qguide [Windows*] set of compiler. The compiler does not generate any object files or executables during the guided auto-parallelization run.

Use the -guide or /Qguide options in addition to your normally used compiler options. The compiler advice targets the optimizations enabled at the chosen optimization level. If you decide to take the advice suggested by the guided auto-parallelization compilation run, then make the suggested code changes or use the suggested compiler options and recompile the program, this time without using the -guide or /Qguide options. The performance of your program should improve.

Use guided auto-parallelization along with auto-parallelization when you have serial code you wish to parallelize using the auto-parallelization options [-parallel or /Qparallel] and also wish to get advice on further parallelizing opportunities that the guided auto-parallelization may suggest.

Use guided auto-parallelization without enabling auto-parallelization when you are interested in improving the performance of your single-threaded code or when you want to improve the performance of your applications with explicit threading without relying on the compiler for auto-parallelization.

Ready to dive in deeper? The Intel Compiler comes with a tutorial and samples on GAP. Tutorials and samples are available for both Fortran and C/C++. Your product documentation is installed in the same root path as your compilers. By default, this is in directory /opt/intel/composerxe/Documentation/en_US. Under this directory, locate the "Getting Started" document for your compiler (Fortran or C++):

  • Fortran <path to docs>/get_started_lf.htm#tutor
  • C/C++ <path to docs>/get_started_lc.htm#tutor

The compiler product User and Reference Guide also contains documentation on using GAP. Open the "Getting Started" document using the paths and links above. From here, find the reference to the "User and Reference Guide" document. Open that document. In the Contents navigation, navigate to "Key Features" -> "Guided Auto Parallelism"

If for some reason you cannot access this directory with a web browser, you can also find this information online.  Visit


Tutorials are ideal for those seeking a step-by-step method to learn compiler features using supplied Samples. There are GAP Tutorials for both C++ and Fortran.

A list of tutorials for all Intel Developer Tools

Take Aways

Guided Autoparallism (GAP) is a tool provided by the Intel Fortran and C++ compilers. It is a tool that gives guidance to the user on removing barriers to vectorization and/or parallelization of loop nests in your code. Guidance can be

  1. Compiler options or pragmas to assist the compiler with vectorization or parallelization
  2. Code transformations or changes that will assist the compiler. Note it does NOT do these coding changes. That is left for the programmer to implement.
  3. Compiler options that will remove barriers to optimization.


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™ architecture. The paths provided in this guide reflect the steps necessary to get best possible application performance.

BACK to Vectorization Essentials

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.