Skip to content

Commit

Permalink
CoreNEURON: remove mod2c support (#2247)
Browse files Browse the repository at this point in the history
* Build wheels with NMODL instead of mod2c
* azure-pipelines.yml: bump timeouts as NMODL is slower

Co-authored-by: Alexandru Săvulescu <[email protected]>
  • Loading branch information
Nicolas Cornu and alexsavulescu authored May 30, 2023
1 parent beca15a commit d2d8110
Showing 19 changed files with 175 additions and 155 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ jobs:

- name: Install apt packages
run: |
sudo apt-get install xfonts-100dpi build-essential doxygen lcov libboost-all-dev libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin patchelf gpg ninja-build
sudo apt-get install xfonts-100dpi build-essential doxygen lcov libboost-all-dev libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin patchelf gpg ninja-build flex bison libfl-dev
shell: bash

- name: Setup Caliper profiler
@@ -76,6 +76,11 @@ jobs:
with:
fetch-depth: 2

- name: Clone nmodl
working-directory: ${{runner.workspace}}/nrn
run: |
git submodule update --init --recursive --force --depth 1 -- external/nmodl
- name: Set up Python@${{ env.PY_MIN_VERSION }}
uses: actions/setup-python@v4
with:
@@ -85,6 +90,7 @@ jobs:
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install --upgrade pip -r nrn_requirements.txt
python -m pip install --upgrade -r external/nmodl/requirements.txt
- name: Set up Python@${{ env.PY_MID_VERSION }}
uses: actions/setup-python@v4
@@ -100,6 +106,7 @@ jobs:
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install --upgrade pip -r nrn_requirements.txt
python -m pip install --upgrade -r external/nmodl/requirements.txt
- name: Build & Test
id: build-test
19 changes: 13 additions & 6 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
@@ -55,15 +55,15 @@ jobs:
- os: ubuntu-22.04
config:
build_mode: cmake
# TODO: -DCORENRN_ENABLE_NMODL=ON -DNMODL_SANITIZERS=undefined
# TODO: -DNMODL_SANITIZERS=undefined
cmake_option: -DNRN_ENABLE_CORENEURON=ON
-DNRN_ENABLE_INTERVIEWS=OFF
flag_warnings: ON
sanitizer: undefined
- os: ubuntu-22.04
config:
build_mode: cmake
# TODO: -DCORENRN_ENABLE_NMODL=ON -DNMODL_SANITIZERS=address,leak
# TODO: -DNMODL_SANITIZERS=address,leak
# TODO: CoreNEURON is only LeakSanitizer-clean if we disable MPI
cmake_option: -DNRN_ENABLE_CORENEURON=ON
-DNRN_ENABLE_INTERVIEWS=OFF
@@ -88,11 +88,11 @@ jobs:
- name: Install homebrew packages
if: startsWith(matrix.os, 'macOS')
run: |
brew install ccache coreutils doxygen flex mpich ninja xz autoconf autoconf automake libtool
brew install ccache coreutils doxygen flex bison mpich ninja xz autoconf autoconf automake libtool
brew unlink mpich
brew install openmpi
brew install --cask xquartz
echo /usr/local/opt/flex/bin >> $GITHUB_PATH
echo /usr/local/opt/flex/bin:/usr/local/opt/bison/bin >> $GITHUB_PATH
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=3 >> $GITHUB_ENV
@@ -104,7 +104,7 @@ jobs:
run: |
sudo apt-get install build-essential ccache libopenmpi-dev \
libmpich-dev libx11-dev libxcomposite-dev mpich ninja-build \
openmpi-bin patchelf
openmpi-bin patchelf flex libfl-dev bison
# The sanitizer builds use ubuntu 22.04
if [[ "${{matrix.os}}" == "ubuntu-20.04" ]]; then
sudo apt-get install g++-7 g++-8
@@ -119,6 +119,11 @@ jobs:
with:
fetch-depth: 2

- name: Clone nmodl
working-directory: ${{runner.workspace}}/nrn
run: |
git submodule update --init --recursive --force --depth 1 -- external/nmodl
- name: Set up Python@${{ env.PY_MIN_VERSION }}
if: ${{matrix.config.python_dynamic == 'ON'}}
uses: actions/setup-python@v4
@@ -130,6 +135,7 @@ jobs:
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install --upgrade pip -r nrn_requirements.txt
python -m pip install --upgrade -r external/nmodl/requirements.txt
- name: Set up Python@${{ env.PY_MAX_VERSION }}
uses: actions/setup-python@v4
@@ -140,6 +146,7 @@ jobs:
working-directory: ${{runner.workspace}}/nrn
run: |
python -m pip install --upgrade pip -r nrn_requirements.txt
python -m pip install --upgrade -r external/nmodl/requirements.txt
- name: Setup MUSIC@${{ env.MUSIC_VERSION }}
if: matrix.config.music == 'ON'
@@ -405,4 +412,4 @@ jobs:
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1
run: exit 1
38 changes: 12 additions & 26 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -54,14 +54,20 @@ mac_m1_cmake_build:
- echo "python3=$(command -v python3) is really ${real_python}"
- PYTHONEXECUTABLE=${real_python} ${real_python} -mvenv venv
- venv/bin/pip install --upgrade pip -r nrn_requirements.txt
- git submodule update --init --recursive --force --depth 1 -- external/nmodl
- venv/bin/pip install --upgrade -r external/nmodl/requirements.txt
- source ./venv/bin/activate
- export PYTHON=${PWD}/venv/bin/python
- ${PYTHON} --version
- '${PYTHON} -c "import os,matplotlib; f = open(os.path.join(os.path.dirname(matplotlib.__file__), \"mpl-data/matplotlibrc\"),\"a\"); f.write(\"backend: TkAgg\");f.close();"'
- 'export CXX=${CXX:-g++}'
- 'export CC=${CC:-gcc}'
- brew install flex bison
- export PATH="/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin:$PATH"
- export INSTALL_DIR=$(pwd)/install
- echo $LANG
- echo $LC_ALL
- 'export PYTHONPATH=$(${PYTHON} -c "import site; print(\":\".join(site.getsitepackages()))")'
- ${PYTHON} -c 'import os,sys; os.set_blocking(sys.stdout.fileno(), True)'
- cmake_args=(-G Ninja)
- if [[ -n "${sanitizer}" ]]; then
@@ -200,53 +206,37 @@ build:nmodl:
extends: [.build_neuron]
needs: ["build:nmodl"]

.build_neuron_mod2c:
extends: [.build_neuron]

build:neuron:mod2c:intel:shared:
extends: [.build_neuron_mod2c, .spack_intel]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper~gpu+coreneuron~legacy-unit~nmodl~openmp+shared+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:nmodl:intel:legacy:
extends: [.build_neuron_nmodl, .spack_intel]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper~gpu+coreneuron~legacy-unit+nmodl~openmp~shared~sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy
SPACK_PACKAGE_SPEC: ~rx3d~caliper~gpu+coreneuron~legacy-unit~openmp~shared~sympy+tests build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:nmodl:intel:shared:
extends: [.build_neuron_nmodl, .spack_intel]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper~gpu+coreneuron~legacy-unit+nmodl~openmp+shared+sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:mod2c:nvhpc:acc:shared:
extends: [.build_neuron_mod2c, .spack_nvhpc]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper+gpu+coreneuron~legacy-unit~nmodl~openmp+shared+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy
SPACK_PACKAGE_SPEC: ~rx3d~caliper~gpu+coreneuron~legacy-unit~openmp+shared+sympy+tests build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:nmodl:nvhpc:acc:legacy:
extends: [.build_neuron_nmodl, .spack_nvhpc]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper+gpu+coreneuron~legacy-unit+nmodl~openmp~shared~sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy
SPACK_PACKAGE_SPEC: ~rx3d~caliper+gpu+coreneuron~legacy-unit~openmp~shared~sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:nmodl:nvhpc:acc:shared:
extends: [.build_neuron_nmodl, .spack_nvhpc]
variables:
SPACK_PACKAGE_SPEC: ~rx3d~caliper+gpu+coreneuron~legacy-unit+nmodl~openmp+shared+sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy
SPACK_PACKAGE_SPEC: ~rx3d~caliper+gpu+coreneuron~legacy-unit~openmp+shared+sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy

build:neuron:nmodl:nvhpc:omp:legacy:
extends: [.build_neuron_nmodl, .spack_nvhpc]
variables:
SPACK_PACKAGE_SPEC: ~rx3d+caliper+gpu+coreneuron~legacy-unit+nmodl+openmp~shared~sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy ^caliper+cuda cuda_arch=70
SPACK_PACKAGE_SPEC: ~rx3d+caliper+gpu+coreneuron~legacy-unit+openmp~shared~sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy ^caliper+cuda cuda_arch=70

build:neuron:nmodl:nvhpc:omp:
extends: [.build_neuron_nmodl, .spack_nvhpc]
variables:
SPACK_PACKAGE_SPEC: ~rx3d+caliper+gpu+coreneuron~legacy-unit+nmodl+openmp~shared+sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy ^caliper+cuda cuda_arch=70
SPACK_PACKAGE_SPEC: ~rx3d+caliper+gpu+coreneuron~legacy-unit+openmp~shared+sympy+tests~unified build_type=FastDebug model_tests=channel-benchmark,olfactory,tqperf-heavy ^caliper+cuda cuda_arch=70

# Test NEURON
test:neuron:mod2c:intel:shared:
extends: [.test_neuron]
needs: ["build:neuron:mod2c:intel:shared"]

test:neuron:nmodl:intel:legacy:
extends: [.test_neuron]
@@ -256,10 +246,6 @@ test:neuron:nmodl:intel:shared:
extends: [.test_neuron]
needs: ["build:neuron:nmodl:intel:shared"]

test:neuron:mod2c:nvhpc:acc:shared:
extends: [.test_neuron, .gpu_node]
needs: ["build:neuron:mod2c:nvhpc:acc:shared"]

test:neuron:nmodl:nvhpc:acc:legacy:
extends: [.test_neuron, .gpu_node]
needs: ["build:neuron:nmodl:nvhpc:acc:legacy"]
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -22,6 +22,3 @@
[submodule "external/CLI11"]
path = external/CLI11
url = https://github.com/CLIUtils/CLI11.git
[submodule "external/mod2c"]
path = external/mod2c
url = https://github.com/BlueBrain/mod2c
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ stages:
jobs:

- job: 'ManyLinuxWheels'
timeoutInMinutes: 30
timeoutInMinutes: 45
pool:
vmImage: 'ubuntu-20.04'
strategy:
@@ -80,7 +80,7 @@ stages:


- job: 'ManyLinuxGPUWheels'
timeoutInMinutes: 30
timeoutInMinutes: 45
pool:
vmImage: 'ubuntu-20.04'
variables:
@@ -133,7 +133,7 @@ stages:

# Jobs to build OSX wheels natively
- job: 'MacOSWheels'
timeoutInMinutes: 40
timeoutInMinutes: 45
pool:
vmImage: 'macOS-11'
strategy:
1 change: 1 addition & 0 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ set(CMAKE_INSTALL_BINDIR bin)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_INCLUDEDIR include)
set(CMAKE_INSTALL_DATADIR share/nrn)
set(CMAKE_INSTALL_DATADIR_NMODL share/nmodl)

# =============================================================================
# Include nrnivmodl makefile generator
8 changes: 4 additions & 4 deletions bin/nrnivmodl-core.in
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ params_BUILD_TYPE="@COMPILE_LIBRARY_TYPE@"
params_NRN_PRCELLSTATE="@CORENRN_NRN_PRCELLSTATE@"

# prefix for common options : make sure to rename these if options are changed.
MAKE_OPTIONS="MECHLIB_SUFFIX MOD2CPP_BINARY MOD2CPP_RUNTIME_FLAGS DESTDIR INCFLAGS LINKFLAGS MODS_PATH VERBOSE BUILD_TYPE NRN_PRCELLSTATE"
MAKE_OPTIONS="MECHLIB_SUFFIX NMODL_BINARY NMODL_RUNTIME_FLAGS DESTDIR INCFLAGS LINKFLAGS MODS_PATH VERBOSE BUILD_TYPE NRN_PRCELLSTATE"

# parse CLI args
while getopts "n:m:a:d:i:l:Vp:r:b:h" OPT; do
@@ -45,11 +45,11 @@ while getopts "n:m:a:d:i:l:Vp:r:b:h" OPT; do
# suffix for mechanism library
params_MECHLIB_SUFFIX="$OPTARG";;
m)
# nmodl or mod2c binary to use
params_MOD2CPP_BINARY="$OPTARG";;
# nmodl binary to use
params_NMODL_BINARY="$OPTARG";;
a)
# additional nmodl flags to be used
params_MOD2CPP_RUNTIME_FLAGS="$OPTARG";;
params_NMODL_RUNTIME_FLAGS="$OPTARG";;
d)
# destination install directory
params_DESTDIR="$OPTARG";;
39 changes: 17 additions & 22 deletions bin/nrnivmodl_core_makefile.in
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ CORENRN_BIN_DIR := $(ROOT)/bin
CORENRN_LIB_DIR := $(ROOT)/lib
CORENRN_INC_DIR := $(ROOT)/include
CORENRN_SHARE_CORENRN_DIR:= $(ROOT)/share/coreneuron
CORENRN_SHARE_MOD2CPP_DIR := $(ROOT)/share/mod2c
CORENRN_SHARE_NMODL_DIR := $(ROOT)/share/nmodl

# name of the CoreNEURON binary
SPECIAL_EXE = $(OUTPUT_DIR)/special-core
@@ -81,15 +81,12 @@ CXX_LINK_EXE_CMD = $(CXX) $(CXXFLAGS) @CMAKE_EXE_LINKER_FLAGS@
CXX_SHARED_LIB_CMD = $(CXX) $(CXXFLAGS) @CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS@ @CMAKE_SHARED_LIBRARY_CXX_FLAGS@ @CMAKE_SHARED_LINKER_FLAGS@

# env variables required for mod2c or nmodl
MOD2CPP_ENV_VAR = @CORENRN_SANITIZER_ENABLE_ENVIRONMENT_STRING@ PYTHONPATH=@CORENRN_NMODL_PYTHONPATH@:${CORENRN_LIB_DIR}/python MODLUNIT=$(CORENRN_SHARE_MOD2CPP_DIR)/nrnunits.lib

# nmodl options
ifeq (@CORENRN_ENABLE_NMODL@, ON)
ifeq (@CORENRN_ENABLE_GPU@, ON)
nmodl_arguments_c=@NMODL_ACC_BACKEND_ARGS@ @NMODL_COMMON_ARGS@
else
nmodl_arguments_c=@NMODL_CPU_BACKEND_ARGS@ @NMODL_COMMON_ARGS@
endif
NMODL_ENV_VAR = @CORENRN_SANITIZER_ENABLE_ENVIRONMENT_STRING@ PYTHONPATH=@CORENRN_NMODL_PYTHONPATH@:${CORENRN_LIB_DIR}/python MODLUNIT=$(CORENRN_SHARE_NMODL_DIR)/nrnunits.lib

ifeq (@CORENRN_ENABLE_GPU@, ON)
nmodl_arguments_c=@NMODL_ACC_BACKEND_ARGS@ @NMODL_COMMON_ARGS@
else
nmodl_arguments_c=@NMODL_CPU_BACKEND_ARGS@ @NMODL_COMMON_ARGS@
endif

# name of the mechanism library with suffix if provided
@@ -110,12 +107,12 @@ else
corenrnmech_lib_target = coremech_lib_shared
endif

# Binary of MOD2C/NMODL depending on CMake option activated
# Binary of NMODL depending on CMake option activated
ifeq (@nmodl_FOUND@, TRUE)
MOD2CPP_BINARY_PATH = $(if $(MOD2CPP_BINARY),$(MOD2CPP_BINARY), @CORENRN_MOD2CPP_BINARY@)
INCLUDES += -I@CORENRN_MOD2CPP_INCLUDE@
NMODL_BINARY_PATH = $(if $(NMODL_BINARY),$(NMODL_BINARY), @CORENRN_NMODL_BINARY@)
INCLUDES += -I@CORENRN_NMODL_INCLUDE@
else
MOD2CPP_BINARY_PATH = $(if $(MOD2CPP_BINARY),$(MOD2CPP_BINARY), $(CORENRN_BIN_DIR)/@nmodl_binary_name@)
NMODL_BINARY_PATH = $(if $(NMODL_BINARY),$(NMODL_BINARY), $(CORENRN_BIN_DIR)/@nmodl_binary_name@)
endif

# MOD files with full path, without path and names without .mod extension
@@ -145,15 +142,13 @@ ALL_OBJS = $(MOD_FUNC_OBJ) $(mod_cpp_objs)
C_RESET := \033[0m
C_GREEN := \033[32m

# Default nmodl flags. Override if MOD2CPP_RUNTIME_FLAGS is not empty
ifeq (@CORENRN_ENABLE_NMODL@, ON)
MOD2CPP_FLAGS_C = $(if $(MOD2CPP_RUNTIME_FLAGS),$(MOD2CPP_RUNTIME_FLAGS),$(nmodl_arguments_c))
endif
# Default nmodl flags. Override if NMODL_RUNTIME_FLAGS is not empty
NMODL_FLAGS_C = $(if $(NMODL_RUNTIME_FLAGS),$(NMODL_RUNTIME_FLAGS),$(nmodl_arguments_c))

$(info Default NMODL flags: @nmodl_arguments_c@)

ifneq ($(MOD2CPP_RUNTIME_FLAGS),)
$(warning Runtime nmodl flags (they replace the default ones): $(MOD2CPP_RUNTIME_FLAGS))
ifneq ($(NMODL_RUNTIME_FLAGS),)
$(warning Runtime nmodl flags (they replace the default ones): $(NMODL_RUNTIME_FLAGS))
endif

# ======== MAIN BUILD RULES ============
@@ -200,7 +195,7 @@ $(MOD_OBJS_DIR)/%.o: $(MOD_TO_CPP_DIR)/%.cpp | $(MOD_OBJS_DIR)

# translate MOD files to CPP using mod2c/NMODL
$(mod_cpp_files): $(MOD_TO_CPP_DIR)/%.cpp: $(MODS_PATH)/%.mod | $(MOD_TO_CPP_DIR)
$(MOD2CPP_ENV_VAR) $(MOD2CPP_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ $(MOD2CPP_FLAGS_C)
$(NMODL_ENV_VAR) $(NMODL_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ $(NMODL_FLAGS_C)

# generate mod registration function. Dont overwrite if it's not changed
$(MOD_FUNC_CPP): build_always | $(MOD_TO_CPP_DIR)
@@ -209,7 +204,7 @@ $(MOD_FUNC_CPP): build_always | $(MOD_TO_CPP_DIR)
mv $(MOD_FUNC_CPP).tmp $(MOD_FUNC_CPP)

# symlink to cpp files provided by coreneuron
$(MOD_TO_CPP_DIR)/%.cpp: $(CORENRN_SHARE_MOD2CPP_DIR)/%.cpp | $(MOD_TO_CPP_DIR)
$(MOD_TO_CPP_DIR)/%.cpp: $(CORENRN_SHARE_NMODL_DIR)/%.cpp | $(MOD_TO_CPP_DIR)
ln -s $< $@

# create directories needed
6 changes: 3 additions & 3 deletions cmake/coreneuron/MakefileBuildOptions.cmake
Original file line number Diff line number Diff line change
@@ -149,8 +149,8 @@ string(
${CORENRN_EXTRA_COMPILE_FLAGS})

# =============================================================================
# nmodl/mod2c related options : TODO
# nmodl related options : TODO
# =============================================================================
# name of nmodl/mod2c binary
get_filename_component(nmodl_name ${CORENRN_MOD2CPP_BINARY} NAME)
# name of nmodl binary
get_filename_component(nmodl_name ${CORENRN_NMODL_BINARY} NAME)
set(nmodl_binary_name ${nmodl_name})
1 change: 0 additions & 1 deletion external/mod2c
Submodule mod2c deleted from 5d79c6
1 change: 1 addition & 0 deletions nrn_requirements.txt
Original file line number Diff line number Diff line change
@@ -12,3 +12,4 @@ pytest
pytest-cov
mpi4py
numpy
find_libpython
Loading

0 comments on commit d2d8110

Please sign in to comment.