-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
120 lines (99 loc) · 4.03 KB
/
CMakeLists.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
cmake_minimum_required(VERSION 3.18)
project(culip LANGUAGES CXX CUDA)
find_package(CUDA 10.0 REQUIRED)
find_package(CUDAToolkit REQUIRED)
find_package(Git REQUIRED)
# CUDA/CXX
foreach(lang CXX CUDA)
set(CMAKE_${lang}_STANDARD 14)
set(CMAKE_${lang}_STANDARD_REQUIRED ON)
set(CMAKE_${lang}_EXTENSIONS OFF)
endforeach()
# CUDA (1/2)
SET(CMAKE_CUDA_ARCHITECTURES 70 75 80 86)
# Directories
set(INCDIR include)
set(SRCDIR src)
file(GLOB HEADERS "${INCDIR}/CULiP/*.hpp")
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda-exponent-distribution-statistics/Makefile)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endif()
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda-cutoff-small-abs-values/Makefile)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endif()
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/json/CMakeLists.txt)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endif()
foreach(library cublas)
set(lib_name culip_${library})
set(exp_lib_home ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda-exponent-distribution-statistics)
set(cutoff_lib_home ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda-cutoff-small-abs-values)
include_directories(${lib_name} PRIVATE ${exp_lib_home}/include ${exp_lib_home}/src/cutf/include)
include_directories(${lib_name} PRIVATE ${cutoff_lib_home}/include ${cutoff_lib_home}/src/cutf/include)
add_library(${lib_name} SHARED
${SRCDIR}/${library}.cu
${SRCDIR}/utils.cu
${SRCDIR}/utils.hpp
${SRCDIR}/params.hpp
${exp_lib_home}/src/main.cu
${cutoff_lib_home}/src/main.cu
${HEADERS}
)
target_include_directories(${lib_name} PUBLIC ${INCDIR})
target_link_libraries(${lib_name} PRIVATE
cuda
cublas_static
cublasLt_static
culibos
)
set_target_properties(${lib_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${lib_name} PROPERTIES PUBLIC_HEADER ${INCDIR}/CULiP/${library}.hpp)
endforeach()
##########################################################################
# Installing
##########################################################################
install(TARGETS culip_cublas
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/CULiP
)
##########################################################################
# Tests
##########################################################################
# Directory
set(TESTSRCDIR tests)
foreach(test cublas)
set(test_out ${test}.test)
add_executable(${test_out} ${TESTSRCDIR}/${test}_test.cu ${HEADERS})
target_include_directories(${test_out} PRIVATE ${INCDIR})
target_link_libraries(${test_out} PRIVATE culip_${test})
target_link_libraries(${test_out} PRIVATE
CUDA::${test}
)
endforeach()
##########################################################################
# Analyzer
##########################################################################
add_executable(CULiP_analyzer ${SRCDIR}/analyzer.cpp ${SRCDIR}/params.hpp)
target_include_directories(CULiP_analyzer PRIVATE ${INCDIR})
set_target_properties(CULiP_analyzer PROPERTIES RUNTIME CULiP_analyzer)
##########################################################################
# ExpStats Analyzer
##########################################################################
add_executable(CULiP_exp_stats_analyzer ${SRCDIR}/exp_stats_analyzer.cpp)
set(jsonlib ${CMAKE_CURRENT_SOURCE_DIR}/src/json)
include_directories(CULiP_exp_stats_analyzer PRIVATE ${jsonlib}/include)
target_include_directories(CULiP_exp_stats_analyzer PRIVATE ${INCDIR})
##########################################################################
# Installing
##########################################################################
install(TARGETS culip_cublas CULiP_analyzer
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/CULiP
RUNTIME DESTINATION bin
)