[Mlir-commits] [mlir] [mlir][gpu] Introduce `gpu.dynamic_shared_memory` Op (PR #71546)
Mehdi Amini
llvmlistbot at llvm.org
Wed Nov 15 01:14:53 PST 2023
================
@@ -554,6 +555,104 @@ static IntegerAttr wrapNumericMemorySpace(MLIRContext *ctx, unsigned space) {
return IntegerAttr::get(IntegerType::get(ctx, 64), space);
}
+/// Generates a symbol with 0-sized array type for dynamic shared memory usage,
+/// or uses existing symbol.
+LLVM::GlobalOp
+getDynamicSharedMemorySymbol(ConversionPatternRewriter &rewriter,
+ Operation *moduleOp, gpu::DynamicSharedMemoryOp op,
+ const LLVMTypeConverter *typeConverter,
+ MemRefType memrefType, unsigned alignmentBit) {
+ uint64_t alignmentByte = alignmentBit / memrefType.getElementTypeBitWidth();
+
+ FailureOr<unsigned> addressSpace =
+ typeConverter->getMemRefAddressSpace(memrefType);
+ if (failed(addressSpace)) {
+ op->emitError() << "conversion of memref memory space "
+ << memrefType.getMemorySpace()
+ << " to integer address space "
+ "failed. Consider adding memory space conversions.";
+ }
+
+ // Step 1. Collect symbol names of LLVM::GlobalOp Ops. Also if any of
+ // LLVM::GlobalOp is suitable for shared memory, return it.
+ llvm::StringSet<> existingGlobalNames;
+ for (auto globalOp :
+ moduleOp->getRegion(0).front().template getOps<LLVM::GlobalOp>()) {
----------------
joker-eph wrote:
Isn't there a getBody() or equivalent in moduleOp?
Also not sure why the `template` is needed here?
https://github.com/llvm/llvm-project/pull/71546
More information about the Mlir-commits
mailing list