[Mlir-commits] [mlir] [mlir][gpu] Introduce `gpu.dynamic_shared_memory` Op (PR #71546)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 7 07:29:13 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 27156dd575d34980c21f97fae4bfbd47a8ca16de f7babc582ea39a01e17617790652f76939757b39 -- mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
index fbea498ee27c..7b643a6f3c5e 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
@@ -557,9 +557,11 @@ static IntegerAttr wrapNumericMemorySpace(MLIRContext *ctx, unsigned space) {
/// Generates a symbol with 0-sized array type for dynamic shared memory usage,
/// or uses existing symbol.
-LLVM::GlobalOp getDynamicSharedMemorySymbol(
- ConversionPatternRewriter &rewriter, gpu::DynamicSharedMemoryOp op,
- const LLVMTypeConverter *typeConverter, MemRefType memrefType, unsigned alignmentBit) {
+LLVM::GlobalOp
+getDynamicSharedMemorySymbol(ConversionPatternRewriter &rewriter,
+ gpu::DynamicSharedMemoryOp op,
+ const LLVMTypeConverter *typeConverter,
+ MemRefType memrefType, unsigned alignmentBit) {
std::optional<LLVM::GlobalOp> existingGlobalOp;
LLVM::LLVMFuncOp funcOp = op->getParentOfType<LLVM::LLVMFuncOp>();
@@ -607,15 +609,16 @@ LogicalResult GPUDynamicSharedMemoryOpLowering::matchAndRewrite(
MemRefType memrefType = op.getResultMemref().getType();
auto elementType = typeConverter->convertType(memrefType.getElementType());
assert(memrefType && "memref is not valid");
-
+
// Step 1: Generate a memref<0xi8> type
MemRefLayoutAttrInterface layout = {};
- auto memrefType0sz = MemRefType::get({0}, elementType, layout, memrefType.getMemorySpace());
+ auto memrefType0sz =
+ MemRefType::get({0}, elementType, layout, memrefType.getMemorySpace());
// Step 2: Generate a global symbol or existing for the dynamic shared
// memory with memref<0xi8> type
LLVM::GlobalOp shmemOp = getDynamicSharedMemorySymbol(
- rewriter, op, getTypeConverter(), memrefType0sz ,alignmentBit);
+ rewriter, op, getTypeConverter(), memrefType0sz, alignmentBit);
assert(shmemOp && "cannot find module op or failed generating global op");
// Step 3. Get address of the global symbol
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 3216e82147da..113f581e6522 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -2040,7 +2040,7 @@ LogicalResult gpu::DynamicSharedMemoryOp::verify() {
<< stringifyEnum(gpu::AddressSpace::Workgroup)
<< "> or " << int(GPUMemorySpace::kSharedMemorySpace);
}
- if(memrefType.hasStaticShape())
+ if (memrefType.hasStaticShape())
return emitOpError() << "result memref type must be memref<?xi8>";
return success();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/71546
More information about the Mlir-commits
mailing list