Using Guided Auto-Parallelization for Embedded Development

GAP Overview

The guided auto parallelism feature of the Intel® compiler is a tool that offers selective advice to improve the performance of serially coded applications by suggesting changes that will take advantage of the compiler's ability to automatically vectorize and parallelize your code as well as improve the efficiency of data operations. Despite having the words "auto parallelism" in its name, this tool does not require you to implement threaded code in order to improve the execution performance of your code nor does it require that your code is already threaded or parallel code.

To use GAP feature, you need to use the -guide option. Any advice generated by the compiler when using the guided auto parallelism tool is optional; you can either implement it or reject it. The advice typically falls under three broad categories:

  • Advice for source modifications: the compiler advices you to make source changes that are localized to a loop-nest or a routine.
  • Advice to apply pragmas: the compiler advises you to apply a new pragma on a certain loop-level if the pragma semantics can be satisfied (you must verify this). In many cases, you may be able to apply the pragma (thus implicitly asserting new program/loop properties) that the compiler can then take advantage of to perform enhanced optimizations.
  • Advice to add compiler options: the compiler advises you to add command-line options that assert new properties.

Thia article will help you to understand the GAP feature of Intel® compiler in the Intel® System Studio product, it will introduce  the command line usage of GAP.

Command line usage

1. -guide(=n)

You only need to add "-guide(=n)" option to your command line to enable GAP feature. Compiler will build your code and then give you advice about how to improve the performance

The argument "n" is the level of the guidance, the values available are 1 through 4

2. run GAP to provide guidance for auto-vectorization, auto parallelism or data transformation

GAP will give guidance for three aspects, which are auto-vectorization, auto parallelism or data transformation. You may also run GAP for each kind of guidance. The options are:

  • -guide-vec[=n]: provide guidance for auto-vectorization
  • -guide-par[=n]: provide guidance for auto parallelism
  • -guide-data-trans[=n]: provide guidance for data transformation

Same with "-guide", the argument "n" is the level of the guidance, the values available for these three options are 1 and 2.

3. Save GAP results/messages to a file

When GAP is enabled, compiler will report GAP messages to console (stderr) by default. You may want to save the GAP messages to a file to analysis. The option to save GAP message to a file is:

-guide-file[=filename] (or -guide-file-append[=filename])

4. Run GAP for certain code

When you compile a source file with GAP option, it will give guidance for the file. To run GAP on a whole project, you only need to make sure all files are compiled with GAP. But, you can also run GAP on certain code. You can use "-guide-opts=string" to tell the compiler to analyze certain code and generate recommendations that may improve optimizations. The argument "string" Is the text denoting the code to analyze and the string must appear within quotes. The possible forms are:

  • filename 
  • filename, routine 
  • filename, range [, range]... 
  • filename, routine, range [, range]...

You can specify more than one of the above forms in a string, using a semicolon between each form. Please see compiler's "User and Reference Guides" for the option to understand more details about "filename", "routine" and "range".

5. Example

See below is a example to show how to compile with GAP and what the GAP messages will look like:

#cat gap.c

	#define N 10000000

	double A[N];

void foo(int cond1, int cond2) {

	    int i, t=7;

	    for (i=0; i<N; i++) {

	#ifdef TEST_GPA



	        if (cond1) {

	            t = i+1;


        if (cond2) {

	            t = i-1;


	        A[i] = t;



	#icc gap.c -c -guide

	GAP REPORT LOG OPENED ON Sat Feb 16 17:34:51 2013

remark #30761: Add -parallel option if you want the compiler to generate recommendations for improving auto-parallelization.

Number of advice-messages emitted for this compilation session: 0.


	#icc gap.c -c -guide -parallel

	GAP REPORT LOG OPENED ON Sat Feb 16 17:34:58 2013

gap.c(6): remark #30523: (PAR) Assign a value to the variable(s) "t" at the beginning of the body of the loop in line 6. This will allow the loop to be parallelized. [VERIFY] Make sure that, in the original program, the variable(s) "t" read in any iteration of the loop has been defined earlier in the same iteration. [ALTERNATIVE] Another way is to use "#pragma parallel private(t)" to parallelize the loop. [VERIFY] The same conditions described previously must hold.

Number of advice-messages emitted for this compilation session: 1.


	#icc gap.c -c -guide -parallel -DTEST_GPA

	GAP REPORT LOG OPENED ON Sat Feb 16 17:35:15 2013

Number of advice-messages emitted for this compilation session: 0.



If you need help to understand the GAP messages, you can read compiler's "User and Reference Guides" document for more details (search "GAP Message").

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