Skip to content

RFC: clc/rusticl: binary size reduction of compiled spirvs

Karol Herbst requested to merge karolherbst/mesa:clc/size_reduction into main

I've played around in order to reduce CPU and memory overhead of compiling OpenCL C.

There are several things here:

  1. serialize clc_parsed_spirv so it can be cached alongside spirvs when e.g. caching the OpenCL C -> SPIR-V compilation
  2. run some LLVM passes on the generated LLVM module (cuts size by roughly 25%)
  3. optimize the spirv (cuts size by roughly 20%)

There is also a bit of more potential, as I can further cut the size of the final spirv by 50% by running MergeFunctions. Sadly this has a chance of generating function pointers which we can't handle without also supporting SPV_INTEL_function_pointers.

I didn't do any actual proper CPU performance analysis on this, but I'd expect that doing the size reduction early on will save us a lot of CPU time inside spirv_to_nir and clc_parse_spirv.

Edited by Karol Herbst

Merge request reports