[Mlir-commits] [mlir] e8f5c07 - [mlir] Move the testing pass for GpuKernelToCubin to the test/ directory
River Riddle
llvmlistbot at llvm.org
Sun Mar 22 03:39:10 PDT 2020
Author: River Riddle
Date: 2020-03-22T03:38:09-07:00
New Revision: e8f5c072f6df444f6baea91a3533509cf4a3779f
URL: https://github.com/llvm/llvm-project/commit/e8f5c072f6df444f6baea91a3533509cf4a3779f
DIFF: https://github.com/llvm/llvm-project/commit/e8f5c072f6df444f6baea91a3533509cf4a3779f.diff
LOG: [mlir] Move the testing pass for GpuKernelToCubin to the test/ directory
Summary:
This removes the static pass registration, and also cleans up some lingering technical debt.
Differential Revision: https://reviews.llvm.org/D76554
Added:
mlir/test/lib/Transforms/TestConvertGPUKernelToCubin.cpp
Modified:
mlir/include/mlir/InitAllPasses.h
mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
mlir/test/lib/Transforms/CMakeLists.txt
mlir/tools/mlir-opt/mlir-opt.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h
index 711b88412a6d..2de889841849 100644
--- a/mlir/include/mlir/InitAllPasses.h
+++ b/mlir/include/mlir/InitAllPasses.h
@@ -97,10 +97,6 @@ inline void registerAllPasses() {
// CUDA
createConvertGpuLaunchFuncToCudaCallsPass();
-#if MLIR_CUDA_CONVERSIONS_ENABLED
- createConvertGPUKernelToCubinPass(
- [](const std::string &, Location, StringRef) { return nullptr; });
-#endif
createLowerGpuOpsToNVVMOpsPass();
// Linalg
diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
index 140026eaf643..1640978b3a18 100644
--- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -49,8 +49,7 @@ static constexpr const char *kCubinAnnotation = "nvvm.cubin";
class GpuKernelToCubinPass
: public OperationPass<GpuKernelToCubinPass, gpu::GPUModuleOp> {
public:
- GpuKernelToCubinPass(
- CubinGenerator cubinGenerator = compilePtxToCubinForTesting)
+ GpuKernelToCubinPass(CubinGenerator cubinGenerator)
: cubinGenerator(cubinGenerator) {}
void runOnOperation() override {
@@ -76,9 +75,6 @@ class GpuKernelToCubinPass
}
private:
- static OwnedCubin compilePtxToCubinForTesting(const std::string &ptx,
- Location, StringRef);
-
std::string translateModuleToPtx(llvm::Module &module,
llvm::TargetMachine &target_machine);
@@ -112,13 +108,6 @@ std::string GpuKernelToCubinPass::translateModuleToPtx(
return ptx;
}
-OwnedCubin
-GpuKernelToCubinPass::compilePtxToCubinForTesting(const std::string &ptx,
- Location, StringRef) {
- const char data[] = "CUBIN";
- return std::make_unique<std::vector<char>>(data, data + sizeof(data) - 1);
-}
-
OwnedCubin GpuKernelToCubinPass::convertModuleToCubin(llvm::Module &llvmModule,
Location loc,
StringRef name) {
@@ -158,7 +147,3 @@ std::unique_ptr<OpPassBase<gpu::GPUModuleOp>>
mlir::createConvertGPUKernelToCubinPass(CubinGenerator cubinGenerator) {
return std::make_unique<GpuKernelToCubinPass>(cubinGenerator);
}
-
-static PassRegistration<GpuKernelToCubinPass>
- pass("test-kernel-to-cubin",
- "Convert all kernel functions to CUDA cubin blobs");
diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt
index e90099203b43..9340e89a3b90 100644
--- a/mlir/test/lib/Transforms/CMakeLists.txt
+++ b/mlir/test/lib/Transforms/CMakeLists.txt
@@ -2,6 +2,7 @@ add_llvm_library(MLIRTestTransforms
TestAllReduceLowering.cpp
TestCallGraph.cpp
TestConstantFold.cpp
+ TestConvertGPUKernelToCubin.cpp
TestLoopFusion.cpp
TestGpuMemoryPromotion.cpp
TestGpuParallelLoopMapping.cpp
@@ -39,6 +40,7 @@ target_link_libraries(MLIRTestTransforms
MLIRAnalysis
MLIREDSC
MLIRGPU
+ MLIRGPUtoCUDATransforms
MLIRLinalgOps
MLIRLinalgTransforms
MLIRLoopOps
diff --git a/mlir/test/lib/Transforms/TestConvertGPUKernelToCubin.cpp b/mlir/test/lib/Transforms/TestConvertGPUKernelToCubin.cpp
new file mode 100644
index 000000000000..2a2259547b37
--- /dev/null
+++ b/mlir/test/lib/Transforms/TestConvertGPUKernelToCubin.cpp
@@ -0,0 +1,34 @@
+//===- TestConvertGPUKernelToCubin.cpp - Test gpu kernel cubin lowering ---===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassManager.h"
+
+using namespace mlir;
+
+namespace {
+static OwnedCubin compilePtxToCubinForTesting(const std::string &, Location,
+ StringRef) {
+ const char data[] = "CUBIN";
+ return std::make_unique<std::vector<char>>(data, data + sizeof(data) - 1);
+}
+} // end anonymous namespace
+
+#if MLIR_CUDA_CONVERSIONS_ENABLED
+namespace mlir {
+void registerTestConvertGPUKernelToCubinPass() {
+ PassPipelineRegistration<>("test-kernel-to-cubin",
+ "Convert all kernel functions to CUDA cubin blobs",
+ [](OpPassManager &pm) {
+ pm.addPass(createConvertGPUKernelToCubinPass(
+ compilePtxToCubinForTesting));
+ });
+}
+} // namespace mlir
+#endif
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index 25650709b1a1..ff0f49f987b6 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -41,6 +41,7 @@ void registerTestAffineDataCopyPass();
void registerTestAllReduceLoweringPass();
void registerTestCallGraphPass();
void registerTestConstantFold();
+void registerTestConvertGPUKernelToCubinPass();
void registerTestFunc();
void registerTestGpuMemoryPromotionPass();
void registerTestLinalgTransforms();
@@ -96,6 +97,9 @@ void registerTestPasses() {
registerTestAllReduceLoweringPass();
registerTestCallGraphPass();
registerTestConstantFold();
+#if MLIR_CUDA_CONVERSIONS_ENABLED
+ registerTestConvertGPUKernelToCubinPass();
+#endif
registerTestFunc();
registerTestGpuMemoryPromotionPass();
registerTestLinalgTransforms();
More information about the Mlir-commits
mailing list