CMakeLists.txt
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
set(LLVM_OPTIONAL_SOURCES
cuda-runtime-wrappers.cpp
mlir-cuda-runner.cpp
)
if(MLIR_CUDA_RUNNER_ENABLED)
if (NOT ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD))
message(SEND_ERROR
"Building the mlir cuda runner requires the NVPTX backend")
endif()
# Configure CUDA runner support. Using check_language first allows us to give
# a custom error message.
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
enable_language(CUDA)
else()
message(SEND_ERROR
"Building the mlir cuda runner requires a working CUDA install")
endif()
# We need the libcuda.so library.
find_library(CUDA_RUNTIME_LIBRARY cuda)
add_llvm_library(cuda-runtime-wrappers SHARED
cuda-runtime-wrappers.cpp
)
target_include_directories(cuda-runtime-wrappers
PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
LLVMSupport
)
target_link_libraries(cuda-runtime-wrappers
LLVMSupport
${CUDA_RUNTIME_LIBRARY}
)
set(FULL_LINK_LIBS
MLIRAffineOps
MLIRLoopToStandard
MLIRGPU
MLIRGPUtoCUDATransforms
MLIRGPUtoNVVMTransforms
MLIRLLVMIR
MLIRStandardOps
MLIRStandardToLLVM
MLIRTargetLLVMIR
MLIRTransforms
MLIRTranslation
)
set(LIBS
MLIRIR
MLIRParser
MLIREDSC
MLIRAnalysis
MLIRExecutionEngine
MLIRJitRunner
MLIRSupport
LLVMCore
LLVMSupport
${CUDA_RUNTIME_LIBRARY}
)
add_llvm_tool(mlir-cuda-runner
mlir-cuda-runner.cpp
)
add_dependencies(mlir-cuda-runner cuda-runtime-wrappers)
target_include_directories(mlir-cuda-runner
PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
llvm_update_compile_flags(mlir-cuda-runner)
whole_archive_link(mlir-cuda-runner ${FULL_LINK_LIBS})
target_link_libraries(mlir-cuda-runner PRIVATE ${FULL_LINK_LIBS} ${LIBS})
endif()