[Mlir-commits] [mlir] [MLIR][GPU-LLVM] Add in-pass signature update option for opencl kernels (PR #105664)
Victor Perez
llvmlistbot at llvm.org
Tue Sep 17 00:44:11 PDT 2024
================
@@ -306,6 +310,36 @@ struct GPUShuffleConversion final : ConvertOpToLLVMPattern<gpu::ShuffleOp> {
}
};
+class MemorySpaceToOpenCLMemorySpaceConverter final : public TypeConverter {
+public:
+ MemorySpaceToOpenCLMemorySpaceConverter() {
+ addConversion([](Type t) { return t; });
+ addConversion([this](BaseMemRefType memRefType) -> std::optional<Type> {
+ // Attach global addr space attribute to memrefs with no addr space attr
+ Attribute memSpaceAttr = memRefType.getMemorySpace();
+ if (memSpaceAttr)
+ return std::nullopt;
+
+ auto addrSpaceAttr = gpu::AddressSpaceAttr::get(
+ memRefType.getContext(), gpu::AddressSpace::Global);
+ if (auto rankedType = dyn_cast<MemRefType>(memRefType)) {
+ return MemRefType::get(memRefType.getShape(),
+ memRefType.getElementType(),
+ rankedType.getLayout(), addrSpaceAttr);
+ }
+ return UnrankedMemRefType::get(memRefType.getElementType(),
+ addrSpaceAttr);
+ });
+ addConversion([this](FunctionType type) {
+ auto inputs = llvm::map_to_vector(
+ type.getInputs(), [this](Type ty) { return convertType(ty); });
+ auto results = llvm::map_to_vector(
+ type.getResults(), [this](Type ty) { return convertType(ty); });
+ return FunctionType::get(type.getContext(), inputs, results);
+ });
+ }
+};
----------------
victor-eds wrote:
True it does not work as per MLIR limitations.
https://github.com/llvm/llvm-project/pull/105664
More information about the Mlir-commits
mailing list