-
Notifications
You must be signed in to change notification settings - Fork 13
/
install_ita.sh
executable file
·249 lines (248 loc) · 10.1 KB
/
install_ita.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
#!/bin/bash
#================================================================================
# Description: This script will install Commander3 on ITA systems: Owls/Beehives.
#================================================================================
# Global configuration:
#------------------------------------------------------------------------------
# Compiler Toolchain to use
# Possible values: nvidia, flang, gnu, intel, oneapi
toolchain="oneapi" #"gnu"
buildtype="Release" #"Release" #"RelWithDebInfo" #Debug
#------------------------------------------------------------------------------
# Absolute path to Commander3 root directory
comm3_root_dir="$(pwd)"
# Address
suffix="\.uio\.no"
# Using regex to figure out which owl I am on.
prefix="owl"
owl1724="$prefix+(1[7-9]|2[0-4])+$suffix"
owl2528="$prefix+(2[5-8])+$suffix"
owl2930="$prefix+(29|30)+$suffix"
owl3135="$prefix+(3[1-5])+$suffix"
owl3637="$prefix+(3[6-7])+$suffix"
# Using regex to figure out which beehive I am on.
prefix="beehive"
bee0123="$prefix+(\d{0}|[1-9](?!\d)|1[0-9]|2[0-3])+$suffix"
bee2631="$prefix+(2[6-9]|3[0-1])+$suffix"
bee3436="$prefix+(3[4-6])+$suffix"
bee3742="$prefix+(3[7-9]|4[0-2])+$suffix"
bee4345="$prefix+(4[3-5])+$suffix"
bee46="$prefix+(46)+$suffix"
bee47="$prefix+(47)+$suffix"
prefix="hyades"
hya1="$prefix+$suffix"
hya2="$prefix+(2)+$suffix"
hya34="$prefix+([3-4])+$suffix"
hya5="$prefix+(5)+$suffix"
hya6="$prefix+(6)+$suffix"
hya79="$prefix+([7-9])+$suffix"
hya1016="$prefix+(1[0-6])+$suffix"
hya1719="$prefix+(1[7-9])+$suffix"
hya20="$prefix+(20)+$suffix"
hya21="$prefix+(21)+$suffix"
#------------------------------------------------------------------------------
# Will compile commander only if on owl/beehive/hyades!
#------------------------------------------------------------------------------
if [[ "${HOSTNAME}" =~ "owl"* ]] || [[ "${HOSTNAME}" =~ "beehive"* ]] || [[ "${HOSTNAME}" =~ "hyades"* ]]
then
#------------------------------------------------------------------------------
# Getting the total number of CPUs, taken from this answer:
# https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
# macOS: Use `sysctl -n hw.*cpu_max`, which returns the values of
# interest directly.
# CAVEAT: Using the "_max" key suffixes means that the *maximum*
# available number of CPUs is reported, whereas the
# current power-management mode could make *fewer* CPUs
# available; dropping the "_max" suffix would report the
# number of *currently* available ones; see [1] below.
#
# Linux: Parse output from `lscpu -p`, where each output line represents
# a distinct (logical) CPU.
# Note: Newer versions of `lscpu` support more flexible output
# formats, but we stick with the parseable legacy format
# generated by `-p` to support older distros, too.
# `-p` reports *online* CPUs only - i.e., on hot-pluggable
# systems, currently disabled (offline) CPUs are NOT
# reported.
#
# Number of LOGICAL CPUs (includes those reported by hyper-threading cores)
# Linux: Simply count the number of (non-comment) output lines from `lscpu -p`,
# which tells us the number of *logical* CPUs.
logicalCpuCount=$([ $(uname) = 'Darwin' ] &&
sysctl -n hw.logicalcpu_max ||
lscpu -p | egrep -v '^#' | wc -l)
# Number of PHYSICAL CPUs (cores).
# Linux: The 2nd column contains the core ID, with each core ID having 1 or
# - in the case of hyperthreading - more logical CPUs.
# Counting the *unique* cores across lines tells us the
# number of *physical* CPUs (cores).
physicalCpuCount=$([ $(uname) = 'Darwin' ] &&
sysctl -n hw.physicalcpu_max ||
lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
#------------------------------------------------------------------------------
echo "You are on ${HOSTNAME}"
#------------------------------------------------------------------------------
# Choosing correct build directory to put CMake files into
if [[ "${HOSTNAME}" =~ $owl1724 ]]; then
build_dir="build_owl1724_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $owl2528 ]]; then
build_dir="build_owl2528_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $owl2930 ]]; then
build_dir="build_owl2930_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $owl3135 ]]; then
build_dir="build_owl3135_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $owl3637 ]]; then
build_dir="build_owl3637_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee0123 ]]; then
build_dir="build_bee0123_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee2631 ]]; then
build_dir="build_bee2631_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee3436 ]]; then
build_dir="build_bee3436_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee3742 ]]; then
build_dir="build_bee3742_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee4345 ]]; then
build_dir="build_bee4345_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee46 ]]; then
build_dir="build_bee46_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $bee47 ]]; then
build_dir="build_bee47_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya1 ]]; then
build_dir="build_hya1_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya2 ]]; then
build_dir="build_hya2_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya34 ]]; then
build_dir="build_hya34_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya5 ]]; then
build_dir="build_hya5_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya6 ]]; then
build_dir="build_hya6_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya79 ]]; then
build_dir="build_hya79_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya1016 ]]; then
build_dir="build_hya1016_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya1719 ]]; then
build_dir="build_hya1719_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya20 ]]; then
build_dir="build_hya20_${toolchain}_${buildtype}"
elif [[ "${HOSTNAME}" =~ $hya21 ]]; then
build_dir="build_hya21_${toolchain}_${buildtype}"
fi
echo $build_dir
#------------------------------------------------------------------------------
# Unloading any loaded module
module purge
# Loading GNU Autotools (autoconf, libtool, automake etc.), GIT and CMake
module load git cmake
# Choosing which compiler toolchain to use
if [[ "$toolchain" =~ "intel" ]]
then
# Compilers
fc="ifort"
cc="icc"
cxx="icpc"
# MPI compilers
mpifc="mpiifort"
mpicc="mpiicc"
mpicxx="mpiicpc"
printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx"
module load Intel_parallel_studio/2020/4.912
#module load Intel_parallel_studio/2018/3.051
elif [[ "$toolchain" =~ "oneapi" ]]
then
# Compilers
fc="ifort"
cc="icc"
cxx="icpc"
# MPI compilers
mpifc="mpiifort"
mpicc="mpiicc"
mpicxx="mpiicpc"
printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx"
module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1
elif [[ "$toolchain" =~ "gnu" ]]
then
# Compilers
fc="gfortran"
cc="gcc"
cxx="g++"
# MPI compilers
mpifc="mpifort"
mpicc="mpicc"
mpicxx="mpicxx"
printf "Using GNU:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx"
module load gcc/13.1
module load openmpi/gcc13/5.0.2
printf "\n"
$mpifc --version
elif [[ "$toolchain" =~ "flang" ]]
then
# Compilers
fc="flang"
cc="clang"
cxx="clang++"
# MPI compilers
mpifc="mpifort"
mpicc="mpicc"
mpicxx="mpicxx"
printf "Using AOCC:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx"
module load openmpi/aocc/4.1.0 AMD/aocc/3.0.0
elif [[ "$toolchain" =~ "nvidia" ]]
then
# Compilers
fc="nvfortran"
cc="nvc"
cxx="nvc++"
# MPI compilers
mpifc="mpifort"
mpicc="mpicc"
mpicxx="mpicxx"
printf "Using NVIDIA:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx"
module load nvhpc/21.7
fi
# Printing Loaded modules
printf "\n"
printf "$(module list)"
#------------------------------------------------------------------------------
# Checking for existence of build directory
echo "Checking for 'build' directory."
abs_path_to_build="$comm3_root_dir/$build_dir"
if [[ -d "$abs_path_to_build" ]];
then
echo "$abs_path_to_build exists! Proceeding..."
else
echo "$abs_path_to_build does not exist! Creating..."
mkdir $abs_path_to_build
fi
#------------------------------------------------------------------------------
if ! [ -f $abs_path_to_build/CMakeCache.txt ]; then
echo "Running CMake as if for the first time"
rm -rf $abs_path_to_build/CMakeCache.txt
#------------------------------------------------------------------------------
# Executing CMake commands for the first time
#------------------------------------------------------------------------------
cmake \
-DCMAKE_INSTALL_PREFIX:PATH="$comm3_root_dir/$build_dir/install" \
-DCMAKE_DOWNLOAD_DIRECTORY:PATH="$comm3_root_dir/downloads" \
-DCMAKE_BUILD_TYPE="$buildtype" \
-DCMAKE_Fortran_COMPILER=$fc \
-DCMAKE_C_COMPILER=$cc \
-DCMAKE_CXX_COMPILER=$cxx \
-DMPI_C_COMPILER=$mpicc \
-DMPI_CXX_COMPILER=$mpicxx \
-DMPI_Fortran_COMPILER=$mpifc \
-DCFITSIO_USE_CURL:BOOL=OFF \
-DUSE_SYSTEM_FFTW:BOOL=OFF \
-DUSE_SYSTEM_CFITSIO:BOOL=OFF \
-DUSE_SYSTEM_HDF5:BOOL=OFF \
-DUSE_SYSTEM_HEALPIX:BOOL=OFF \
-DUSE_SYSTEM_BLAS:BOOL=ON \
-S $comm3_root_dir -B $abs_path_to_build
fi
#------------------------------------------------------------------------------
# Build and install command
#------------------------------------------------------------------------------
cmake --build $comm3_root_dir/$build_dir --target install -j $physicalCpuCount #-v
else
printf "TERMINATING: NOT ON ITA MACHINE!"
fi