You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added `iree-opt-level` to docs and add tip pointing to the "Optimization
Options" page.
---------
Signed-off-by: Ian Wood <[email protected]>
Signed-off-by: Elias Joseph <[email protected]>
Copy file name to clipboardExpand all lines: docs/website/docs/reference/optimization-options.md
+74-9Lines changed: 74 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,80 @@ These flags can be passed to the:
16
16
constructor
17
17
*`ireeCompilerOptionsSetFlags()` compiler C API function
18
18
19
+
## Optimization level
20
+
21
+
As in other compilers like clang and gcc, IREE provides a high level optimization
22
+
level flag (`iree-opt-level`) that enables different sets of underlying options.
23
+
24
+
`iree-opt-level` specifies the optimization level for the entire compilation
25
+
flow. Lower optimization levels prioritize debuggability and stability, while
26
+
higher levels focus on maximizing performance. By default, `iree-opt-level` is
27
+
set to `O0` (minimal or no optimizations).
28
+
29
+
!!! note
30
+
31
+
Not all flags that control performance are nested under `iree-opt-level`.
32
+
See [High level program optimizations](#high-level-program-optimizations)
33
+
below for subflags not covered by optimization flags.
34
+
35
+
This flag takes the following values:
36
+
37
+
| Optimization Level | Pros | Cons |
38
+
|-------------------|------|------|
39
+
|**O0** (Default, Minimal Optimizations) | <ulstyle="list-style-type:none;"><li>✔️ Fastest compilation time.</li><li>✔️ Generated code is easier to debug.</li><li>✔️ Keeps assertions enabled</li></ul> | <ulstyle="list-style-type:none;"><li>❌ Poor runtime performance.</li><li>❌ Higher runtime memory usage.</li><li>❌ Larger code size due to lack of optimization.</li></ul> |
40
+
|**O1** (Basic Optimizations) | <ulstyle="list-style-type:none;"><li>✔️ Enables optimizations, allowing for better runtime performance.</li><li>✔️ Optimizations are compatible with all backends.</li></ul> | <ulstyle="list-style-type:none;"><li>➖ Only applies conservative optimizations.</li><li>❌ Reduced debuggability.</li></ul> |
41
+
|**O2** (Optimizations without full backend support) | <ulstyle="list-style-type:none;"><li>✔️ Even more aggressive optimizations.</li><li>✔️ Strikes a balance between optimization level and compatibility.</li></ul> | <ulstyle="list-style-type:none;"><li>➖ Some optimizations may not be supported by all backends.</li><li>❌ Reduced debuggability.</li></ul> |
42
+
|**O3** (Aggressive Optimization) | <ulstyle="list-style-type:none;"><li>✔️ Highest runtime performance.</li><li>✔️ Enables advanced and aggressive transformations.</li><li>✔️ Exploits backend-specific optimizations for optimal efficiency.</li></ul> | <ulstyle="list-style-type:none;"><li>➖ Longer compile times.</li><li>❌ Some optimizations may be unstable.</li><li>❌ Reduced debuggability.</li></ul> |
43
+
44
+
Although `iree-opt-level` sets the default for each subflag, they can be
45
+
explicitly set on or off independently.
46
+
47
+
For example:
48
+
49
+
```bash
50
+
# Apply the default optimizations of `O2` but don't remove assertions.
0 commit comments