forked from ml-opt/dnn_opt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (55 loc) · 2.56 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(dnn_opt)
SET(ENABLE_CORE ON)
SET(ENABLE_COPT OFF)
SET(ENABLE_CUDA OFF)
SET(ENABLE_EXAMPLE ON)
INCLUDE_DIRECTORIES(src)
############################## CORE SETTINGS #################################
IF(ENABLE_CORE)
ADD_DEFINITIONS(-DENABLE_CORE)
FILE(GLOB_RECURSE CORE_SRC "src/core/*.cpp" "src/core/*.h")
ADD_LIBRARY(dnn_opt_core ${CORE_SRC})
SET_TARGET_PROPERTIES(dnn_opt_core PROPERTIES CXX_STANDARD 11 CXXSTANDARD_REQUIRED YES)
SET_TARGET_PROPERTIES(dnn_opt_core PROPERTIES LINKER_LANGUAGE CXX)
ENDIF(ENABLE_CORE)
############################## COPT SETTINGS #################################
IF(ENABLE_COPT)
ADD_DEFINITIONS(-DENABLE_COPT)
FIND_PACKAGE(BLAS REQUIRED)
INCLUDE(FindOpenMP)
INCLUDE_DIRECTORIES(${BLAS_INCLUDE_DIR} ${LAPACK_INCLUDE_DIR})
SET(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${BLAS_LINKER_FLAGS})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
FILE(GLOB_RECURSE COPT_SRC "src/copt/*.cpp" "src/copt/*.h")
ADD_LIBRARY(dnn_opt_copt ${COPT_SRC})
TARGET_LINK_LIBRARIES(dnn_opt_copt dnn_opt_core ${BLAS_LIBRARIES})
SET_TARGET_PROPERTIES(dnn_opt_copt PROPERTIES CXX_STANDARD 11 CXXSTANDARD_REQUIRED YES)
SET_TARGET_PROPERTIES(dnn_opt_copt PROPERTIES LINKER_LANGUAGE CXX)
ENDIF(ENABLE_COPT)
############################## CUDA SETTINGS #################################
IF(ENABLE_CUDA)
ADD_DEFINITIONS(-DENABLE_CUDA)
FIND_PACKAGE(CUDA REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# This is because a cuda-7 bug when using gcc-5
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_MWAITXINTRIN_H_INCLUDED")
FILE(GLOB_RECURSE CUDA_SRC "src/cuda/*.cu")
CUDA_COMPILE(CUDA ${CUDA_SRC} )
CUDA_ADD_LIBRARY(dnn_opt_cuda ${CUDA})
TARGET_LINK_LIBRARIES(dnn_opt_cuda dnn_opt_copt dnn_opt_core -L/usr/lib/cuda/lib64 -lcurand -lcublas)
ENDIF(ENABLE_CUDA)
############################### MPI SETTINGS #################################
#FIND_PACKAGE(MPI REQUIRED)
#SET(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
#SET(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
#INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
#TARGET_LINK_LIBRARIES(DNN_OPT ${MPI_LIBRARIES})
################################# EXAMPLES ###################################
IF(ENABLE_EXAMPLE)
add_subdirectory(examples/benchmark)
add_subdirectory(examples/neural)
add_subdirectory(examples/hpo)
ENDIF(ENABLE_EXAMPLE)