-
Notifications
You must be signed in to change notification settings - Fork 58
/
configure
executable file
·144 lines (126 loc) · 3.24 KB
/
configure
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
#!/bin/bash
set -e
cd $(dirname $0)
. ./scripts/utils/measure.sh
if [ -z "${BUILD_GTEST}" ]; then
BUILD_GTEST=0 # download and build gtest from source
fi
BUILD_TENSORFLOW_OPS=0
BUILD_TESTS=0 # build unit tests
BUILD_TOOLS=0
ENABLE_MPI=0
ENABLE_NCCL=0
ENABLE_TRACE=0
VERBOSE=0
# defaults
NCCL_HOME=$HOME/local/nccl
MPI_HOME=$HOME/local/openmpi
parse_args() {
for i in "$@"; do
case $i in
--prefix=*)
PREFIX="${i#*=}"
;;
--build-tensorflow-ops)
BUILD_TENSORFLOW_OPS=1
;;
--build-tools)
BUILD_TOOLS=1
;;
--build-gtest)
BUILD_GTEST=1
;;
--build-tests)
BUILD_TESTS=1
;;
--no-tests)
BUILD_TESTS=0
;;
--disable-cxx11-abi)
DISABLE_CXX11_ABI=1
;;
--enable-trace)
ENABLE_TRACE=1
;;
--enable-mpi)
ENABLE_MPI=1
;;
--enable-nccl)
ENABLE_NCCL=1
;;
--with-mpi=*)
MPI_HOME="${i#*=}"
ENABLE_MPI=1
;;
--with-nccl=*)
NCCL_HOME="${i#*=}"
ENABLE_NCCL=1
;;
--verbose)
VERBOSE=1
;;
*)
echo "unknown argument $i"
exit 1
;;
esac
done
}
CMAKE_FLAGS=
add_cmake_flag() {
echo "using $1=$2"
CMAKE_FLAGS="$CMAKE_FLAGS -D$1=$2"
}
add_cmake_flags() {
if [ ${BUILD_GTEST} = 1 ] && [ ! -z ${GTEST_GIT_URL} ]; then
add_cmake_flag GTEST_GIT_URL ${GTEST_GIT_URL}
fi
if [ ! -z ${ENABLE_TRACE} ]; then
add_cmake_flag KUNGFU_ENABLE_TRACE ${ENABLE_TRACE}
if [ ! -z ${STDTRACER_GIT_URL} ]; then
add_cmake_flag STDTRACER_GIT_URL ${STDTRACER_GIT_URL}
fi
fi
if [ ${BUILD_TENSORFLOW_OPS} = 1 ]; then
if [ -z "${PYTHON}" ]; then
PYTHON=$(which python3)
fi
add_cmake_flag PYTHON $PYTHON
fi
add_cmake_flag CMAKE_PREFIX_PATH "$HOME/local;$HOME/local/gtest"
add_cmake_flag CMAKE_BUILD_TYPE Release
add_cmake_flag LIBRARY_OUTPUT_PATH $(pwd)/lib
add_cmake_flag CMAKE_RUNTIME_OUTPUT_DIRECTORY $(pwd)/bin
add_cmake_flag CMAKE_VERBOSE_MAKEFILE ${VERBOSE}
add_cmake_flag CMAKE_EXPORT_COMPILE_COMMANDS ${VERBOSE}
add_cmake_flag KUNGFU_BUILD_GTEST ${BUILD_GTEST}
add_cmake_flag KUNGFU_BUILD_TESTS ${BUILD_TESTS}
add_cmake_flag KUNGFU_BUILD_TF_OPS ${BUILD_TENSORFLOW_OPS}
add_cmake_flag KUNGFU_BUILD_TOOLS ${BUILD_TOOLS}
add_cmake_flag DISABLE_CXX11_ABI $DISABLE_CXX11_ABI
if [ ! -z ${PREFIX} ]; then
add_cmake_flag CMAKE_INSTALL_PREFIX ${PREFIX}
fi
if [ ${ENABLE_MPI} -gt 0 ]; then
add_cmake_flag MPI_HOME ${MPI_HOME}
fi
if [ ${ENABLE_NCCL} -gt 0 ]; then
add_cmake_flag NCCL_HOME ${NCCL_HOME}
add_cmake_flag KUNGFU_ENABLE_NCCL 1
fi
if [ $(uname) = "Linux" ]; then
add_cmake_flag KUNGFU_ENABLE_AFFINITY 1
fi
}
cleanup_cmake_cache() {
if [ -f CMakeCache.txt ]; then
rm CMakeCache.txt
fi
}
main() {
parse_args $@
add_cmake_flags
cleanup_cmake_cache
cmake . $CMAKE_FLAGS
}
measure main $@