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: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/alphabetical-option-list.html



Compiler

Language

Cray compiler wrapper

Underlying Intel oneAPI 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

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 #define directive. For example, -DMPI=1.

-fuse-ld=name

Use a different linker, i.e., name, instead of the default linker ld. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/fuse-ld.html.

-H

Display the include file order and continue compilation.

-Idir (Capital i)

Specify an additional directory, i.e., dir, to search for include files.

-lname (Lowercase l)

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 (.s) then stop.

-shared

Produce a dynamic shared object instead of an executable. Usually use with -fPIC.

-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: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/std-qstd.html.

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

Flags / Options

Short description

-debug=keyword

Select the type of debugging information keyword. Some are enabled by default. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/debug-linux.html.

-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 N of debugging information, e.g., -g3. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/g.html.

-v

Show the commands and execute them.

-w[N]

Generate level N of diagnostic messages, e.g., -w3. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/w-w.html.

-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

Flags / Options

Short description

-fast

Equivalent to -ipo -O3 -static -fp-model fast

-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., -ffp-contract=off. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/ffp-contract.html.

-finline

Inline all functions declared with __inline and perform C++ inlining.

-flto

Enable whole program link time optimization (LTO). This option is equivalent to -ipo. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/flto.html.

-fp-model=keyword

Controls the semantics of floating-point optimization. For example,

  • -fp-model=fast
    = Enable all aggressive optimizations although it may affect the accuracy or reproducibility of computations. [Default]

  • -fp-model=precise
    = Only enable optimizations that are value-safe.

  • -fp-model=strict
    = Disable optimizations that may violate the IEEE 754 standard.

Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/fp-model-fp.html.

-fp-speculation=keyword

Specify the mode in which to speculate on floating-point operations.

  • -fp-speculation=fast
    = Enable speculation on floating-point operations. [Default]

  • -fp-speculation=safe
    = Disable speculation if there is a possibility that the speculation may cause a floating-point exception.

  • -fp-speculation=strict
    = Disable speculations on floating-point operations.

Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/fp-speculation-qfp-speculation.html.

-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: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/fvec-remainder-loops-qvec-remainder-loops.html.

-ipo

Enable interprocedural optimization between files. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/ipo-qipo.html.

-O[Num]

Specify the code optimization level Num for applications, e.g., -O3. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-1/o-001.html.

-Ofast

Equivalent to -fast and -ipo -O3 -static -fp-model fast

-Os

Enable optimizations that do not increase code size; it produces smaller code size than -O2.

-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., -qopt-report=2.

-unroll=Num

Specify the maximum number of times Num to unroll loops, e.g., -unroll=8.

-no-vec

Disable vectorization, which is enabled by default at -O2 or higher.

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

Flags / Options

Short description

-fiopenmp

Compile/Link with OpenMP features enabled. Equivalent to -qopenmp.

-qopenmp

Compile/Link with OpenMP features enabled. Equivalent to -fiopenmp.

-qopenmp-link=static

Link to static OpenMP runtime libraries. Default: -qopenmp-link=dynamic.

SYCL

Flags / Options

Short description

Flags / Options

Short description

-fsycl

Compile/Link as a SYCL program

-fsycl-targets=targets

Generate code for specified device targets.

  • -fsycl-targets=nvptx64-nvidia-cuda
    Generate code for NVIDIA GPUs

-Xsycl-target-backend

Pass options to the backend tool.

  • --cuda-gpu-arch=sm_80
    Specify CUDA compatibility sm_80 (NVIDIA A100)

Intel oneAPI Math Kernel Library (oneMKL)

Flags / Options

Short description

Others

Flags / Options

Short description

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 -fPIE into an executable. Ref: https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/pie.html.

-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