Intel® C++ Compiler 16.0 User and Reference Guide
Controls optimization for one function or all functions after its first occurrence.
#pragma [intel|GCC] optimization_level n |
intel|GCC |
Indicates the interpretation to use |
n |
An integer value specifying an optimization level; valid values are:
|
The optimization_level pragma is used to restrict optimization for a specific function while optimizing the remaining application using a different, higher optimization level. For example, if you specify option level O3 for the application and specify #pragma optimization_level 1, the marked function will be optimized at option level O1, while the remaining application will be optimized at the higher level.
In general, the pragma optimizes the function at the level specified as n; however, certain compiler optimizations, like Inter-procedural Optimization (IPO), are not enabled or disabled during translation unit compilation. For example, if you enable IPO and a specific optimization level, IPO is enabled even for the function targeted by this pragma; however, IPO might not be fully implemented regardless of the optimization level specified at the command line. The reverse is also true.
Scope of optimization restriction
On Linux* and OS X* systems, the scope of the optimization restriction can be affected by arguments passed to the -pragma-optimization-level compiler option as explained in the following table.
Syntax |
Behavior |
---|---|
#pragma intel optimization_level n |
Applies the pragma only to the next function, using the specified optimization level, regardless of the argument passed to the -pragma-optimization-level option. |
#pragma GCC optimization_level n or |
Applies the pragma to all subsequent functions, using the specified optimization level, regardless of the argument passed to the -pragma-optimization-level option. Specifying reset reverses the effect of the most recent #pragma GCC optimization_level statement, by returning to the optimization level previously specified. |
#pragma optimization_level n |
Applies either the Intel® C++ Compiler implementation or the GCC* interpretation. Interpretation depends on the argument passed to the -pragma-optimization-level option. |
On Windows* systems, the pragma always uses the intel interpretation; the pragma is applied only to the next function.
Place the pragma immediately before the function being affected.
Example: intel interpretation of the optimization_level pragma |
---|
#pragma intel optimization_level 1 gamma() { ... } |
Example: GCC* interpretation of the optimization_level pragma |
---|
#pragma GCC optimization_level 1 gamma() { ... } |