Other Considerations

There are some notable differences between the Intel® C++ Compiler and gcc. Consider the following as you begin compiling your gcc code with the Intel C++ Compiler:

Setting the Environment

The Intel compilers rely on environment variables for the location of compiler binaries, libraries, man pages, and license files. In some cases these are different from the environment variables that gcc uses. Another difference is that these variables are not set by default after installing the Intel compiler. The following environment variables need to be set prior to running the Intel compiler:

You can 'source' the iccvars.sh shell script (included with the compiler) to set these environment variables for you. See Invoking the Compiler from the Command Line for details on using iccvars.sh.

Note

Setting these environment variables with iccvars.sh does not impose a conflict with gcc. You should be able to use both compilers in the same shell.  

Using Optimization

The Intel C++ Compiler is an optimizing compiler that begins with the assumption that you want improved performance from your application when it is executed on Intel architecture. Consequently, certain optimizations, such as -O2, are part of the default invocation of the Intel compiler. By default, gcc turns off optimization - the equivalent of compiling with -O or -O0. Other forms of the -O<n> option compare as follows:

Option Intel gcc
-O0 Turns off optimization. Default. Turns off optimization. Same as -O.
-O1 Decreases code size with some increase in speed. Decreases code size with some increase in speed.
-O2 Default. Favors speed optimization with some increase in code size. Same as -O. Intrinsics, loop unrolling, and inlining are performed. Optimizes for speed as long as there is not an increase in code size. Loop unrolling and function inlining, for example, are not performed.
-O3 Enables -O2 optimizations plus more aggressive optimizations, such as prefetching, scalar replacement, and loop and memory access transformations. Optimizes for speed while generating larger code size. Includes -O2 optimizations plus loop unrolling and inlining. Similar to -O2 -ip on Intel compiler.

See Also

Targeting Intel Processors

While many of the same options that target specific processors are supported with both compilers, Intel includes options that utilize processor-specific instruction scheduling to target the latest Intel processors. If you compile your gcc application with the -march or -mtune option, consider using Intel's -x or -ax options for applications that run on IA-32 or Intel® 64 architecture. If your application runs on IA-64 architecture, use the -tpp option.

Modifying Your Configuration

The Intel compiler lets you maintain configuration and response files that are part of compilation. Options stored in the configuration file apply to every compilation, while options stored in response files apply only where they are added on the command line. If you have several options in your makefile that apply to every build, you may find it easier to move these options to the configuration file (../bin/icc.cfg and ../bin/icpc.cfg).

In a multi-user, networked environment, options listed in the icc.cfg and icpc.cfg files are generally intended for everyone who uses the compiler. If you need a separate configuration, you can use the ICCCFG or ICPCCFG environment variable to specify the name and location of your own .cfg file, such as /my_code/my_config.cfg. Anytime you instruct the compiler to use a different configuration file, the system configuration files (icc.cfg and icpc.cfg) are ignored.

See Also

Using the Intel Math Library

With the Intel C++ Compiler, the Intel Math Library, libimf, is linked by default when calling math functions that require the library. Some functions, such as sin, do not require a call to the library, since the compiler already knows how to compute the sin function. The Intel Math Library includes many functions not found in the standard libm. A simple example using the sind function follows:

 

#include <stdio.h>

#include <mathimf.h>

double sind(double);

double x = 90.0;

int main(void){

    printf("The sine of %f degrees is %f\n", x, sind(x) );

return(0);

}

 

Note

You cannot make calls the Intel Math Library with gcc.