Other Considerations
There are some notable differences between the
Intel® oneAPI
and GCC*. Consider the following as you begin compiling your source code with the
DPC++/C++
CompilerIntel® oneAPI
.
DPC++/C++
CompilerSet the Environment
The
Intel® oneAPI
relies 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
DPC++/C++
CompilerIntel® oneAPI
. The following environment variables
DPC++/C++
Compilercan be
set prior to running the
Intel® oneAPI
:
DPC++/C++
Compiler- PATH: Add the location of the compiler binaries toPATH.
- LD_LIBRARY_PATH: Sets the location where the generated executable picks up the runtime libraries (*.so files).
- MANPATH– add the location of the compiler man pages () toicx or icpxfor C++ ordpcppfor DPC++MANPATH.
To set these environment variables,
you can source the
setvars.sh
script (e.g.
source setvars.sh
).Setting these environment variables with
does not impose a conflict with GCC. You should be able to use both compilers in the same shell.
setvars.sh
Use Optimization
The
option compare as follows:
Intel® oneAPI
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 option
DPC++/C++
CompilerO2
, are part of the default invocation of the
Intel® oneAPI
. Optimization is turned off in GCC by default, the equivalent of compiling with option
DPC++/C++
CompilerO0
. Other forms of the
O
<n>
Option
| Intel® oneAPI
DPC++/C++ Compiler | GCC
|
---|---|---|
-O0 | Turns off optimization.
| Default. Turns off optimization.
|
-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 option
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 option
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 option
O2 optimizations plus loop unrolling and inlining.
|
Target 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.
Modify Your Configuration
The
).
Intel® oneAPI
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 (DPC++/C++
Compilericx.cfg or icpx.cfg
for C++ or
dpcpp.cfg
for DPC++In a multi-user, networked environment, options listed in the
files are generally intended for everyone who uses the compiler. If you need a separate configuration, you can use the
environment variable to specify the name and location of your own
) are ignored.
icx.cfg or icpx.cfg
for C++ or
dpcpp.cfg
for DPC++ICXCFG or ICPXCFG
for C++ or
DPCPPCFG
for DPC++.cfg
file, such as
/my_code/my_config.cfg
. Anytime you instruct the compiler to use a different configuration file, the system configuration files (icx.cfg or icpx.cfg
for C++ or
dpcpp.cfg
for DPC++Use the Intel Libraries
The
Intel® oneAPI
supplies additional libraries that contain optimized implementations of many commonly used functions. Some of these functions are implemented using CPU dispatch. This means that different code may be executed when run on different processors.
DPC++/C++
CompilerSupplied libraries include the
Intel® oneAPI
Math Library (DPC++/C++
Compilerlibimf
), the Short Vector Math Library (libsvml
),
libirc
, as well as others. These libraries are linked in by default. Some library functions, such as
sin
or
memset
, may not require a call to the library, since the compiler may inline the code for the function.
The Intel Compiler Math Libraries contain performance-optimized implementations for various Intel platforms. By default, the best implementation for the underlying hardware is selected at runtime. The library dispatch of multi-threaded code may lead to apparent data races, which may be detected by certain software analysis tools. However, as long as the threads are running on cores with the same CPUID, these data races are harmless and are not a cause for concern.
Intel® oneAPI
Math Library (DPC++/C++
Compilerlibimf
)With the Intel® Compiler, the math library,
libimf
, is linked by default. Some functions, such as sin, may not require a call to the library, since the compiler already knows how to compute the
sin
function. The math library also includes some functions not found in the standard math library.
You cannot make calls to the math library with GCC.
Many routines in the
libimf
library are more optimized for Intel® microprocessors than for non-Intel microprocessors.Short Vector Math Library (
libsvml
)When vectorization is being done, the compiler may translate some calls to the
libimf
math library functions into calls to
libsvml
functions. These functions implement the same basic operations as the math library, but operate on short vectors of operands. This results in greater efficiency. In some cases, the
libsvml
functions are slightly less precise than the equivalent
libimf
functions.
Many routines in the
libimf
library are more optimized for Intel® microprocessors than for non-Intel microprocessors.libirc
libirc
contains optimized implementations of some commonly used string and memory functions. For example, it contains functions that are optimized versions of
memcpy
and
memset
. The compiler will automatically generate calls to these functions when it sees calls to
memcpy
and
memset
. The compiler may also transform loops that are equivalent to
memcpy
or
memset
into calls to these functions.
Many routines in the
libirc
library are more optimized for Intel® microprocessors than for non-Intel microprocessors.Product and Performance Information
|
---|
Performance varies by use, configuration and other factors. Learn more at
www.Intel.com/PerformanceIndex.
Notice revision #20201201
|