[Mlir-commits] [mlir] 850cb13 - Do not build the CUBIN conversion pass when NVPTX Backend isn't configured
Mehdi Amini
llvmlistbot at llvm.org
Fri Feb 14 01:33:30 PST 2020
Author: Mehdi Amini
Date: 2020-02-14T09:33:12Z
New Revision: 850cb135a3b8f7e226a40186954599187fe0f6b2
URL: https://github.com/llvm/llvm-project/commit/850cb135a3b8f7e226a40186954599187fe0f6b2
DIFF: https://github.com/llvm/llvm-project/commit/850cb135a3b8f7e226a40186954599187fe0f6b2.diff
LOG: Do not build the CUBIN conversion pass when NVPTX Backend isn't configured
This pass would currently build, but fail to run when this backend isn't
linked in. On the other hand, we'd like it to initialize only the NVPTX
backend, which isn't possible if we continue to build it without the
backend available. Instead of building a broken configuration, let's
skip building the pass entirely.
Differential Revision: https://reviews.llvm.org/D74592
Added:
Modified:
mlir/CMakeLists.txt
mlir/include/mlir/InitAllPasses.h
mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
Removed:
################################################################################
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 4b46939aa88d..b9980c3795b3 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -44,6 +44,8 @@ if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
else()
set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
endif()
+# TODO: we should use a config.h file like LLVM does
+add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED})
set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h
index b867e0624916..6b28041bf980 100644
--- a/mlir/include/mlir/InitAllPasses.h
+++ b/mlir/include/mlir/InitAllPasses.h
@@ -90,8 +90,10 @@ 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/CMakeLists.txt b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
index a758f7b935ef..484bc9dbd89c 100644
--- a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
@@ -1,7 +1,16 @@
-add_llvm_library(MLIRGPUtoCUDATransforms
+set(LLVM_OPTIONAL_SOURCES
ConvertKernelFuncToCubin.cpp
+)
+
+set(SOURCES
ConvertLaunchFuncToCudaCalls.cpp
)
+
+if (MLIR_CUDA_CONVERSIONS_ENABLED)
+ list(APPEND SOURCES "ConvertKernelFuncToCubin.cpp")
+endif()
+
+add_llvm_library(MLIRGPUtoCUDATransforms ${SOURCES})
target_link_libraries(MLIRGPUtoCUDATransforms
MLIRGPU
MLIRLLVMIR
diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
index fe571cf31548..140026eaf643 100644
--- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -57,9 +57,10 @@ class GpuKernelToCubinPass
gpu::GPUModuleOp module = getOperation();
// Make sure the NVPTX target is initialized.
- llvm::InitializeAllTargets();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllAsmPrinters();
+ LLVMInitializeNVPTXTarget();
+ LLVMInitializeNVPTXTargetInfo();
+ LLVMInitializeNVPTXTargetMC();
+ LLVMInitializeNVPTXAsmPrinter();
auto llvmModule = translateModuleToNVVMIR(module);
if (!llvmModule)
More information about the Mlir-commits
mailing list