[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
This commit is contained in:
River Riddle 2020-03-22 03:13:40 -07:00
parent e74961eee2
commit e8f5c072f6
5 changed files with 41 additions and 20 deletions

View file

@ -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

View file

@ -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 @@ public:
}
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");

View file

@ -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

View file

@ -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

View file

@ -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();