[Mlir-commits] [mlir] [MLIR] SPIRV Target Attribute (PR #69949)
Sang Ik Lee
llvmlistbot at llvm.org
Thu Oct 26 11:19:39 PDT 2023
silee2 wrote:
> @silee2 I'll take a closer look later, at first glance it looks like everything is there.
>
> Just one quick question, can you describe the next PR a bit more? Because you shouldn't need to make the target LLVMIR aware, as the binary embedding is mostly dialect agnostic, so there shouldn't be an issue with `SPIRVTargetAttr` not having a translation to LLVM. From what I remember from the original PR the only other modification needed is changing how the kernel is launched, and that change must be done in [Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp ](https://github.com/llvm/llvm-project/blob/main/mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp)
Yes. SelectObjectAttr.cpp is the only function change.
But the new target attribute "spirv.target" is part of SPIRV dialect.
And SPIRV dialect becomes a new dialect as part of input to LLVMIR translation.
The additional change updates
mlir/include/mlir/Target/LLVMIR/Dialect/All.h
which now includes
registerSPIRVDialectTranslation(registry);
There are no actual SPIRV ops to translate and just a single attribute type.
So the new files
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
and
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
are mostly empty.
Without those changes, mlir-cpu-runner will see spirv.target attribute in the input which is part of SPIRV dialect. And since SPIRV dialect is not registered, mlir-cpu-runner throws an error.
NVVM and ROCDL did not have this issue since NVVM and ROCDL was already registered as an input dialect for LLVMIR translation.
https://github.com/llvm/llvm-project/pull/69949
More information about the Mlir-commits
mailing list