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
This commit is contained in:
parent
07211d951d
commit
850cb135a3
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -57,9 +57,10 @@ public:
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue