[Mlir-commits] [mlir] 74ffe8d - [mlir] Remove ConvertKernelFuncToBlob

Christian Sigg llvmlistbot at llvm.org
Fri Mar 19 01:33:55 PDT 2021


Author: Christian Sigg
Date: 2021-03-19T09:33:47+01:00
New Revision: 74ffe8dc590c29f1895e7b9cabf13944ffef16cb

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

LOG: [mlir] Remove ConvertKernelFuncToBlob

All users have been converted to gpu::SerializeToBlobPass.

Reviewed By: ftynse

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

Added: 
    

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

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


################################################################################
diff  --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
index fb5e8202df63..173d8feced35 100644
--- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
+++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
@@ -60,37 +60,6 @@ createGpuToLLVMConversionPass(StringRef gpuBinaryAnnotation = {});
 void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter,
                                          OwningRewritePatternList &patterns,
                                          StringRef gpuBinaryAnnotation = {});
-
-/// Creates a pass to convert kernel functions into GPU target object blobs.
-///
-/// This transformation takes the body of each function that is annotated with
-/// the 'gpu.kernel' attribute, copies it to a new LLVM module, compiles the
-/// module with help of the GPU backend to target object and then invokes
-/// the provided blobGenerator to produce a binary blob. Such blob is then
-/// attached as a string attribute to the kernel function.
-///
-/// Following callbacks are to be provided by user:
-/// - loweringCallback : lower the module to an LLVM module.
-/// - blobGenerator : build a blob executable on target GPU.
-///
-/// Information wrt LLVM backend are to be supplied by user:
-/// - triple : target triple to be used.
-/// - targetChip : mcpu to be used.
-/// - features : target-specific features to be used.
-///
-/// Information about result attribute is to be specified by user:
-/// - gpuBinaryAnnotation : the name of the attribute which contains the blob.
-///
-/// After the transformation, the body of the kernel function is removed (i.e.,
-/// it is turned into a declaration).
-///
-/// A non-empty gpuBinaryAnnotation overrides the pass' command line option.
-std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
-createConvertGPUKernelToBlobPass(LoweringCallback loweringCallback,
-                                 BlobGenerator blobGenerator, StringRef triple,
-                                 StringRef targetChip, StringRef features,
-                                 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 d9f6867556c6..04ff2a994091 100644
--- a/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUCommon/CMakeLists.txt
@@ -16,7 +16,6 @@ endif()
 
 add_mlir_conversion_library(MLIRGPUToGPURuntimeTransforms
   ConvertLaunchFuncToRuntimeCalls.cpp
-  ConvertKernelFuncToBlob.cpp
   GPUOpsLowering.cpp
 
   DEPENDS

diff  --git a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp b/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
deleted file mode 100644
index e8f9a7a46936..000000000000
--- a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-//===- ConvertKernelFuncToBlob.cpp - MLIR GPU lowering passes -------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a pass to convert gpu kernel functions into a
-// corresponding binary blob that can be executed on a GPU. Currently
-// only translates the function itself but no dependencies.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
-
-#include "mlir/Dialect/GPU/GPUDialect.h"
-#include "mlir/Dialect/GPU/Passes.h"
-#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Pass/PassRegistry.h"
-#include "mlir/Support/LogicalResult.h"
-
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/Mutex.h"
-#include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
-
-using namespace mlir;
-
-namespace {
-
-/// A pass converting tagged kernel modules to a blob with target instructions.
-///
-/// If tagged as a kernel module, each contained function is translated to
-/// user-specified IR. A user provided BlobGenerator then compiles the IR to
-/// GPU binary code, which is then attached as an attribute to the function.
-/// The function body is erased.
-class GpuKernelToBlobPass
-    : public PassWrapper<GpuKernelToBlobPass, gpu::SerializeToBlobPass> {
-public:
-  GpuKernelToBlobPass(LoweringCallback loweringCallback,
-                      BlobGenerator blobGenerator, StringRef triple,
-                      StringRef targetChip, StringRef features,
-                      StringRef gpuBinaryAnnotation)
-      : loweringCallback(loweringCallback), blobGenerator(blobGenerator) {
-    if (!triple.empty())
-      this->triple = triple.str();
-    if (!targetChip.empty())
-      this->chip = targetChip.str();
-    if (!features.empty())
-      this->features = features.str();
-    if (!gpuBinaryAnnotation.empty())
-      this->gpuBinaryAnnotation = gpuBinaryAnnotation.str();
-  }
-
-private:
-  // Translates the 'getOperation()' result to an LLVM module.
-  // Note: when this class is removed, this function no longer needs to be
-  // virtual.
-  std::unique_ptr<llvm::Module>
-  translateToLLVMIR(llvm::LLVMContext &llvmContext) override {
-    return loweringCallback(getOperation(), llvmContext, "LLVMDialectModule");
-  }
-
-  // Serializes the target ISA to binary form.
-  std::unique_ptr<std::vector<char>>
-  serializeISA(const std::string &isa) override {
-    return blobGenerator(isa, getOperation().getLoc(),
-                         getOperation().getName());
-  }
-
-  LoweringCallback loweringCallback;
-  BlobGenerator blobGenerator;
-};
-
-} // anonymous namespace
-
-std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
-mlir::createConvertGPUKernelToBlobPass(LoweringCallback loweringCallback,
-                                       BlobGenerator blobGenerator,
-                                       StringRef triple, StringRef targetChip,
-                                       StringRef features,
-                                       StringRef gpuBinaryAnnotation) {
-  return std::make_unique<GpuKernelToBlobPass>(loweringCallback, blobGenerator,
-                                               triple, targetChip, features,
-                                               gpuBinaryAnnotation);
-}


        


More information about the Mlir-commits mailing list