For constant workgroup sizes in gpu.launch
it’s easy since we can just fold that into the generated SPIR-V module. For non-constant cases, we should still be able to define workgroup sizes at launch time via specialization constants. Seeing an gpu.launch
with non-constant workgroup sizes, I think we should generate a SPIR-V module with specialization constants for the workgroup sizes. Then before launch, which is vkCmdDispatch
in Vulkan, the Vulkan runtime should feed in the concrete values for the specialization constants for hardware driver compilers to finally compile the SPIR-V module. This cames at its costs: we need to specialize and recompile the SPIR-V module for every gpu.launch
with non-constant workgroup sizes.
For IREE specifically, due to the fact that the runtime side is in IREE and the CodeGen side is in MLIR core, we need extra handshake and contracts to make the above happen. (E.g., the CodeGen need to know the SpecId
s for the specialization constants to generate.)