forked from PaddlePaddle/Anakin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (131 loc) · 6.51 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
# ----------------------------------------------------------------------------
# Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved
# @file root cmakefile
# @auther cuichaowen
# @date 2017-10-24
# ----------------------------------------------------------------------------
include(cmake/thirdparty_version.cmake)
cmake_minimum_required(VERSION ${MIN_CMAKE_V} FATAL_ERROR)
project(ANAKIN C CXX)
include(cmake/msg_color.cmake)
include(cmake/utils.cmake)
include(cmake/statistic.cmake)
include(cmake/cuda.cmake)
# ----------------------------------------------------------------------------
# section: global anakin version and lib name
# ----------------------------------------------------------------------------
# global anakin version 2.0.1
set(VERSION_MAJOR "2")
set(VERSION_MINOR "0")
set(VERSION_PATCH "1")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# anakin lib name and global directories
set(anakin_lib_so "anakin")
set(anakin_lib_static "anakin_static")
# set root dir of modules
set(ANAKIN_ROOT ${PROJECT_SOURCE_DIR})
include_directories(${ANAKIN_ROOT})
set(ANAKIN_FRAMEWORK ${ANAKIN_ROOT}/framework)
set(ANAKIN_UTILS ${ANAKIN_ROOT}/utils)
set(ANAKIN_MODEL_PARSER ${ANAKIN_FRAMEWORK}/model_parser)
set(ANAKIN_SABER ${ANAKIN_ROOT}/saber)
set(ANAKIN_UNIT_TEST ${ANAKIN_ROOT}/test)
# ----------------------------------------------------------------------------
# section: options for anakin
# ----------------------------------------------------------------------------
#anakin data float precision
anakin_option(ANAKIN_TYPE_FP64 "define the FP64 for data precision." NO)
anakin_option(ANAKIN_TYPE_FP32 "define the FP32 for data precision." YES)
anakin_option(ANAKIN_TYPE_FP16 "define the FP16 for data precision." NO)
anakin_option(ANAKIN_TYPE_INT8 "define the INT8 for data precision." NO)
#select the plantform to build
anakin_option(USE_GPU_PLACE "Select the build mode for GPU place." YES)
anakin_option(USE_X86_PLACE "Select the build mode for X86 place." YES)
anakin_option(USE_ARM_PLACE "Select the build mode for ARM place." NO)
# plantfrom details
anakin_option(NVIDIA_GPU "Use NVIDIA GPU place." YES if USE_GPU_PLACE)
anakin_option(AMD_GPU "Use AMD GPU place." NO if USE_GPU_PLACE AND NOT NVIDIA_GPU)
anakin_option(TARGET_ANDROID "" NO if USE_ARM_PLACE)
anakin_option(TARGET_IOS "" NO if USE_ARM_PLACE)
# compile options for NVIDIA_GPU place
anakin_option(USE_CUDA "Use Cuda libs." YES if NVIDIA_GPU)
anakin_option(USE_CUBLAS "Use Cublas libs." YES if USE_CUDA)
anakin_option(USE_CURAND "Use Curand libs." YES if USE_CUDA)
anakin_option(USE_CUFFT "Use CuFFT libs." YES if USE_CUDA)
anakin_option(USE_CUDNN "Use Cudnn libs." YES if USE_CUDA)
anakin_option(BUILD_CROSS_PLANTFORM "Build anakin lib for any nvidia device plantform." YES if USE_CUDA)
anakin_option(BUILD_FAT_BIN "Build anakin cuda fat-bin lib for all device plantform" NO if NOT BUILD_CROSS_PLANTFORM)
if(USE_CUDA)
# Select gpu target arch for local high performance implement sass code . Now we have checked on sm_61 sm_50 and it works well.
set(SELECTED_SASS_TARGET_ARCH "61")
endif()
if((NOT BUILD_FAT_BIN) AND (NOT BUILD_CROSS_PLANTFORM) AND USE_CUDA)
# Select the only nvidia gpu arch you want to be built on
set(TARGET_GPUARCH 6.1)
endif()
# build options for cuda.
anakin_option(BUILD_CUBIN "BUILD with the -cubin option in Device mode" NO if USE_CUDA)
anakin_option(COMPILE_PTX "Returns a list of PTX files generated from src." NO if USE_CUDA)
# common build options
anakin_option(ENABLE_DEBUG "Enable DEBUG(default) mode." NO)
anakin_option(ENABLE_VERBOSE_MSG "Enable verbose=1 : compile msg during make." NO)
anakin_option(DISABLE_ALL_WARNINGS "Disable all the warning msg during compile." YES)
anakin_option(ENABLE_NOISY_WARNINGS "Enable noisy warning msg during compile." NO if DISABLE_ALL_WARNINGS)
# using 3rd party libs
anakin_option(USE_GLOG "Build Glog components." NO)
anakin_option(USE_PROTOBUF "Build Google protobuf components." YES)
#anakin_option(USE_OPENCV "Use static opencv libs." NO)
anakin_option(USE_BOOST "Use static BOOST libs." NO)
anakin_option(USE_MKL "Use static BOOST libs." NO)
anakin_option(USE_OPENMP "Use Openmp when in andriod environment." YES if TARGET_ANDROID)
anakin_option(USE_GTEST "Use googletest libs." NO if BUILD_WITH_UNIT_TEST)
anakin_option(USE_PYTHON "Generate py wrappers." NO)
anakin_option(USE_OPENCL "Use OpenCL ." NO)
anakin_option(USE_GFLAGS "Build Google gflags components." NO)
anakin_option(USE_MKLML "Use MKLML libs." YES if USE_X86_PLACE)
anakin_option(USE_XBYAK "Use XBYAK libs." YES if USE_X86_PLACE)
# build components
anakin_option(BUILD_WITH_UNIT_TEST "Build anakin unit test components." YES)
# build target
anakin_option(BUILD_SHARED "Build anakin shared lib." YES)
anakin_option(BUILD_STATIC "Build anakin static lib." YES if NOT BUILD_SHARED)
anakin_option(ENABLE_OP_TIMER "Enable op timer mode." NO)
# ----------------------------------------------------------------------------
# section: anakin compiler and linker options
# ----------------------------------------------------------------------------
if(ENABLE_DEBUG)
set(CMAKE_BUILD_TYPE Debug FORCE)
else()
set(CMAKE_BUILD_TYPE Release FORCE)
endif()
# ----------------------------------------------------------------------------
# section:configure a header file to pass some of the CMake settings to the source
# code
# ----------------------------------------------------------------------------
configure_file (
"${PROJECT_SOURCE_DIR}/cmake/config/anakin_config.h.in"
"${PROJECT_BINARY_DIR}/anakin_config.h"
)
# add the binary tree to the search path so that anakin will find ak_config.h
include_directories(${PROJECT_BINARY_DIR})
# ----------------------------------------------------------------------------
# section: find modules and configure
# ----------------------------------------------------------------------------
include(cmake/find_modules.cmake)
# check and set base compile options
include(cmake/compiler_options.cmake)
# gather all the config options to anakin
include(cmake/gather.cmake)
# ----------------------------------------------------------------------------
# section: build and install anakin
# ----------------------------------------------------------------------------
# add source sub_directory whick holds the cmake build module
# fetch files of model_parser
add_subdirectory(${ANAKIN_MODEL_PARSER})
add_subdirectory(${ANAKIN_SABER})
add_subdirectory(${ANAKIN_FRAMEWORK})
if(BUILD_WITH_UNIT_TEST)
add_subdirectory(${ANAKIN_UNIT_TEST})
endif()
anakin_print_statistic()
#set(executable_output_path ${PROJECT_BINARY_DIR}/unit_test)