Skip to content

Commit

Permalink
Merge branch 'master' into leite/balanced_files2
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdonline authored Nov 6, 2024
2 parents 342e8f8 + 2abbd25 commit c72d108
Show file tree
Hide file tree
Showing 33 changed files with 280 additions and 434 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

strategy:
matrix:
os: [ macOS-12, ubuntu-20.04]
os: [macOS-13, ubuntu-20.04]
config:
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "setuptools"}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", music: ON}
Expand Down
47 changes: 46 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ option(NRN_ENABLE_THREADS "Allow use of multithreading" ${NRN_ENABLE_THREADS_DEF
option(NRN_ENABLE_MPI "Enable MPI support" ${NRN_ENABLE_MPI_DEFAULT})
option(NRN_ENABLE_MUSIC "Enable MUSIC support" ${NRN_ENABLE_MUSIC_DEFAULT})
option(NRN_ENABLE_RX3D "Enable rx3d support" ${NRN_ENABLE_RX3D_DEFAULT})
option(NRN_ENABLE_NMODL "Enable NMODL code-generator support" ${NRN_ENABLE_NMODL_DEFAULT})
option(NRN_ENABLE_CORENEURON "Enable CoreNEURON support" ${NRN_ENABLE_CORENEURON_DEFAULT})
option(NRN_ENABLE_BACKTRACE "Enable pretty-printed backtraces" ${NRN_ENABLE_BACKTRACE_DEFAULT})
option(NRN_ENABLE_TESTS "Enable unit tests" ${NRN_ENABLE_TESTS_DEFAULT})
Expand Down Expand Up @@ -502,6 +503,49 @@ endif()
# initialize CLI11 submodule
cpp_cc_git_submodule(CLI11 BUILD PACKAGE CLI11 REQUIRED)

# =============================================================================
# Enable NMODL code-generator support
# =============================================================================
if(NRN_ENABLE_NMODL OR NRN_ENABLE_CORENEURON)

set(NMODL_ENABLE_PYTHON_BINDINGS
OFF
CACHE BOOL "Enable NMODL python bindings")
nrn_add_external_project(nmodl)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
set(NMODL_TARGET_TO_DEPEND nmodl)
set(NMODL_PROJECT_BINARY_DIR ${CMAKE_BINARY_DIR}/external/nmodl)
# install nrnunits.lib and libpywrapper.so from external/nmodl
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/lib/libpywrapper${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION lib
COMPONENT pywrapper
OPTIONAL)
install(
FILES ${NMODL_PROJECT_BINARY_DIR}/share/nmodl/nrnunits.lib
DESTINATION share/nmodl
COMPONENT nrnunits)

# set correct arguments for nmodl for cpu/gpu target
set(CORENRN_NMODL_FLAGS
""
CACHE STRING "Extra NMODL options such as passes")

endif()

# =============================================================================
# Flags for using NOCMODL/NMODL
# =============================================================================
if(NRN_ENABLE_NMODL)
set(NRN_NMODL_--neuron "--neuron")
set(NRN_CODEGENERATOR_NAME "nmodl")
set(NRN_CODEGENERATOR_TARGET nmodl)
else()
set(NRN_NMODL_--neuron "")
set(NRN_CODEGENERATOR_NAME "nocmodl")
set(NRN_CODEGENERATOR_TARGET nocmodl)
endif()

# =============================================================================
# Enable CoreNEURON support
# =============================================================================
Expand Down Expand Up @@ -536,7 +580,7 @@ if(NRN_ENABLE_CORENEURON)
get_property(CORENRN_LIB_LINK_FLAGS GLOBAL PROPERTY CORENRN_LIB_LINK_FLAGS)
get_property(CORENRN_NEURON_LINK_FLAGS GLOBAL PROPERTY CORENRN_NEURON_LINK_FLAGS)
get_property(CORENRN_ENABLE_SHARED GLOBAL PROPERTY CORENRN_ENABLE_SHARED)
get_property(CORENRN_NMODL_BINARY GLOBAL PROPERTY CORENRN_NMODL_BINARY)

# NEURON tests that link against CoreNEURON need to depend on it.
set(CORENEURON_TARGET_TO_DEPEND coreneuron-for-tests)

Expand Down Expand Up @@ -1047,6 +1091,7 @@ if(NRN_ENABLE_CORENEURON)
message(STATUS " PATH | ${CORENEURON_DIR}")
message(STATUS " LINK FLAGS | ${CORENRN_LIB_LINK_FLAGS}")
endif()
message(STATUS "NMODL codegen | ${NRN_ENABLE_NMODL}")
if(NRN_UNIVERSAL2_BUILD)
message(STATUS "CMAKE_OSX_ARCH| ${CMAKE_OSX_ARCHITECTURES}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ stages:
- job: 'MacOSWheels'
timeoutInMinutes: 60
pool:
vmImage: 'macOS-12'
vmImage: 'macOS-13'
strategy:
matrix:
Python38:
Expand Down
2 changes: 1 addition & 1 deletion bin/nrnivmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ for i in "${files[@]}" ; do
echo "\
${base_name// /\\ }.cpp: ${f}.mod \$(NOCMODL)
@printf \" -> \$(C_GREEN)NMODL\$(C_RESET) \$<\\\n\"
(cd \"$dir_name\"; @NRN_NOCMODL_SANITIZER_ENVIRONMENT_STRING@ MODLUNIT=\$(NRNUNITS) \$(NOCMODL) \"$base_name.mod\" -o \"$mdir\" $UserNMODLFLAGS)
(cd \"$dir_name\"; @NRN_NOCMODL_SANITIZER_ENVIRONMENT_STRING@ MODLUNIT=\$(NRNUNITS) \$(NOCMODL) \"$base_name.mod\" @NRN_NMODL_--neuron@ -o \"$mdir\" $UserNMODLFLAGS)
./${base_name// /\\ }.o: ${base_name// /\\ }.cpp
@printf \" -> \$(C_GREEN)Compiling\$(C_RESET) ${PWD}/\$<\\\n\"
Expand Down
6 changes: 4 additions & 2 deletions bin/nrnivmodl_core_makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ DESTDIR =
TARGET_LIB_TYPE = $(BUILD_TYPE)

# required for OSX to execute nrnivmodl-core
ifeq ($(origin SDKROOT), undefined)
export SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
ifeq ($(OS_NAME), Darwin)
ifeq ($(origin SDKROOT), undefined)
export SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
endif
endif

# CoreNEURON installation directories
Expand Down
2 changes: 1 addition & 1 deletion bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CXX_LINK_EXE = $(CXX) $(CXXFLAGS) @CMAKE_EXE_LINKER_FLAGS@ @NRN_LINK_FLAGS_STRIN
CXX_LINK_SHARED = $(CXX) $(CXXFLAGS) @CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS@ @CMAKE_SHARED_LIBRARY_CXX_FLAGS@ @CMAKE_SHARED_LINKER_FLAGS@ @NRN_LINK_FLAGS_STRING@

ifeq ($(UserNMODLBIN), )
NOCMODL = $(bindir)/nocmodl
NOCMODL = $(bindir)/@NRN_CODEGENERATOR_NAME@
else
NOCMODL = $(UserNMODLBIN)
endif
Expand Down
1 change: 1 addition & 0 deletions cmake/BuildOptionDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(NRN_ENABLE_THREADS_DEFAULT ON)
set(NRN_ENABLE_MPI_DEFAULT ON)
set(NRN_ENABLE_MUSIC_DEFAULT OFF)
set(NRN_ENABLE_RX3D_DEFAULT ON)
set(NRN_ENABLE_NMODL_DEFAULT OFF)
set(NRN_ENABLE_CORENEURON_DEFAULT OFF)
set(NRN_ENABLE_BACKTRACE_DEFAULT OFF)
set(NRN_ENABLE_TESTS_DEFAULT OFF)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if(NRN_ENABLE_COVERAGE)
if(NOT BUILD_TYPE_UPPER STREQUAL "DEBUG")
message(WARNING "Using CMAKE_BUILD_TYPE=Debug is recommended with NRN_ENABLE_COVERAGE")
endif()
set(NRN_COVERAGE_FLAGS_UNQUOTED --coverage -fno-inline)
set(NRN_COVERAGE_FLAGS_UNQUOTED --coverage -fno-inline -fprofile-update=atomic)
string(JOIN " " NRN_COVERAGE_FLAGS ${NRN_COVERAGE_FLAGS_UNQUOTED})
set(NRN_COVERAGE_LINK_FLAGS --coverage)

Expand Down
7 changes: 4 additions & 3 deletions cmake/MacroHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,18 @@ macro(nocmodl_mod_to_cpp modfile_basename)
if(CMAKE_VERSION VERSION_LESS "3.17")
set(REMOVE_CMAKE_COMMAND "remove")
endif()
get_filename_component(modfile_output_dir ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod DIRECTORY)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/${modfile_basename}.cpp
COMMAND
${CMAKE_COMMAND} -E env "MODLUNIT=${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib"
${NRN_NOCMODL_SANITIZER_ENVIRONMENT} $<TARGET_FILE:nocmodl>
${PROJECT_SOURCE_DIR}/${modfile_basename}.mod
${NRN_NOCMODL_SANITIZER_ENVIRONMENT} $<TARGET_FILE:${NRN_CODEGENERATOR_TARGET}>
${PROJECT_SOURCE_DIR}/${modfile_basename}.mod ${NRN_NMODL_--neuron} -o ${modfile_output_dir}
COMMAND sed ${NOCMODL_SED_EXPR} ${PROJECT_SOURCE_DIR}/${modfile_basename}.cpp >
${PROJECT_BINARY_DIR}/${modfile_basename}.cpp
COMMAND ${CMAKE_COMMAND} -E ${REMOVE_CMAKE_COMMAND}
${PROJECT_SOURCE_DIR}/${modfile_basename}.cpp
DEPENDS nocmodl ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod
DEPENDS ${NRN_CODEGENERATOR_TARGET} ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod
${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/nrniv)
endmacro()
Expand Down
42 changes: 0 additions & 42 deletions cmake/coreneuron/packages/Findnmodl.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion docs/install/mac_pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ generally only for the architecture indicated by ```uname -m```. That is
ok for openmpi but since the various python libraries are linked against
during build to create the version specific neuron modules, those python
installers also have to be universal. Fortunately, universal python versions
can be found at [python.org](http://python.org/Downloads/macOS) at least for
can be found at [python.org](https://www.python.org/downloads/macos) at least for
(as of 2022-01-01) python3.8, python3.9, and python3.10.

- ```xcode-select --install```:
Expand Down
50 changes: 0 additions & 50 deletions docs/nmodl/NMODL_language.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -444,56 +444,6 @@
"### LOCAL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### DISCRETE\n",
"\n",
"Short description"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Example mod file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cat mod/disc.mod"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Functionality example"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cat python_scripts/disc.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%run python_scripts/disc.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
24 changes: 0 additions & 24 deletions docs/nmodl/mod/disc.mod

This file was deleted.

26 changes: 0 additions & 26 deletions docs/nmodl/python_scripts/disc.py

This file was deleted.

2 changes: 1 addition & 1 deletion external/nmodl
Submodule nmodl updated 159 files
2 changes: 1 addition & 1 deletion share/examples/nrniv/nmodl/cadifusl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ INITIAL {
}
}

LOCAL frat[NANN] : gets extra cm when multiplied by diam
LOCAL frat[NANN] : gets extra cm when multiplied by diam

PROCEDURE coord() {
LOCAL r, dr2
Expand Down
8 changes: 6 additions & 2 deletions share/examples/nrniv/nmodl/cagkftab.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def test_1d():
test_1d_vecs = test_1d() # keep in existence in case of later use


def assert_isclose(a, b, abs_tol):
assert isclose(a, b, abs_tol=abs_tol), f"{a = } {b = } delta = {a - b} {abs_tol = }"


def setup_tables():
ln_ca_range = (-18, 4, 0.1) # about 1e-9 to 1e2 in steps of 0.1 log unit
v_range = (-80, 50, 1) # -80mV to 50mV in 1mV steps
Expand All @@ -132,8 +136,8 @@ def setup_tables():
for j, lnca in enumerate(casteps):
malp.x[i][j] = alp(v, lnca)
mbet.x[i][j] = bet(v, lnca)
assert isclose(malp.x[i][j], h.alp_cagk(v, exp(lnca)), abs_tol=1e-9)
assert isclose(mbet.x[i][j], h.bet_cagk(v, exp(lnca)), abs_tol=1e-9)
assert_isclose(malp.x[i][j], h.alp_cagk(v, exp(lnca)), abs_tol=1e-9)
assert_isclose(mbet.x[i][j], h.bet_cagk(v, exp(lnca)), abs_tol=1e-9)

# dimensions specified in size, min, max format
h.table_alp_cagkftab(
Expand Down
3 changes: 2 additions & 1 deletion share/examples/nrniv/nmodl/nonlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

def dif(tol):
for cell in cells:
assert cell.dif() < tol
residual = cell.dif()
assert residual < tol, f"{residual = }, {tol = }"


def solve(a, b, c):
Expand Down
4 changes: 0 additions & 4 deletions share/examples/nrniv/nmodl/synpre.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,4 @@ PROCEDURE getonset() {
if (vpre > vprethresh && t > onset + deadtime) {
onset = t
}

VERBATIM
return 0;
ENDVERBATIM
}
Loading

0 comments on commit c72d108

Please sign in to comment.