I’ve started digging around the static/fat library builds of GitHub - ROCmSoftwarePlatform/rocMLIR , trying to slim them down (since a debug build ran into a 4 GB library size limit on Windows, and while there’s a workaround, I’m still trying to solve the underlying questions).
I’ve managed to prevent a lot of dialect libraries from being built by default already, but I noticed that some parts of the core code, such as ConvertVectorToLLVM
or the LLVM translator, will always include certain hardware- or backend-specific libraries and that there’s no way to disable that. For example, even though rocMLIR will never be generating ARM code or using Intel’s AMX, the code to handle those operations is always built and then only disabled at runtime.
LLVM, by contrast, has LLVM_ENABLE_BACKENDS
, where, if I want, I can list out exactly the architectures I want to target and thus avoid of building large portions of code I know I’ll never need.
I propose that, when it comes to backend-specific dialects or code, we should have a MLIR_ENABLE_BACKENDS
value in CMake. It should, as in LLVM, default to all
(aka every available backend) but it should be overridable in order to reduce bloat in libMLIR (or something that’s including parts of it).
The upside to this is that certain parts of the MLIR build will become more configurable - that is, I will be able to, for example, only include the LLVM, GPU, and ROCDL dialect translations I want when I pull in “LLVM Translation”.
The downside is that this’ll clutter up certain parts of the build with if ()
s and #ifdef
s.
My initial thoughts for the values in MLIR_ENABLE_BACKENDS
are
AMDGPU
/ROCDL
NVGPU
/NVVM
X86
(which’ll include Amx as needed, though someone might want to split that out later)OpenACC
OpenMP
Arm
(standing for all the various Arm* dialects’ usages)
The output targets themselves (LLVMIR/SPIRV/…) don’t need this treatment, since they’re already independent components you can choose to include or exclude from your build.