Skip to content

Commit d1edc7f

Browse files
committed
Add more numbers about MLIR binary sizes with the example binaries (NFC)
1 parent ca84935 commit d1edc7f

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

mlir/examples/minimal-opt/README.md

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,48 @@
33
This folder contains example of minimal MLIR setup that can showcase the
44
intended binary footprint of the framework.
55

6-
- mlir-cat: ~2MB
7-
This includes the Core IR, the builtin dialect, the textual parser/printer,
8-
the support for bytecode serialization.
9-
- mlir-minimal-opt: ~3MB
10-
This adds all the tooling for an mlir-opt tool: the pass infrastructure
11-
and all the instrumentation associated with it.
12-
- mlir-miminal-opt-canonicalize: ~4.8MB
13-
This add the canonicalizer pass, which pulls in all the pattern/rewrite
14-
machinery, including the PDL compiler and intepreter.
6+
- mlir-cat: This includes the Core IR, the builtin dialect, the textual
7+
parser/printer, the support for bytecode serialization.
8+
- mlir-minimal-opt: This adds all the tooling for an mlir-opt tool: the pass
9+
infrastructure and all the instrumentation associated with it.
10+
- mlir-miminal-opt-canonicalize: This add the canonicalizer pass, which pulls in
11+
all the pattern/rewrite machinery, including the PDL compiler and intepreter.
12+
13+
Below are some example measurements taken at the time of the LLVM 17 release,
14+
using clang-14 on a X86 Ubuntu and [bloaty](https://github.com/google/bloaty).
15+
16+
| | Base | Os | Oz | Os LTO | Oz LTO |
17+
| :------------------------------: | ------ | ------ | ------ | ------ | ------ |
18+
| `mlit-cat` | 1018kB | 836KB | 879KB | 697KB | 649KB |
19+
| `mlir-minimal-opt` | 1.54MB | 1.25MB | 1.29MB | 1.10MB | 1.00MB |
20+
| `mlir-minimal-opt-canonicalizer` | 2.24MB | 1.81MB | 1.86MB | 1.62MB | 1.48MB |
21+
22+
Base configuration:
23+
24+
```
25+
cmake ../llvm/ -G Ninja \
26+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
27+
-DLLVM_CCACHE_BUILD=ON \
28+
-DLLVM_ENABLE_PROJECTS=mlir \
29+
-DLLVM_BUILD_EXAMPLES=ON \
30+
-DLLVM_TARGETS_TO_BUILD="Native" \
31+
-DCMAKE_C_COMPILER=clang \
32+
-DCMAKE_CXX_COMPILER=clang++ \
33+
-DLLVM_ENABLE_LLD=ON \
34+
-DLLVM_ENABLE_BACKTRACES=OFF \
35+
-DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=-Wl,-icf=all
36+
```
37+
38+
Note: to measure the on-disk size, you need to run `strip bin/mlir-cat` first to
39+
remove all the debug info (which are useful for `bloaty` though).
40+
41+
The optimization level can be tuned with `-Os` or `-Oz`:
42+
43+
- `-DCMAKE_C_FLAGS_RELWITHDEBINFO="-Os -g -DNDEBUG" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-Os -g -DNDEBUG"`
44+
- `-DCMAKE_C_FLAGS_RELWITHDEBINFO="-Oz -g -DNDEBUG" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-Oz -g -DNDEBUG"`
45+
46+
Finally LTO can also be enabled with `-DLLVM_ENABLE_LTO=FULL`.
47+
48+
Bloaty can provide measurements using:
49+
`bloaty bin/mlir-cat -d compileunits --domain=vm` or
50+
`bloaty bin/mlir-cat -d symbols --demangle=full --domain=vm`

0 commit comments

Comments
 (0)