-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.sh
executable file
·145 lines (127 loc) · 3.58 KB
/
BUILD.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
#!/bin/bash
#
# A script file that builds and runs/tests HiOp on various paricular clusters, such as
# summit and ascent @ ORNL and newell and marianas @ PNNL
#
# Usage: In a shell run
#
# ./BUILD.sh
#
#
# Sometimes the cluster name is not detected correctly; in this cases, one can specify
# the cluster name by prefixing the command with MY_CLUSTER=cluster_name, e.g.,
#
# MY_CLUSTER=ascent ./BUILD.sh
#
# All variables that will change the build script's behaviour:
#
# - MAKE_CMD command the script will use to run makefiles
# - CTEST_CMD command the script will use to run ctest
# - FULL_BUILD_MATRIX (bool) test all possible builds
# - BUILDDIR path to temp build directory
# - EXTRA_CMAKE_ARGS extra arguments passed to CMake
# - MY_CLUSTER determines cluster-specific variables to use
# - BUILDMATRIX_LOGFILE path to file where builds will be logged
export BASE_PATH=$(dirname $0)
export MAKE_CMD=${MAKE_CMD:-'make -j 8'}
export CTEST_CMD=${CTEST_CMD:-'ctest -VV --timeout 1800'}
# we want this settable via env var to make CI triggered builds simpler
export FULL_BUILD_MATRIX=${FULL_BUILD_MATRIX:-0}
export BUILDDIR=${BUILDDIR:-"$(pwd)/build"}
export EXTRA_CMAKE_ARGS=${EXTRA_CMAKE_ARGS:-""}
export BUILD=1
export TEST=1
cleanup() {
echo
echo Exit code $1 caught in build script.
echo
if [[ "$1" == "0" ]]; then
echo BUILD_STATUS:0
else
echo
echo Failure found in build script.
echo
echo BUILD_STATUS:1
fi
}
trap 'cleanup $? $LINENO' EXIT
while [[ $# -gt 0 ]]
do
case $1 in
--full-build-matrix)
echo
echo Running full build matrix
echo
export FULL_BUILD_MATRIX=1
shift
;;
--build-only|-B)
echo
echo Building only
echo
export BUILD=1
export TEST=0
shift
;;
--test-only|-T)
echo
echo Testing only
echo
export BUILD=0
export TEST=1
shift
;;
--help|*)
trap - 1 2 3 15 # we don't need traps if a user is asking for help
cat <<EOD
Usage:
$ MY_CLUSTER='clustername' $0
Optional arguments:
--build-only Only build, don't test
--test-only Only run tests, don't build
--full-build-matrix Run entire matrix of build configurations
--help Show this message
EOD
exit 1
;;
esac
done
set -xv
# If MY_CLUSTER is not set by user, try to discover it from environment
if [[ ! -v MY_CLUSTER ]]
then
export MY_CLUSTER=`uname -n | sed -e 's/[0-9]//g' -e 's/\..*//'`
fi
# Some clusters have compute nodes with slightly different hostnames, so we
# set MY_CLUSTER appropriately
if [[ $MY_CLUSTER =~ newell* ]]; then
export MY_CLUSTER=newell
elif [[ $MY_CLUSTER =~ dl* ]]; then
export MY_CLUSTER=marianas
fi
module purge
# If we have modules/variables defined for the current cluster, use them
if [ -f "./scripts/$(echo $MY_CLUSTER)Variables.sh" ]; then
source "./scripts/$(echo $MY_CLUSTER)Variables.sh"
echo "Using ./scripts/$(echo $MY_CLUSTER)Variables.sh"
fi
# The following is required when running from Gitlab CI via slurm job
if [ -z "$SLURM_SUBMIT_DIR" ]; then
cd $BASE_PATH || exit 1
fi
# Fail fast if we can't find NVBLAS_CONFIG_FILE since it's needed for all GPU builds
if [[ ! -v NVBLAS_CONFIG_FILE ]] || [[ ! -f "$NVBLAS_CONFIG_FILE" ]]
then
echo "Please provide file 'nvblas.conf' in $BUILDDIR or set variable to desired location."
exit 1
fi
module list
if [[ $FULL_BUILD_MATRIX -eq 1 ]]; then
source ./scripts/fullBuildMatrix.sh
buildMatrix $TEST
exit $?
else
source ./scripts/defaultBuild.sh
defaultBuild
exit $?
fi