-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·253 lines (226 loc) · 7.61 KB
/
install.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
#!/bin/bash
# stop on error
set -e
# build and install directories
export BASE_DIR=$(pwd)
export SOURCE_DIR=$BASE_DIR/sources
export BUILD_DIR=$BASE_DIR/build
export INSTALL_DIR=$BASE_DIR/install
mkdir -p $SOURCE_DIR $INSTALL_DIR
# Re-install -> Do not delete x86_64
# To re-install provide just an arbitrary arguement
if [ $# -eq 0 ]
then
REINSTALL=0
else
REINSTALL=1
fi
# =============================================================================
# 1. Setting source & build dependencies
# =============================================================================
# Modules to load typically on the cluster environment
# TODO: change the modules based on your environment
setup_modules() {
printf "\n----------------- SETTING MODULES --------------\n"
module purge
module load unstable
module load cmake git flex bison python-dev hpe-mpi
}
# TODO Adjust compiler loading according to your system
load_gcc() {
module load gcc
export CC=$(which gcc)
export CXX=$(which g++)
}
unload_gcc() {
module unload gcc
unset CC
unset CXX
}
load_intel() {
module load intel
export CC=$(which icc)
export CXX=$(which icpc)
}
unload_intel() {
module unload intel
unset CC
unset CXX
}
load_pgi_cuda() {
module load gcc nvhpc cuda
export CC=$(which nvc)
export CXX=$(which nvc++)
}
unload_pgi_cuda() {
module unload gcc nvhpc cuda
unset CC
unset CXX
}
# =============================================================================
# NO NEED TO EDIT BELLOW HERE
# =============================================================================
# Clone neuron repository
setup_source() {
printf "\n----------------- CLONING REPO --------------\n"
[[ -d $SOURCE_DIR/nrn ]] || git clone --recursive https://github.com/neuronsimulator/nrn.git $SOURCE_DIR/nrn
}
# Install python packages if not exist in standard environment
setup_python_packages() {
printf "\n----------------- SETUP PYTHON PACKAGES --------------\n"
[[ -d $SOURCE_DIR/venv ]] || python3 -mvenv $SOURCE_DIR/venv
. $SOURCE_DIR/venv/bin/activate
pip3 install Jinja2 PyYAML pytest "sympy<1.6"
}
# =============================================================================
# 2. Installing base software
# =============================================================================
# Install NMODL which is used for translating DSL to C++ code. This could be built with GNU
# toolchain as this is used as source-to-source compiler.
install_nmodl() {
printf "\n----------------- INSTALL NMODL --------------\n"
load_gcc
mkdir -p $BUILD_DIR/nmodl && pushd $BUILD_DIR/nmodl
cmake $SOURCE_DIR/nrn/external/coreneuron/external/nmodl \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/NMODL \
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j && make install
popd
unload_gcc
}
# =============================================================================
# 3. Installing simulation engine
# =============================================================================
install_nrn_cnrn_cpu_mod2c() {
printf "\n----------------- INSTALL NEURON+CORENEURON+MOD2C (CPU) --------------\n"
load_intel
mkdir -p $BUILD_DIR/nrn_cnrn_cpu_mod2c && pushd $BUILD_DIR/nrn_cnrn_cpu_mod2c
cmake $SOURCE_DIR/nrn \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/nrn_cnrn_cpu_mod2c \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_RX3D=OFF \
-DNRN_ENABLE_MPI=ON \
-DCORENRN_ENABLE_OPENMP=OFF \
-DNRN_ENABLE_CORENEURON=ON \
-DCORENRN_ENABLE_GPU=OFF \
-DCORENRN_ENABLE_NMODL=OFF \
-DNRN_ENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=$(which python3) \
-DNRN_ENABLE_TESTS=OFF \
-DCORENRN_ENABLE_UNIT_TESTS=OFF \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j && make install
popd
unload_intel
}
install_nrn_cnrn_cpu_nmodl() {
printf "\n----------------- INSTALL NEURON+CORENEURON+NMODL (CPU) --------------\n"
load_intel
mkdir -p $BUILD_DIR/nrn_cnrn_cpu_nmodl && pushd $BUILD_DIR/nrn_cnrn_cpu_nmodl
cmake $SOURCE_DIR/nrn \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/nrn_cnrn_cpu_nmodl \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_RX3D=OFF \
-DNRN_ENABLE_MPI=ON \
-DCORENRN_ENABLE_OPENMP=OFF \
-DNRN_ENABLE_CORENEURON=ON \
-DCORENRN_ENABLE_GPU=OFF \
-DCORENRN_ENABLE_NMODL=ON \
-DCORENRN_NMODL_DIR=$INSTALL_DIR/NMODL \
-DCORENRN_NMODL_FLAGS="sympy --analytic" \
-DNRN_ENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=$(which python3) \
-DNRN_ENABLE_TESTS=OFF \
-DCORENRN_ENABLE_UNIT_TESTS=OFF \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j && make install
popd
unload_intel
}
install_nrn_cnrn_gpu_mod2c() {
printf "\n----------------- INSTALL NEURON+CORENEURON+MOD2C (GPU) --------------\n"
load_pgi_cuda
mkdir -p $BUILD_DIR/nrn_cnrn_gpu_mod2c && pushd $BUILD_DIR/nrn_cnrn_gpu_mod2c
cmake $SOURCE_DIR/nrn \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/nrn_cnrn_gpu_mod2c \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_RX3D=OFF \
-DNRN_ENABLE_MPI=ON \
-DCORENRN_ENABLE_OPENMP=OFF \
-DNRN_ENABLE_CORENEURON=ON \
-DCORENRN_ENABLE_GPU=ON \
-DCORENRN_ENABLE_NMODL=OFF \
-DNRN_ENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=$(which python3) \
-DNRN_ENABLE_TESTS=OFF \
-DCORENRN_ENABLE_UNIT_TESTS=OFF \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_CUDA_COMPILER=nvcc \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j && make install
popd
unload_pgi_cuda
}
install_nrn_cnrn_gpu_nmodl() {
printf "\n----------------- INSTALL NEURON+CORENEURON+NMODL (GPU) --------------\n"
load_pgi_cuda
mkdir -p $BUILD_DIR/nrn_cnrn_gpu_nmodl && pushd $BUILD_DIR/nrn_cnrn_gpu_nmodl
cmake $SOURCE_DIR/nrn \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/nrn_cnrn_gpu_nmodl \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_RX3D=OFF \
-DNRN_ENABLE_MPI=ON \
-DCORENRN_ENABLE_OPENMP=OFF \
-DNRN_ENABLE_CORENEURON=ON \
-DCORENRN_ENABLE_GPU=ON \
-DCORENRN_ENABLE_NMODL=ON \
-DCORENRN_NMODL_DIR=$INSTALL_DIR/NMODL \
-DCORENRN_NMODL_FLAGS="sympy --analytic" \
-DNRN_ENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=$(which python3) \
-DNRN_ENABLE_TESTS=OFF \
-DCORENRN_ENABLE_UNIT_TESTS=OFF \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_CUDA_COMPILER=nvcc \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j && make install
popd
unload_pgi_cuda
}
# Provide the BUILD_TYPE as argument
run_nrnivmodl() {
BUILD_TYPE=$1
mkdir -p $INSTALL_DIR/$BUILD_TYPE/special && pushd $INSTALL_DIR/$BUILD_TYPE/special
# Delete any executables from previous runs
if [ $REINSTALL == 0 ]
then
rm -rf x86_64
fi
# Run nrnivmodl-core to generate the CoreNEURON library
../bin/nrnivmodl -coreneuron $BASE_DIR/mechanisms
popd
}
# 1. Setting source & build dependencies
setup_source
setup_modules
setup_python_packages
# 2. Installing base software
install_nmodl
# 3. Installing simulation engine
install_nrn_cnrn_cpu_mod2c
install_nrn_cnrn_cpu_nmodl
install_nrn_cnrn_gpu_mod2c
install_nrn_cnrn_gpu_nmodl
# 4. Generate library
run_nrnivmodl nrn_cnrn_cpu_mod2c
run_nrnivmodl nrn_cnrn_cpu_nmodl
run_nrnivmodl nrn_cnrn_gpu_mod2c
run_nrnivmodl nrn_cnrn_gpu_nmodl