-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·177 lines (134 loc) · 6.38 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
set(CUDA_STATIC_LIBS cme_util fspmat_csr_kernels fspmat_hyb_kernels fspmat_kron_kernels)
set(CUDA_FSP_LIBS FSPMat KryExpvFSP)
set(TESTS
test_fsp_mat
test_fsp_get_states
test_kry_expv
test_kronecker_kernel
test_hyb_kernel
test_sundials
)
set(BENCHMARKS
benchmark_fsp_mat
benchmark_sundials
)
set(PROBLEMS
hog1p_5species
)
set (EXTERNAL_LIBS
-lcusparse -lcudart -lcublas
-lsundials_cvode -lsundials_nveccuda
)
if (APPLE)
PROJECT(CUDA_FSP)
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
#set(CMAKE_CXX_COMPILER g++-8)
message("Apple")
find_package(CUDA)
set(CMAKE_CUDA_FLAGS "-lineinfo")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O2")
set(CMAKE_CUDA_SEPARABLE_COMPILATION true)
set(CMAKE_CXX_FLAGS " -O3 -std=c++11 -g")
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR})
# Where to put .a files (archive for static libraries)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Where to put .so files (dynamic libraries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Where to put the executable files
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Set the folders to include
include_directories(${CMAKE_SOURCE_DIR}/src)
#include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(/usr/local/include)
foreach (lib ${CUDA_STATIC_LIBS})
cuda_add_library(${lib} src/${lib}.h src/${lib}.cu)
target_compile_features(${lib} PUBLIC cxx_std_11)
set_target_properties(${lib} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endforeach ()
foreach (lib ${CUDA_FSP_LIBS})
cuda_add_library(${lib} SHARED src/${lib}.h src/${lib}.cu)
target_compile_features(${lib} PUBLIC cxx_std_11)
set_target_properties(${lib} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(${lib} ${CUDA_STATIC_LIBS})
endforeach ()
#target_link_libraries(FSPMat cme_util)
add_executable(dummy tests/zero_test.cpp)
target_link_libraries(dummy)
foreach (PROG ${TESTS})
cuda_add_executable(${PROG} ${CMAKE_SOURCE_DIR}/tests/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} -lcusparse)
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endforeach ()
foreach (PROG ${BENCHMARKS})
cuda_add_executable(${PROG} ${CMAKE_SOURCE_DIR}/benchmarks/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} ${CUDA_STATIC_LIBS} -lcusparse -lcudart -lcublas )
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${PROG} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
foreach (PROG ${PROBLEMS})
cuda_add_executable(${PROG} ${CMAKE_SOURCE_DIR}/problems/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} ${CUDA_STATIC_LIBS} -lcusparse -lcudart -lcublas )
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${PROG} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
else ()
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
PROJECT(CUDA_FSP LANGUAGES CXX CUDA)
# set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --compiler-options '-fPIC'")
set(CMAKE_CUDA_FLAGS "-lineinfo -O2 -DKEXPV_VERBOSE")
set(CMAKE_CUDA_SEPARABLE_COMPILATION true)
set(CMAKE_CXX_FLAGS " -g -O3 -std=c++11 ")
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR})
# Where to put .a files (archive for static libraries)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Where to put .so files (dynamic libraries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Where to put the executable files
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Set the folders to include
include_directories(${CMAKE_SOURCE_DIR}/src)
#include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(/usr/local/include)
include_directories(/usr/local/cuda/include)
include_directories(src)
add_executable(dummy tests/zero_test.cpp)
target_link_libraries(dummy)
foreach (lib ${CUDA_STATIC_LIBS})
add_library(${lib} STATIC src/${lib}.h src/${lib}.cu)
target_compile_features(${lib} PUBLIC cxx_std_11)
set_target_properties(${lib} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${lib} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
foreach (lib ${CUDA_FSP_LIBS})
add_library(${lib} src/${lib}.h src/${lib}.cu)
target_compile_features(${lib} PUBLIC cxx_std_11)
set_target_properties(${lib} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${lib} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${lib} ${CUDA_STATIC_LIBS} -larmadillo)
endforeach ()
foreach (PROG ${TESTS})
add_executable(${PROG} ${CMAKE_SOURCE_DIR}/tests/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} ${CUDA_STATIC_LIBS} ${EXTERNAL_LIBS} )
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${PROG} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
foreach (PROG ${BENCHMARKS})
add_executable(${PROG} ${CMAKE_SOURCE_DIR}/benchmarks/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} ${CUDA_STATIC_LIBS} ${EXTERNAL_LIBS} )
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${PROG} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
foreach (PROG ${PROBLEMS})
add_executable(${PROG} ${CMAKE_SOURCE_DIR}/problems/${PROG}.cu)
target_link_libraries(${PROG} ${CUDA_FSP_LIBS} ${CUDA_STATIC_LIBS} ${EXTERNAL_LIBS} )
target_compile_features(${PROG} PUBLIC cxx_std_11)
set_target_properties(${PROG} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(${PROG} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach ()
endif ()