[PATCH] D74592: Do not build the CUBIN conversion pass when NVPTX Backend isn't configured

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 01:17:59 PST 2020


mehdi_amini created this revision.
mehdi_amini added a reviewer: bkramer.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, herhut, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mgorny.
Herald added a reviewer: mravishankar.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74592

Files:
  mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
  mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp


Index: mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
===================================================================
--- mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -57,9 +57,10 @@
     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)
Index: mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
===================================================================
--- mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
+++ 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)
+ append(SOURCES   ConvertKernelFuncToCubin.cpp)
+endif()
+
+add_llvm_library(MLIRGPUtoCUDATransforms ${SOURCES})
 target_link_libraries(MLIRGPUtoCUDATransforms
   MLIRGPU
   MLIRLLVMIR


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74592.244584.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200214/e0732b11/attachment.bin>


More information about the llvm-commits mailing list