Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit bf50e5e

Browse files
authored
Fixing nrnivcore-modl in build (& cleanup) +CI (#224)
* Creating proper include dir in build * Improvements - dont rely MOD2C is in deps/external - compat with NMODL - coreneuron build use plain nrnivmodl-core * Fix Home to be WORKSPACE and avoid clashes * Tests: Environment setup for bb5 2020 * Start by always unsetting MODULEPATH * Init all envs same way inc spack and MPT unset
1 parent 6726f6d commit bf50e5e

14 files changed

+81
-89
lines changed

coreneuron/CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ set_target_properties(coreneuron corenrnmech scopmath ${link_cudacoreneuron}
190190
add_custom_command(TARGET coreneuron
191191
POST_BUILD
192192
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core
193-
-i "-I${CORENEURON_PROJECT_SOURCE_DIR} -I${CORENRN_NMODL_INCLUDE}"
194-
-m "${CORENRN_NMODL_BINARY}"
195193
${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod
196194
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
197195
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/special-core
@@ -224,19 +222,28 @@ set(CORENRN_LINK_LIBS "${CORENRN_LINK_LIBS}" PARENT_SCOPE)
224222
# =============================================================================
225223
# Copy files for nrnivmodl-core workflow during build time
226224
# =============================================================================
227-
configure_file(${MODFUNC_PERL_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/mod_func.c.pl @ONLY)
228-
configure_file(${KINDERIV_PYTHON_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/kinderiv.py)
229-
configure_file(${DIMPLIC_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/dimplic.cpp)
230-
configure_file(${ENGINEMECH_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp)
231225

232-
configure_file("engine.h" ${CMAKE_BINARY_DIR}/include/coreneuron/engine.h)
233-
configure_file("enginemech.h" ${CMAKE_BINARY_DIR}/include/coreneuron/enginemech.h)
226+
configure_file(${MODFUNC_PERL_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/mod_func.c.pl COPYONLY)
227+
configure_file(${KINDERIV_PYTHON_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/kinderiv.py COPYONLY)
228+
configure_file(${DIMPLIC_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/dimplic.cpp COPYONLY)
229+
configure_file(${ENGINEMECH_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp COPYONLY)
230+
231+
# Make headers avail to build tree
232+
file(GLOB_RECURSE main_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.h *.hpp *.ispc)
233+
foreach(header ${main_headers})
234+
configure_file("${header}" "${CMAKE_BINARY_DIR}/include/coreneuron/${header}" COPYONLY)
235+
endforeach()
234236
configure_file("utils/profile/profiler_interface.h"
235-
${CMAKE_BINARY_DIR}/include/coreneuron/nrniv/profiler_interface.h)
236-
configure_file("mechanism/nrnoc_ml.ispc" ${CMAKE_BINARY_DIR}/include/coreneuron/mechanism/nrnoc_ml.ispc)
237+
${CMAKE_BINARY_DIR}/include/coreneuron/nrniv/profiler_interface.h COPYONLY)
237238

238-
# TODO : this doesn't get re-copied if source changes
239-
file(COPY "utils/randoms" DESTINATION ${CMAKE_BINARY_DIR}/include/coreneuron/utils)
239+
if(NOT CORENRN_ENABLE_NMODL)
240+
# MOD2C puts UNITS_FILE in share, but we need to see it in share/mod2c
241+
# We create a link since we know neither the source location nor when its copied
242+
FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/share/mod2c/")
243+
ADD_CUSTOM_TARGET(link_units ALL
244+
COMMAND ${CMAKE_COMMAND} -E create_symlink
245+
"${NMODL_UNITS_FILE}" "${CMAKE_BINARY_DIR}/share/mod2c/nrnunits.lib")
246+
endif()
240247

241248
# main program required for building special-core
242249
file(COPY apps/coreneuron.cpp DESTINATION ${CMAKE_BINARY_DIR}/share/coreneuron)

extra/nrnivmodl-core.in

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ PARALLELISM=4
1313
SAVE_FILE="@CMAKE_HOST_SYSTEM_PROCESSOR@/nrnivmodl_options.txt"
1414
params_MODS_PATH="."
1515

16+
# To support build + install later we save/restore options
17+
# Attempt to load previous definitions
18+
if [ -f "$SAVE_FILE" ]; then
19+
echo "[INFO] Loading definitions from previous nrnivmodl-core execution"
20+
while read line; do
21+
echo " + $line" && eval "$line"
22+
done < "$SAVE_FILE"
23+
fi
24+
25+
# Parse args (overriding)
1626
while getopts "n:m:v:d:i:l:p:hV" OPT; do
1727
case "$OPT" in
1828
n)
@@ -49,18 +59,10 @@ done
4959
shift $(($OPTIND - 1))
5060

5161
if [ $# -gt 1 ]; then
52-
echo "Error: $APP_NAME expects at most one mod dir. See syntax: '$APP_NAME -h' "
62+
echo "[ERROR] $APP_NAME expects at most one mod dir. See syntax: '$APP_NAME -h' "
5363
exit 1
5464
fi
5565

56-
# To support build + install later we save/restore options
57-
# Attempt to load previous definitions
58-
if [ -f "$SAVE_FILE" ]; then
59-
while read line; do
60-
echo "$line"
61-
eval "$line"
62-
done < "$SAVE_FILE"
63-
fi
6466

6567
# If defined mods dir be in $1
6668
if [ $# -eq 1 ]; then
@@ -79,6 +81,8 @@ fi
7981
mkdir -p "$(dirname "$SAVE_FILE")"
8082
echo "# nrnivmodl-core options. Mods location: $params_MODS_PATH" > $SAVE_FILE
8183

84+
85+
# Build params to make command (and save them to file)
8286
make_params=("ROOT=${ROOTDIR}")
8387

8488
for param in $MAKE_OPTIONS; do
@@ -94,6 +98,7 @@ if [ "$params_DESTDIR" ]; then
9498
make_params+=("install")
9599
fi
96100

101+
echo "[INFO] Running make with params: ${make_params[@]}"
97102
make -j$PARALLELISM -f "${ROOTDIR}/share/coreneuron/nrnivmodl_core_makefile" "${make_params[@]}"
98103

99-
echo "mods built successfully."
104+
echo "[INFO] mods built successfully."

tests/jenkins/Jenkinsfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ pipeline {
1010
string(name: 'NEURON_BRANCH', defaultValue: '',
1111
description: 'Which branch of neuron to use. For master branch (neuron@develop) leave this parameter blank.')
1212
}
13+
14+
environment {
15+
HOME = "${WORKSPACE}"
16+
JENKINS_DIR = "${WORKSPACE}/tests/jenkins"
17+
}
18+
1319
stages {
1420

1521
stage('install Spack'){
@@ -327,9 +333,7 @@ pipeline {
327333
}
328334
post {
329335
always {
330-
dir("${WORKSPACE}") {
331-
deleteDir()
332-
}
336+
cleanWs()
333337
}
334338
}
335339
}

tests/jenkins/_env_setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Upstream modules
2+
unset MODULEPATH
3+
source /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
4+
module load unstable
5+
6+
# Local spack
7+
BUILD_HOME="${WORKSPACE}/BUILD_HOME"
8+
INSTALL_HOME="${WORKSPACE}/INSTALL_HOME"
9+
export SPACK_ROOT="${BUILD_HOME}/spack"
10+
export SPACK_INSTALL_PREFIX="${SPACK_INSTALL_PREFIX:-${INSTALL_HOME}}"
11+
export SOFTS_DIR_PATH=$SPACK_INSTALL_PREFIX # Deprecated, but might still be reqd
12+
export PATH=$SPACK_ROOT/bin:/usr/bin:$PATH
13+
export MODULEPATH=$SPACK_INSTALL_PREFIX/modules/tcl/$(spack arch):$MODULEPATH
14+
15+
# Common init
16+
unset $(env|awk -F= '/^(PMI|SLURM)_/ {if ($1 != "SLURM_ACCOUNT") print $1}')
17+
module load hpe-mpi

tests/jenkins/install_coreneuron.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
. /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
5+
source ${JENKINS_DIR:-.}/_env_setup.sh
66

77
CORENRN_TYPE="$1"
88

tests/jenkins/install_neuron.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,10 @@ patch_neuron() (
1818
fi
1919
)
2020

21-
set -x
2221
set -e
22+
source ${JENKINS_DIR:-.}/_env_setup.sh
2323

24-
export SPACK_ROOT="$WORKSPACE/BUILD_HOME/spack/"
25-
export SPACK_INSTALL_PREFIX="${SPACK_INSTALL_PREFIX:-${WORKSPACE}/INSTALL_HOME}"
26-
source ${SPACK_ROOT}/share/spack/setup-env.sh
27-
source /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
28-
export PATH=$WORKSPACE/BUILD_HOME/spack/bin:/usr/bin:$PATH
29-
export MODULEPATH=$SPACK_INSTALL_PREFIX/modules/tcl/$(spack arch):$MODULEPATH
30-
31-
unset $(env|awk -F= '/^(PMI|SLURM)_/ {if ($1 != "SLURM_ACCOUNT") print $1}')
32-
24+
set -x
3325
patch_neuron
34-
3526
spack install neuron+debug@develop
3627
module av neuron

tests/jenkins/nrnivmodl-core.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/bash
22

3-
set -xe
3+
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
5+
module load intel
46

5-
. /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
6-
module load intel hpe-mpi
7+
set -x
78
TEST_DIR="$1"
89
CORENRN_TYPE="$2"
910

tests/jenkins/nrnivmodl.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
#!/usr/bin/bash
22

33
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
5+
module load neuron
46

7+
set -x
58
TEST_DIR="$1"
69

7-
. /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
8-
export SPACK_INSTALL_PREFIX="${SPACK_INSTALL_PREFIX:-${WORKSPACE}/INSTALL_HOME}"
9-
export PATH=$WORKSPACE/BUILD_HOME/spack/bin:/usr/bin:$PATH
10-
export MODULEPATH=$SPACK_INSTALL_PREFIX/modules/tcl/$(spack arch):$MODULEPATH
11-
12-
module load intel neuron
13-
14-
unset $(env|awk -F= '/^(PMI|SLURM)_/ {if ($1 != "SLURM_ACCOUNT") print $1}')
15-
1610
cd $WORKSPACE/${TEST_DIR}
1711
nrnivmodl mod

tests/jenkins/ringtest.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#!/usr/bin/bash
22

33
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
45

5-
module load hpe-mpi
6-
export MPI_UNBUFFERED_STDIO=1
6+
set -x
77
CORENRN_TYPE="$1"
8-
9-
if [ "${CORENRN_TYPE}" = "GPU-non-unified" ] || [ "${CORENRN_TYPE}" = "GPU-unified" ]; then
10-
unset $(env|awk -F= '/^(PMI|SLURM)_/ {if ($1 != "SLURM_ACCOUNT") print $1}')
11-
fi
8+
export MPI_UNBUFFERED_STDIO=1
129

1310
cd $WORKSPACE/build_${CORENRN_TYPE}
1411
echo "Testing ${CORENRN_TYPE}"

tests/jenkins/run_corenrn.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/bash
22

33
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
45

5-
module load hpe-mpi
6+
set -x
67
TEST_DIR="$1"
78
CORENRN_TYPE="$2"
89
TEST="$3"

tests/jenkins/run_corenrn_restore.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/bash
22

33
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
45

5-
module load hpe-mpi
6-
6+
set -x
77
CORENRN_TYPE="$1"
88
MPI_RANKS="$2"
99

tests/jenkins/run_neuron.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/bash
22

33
set -e
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
45

5-
module load hpe-mpi
6+
set -x
67
TEST_DIR="$1"
78
TEST="$2"
89
MPI_RANKS="$3"

tests/jenkins/run_neuron_direct.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
#!/usr/bin/bash
22

33
set -e
4-
set -x
4+
source ${JENKINS_DIR:-.}/_env_setup.sh
5+
module load neuron
56

7+
set -x
68
CORENRN_TYPE="$1"
7-
8-
unset MODULEPATH
9-
. /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
10-
export SPACK_INSTALL_PREFIX="${SPACK_INSTALL_PREFIX:-${WORKSPACE}/INSTALL_HOME}"
11-
export PATH=$WORKSPACE/BUILD_HOME/spack/bin:/usr/bin:$PATH
12-
export MODULEPATH=$SPACK_INSTALL_PREFIX/modules/tcl/$(spack arch):$MODULEPATH
13-
14-
module load hpe-mpi neuron
15-
169
export CORENEURONLIB=$WORKSPACE/install_${CORENRN_TYPE}/lib/libcoreneuron.so
17-
18-
unset $(env|awk -F= '/^(PMI|SLURM)_/ {if ($1 != "SLURM_ACCOUNT") print $1}')
19-
2010
python $WORKSPACE/tests/jenkins/neuron_direct.py

tests/jenkins/spack_setup.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@ echo "
77
Preparing spack environment...
88
====================================================================="
99

10-
export SPACK_INSTALL_PREFIX="${SPACK_INSTALL_PREFIX:-${WORKSPACE}/INSTALL_HOME}"
11-
export SOFTS_DIR_PATH=$SPACK_INSTALL_PREFIX # Deprecated, but might still be reqd
12-
13-
BUILD_HOME="${WORKSPACE}/BUILD_HOME"
14-
export SPACK_ROOT="${BUILD_HOME}/spack"
15-
16-
# ENV SETUP
17-
18-
# TODO: /usr/bin was added as a quickfix due to git dependencies probs
19-
export PATH=$SPACK_ROOT/bin/spack:/usr/bin:$PATH
20-
21-
# MODULES
22-
# Use spack only modules. Last one is added by changing MODULEPATH since it might not exist yet
23-
module purge
24-
unset MODULEPATH
25-
source /gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
26-
export MODULEPATH=$SPACK_INSTALL_PREFIX/modules/tcl/$(spack arch):$MODULEPATH
2710

2811
############################# CLONE/SETUP REPOSITORY #############################
2912

@@ -43,6 +26,7 @@ install_spack() (
4326

4427
)
4528

29+
source ${JENKINS_DIR:-.}/_env_setup.sh
4630

4731
install_spack
4832

0 commit comments

Comments
 (0)