forked from UoB-HPC/BabelStream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-prepare-bionic.sh
executable file
·375 lines (309 loc) · 10.1 KB
/
ci-prepare-bionic.sh
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
#!/usr/bin/env bash
set -eu
WORK_DIR="${1:-.}"
MODE="${2:-SETUP}"
PARALLEL="${3:-false}"
FORCE_DOWNLOAD=false
if [ "$_" = "$0" ]; then
echo "This script must be sourced for the exports to work!"
exit 1
fi
case "$MODE" in
SETUP)
SETUP=true
echo "Preparing env with setup..."
;;
VARS)
SETUP=false
echo "Preparing env without setup..."
;;
*)
echo "Bad option"
echo "$0 <work_dir:dir> <VARS|SETUP> <parallel:bool>"
exit 1
;;
esac
mkdir -p "$WORK_DIR"
PREV_DIR="$PWD"
cd "$WORK_DIR" || exit 1
export_var() {
export "$1"="$2"
# see
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
if [ "${GITHUB_ACTIONS:-false}" = true ]; then
echo "$1=$2" >>"$GITHUB_ENV"
fi
}
check_size() {
if [ "$SETUP" = true ]; then
echo "Used space for $PWD"
du -sh .
df -h .
fi
}
get_and_install_deb() {
local name="$1"
local install_dir="$2"
local pkg_url="$3"
shift
local wget_args=("$@")
local pkg_name="$name.deb"
if [ "$SETUP" = true ]; then
if [ ! -f "$pkg_name" ] || [ "$FORCE_DOWNLOAD" = true ]; then
echo "$pkg_name not found, downloading"
rm -f "$pkg_name"
# shellcheck disable=SC2086
wget -q --show-progress --progress=bar:force:noscroll "${wget_args[@]}" "$pkg_url" -O "$pkg_name"
fi
# rm -rf "$install_dir"
echo "Preparing to install $pkg_name locally to $install_dir ..."
dpkg-deb -x "$pkg_name" "$install_dir"
echo "$pkg_name installed, deleting $pkg_name ..."
rm -f "$pkg_name" # delete for space
fi
}
get() {
local name="$1"
local pkg_url="$2"
if [ "$SETUP" = true ]; then
if [ ! -f "$name" ] || [ "$FORCE_DOWNLOAD" = true ]; then
echo "$name not found, downloading..."
wget -q --show-progress --progress=bar:force:noscroll "$pkg_url" -O "$name"
fi
fi
}
get_and_untar() {
local name="$1"
local pkg_url="$2"
if [ "$SETUP" = true ]; then
if [ ! -f "$name" ] || [ "$FORCE_DOWNLOAD" = true ]; then
echo "$name not found, downloading..."
wget -q --show-progress --progress=bar:force:noscroll "$pkg_url" -O "$name"
fi
echo "Preparing to extract $name ..."
tar -xf "$name"
echo "$name extracted, deleting archive ..."
rm -f "$name" # delete for space
fi
}
verify_bin_exists() {
if [ ! -f "$1" ]; then
echo "[FAIL] $1 does not exist or is not a file!"
exit 1
else echo "[OK! ] $1"; fi
}
verify_dir_exists() {
if [ ! -d "$1" ]; then
echo "[FAIL] $1 does not exist or is not a directory!"
exit 1
else echo "[OK! ] $1"; fi
}
setup_aocc() {
echo "Preparing AOCC"
local aocc_ver="2.3.0"
local tarball="aocc-$aocc_ver.tar.xz"
# XXX it's actually XZ compressed, so it should be tar.xz
local AOCC_URL="http://developer.amd.com/wordpress/media/files/aocc-compiler-2.3.0.tar"
# local AOCC_URL="http://localhost:8000/aocc-compiler-2.3.0.tar"
get_and_untar "$tarball" "$AOCC_URL"
export_var AOCC_CXX "$PWD/aocc-compiler-$aocc_ver/bin/clang++"
verify_bin_exists "$AOCC_CXX"
"$AOCC_CXX" --version
check_size
}
setup_nvhpc() {
echo "Preparing Nvidia HPC SDK"
local tarball="nvhpc.tar.gz"
# local url="http://localhost:8000/nvhpc_2021_212_Linux_x86_64_cuda_11.2.tar.gz"
local url="https://developer.download.nvidia.com/hpc-sdk/21.2/nvhpc_2021_212_Linux_x86_64_cuda_11.2.tar.gz"
get_and_untar "$tarball" "$url"
local sdk_dir="$PWD/nvhpc_2021_212_Linux_x86_64_cuda_11.2/install_components/Linux_x86_64/21.2"
local bin_dir="$sdk_dir/compilers/bin"
"$bin_dir/makelocalrc" "$bin_dir" -x
export_var NVHPC_NVCXX "$bin_dir/nvc++"
export_var NVHPC_NVCC "$sdk_dir/cuda/11.2/bin/nvcc"
export_var NVHPC_CUDA_DIR "$sdk_dir/cuda/11.2"
echo "Installed CUDA versions:"
ls "$sdk_dir/cuda"
verify_bin_exists "$NVHPC_NVCXX"
verify_bin_exists "$NVHPC_NVCC"
"$NVHPC_NVCXX" --version
"$NVHPC_NVCC" --version
check_size
}
setup_aomp() {
echo "Preparing AOMP"
local AOMP_URL="https://github.com/ROCm-Developer-Tools/aomp/releases/download/rel_11.12-0/aomp_Ubuntu1804_11.12-0_amd64.deb"
# local AOMP_URL="http://0.0.0.0:8000/aomp_Ubuntu1804_11.12-0_amd64.deb"
get_and_install_deb "aomp" "aomp" "$AOMP_URL"
export_var AOMP_CXX "$PWD/aomp/usr/lib/aomp/bin/clang++"
verify_bin_exists "$AOMP_CXX"
"$AOMP_CXX" --version
check_size
}
setup_oclcpu() {
echo "Preparing Intel CPU OpenCL runtime"
local tarball="oclcpuexp.tar.gz"
local url="https://github.com/intel/llvm/releases/download/2020-12/oclcpuexp-2020.11.11.0.04_rel.tar.gz"
# local url="http://localhost:8000/oclcpuexp-2020.11.11.0.04_rel.tar.gz"
get_and_untar "$tarball" "$url"
export_var OCL_LIB "$PWD/x64/libOpenCL.so"
verify_bin_exists "$OCL_LIB"
check_size
}
setup_kokkos() {
echo "Preparing Kokkos"
local kokkos_ver="3.3.01"
local tarball="kokkos-$kokkos_ver.tar.gz"
local url="https://github.com/kokkos/kokkos/archive/$kokkos_ver.tar.gz"
# local url="http://localhost:8000/$kokkos_ver.tar.gz"
get_and_untar "$tarball" "$url"
export_var KOKKOS_SRC "$PWD/kokkos-$kokkos_ver"
verify_dir_exists "$KOKKOS_SRC"
check_size
}
setup_raja() {
echo "Preparing RAJA"
local raja_ver="0.13.0"
local tarball="raja-$raja_ver.tar.gz"
local url="https://github.com/LLNL/RAJA/releases/download/v0.13.0/RAJA-v$raja_ver.tar.gz"
# local url="http://localhost:8000/RAJA-v$raja_ver.tar.gz"
get_and_untar "$tarball" "$url"
export_var RAJA_SRC "$PWD/RAJA-v$raja_ver"
verify_dir_exists "$RAJA_SRC"
check_size
}
setup_clang_gcc() {
echo "deb http://archive.ubuntu.com/ubuntu focal main universe" | sudo tee -a /etc/apt/sources.list
sudo apt-get update -qq
sudo apt-get install -y -qq gcc-10-offload-nvptx gcc-10-offload-amdgcn libtbb2 libtbb-dev g++-10
export_var GCC_CXX "$(which g++-10)"
verify_bin_exists "$GCC_CXX"
"$GCC_CXX" --version
export_var GCC_STD_PAR_LIB "tbb"
export_var GCC_OMP_OFFLOAD_AMD true
export_var GCC_OMP_OFFLOAD_NVIDIA true
clang++ --version
export_var CLANG_CXX "$(which clang++)"
verify_bin_exists "$CLANG_CXX"
"$CLANG_CXX" --version
export_var CLANG_STD_PAR_LIB "tbb"
export_var CLANG_OMP_OFFLOAD_AMD false
export_var CLANG_OMP_OFFLOAD_NVIDIA false
check_size
}
setup_rocm() {
wget -q -O - "https://repo.radeon.com/rocm/rocm.gpg.key" | sudo apt-key add -
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/debian/ xenial main' | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt-get update -qq
sudo apt-get install -y -qq rocm-dev
# AMD needs this rocm_path thing exported...
export_var ROCM_PATH "/opt/rocm-4.1.0"
export_var HIP_CXX "$ROCM_PATH/bin/hipcc"
verify_bin_exists "$HIP_CXX"
"$HIP_CXX" --version
check_size
}
setup_dpcpp() {
local nightly="20210106"
local tarball="dpcpp-$nightly.tar.gz"
local url="https://github.com/intel/llvm/releases/download/sycl-nightly/$nightly/dpcpp-compiler.tar.gz"
# local url="http://localhost:8000/dpcpp-compiler.tar.gz"
get_and_untar "$tarball" "$url"
export_var DPCPP_DIR "$PWD/dpcpp_compiler/"
verify_dir_exists "$DPCPP_DIR"
"$DPCPP_DIR/bin/clang++" --version
check_size
}
setup_hipsycl() {
sudo apt-get install -y -qq libboost-fiber-dev libboost-context-dev
local hipsycl_ver="0.9.0"
local tarball="v$hipsycl_ver.tar.gz"
local install_dir="$PWD/hipsycl_dist_$hipsycl_ver"
local url="https://github.com/illuhad/hipSYCL/archive/v$hipsycl_ver.tar.gz"
# local url="http://localhost:8000/hipSYCL-$hipsycl_ver.tar.gz"
get_and_untar "$tarball" "$url"
if [ "$SETUP" = true ]; then
local src="$PWD/hipSYCL-$hipsycl_ver"
rm -rf "$src/build"
rm -rf "$install_dir"
cmake "-B$src/build" "-H$src" \
-DCMAKE_C_COMPILER="$(which gcc-10)" \
-DCMAKE_CXX_COMPILER="$(which g++-10)" \
-DCMAKE_INSTALL_PREFIX="$install_dir" \
-DWITH_ROCM_BACKEND=OFF \
-DWITH_CUDA_BACKEND=OFF \
-DWITH_CPU_BACKEND=ON
cmake --build "$src/build" --target install -j "$(nproc)"
fi
export_var HIPSYCL_DIR "$install_dir"
verify_dir_exists "$HIPSYCL_DIR"
# note: this will forward --version to the default compiler so it won't say anything about hipsycl
"$HIPSYCL_DIR/bin/syclcc-clang" --version
check_size
}
setup_computecpp() {
echo "TODO ComputeCpp requires registration+login to download"
}
if [ "${GITHUB_ACTIONS:-false}" = true ]; then
echo "Running in GitHub Actions, defaulting to special export"
TERM=xterm
export TERM=xterm
if [ "$SETUP" = true ]; then
echo "Deleting extra packages for space in 5 seconds..."
sleep 5
echo "Starting apt-get remove:"
sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
check_size
fi
else
echo "Running locally, defaulting to standard export"
fi
setup_cmake() {
echo "Preparing CMake"
local cmake_release="https://github.com/Kitware/CMake/releases/download"
get "cmake-3.13.sh" "$cmake_release/v3.13.4/cmake-3.13.4-Linux-x86_64.sh"
chmod +x "./cmake-3.13.sh" && sh "./cmake-3.13.sh" --skip-license --include-subdir
export_var CMAKE_3_13_BIN "$PWD/cmake-3.13.4-Linux-x86_64/bin/cmake"
verify_bin_exists "$CMAKE_3_13_BIN"
"$CMAKE_3_13_BIN" --version
get "cmake-3.15.sh" "$cmake_release/v3.15.7/cmake-3.15.7-Linux-x86_64.sh"
chmod +x "./cmake-3.15.sh" && "./cmake-3.15.sh" --skip-license --include-subdir
export_var CMAKE_3_15_BIN "$PWD/cmake-3.15.7-Linux-x86_64/bin/cmake"
verify_bin_exists "$CMAKE_3_15_BIN"
"$CMAKE_3_15_BIN" --version
get "cmake-3.18.sh" "$cmake_release/v3.18.6/cmake-3.18.6-Linux-x86_64.sh"
chmod +x "./cmake-3.18.sh" && "./cmake-3.18.sh" --skip-license --include-subdir
export_var CMAKE_3_18_BIN "$PWD/cmake-3.18.6-Linux-x86_64/bin/cmake"
verify_bin_exists "$CMAKE_3_18_BIN"
"$CMAKE_3_18_BIN" --version
check_size
}
if [ "$PARALLEL" = true ]; then
(setup_clang_gcc && setup_rocm && setup_hipsycl) & # these need apt so run sequentially
setup_cmake &
setup_oclcpu &
setup_aocc &
setup_nvhpc &
setup_aomp &
setup_dpcpp &
setup_kokkos &
setup_raja &
wait
else
setup_cmake
setup_aocc
setup_oclcpu
setup_nvhpc
setup_aomp
setup_dpcpp
setup_kokkos
setup_raja
# these need apt
setup_clang_gcc
setup_rocm
setup_hipsycl
fi
echo "Done!"
cd "$PREV_DIR" || exit 1