[Mlir-commits] [mlir] a5f9cda - [mlir] Rename gpu-to-llvm pass implementation file

Christian Sigg llvmlistbot at llvm.org
Fri Mar 19 05:58:22 PDT 2021


Author: Christian Sigg
Date: 2021-03-19T13:58:13+01:00
New Revision: a5f9cda17333530de3d78282d10f53abfaa00906

URL: https://github.com/llvm/llvm-project/commit/a5f9cda17333530de3d78282d10f53abfaa00906
DIFF: https://github.com/llvm/llvm-project/commit/a5f9cda17333530de3d78282d10f53abfaa00906.diff

LOG: [mlir] Rename gpu-to-llvm pass implementation file

Also remove populate patterns function and binary annotation name option.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D98930

Added: 
    mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp

Modified: 
    mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
    mlir/lib/Conversion/GPUCommon/CMakeLists.txt

Removed: 
    mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp


################################################################################
diff  --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
index 173d8feced35..878861e406e4 100644
--- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
+++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
@@ -43,23 +43,14 @@ using BlobGenerator =
 using LoweringCallback = std::function<std::unique_ptr<llvm::Module>(
     Operation *, llvm::LLVMContext &, StringRef)>;
 
-/// Creates a pass to convert a gpu.launch_func operation into a sequence of
-/// GPU runtime calls.
+/// Creates a pass to convert a GPU operations into a sequence of GPU runtime
+/// calls.
 ///
 /// This pass does not generate code to call GPU runtime APIs directly but
 /// instead uses a small wrapper library that exports a stable and conveniently
 /// typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP).
-///
-/// A non-empty gpuBinaryAnnotation overrides the pass' command line option.
-std::unique_ptr<OperationPass<ModuleOp>>
-createGpuToLLVMConversionPass(StringRef gpuBinaryAnnotation = {});
+std::unique_ptr<OperationPass<ModuleOp>> createGpuToLLVMConversionPass();
 
-/// Collect a set of patterns to convert from the GPU dialect to LLVM.
-///
-/// A non-empty gpuBinaryAnnotation overrides the pass' command line option.
-void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter,
-                                         OwningRewritePatternList &patterns,
-                                         StringRef gpuBinaryAnnotation = {});
 } // namespace mlir
 
 #endif // MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_

diff  --git a/mlir/lib/Conversion/GPUCommon/CMakeLists.txt b/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
index 04ff2a994091..65ad9de0b20c 100644
--- a/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
@@ -15,7 +15,7 @@ if (MLIR_ROCM_CONVERSIONS_ENABLED)
 endif()
 
 add_mlir_conversion_library(MLIRGPUToGPURuntimeTransforms
-  ConvertLaunchFuncToRuntimeCalls.cpp
+  GPUToLLVMConversion.cpp
   GPUOpsLowering.cpp
 
   DEPENDS

diff  --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
similarity index 98%
rename from mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
rename to mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
index 0e3bf166c47e..d490c5247a9f 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
@@ -41,10 +41,7 @@ namespace {
 class GpuToLLVMConversionPass
     : public GpuToLLVMConversionPassBase<GpuToLLVMConversionPass> {
 public:
-  GpuToLLVMConversionPass(StringRef gpuBinaryAnnotation) {
-    if (!gpuBinaryAnnotation.empty())
-      this->gpuBinaryAnnotation = gpuBinaryAnnotation.str();
-  }
+  GpuToLLVMConversionPass() = default;
 
   GpuToLLVMConversionPass(const GpuToLLVMConversionPass &other)
       : GpuToLLVMConversionPassBase(other) {}
@@ -318,7 +315,21 @@ void GpuToLLVMConversionPass::runOnOperation() {
   populateStdToLLVMConversionPatterns(converter, patterns);
   populateAsyncStructuralTypeConversionsAndLegality(&getContext(), converter,
                                                     patterns, target);
-  populateGpuToLLVMConversionPatterns(converter, patterns, gpuBinaryAnnotation);
+
+  converter.addConversion(
+      [context = &converter.getContext()](gpu::AsyncTokenType type) -> Type {
+        return LLVM::LLVMPointerType::get(IntegerType::get(context, 8));
+      });
+  patterns.insert<ConvertAllocOpToGpuRuntimeCallPattern,
+                  ConvertDeallocOpToGpuRuntimeCallPattern,
+                  ConvertHostRegisterOpToGpuRuntimeCallPattern,
+                  ConvertMemcpyOpToGpuRuntimeCallPattern,
+                  ConvertWaitAsyncOpToGpuRuntimeCallPattern,
+                  ConvertWaitOpToGpuRuntimeCallPattern,
+                  ConvertAsyncYieldToGpuRuntimeCallPattern>(converter);
+  patterns.insert<ConvertLaunchFuncOpToGpuRuntimeCallPattern>(
+      converter, gpuBinaryAnnotation);
+  patterns.insert<EraseGpuModuleOpPattern>(&converter.getContext());
 
   if (failed(
           applyPartialConversion(getOperation(), target, std::move(patterns))))
@@ -784,25 +795,6 @@ LogicalResult ConvertMemcpyOpToGpuRuntimeCallPattern::matchAndRewrite(
 }
 
 std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
-mlir::createGpuToLLVMConversionPass(StringRef gpuBinaryAnnotation) {
-  return std::make_unique<GpuToLLVMConversionPass>(gpuBinaryAnnotation);
-}
-
-void mlir::populateGpuToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, OwningRewritePatternList &patterns,
-    StringRef gpuBinaryAnnotation) {
-  converter.addConversion(
-      [context = &converter.getContext()](gpu::AsyncTokenType type) -> Type {
-        return LLVM::LLVMPointerType::get(IntegerType::get(context, 8));
-      });
-  patterns.insert<ConvertAllocOpToGpuRuntimeCallPattern,
-                  ConvertDeallocOpToGpuRuntimeCallPattern,
-                  ConvertHostRegisterOpToGpuRuntimeCallPattern,
-                  ConvertMemcpyOpToGpuRuntimeCallPattern,
-                  ConvertWaitAsyncOpToGpuRuntimeCallPattern,
-                  ConvertWaitOpToGpuRuntimeCallPattern,
-                  ConvertAsyncYieldToGpuRuntimeCallPattern>(converter);
-  patterns.insert<ConvertLaunchFuncOpToGpuRuntimeCallPattern>(
-      converter, gpuBinaryAnnotation);
-  patterns.insert<EraseGpuModuleOpPattern>(&converter.getContext());
+mlir::createGpuToLLVMConversionPass() {
+  return std::make_unique<GpuToLLVMConversionPass>();
 }


        


More information about the Mlir-commits mailing list