Intel® oneAPI DPC++/C++ compiler
Essential Intel C/C++ compiler flags for general software compilation are summarized on this page.
Based on: Intel® oneAPI 2023.1 (cpeIntel/23.09 on LANTA)
Reference: Alphabetical Option List
Compiler
Language | Cray compiler wrapper | Underlying Intel oneAPI compiler |
---|---|---|
C | cc | icx |
C++ | CC | icpx |
Flags / Options
The icx
and icpx
commands support the same set of options.
Compilation
Flags / Options | Short description |
---|---|
-c | Prevent linking after the object file is generated. This option is useful when compiling more than one targets with common source files. |
-Dname[=value] | Define a macro name that can be associated with an optional value. This is a compile-time version of |
-fuse-ld=name | Use a different linker, i.e., name, instead of the default linker |
-H | Display the include file order and continue compilation. |
-Idir | Specify an additional directory, i.e., dir, to search for include files. |
-lname | Employ name library, i.e., libname.so or libname.a, when linking. This option should follows the last object file it applies to. |
-Ldir | Search for libraries in dir directory before searching the standard directories. This option is usually placed prior to -lname option. |
-o target-name | Specify the name of the output file. |
-S | Compile to an assembly file ( |
-shared | Produce a dynamic shared object instead of an executable. Usually use with |
-static | Prevents linking with shared libraries |
-std=val | Follow a C/C++ language standard where val are c++2b, c++20, c++17, c++14, c++11, C18, C11, or C99. Ref: std, Qstd. |
Warnings / Errors / Debug
Mostly, -Wxxx
indicates warning enabled, while -Wno-xxx
implies warning disabled.
(See also https://clang.llvm.org/docs/DiagnosticsReference.html )
Flags / Options | Short description |
---|---|
-debug=keyword | Select the type of debugging information keyword. Some are enabled by default. Ref: debug (Linux*). |
-dryrun | Show the commands but do not execute them. |
-fsyntax-only | Check for syntax errors. No object file will be produced. |
-g[N] | Generate level |
-v | Show the commands and execute them. |
-w[N] | Generate level |
-Wall | Display all errors and warnings that are typically reported by GCC -Wall option. (Note: -Wall and -w[N] are mutually exclusive) |
-Wcheck-unicode-security | Enable/Disable checking for unicode vulnerabilities. |
-Wno-deprecated | Enable/Disable warnings issued for deprecated C++ headers. |
-Weffc++ | Enable warnings based on certain C++ programming guidelines. |
-Werror | Change all warnings to errors. |
-Werror-all | Change all warnings and enabled remarks to errors. |
-Wno-implicit-function-declaration | Enable/Disable errors issued when implicitly declare functions. |
-Wno-implicit-int | Enable/Disable errors issued when implicitly declare variables. |
-Wformat | Enable/Disable argument checking for calls to printf, scanf, and so on. |
-Wformat-security | Enable/Disable warnings issued when the use of format functions may cause security problems. |
-Wmissing-declarations | Enable/Disable warnings issued for global functions and variables without prior declaration. |
-Wreorder | Issue warnings when the order of member initializers does not match the order in which they must be executed. |
-Wshadow | Enable/Disable warnings issued when a variable declaration hides a previous declaration. |
-Wsign-compare | Enable/Disable warnings issued when a comparison between signed and unsigned values could produce an incorrect result. |
-Wuninitialized | Enable/Disable warnings issued when a variable is used before being initialized. |
Optimization
Flags / Options | Short description |
---|---|
-fast | Equivalent to |
-fno-exceptions | Disable exception handling table generation, resulting in smaller code. |
-ffp-contract=keyword | Control when the compiler is permitted to form fused floating-point operations, e.g., |
-finline | Inline all functions declared with |
-flto | Enable whole program link time optimization (LTO). This option is equivalent to |
-fp-model=keyword | Controls the semantics of floating-point optimization. For example,
Ref: fp-model, fp. |
-fp-speculation=keyword | Specify the mode in which to speculate on floating-point operations.
|
-fpack-struct | Pack structure members closely together. Using this option may result in code that is unusable with standard (system) c and C++ libraries. |
-fvec-remainder-loops | Perform additional steps to vectorize the remainder loop that was created when vectorize the original loop. Ref: fvec-remainder-loops, Qvec-remainder-loops. |
-ipo | Enable interprocedural optimization between files. Ref: ipo, Qipo. |
-O[Num] | Specify the code optimization level |
-Ofast | Equivalent to |
-Os | Enable optimizations that do not increase code size; it produces smaller code size than |
-qopt-dynamic-align | Enable dynamic data alignment optimizations, which can improve the performance of some vectorized code, but also increased code size and compile time. |
-qopt-report=Num | Enable the generation of a YAML file that includes optimization transformation information with the level of detail Num, e.g., |
-unroll=Num | Specify the maximum number of times Num to unroll loops, e.g., |
-no-vec | Disable vectorization, which is enabled by default at |
Machine-dependent optimization flags, such as -march=core-avx2, -mtune=core-avx2, -mavx2, and -xHost, should NOT be employed directly. Instead, users should pass them implicitly by loading craype-x86-milan
and using Cray compiler wrappers cc
, CC
(see).
OpenMP
Flags / Options | Short description |
---|---|
-fiopenmp | Compile/Link with OpenMP features enabled. Equivalent to |
-qopenmp | Compile/Link with OpenMP features enabled. Equivalent to |
-qopenmp-link=static | Link to static OpenMP runtime libraries. Default: |
SYCL
Flags / Options | Short description |
---|---|
-fsycl | Compile/Link as a SYCL program |
-fsycl-targets=targets | Generate code for specified device targets.
|
-Xsycl-target-backend | Pass options to the backend tool.
|
Intel oneAPI Math Kernel Library (oneMKL)
Flags / Options | Short description |
---|---|
-qmkl | Link to the (parallel) oneMKL library. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/qmkl-qmkl.html. |
-qmkl-ilp64 | Link to the (parallel) ILP64 version of the oneMKL library. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/qmkl-ilp64-qmkl-ilp64.html#GUID-FC2B7583-DE31-4DD5-AB44-50B19FFAB198 . |
Others
Flags / Options | Short description |
---|---|
-fPIC | Generate position-independent code. Usually used when building shared objects. |
-fPIE | Generate position-independent code that can ONLY be linked into executables. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/fpie.html. |
-pie | Link code compiled with |
-pthread | Compile/Link with POSIX thread library for multi-threading support. |
Porting from Intel Classic to Intel oneAPI
Intel oneAPI is built on LLVM clang compiler and thus inherits errors/warnings that are not presented in Intel Classic. The most frequently encountered errors are the implicit declaration of functions and variables that violate ISO C99 standard and later. Although these errors can be silent by passing
-Wno-implicit-function-declaration
and-Wno-implicit-int
respectively, it is strongly encouraged to declare and specify types of all functions and variables explicitly.Intel oneAPI does NOT support all flags/options available in Intel Classic, e.g.,
-diag-dump
and-fp-model consistent
. (In the case of-fp-model consistent
, however,-fp-model=precise -fimf-arch-consistency=true -no-fma
can be used in substitution.)Intel oneAPI does NOT support all Intel-specific pragmas/directives available in Intel Classic. The unsupported pragmas will be reported at compile time, if users do not intentionally silent it by passing
-Wno-unknown-pragmas
.Intel oneAPI has a different set of predefined macro and compiler version string format. This could cause the Intel oneAPI compiler to be undetected (or mistakenly detected as LLVM clang) in some software build systems. Upgrades or modifications are usually required on a case-by-case basis.
Intel oneAPI has built-in functions, SIMD intrinsic functions and some language extensions that are more aligned with Clang syntax than Intel Classic syntax. For more details, see https://clang.llvm.org/docs/LanguageExtensions.html.
Intel oneAPI adopted Linking Interprocedural Optimizations (IPO) and Profile Guided Optimizations (PGO) from LLVM clang which is fundamentally different from those previously available in Intel Classic.
Intel oneAPI compiler does NOT support Intel® Cilk™ Plus.
For more information, visit https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-icc-users-to-dpcpp-or-icx.html.
References & Further reading
https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/2023-1/overview.html
https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-1/overview.html
https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#
https://github.com/oneapi-src/oneAPI-samples/tree/master/DirectProgramming