-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
71 lines (64 loc) · 2.63 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
cmake_minimum_required(VERSION 3.8)
project(insnet CXX)
if(CMAKE_BUILD_TYPE MATCHES debug)
add_definitions(-DN3LDG_DEBUG)
message("building n3ldg++ for debug")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3 -std=c++14 -O1 -fno-inline -ggdb3" )
elseif(CMAKE_BUILD_TYPE MATCHES profile)
message("building n3ldg++ for profile")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O2 -pg -DNDEBUG" )
else()
message("building n3ldg++ for release")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -Ofast -march=native" )
endif()
IF(USE_DOUBLE)
ADD_DEFINITIONS(-DUSE_DOUBLE)
ENDIF()
IF(TEST_CUDA)
ADD_DEFINITIONS(-DTEST_CUDA)
ENDIF()
IF(DEVICE_MEMORY)
ADD_DEFINITIONS(-DDEVICE_MEMORY)
ENDIF()
include_directories(include)
include_directories(include/fmt/include)
if(USE_CUDA)
set(CUDA_SEPARABLE_COMPILATION ON)
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math;-arch=compute_${CARD_NUMBER};-code=sm_${CARD_NUMBER};-std=c++14;-DVERBOSE;-DEIGEN_USE_GPU;-DHAVE_CUDA;")
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
if (CMAKE_BUILD_TYPE MATCHES debug)
list(APPEND CUDA_NVCC_FLAGS "-G")
list(APPEND CUDA_NVCC_FLAGS "-g")
list(APPEND CUDA_NVCC_FLAGS "-O1")
else()
list(APPEND CUDA_NVCC_FLAGS "-O3")
endif()
add_definitions(-DUSE_GPU)
find_package(CUDA REQUIRED)
find_cuda_helper_libs(curand)
set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_ROOT})
message("CUDA_INCLUDE: " ${CUDA_INCLUDE_DIRS})
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_curand_LIBRARY})
message("CUDA_LIBRARIES: ${CUDA_LIBRARIES}")
set(libs ${libs} ${CUDA_LIBRARIES})
cuda_add_library(insnet_cuda include/insnet/cuda/impl.cu)
cuda_add_cublas_to_target(insnet_cuda)
target_compile_features(insnet_cuda PUBLIC cxx_std_14)
set_target_properties(insnet_cuda PROPERTIES POSITION_INDEPENDENT_CODE ON)
set(libs ${libs} insnet_cuda)
endif()
add_subdirectory(include/fmt)
aux_source_directory(include/insnet/base insnet_src)
aux_source_directory(include/insnet/block insnet_src)
aux_source_directory(include/insnet/computation-graph insnet_src)
aux_source_directory(include/insnet/loss insnet_src)
aux_source_directory(include/insnet/nlp insnet_src)
aux_source_directory(include/insnet/operator insnet_src)
aux_source_directory(include/insnet/optimizer insnet_src)
aux_source_directory(include/insnet/param insnet_src)
aux_source_directory(include/insnet/util insnet_src)
add_library(insnet STATIC ${insnet_src})
target_include_directories(insnet PUBLIC include PUBLIC include/fmt/include)
set(libs ${libs} fmt)
target_link_libraries(insnet ${libs})