Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Use Compiler Options

A compiler option is a case-sensitive, command line expression used to change the compiler's default operation. Compiler options are not required to compile your program, but they can control different aspects of your application, such as:

  • Code generation
  • Optimization
  • Output file (type, name, location)
  • Linking properties
  • Size of the executable
  • Speed of the executable

Linux

When you specify compiler options on the command line, the following syntax applies:

[invocation] [option] [@response_file] file1 [file2...]		    

The invocation is icx, icpx, or icpx -fsycl.

The option represents zero or more compiler options and the file is any of the following:

  • C or C++ source file (.C, .c, .cc, .cpp, .cxx, .c++, .i, .ii)
  • Assembly file (.s, .S)
  • Object file (.o)
  • Static library (.a)

When compiling C language sources, invoke the compiler with icx. When compiling C++ language sources or a combination of C and C++, invoke the compiler with icpx. When compiling SYCL-based sources, invoke the compiler with icpx -fsycl.

Windows

When you specify compiler options on the command line, the following syntax applies:

[invocation] [option] [@response_file] file1 [file2 ...] [/link linker_option]

The invocation is icx or icx-cl -fsycl.

The option represents zero or more compiler options, the linker_option represents zero or more linker options, and the file is any of the following:

  • C or C++ source file (.c, .cc, .ccp, .cxx, .i)
  • Assembly file (.asm)
  • Object (.obj)
  • Static library (.lib)

The optional response_file is a text file that lists the compiler options you want to include during compilation. See Use Response Files for additional information.

Default Operation

The compiler invokes many options by default. In this example, the compiler includes the option O2 (and other default options) in the compilation. Using C++ as an example:

Linux

icpx main.c

Windows

icx main.c

Each time you invoke the compiler, options listed in the corresponding configuration file override any competing default options. For example, if your configuration file includes the O3 option, the compiler uses O3 rather than the default O2 option. Use the configuration file to list the options for the compiler to use for every compilation. See Using Configuration Files.

NOTE:
The default .cfg files are not valid for the compiler. You can use the -config<name> option instead of a default .cfg file. <name> can be a configuration file that is in the bin directory, or you can use the full path your selected .cfg file.

Options specified in the command line environment variable override any competing default options and options listed in the configuration file.

Finally, options used on the command line override any competing options that may be specified elsewhere (default options, options in the configuration file, and options specified in the command line environment variable). If you specify the option O1 this option setting takes precedence over competing option defaults and competing options in the configuration files, in addition to the competing options in the command line environment variable.

Certain #pragma statements in your source code can override competing options specified on the command line. If a function in your code is preceded by #pragma optimize("", off), then optimization for that function is turned off. The override is valid even when the O2 optimization is on by default, the O3 is listed in the configuration file, and the O1 is specified on the command line for the rest of the program.

Use Competing Options

The compiler reads command line options from left to right. If your compilation includes competing options, then the compiler uses the one furthest to the right. Using C++ as an example:

Linux

icpx –xSSSE3 main.c file1.c –xSSE4.2 file2.c

Windows

icx /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c

The compiler sees [Q]xSSSE3 or O1 and [Q]xSSE4.2 or O2 as two forms of the same option, where only one form can be used. Since [Q]xSSE4.2 or O2 are last (furthest to the right), they are used.

All options specified on the command line are used to compile each file. The compiler does not compile individual files with specific options.

A rare exception to this rule is the -x type option on Linux. Using C++ as an example:

Linux

icpx -x c file1 -x c++ file2 -x assembler file3

The type argument identifies each file type for the compiler.

Use Options with Arguments

Compiler options can be as simple as a single letter, such as the option E. Many options accept or require arguments. The O option, for example, accepts a single-value argument that the compiler uses to determine the degree of optimization. Other options require at least one argument and can accept multiple arguments. For most options that accept arguments, the compiler warns you if your option and argument are not recognized. If you specify O9, the compiler issues a warning, then ignores the unrecognized option O9, and proceeds with the compilation.

The O option does not require an argument, but there are other options that must include an argument. The I option requires an argument that identifies the directory to add to the include file search path. If you use this option without an argument, the compiler will not finish its compilation.

Other Forms of Options

You can toggle some options on or off by using the negation convention. For example, the [Q]ipo option (and many others) includes negation forms, -no-ipo (Linux) and /Qipo- (Windows), to change the state of the option.

Option Categories

When you invoke the Intel oneAPI DPC++/C++ Compiler and specify a compiler option, you have a wide range of choices to influence the compiler's default operation. Intel oneAPI DPC++/C++ Compiler options typically correspond to one or more of the following categories:

  • Advanced Optimization
  • Code Generation
  • Compatibility
  • Compiler Diagnostics
  • Component Control (Not available for device compilation.)
  • Data
  • Floating Point
  • Inlining
  • Interprocedural Optimizations (IPO)
  • Language
  • Linking/Linker
  • Miscellaneous
  • Offload Compilation, OpenMP, and Parallel Processing
  • OpenMP and Parallel Processing
  • Optimization
  • Optimization Report
  • Output
  • Preprocessor