-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path999-build-everything
executable file
·181 lines (151 loc) · 5.98 KB
/
999-build-everything
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
itb_exit() {
local -i ec=$?
if [[ -n "${BASH_VERSION}" ]]; then
local -i n=${#BASH_SOURCE[@]}
local -r recipe_name="${BASH_SOURCE[n]}"
else
local -r recipe_name="${ZSH_ARGZERO}"
fi
echo -n "${recipe_name}: "
if (( ec == 0 )); then
echo "done!"
elif (( ec == ITB_ERR_ARG )); then
echo "argument error!"
elif (( ec == ITB_ERR_SETUP )); then
echo "error in setting everything up!"
elif (( ec == ITB_ERR_SYSTEM )); then
echo "unexpected system error!"
elif (( ec == ITB_ERR_DOWNLOAD )); then
echo "error in downloading the source file!"
elif (( ec == ITB_ERR_UNTAR )); then
echo "error in un-taring the source file!"
elif (( ec == ITB_ERR_CONFIGURE )); then
echo "error in configuring the software!"
elif (( ec == ITB_ERR_MAKE )); then
echo "error in compiling the software!"
elif (( ec == ITB_ERR_PRE_INSTALL )); then
echo "error in pre-installing the software!"
elif (( ec == ITB_ERR_INSTALL )); then
echo "error in installing the software!"
elif (( ec == ITB_ERR_POST_INSTALL )); then
echo "error in post-installing the software!"
else
echo "oops, unknown error!!!"
fi
exit ${ec}
}
export -f itb_exit > /dev/null
# General build parameters
export build_type=
compiler=${compiler:-$(which g++)}
export compiler
mode=Release
export ITB_DOWNLOAD_DIR=${ITB_DOWNLOAD_DIR:-$PWD}
export ITB_SRC_DIR=${ITB_SRC_DIR:-$PWD}
export ITB_PREFIX=${ITB_PREFIX:-$PWD}
# Build targets
build_kokkos=false
build_heffte=false
build_ippl=false
# Kokkos backends
CUDA=OFF
OPENMP=OFF
SERIAL=OFF
GPU_ARCH=AMPERE80
CPU_ARCH=NATIVE
# heFFTe backends
CUFFT=OFF
FFTW=OFF
MKL=OFF
# IPPL settings
export ENABLE_FFT=ON
export ENABLE_ALPINE=ON
export ENABLE_UNIT_TESTS=ON
EXPORT_COMMANDS=
function help() {
echo "Usage: $0 [flags...]"
echo "For long form options, arguments must be given after an equal sign (--opt=arg)."
echo "Refer to the comments in this shell script for additional details."
echo "Flags:"
echo " -h|--help: show this help"
echo " -t|--target target: preset build for target (cuda/openmp/serial) or name for custom build;"
echo " this flag is REQUIRED as it will be used to identify the build directories"
# Kokkos configuration
echo " --enable-cuda: enable CUDA for Kokkos"
echo " --enable-openmp: enable OpenMP for Kokkos"
echo " --enable-serial: enable serial for Kokkos"
# Architectures: https://kokkos.github.io/kokkos-core-wiki/keywords.html#keywords-arch
echo " -g|--cudacc capability: set GPU compute capability for Kokkos CUDA (default Ampere 80, written as AMPERE80)"
echo " -c|--cpu arch: set CPU architecture for Kokkos optimizations (default local machine, i.e. NATIVE)"
# heFFTe configuration
echo " --enable-cufft: enable cuFFT for heFFTe"
echo " --enable-fftw: enable FFTW for heFFTe"
echo " --enable-mkl: enable MKL for heFFTe"
# IPPL configuration
echo " -p|--nofft: disable FFTs in IPPL (default enabled)"
echo " -u|--nounit: disable IPPL unit tests"
# LSP: language server protocol (https://en.wikipedia.org/wiki/Language_Server_Protocol)
# CMake can be configured to export information that would allow certain editor tools (like clangd)
# to provide language- and program-aware diagnostics, such as signature mismatches or other
# symbol-related errors.
echo " --export: export IPPL compile commands for LSPs (such as clangd)"
# General build configuration
echo " -d|--debug: debug build"
echo " --mode build_mode: set build mode directly (Release, Debug, etc)"
# Choose build targets
echo " -k|--kokkos: configure and build Kokkos"
echo " -f|--heffte: configure and build heFFTe"
echo " -i|--ippl: configure and build IPPL"
}
# POSIX compliant long options with getopts:
# https://stackoverflow.com/a/28466267/2773311
die() { echo "$1"; exit 1; }
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$opt option"; fi; }
while getopts "ht:dkfic:pug:-:" opt; do
if [ "$opt" = "-" ]; then # long option: reformulate OPT and OPTARG
opt="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#"$opt"}" # extract long option argument (may be empty)
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi
case $opt in
h | help) help; exit 0 ;;
t | target) needs_arg; build_type=$OPTARG ;;
d | debug) mode=Debug ;;
mode) mode=$OPTARG ;;
k | kokkos) build_kokkos=true ;;
f | heffte) build_heffte=true ;;
i | ippl) build_ippl=true ;;
p | nofft) ENABLE_FFT=OFF; ENABLE_ALPINE=OFF ;;
u | nounit) ENABLE_UNIT_TESTS=OFF ;;
export) EXPORT_COMMANDS="-DCMAKE_EXPORT_COMPILE_COMMANDS=1" ;;
g | cudacc) needs_arg; GPU_ARCH=$OPTARG ;;
c | cpu) needs_arg; CPU_ARCH=$OPTARG ;;
enable-cuda) CUDA=ON ;;
enable-openmp) OPENMP=ON ;;
enable-serial) SERIAL=ON ;;
enable-cufft) CUFFT=ON ;;
enable-fftw) FFTW=ON ;;
enable-mkl) MKL=ON ;;
?) exit 1 ;;
esac
done
if [ -z "$build_type" ]; then
echo "No build target specified. Run $0 --help for more details."
exit 1
fi
export Kokkos_DIR=${Kokkos_DIR:-"${ITB_PREFIX}_${build_type}"}
export Heffte_DIR=${Heffte_DIR:-"${ITB_PREFIX}_${build_type}"}
if [ $build_kokkos == true ]; then
build_type=$build_type compute_capability=$GPU_ARCH cpu_arch=$CPU_ARCH \
ITB_PREFIX="$Kokkos_DIR" CUDA=$CUDA OPENMP=$OPENMP SERIAL=$SERIAL \
"$(dirname "$0")"/100-build-kokkos
fi
if [ $build_heffte == true ]; then
backend='' build_type=$build_type \
ITB_PREFIX="$Heffte_DIR" CUFFT=$CUFFT FFTW=$FFTW MKL=$MKL \
"$(dirname "$0")"/200-build-heffte
fi
if [ $build_ippl == true ]; then
ITB_PREFIX="${ITB_PREFIX}_${build_type}" ADDITIONAL_CMAKE_FLAGS=$EXPORT_COMMANDS build_mode=$mode "$(dirname "$0")"/300-build-ippl
fi