forked from Sofranac-Boro/gpu-domain-propagator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
101 lines (77 loc) · 2.96 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
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(gpu-domain-propagator LANGUAGES CUDA CXX)
#python3
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
# CUDA
find_package(CUDA 10.0 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 11)
#OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
SET(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS} ")
endif ()
if (ARCH)
string(APPEND CMAKE_CUDA_FLAGS " -gencode=arch=compute_${ARCH},code=sm_${ARCH}")
else ()
message("No CUDA architecture specified. To compile optimized code for your CUDA device please specify your device architecture through the ARCH flag.")
endif ()
if("${FASTMATH}" STREQUAL "On")
message("Enabling fast math setting. This might cause floating point trouble!")
string(APPEND CMAKE_CUDA_FLAGS " --use_fast_math")
endif()
# make 'Release' the default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
# add_definitions(-DVERBOSE -DDEBUG)
add_definitions(-DVERBOSE=1 -DDEBUG)
string(APPEND CMAKE_CUDA_FLAGS_DEBUG " -G")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
# add_definitions(-DVERBOSE -DDEBUG)
add_definitions(-DVERBOSE=1)
string(APPEND CMAKE_CUDA_FLAGS_DEBUG " -G")
endif()
if("${VERBOSITY}" STREQUAL 1)
add_definitions(-DVERBOSE=1)
endif()
if("${VERBOSITY}" STREQUAL 2)
add_definitions(-DVERBOSE=2)
endif()
if (FOLLOW_VAR)
add_definitions(-DFOLLOW_VAR=${FOLLOW_VAR})
endif()
if (FOLLOW_CONS)
add_definitions(-DFOLLOW_CONS=${FOLLOW_CONS})
endif()
add_library(GpuProp SHARED
src/misc.cpp
src/kernels/util_kernels.cu
src/propagation_methods.cu
src/interface.cu)
# build with -std=c++11. PUBLIC will make anything linking to this to also build with c++11
# position independent code, -fPIC
# -dc - separable compilation
target_compile_features(GpuProp PUBLIC cxx_std_11)
set_target_properties(GpuProp PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(GpuProp PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET GpuProp PROPERTY CUDA_ARCHITECTURES ${ARCH})
target_link_libraries(GpuProp ${CUDA_cusparse_LIBRARY})
add_executable(testexec test/test_main.cu
src/misc.cpp
src/kernels/util_kernels.cu
src/propagation_methods.cu
test/test_infra.cu
src/interface.cu)
set_property(TARGET testexec PROPERTY CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET testexec PROPERTY CUDA_ARCHITECTURES ${ARCH})
set_target_properties(testexec PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(testexec ${CUDA_cusparse_LIBRARY} GpuProp)
add_executable(gdp src/main.cpp)
target_link_libraries(gdp GpuProp ${PYTHON_LIBRARIES})