forked from Nek5000/nekRS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makenrs
executable file
·231 lines (196 loc) · 5.72 KB
/
makenrs
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
#!/bin/bash
#set -x
###############################################################################
# USER SETTINGS
###############################################################################
: ${NEKRS_INSTALL_DIR:=${HOME}/.local/nekrs}
: ${NEKRS_CC:="mpicc"}
: ${NEKRS_CXX:="mpic++"}
: ${NEKRS_FC:="mpif77"}
: ${NEKRS_CXXFLAGS:=""}
: ${OCCA_CXX:="g++"}
: ${OCCA_CXXFLAGS:="-O2 -ftree-vectorize -funroll-loops -march=native -mtune=native"}
###############################################################################
# DONT'T TOUCH WHAT FOLLOWS !!!
###############################################################################
set -e -a
function nekrs_info() {
local GREEN='\033[0;92m'
local NC='\033[0m'
echo -e "${GREEN} $1 ${NC}"
}
export -f nekrs_info
function nekrs_error() {
local RED='\033[0;31m'
local NC='\033[0m'
echo -e "${RED} $1 ${NC}"
}
export -f nekrs_error
NEKRS_SOURCED=0
(return 0 2>/dev/null) && NEKRS_SOURCED=1
if [ ${NEKRS_SOURCED} -eq 1 ]; then
NEKRS_EXIT_CMD=return
else
NEKRS_EXIT_CMD=exit
fi
export NEKRS_BUILD_DIR=`pwd`/build
if [[ "$#" -eq 1 ]]; then
if [[ "$1" = *"clean"* ]]; then
set +e
read -p "Uninstall from $NEKRS_INSTALL_DIR? [N]" yn
case $yn in
[Yy]* )
make -C "${NEKRS_BUILD_DIR}" uninstall
;;
* )
;;
esac
read -p "Clean build in $NEKRS_BUILD_DIR? [N]" yn
case $yn in
[Yy]* )
make -C "${NEKRS_BUILD_DIR}" clean
;;
* )
;;
esac
set -e
exit 0
elif [[ "$1" = *"tar"* ]]; then
nekrs_info "Downloading sources and creating distribution tarball ..."
else
nekrs_info "Usage: makenrs [clean|tar]"
${NEKRS_EXIT_CMD} 1
fi
fi
if [ $SHELL != "/bin/bash" ] && [ $SHELL != "/bin/zsh" ]; then
echo "Error: user's login shell needs to be bash or zsh!"
${NEKRS_EXIT_CMD} 1
fi
if [[ "$#" -lt 1 ]]; then
if [ -z ${OCCA_CUDA_ENABLED} ]; then
read -p "enable CUDA backend? [N]" yn
case $yn in
[Yy]* )
OCCA_CUDA_ENABLED=1
;;
esac
fi
if [ -z ${OCCA_HIP_ENABLED} ]; then
read -p "enable HIP backend? [N]" yn
case $yn in
[Yy]* )
OCCA_HIP_ENABLED=1
;;
esac
fi
if [ -z ${OCCA_OPENCL_ENABLED} ]; then
read -p "enable OPENCL backend? [N]" yn
case $yn in
[Yy]* )
OCCA_OPENCL_ENABLED=1
;;
esac
fi
fi
: ${OCCA_CUDA_ENABLED:=0}
: ${OCCA_HIP_ENABLED:=0}
: ${OCCA_OPENCL_ENABLED:=0}
: ${OCCA_METAL_ENABLED:=0}
USE_OCCA_MEM_BYTE_ALIGN="64"
if uname -a | grep 'ppc64'; then
NEKRS_CXXFLAGS=$(echo "$NEKRS_CXXFLAGS" | sed -e "s/march/mcpu/g")
OCCA_CXXFLAGS=$(echo "$OCCA_CXXFLAGS" | sed -e "s/march/mcpu/g")
fi
NEKRS_CFLAGS="${NEKRS_CXXFLAGS}"
NEKRS_FFLAGS="${NEKRS_CXXFLAGS}"
NEKRS_LIBP_DEFINES="-DUSE_NULL_PROJECTION=1"
NEKRS_NEK5000_PPLIST="PARRSB DPROCMAP"
export OCCA_CUDA_ENABLED
export OCCA_HIP_ENABLED
export OCCA_OPENCL_ENABLED
export OCCA_METAL_ENABLED
export NEKRS_CC
export NEKRS_CXX
export NEKRS_FC
export NEKRS_CFLAGS
export NEKRS_CXXFLAGS
export NEKRS_FFLAGS
export NEKRS_DEBUG
mkdir -p ${NEKRS_INSTALL_DIR} > /dev/null 2>&1
NEKRS_INSTALL_DIR=`echo "$(cd "$(dirname "${NEKRS_INSTALL_DIR}")"; pwd)/$(basename "${NEKRS_INSTALL_DIR}")"`
export NEKRS_INSTALL_DIR
export NEKRS_LIBP_DEFINES
export NEKRS_NEK5000_PPLIST
export NEKRS_DIR=`pwd`
export NEKRS_UDF_DIR="${NEKRS_INSTALL_DIR}/udf"
export NEKRS_NEKINTERFACE_DIR="${NEKRS_INSTALL_DIR}/nekInterface"
export NEKRS_NEK5000_DIR="${NEKRS_INSTALL_DIR}/nek5000"
export NEKRS_LIBP_DIR="${NEKRS_INSTALL_DIR}/libparanumal"
export PATH="${NEKRS_INSTALL_DIR}/bin:${PATH}"
if [ ${NEKRS_SOURCED} -eq 1 ]; then
${NEKRS_EXIT_CMD} 0
fi
if [ "${NEKRS_DIR}" = "${NEKRS_INSTALL_DIR}" ]; then
nekrs_error "Install directory and source directory are the same."
${NEKRS_EXIT_CMD} 1
fi
# =======================
# Run CMake
# =======================
mkdir -p "${NEKRS_BUILD_DIR}" > /dev/null 2>&1
#rm -rf "${NEKRS_BUILD_DIR}"/CMakeCache.txt "${NEKRS_BUILD_DIR}"/*.cmake > /dev/null 2>&1
cd "${NEKRS_BUILD_DIR}"
# ENABLE_CUDA, ENABLE_OPENCL, etc., are used by OCCA's CMakeLists
cmake -Wno-dev \
-Wfatal-errors \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_Fortran_COMPILER="${NEKRS_FC}" \
-DCMAKE_C_COMPILER="${NEKRS_CC}" \
-DCMAKE_CXX_COMPILER="${NEKRS_CXX}" \
-DCMAKE_Fortran_FLAGS="${NEKRS_FFLAGS}" \
-DCMAKE_C_FLAGS="${NEKRS_CFLAGS}" \
-DCMAKE_CXX_FLAGS="${NEKRS_CXXFLAGS}" \
-DCMAKE_INSTALL_PREFIX="${NEKRS_INSTALL_DIR}" \
-DNEK5000_PPLIST="${NEKRS_NEK5000_PPLIST}" \
-DLIBP_DEFINES="${NEKRS_LIBP_DEFINES}" \
-DUSE_OCCA_MEM_BYTE_ALIGN="${USE_OCCA_MEM_BYTE_ALIGN}" \
-DOCCA_CXX="${OCCA_CXX}" \
-DOCCA_CXXFLAGS="${OCCA_CXXFLAGS}" \
-DENABLE_CUDA="${OCCA_CUDA_ENABLED}" \
-DENABLE_OPENCL="${OCCA_OPENCL_ENABLED}" \
-DENABLE_HIP="${OCCA_HIP_ENABLED}" \
-DENABLE_METAL="${OCCA_METAL_ENABLED}" \
${NEKRS_DIR}
# =========================
# Make tarball if requested
# =========================
if [ "$#" -eq 1 ]; then
if [[ "$1" = *"tar"* ]]; then
make tar
cd ..
rm -rf build
fi
${NEKRS_EXIT_CMD} 0
fi
# =========================
# Otherwise, make install
# =========================
make -j6 install
if [ $? -ne 0 ]; then
echo
echo "##################################################################"
echo
echo "An error occured duing installation!"
echo
echo "##################################################################"
${NEKRS_EXIT_CMD} 1
else
echo
echo "##################################################################"
echo
echo "Installation to $NEKRS_INSTALL_DIR successful!"
echo
echo "##################################################################"
${NEKRS_EXIT_CMD} 0
fi
echo