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

Commit 2b329db

Browse files
authored
Enable nmodl as submodule to CoreNEURON (#208)
- can use following command to enable submodule: cmake .. -DCORENRN_ENABLE_NMODL=ON -DCORENRN_ENABLE_ISPC=OFF cmake .. -DCORENRN_ENABLE_NMODL=ON -DCORENRN_ENABLE_ISPC=ON - Option -DCORENRN_ENABLE_NMODL=OFF (default) should use old mod2c - One can set -DCORENRN_NMODL_DIR=<nmodl_install_prefix> to use pre-compiled NMODL - Update nmodl submodule to latest master
1 parent edbf5eb commit 2b329db

File tree

10 files changed

+67
-35
lines changed

10 files changed

+67
-35
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
path = external/mod2c
33
url = https://github.com/BlueBrain/mod2c
44
branch = master
5+
[submodule "external/nmodl"]
6+
path = external/nmodl
7+
url = https://github.com/BlueBrain/nmodl

CMake/AddNmodlSubmodule.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# =============================================================================
2+
# Copyright (C) 2016-2019 Blue Brain Project
3+
#
4+
# See top-level LICENSE file for details.
5+
# =============================================================================
6+
7+
include(FindPkgConfig)
8+
9+
find_path(NMODL_PROJ NAMES CMakeLists.txt PATHS "${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl")
10+
find_package_handle_standard_args(NMODL REQUIRED_VARS NMODL_PROJ)
11+
12+
if(NOT NMODL_FOUND)
13+
find_package(Git 1.8.3 QUIET)
14+
if(NOT ${GIT_FOUND})
15+
message(FATAL_ERROR "git not found, clone repository with --recursive")
16+
endif()
17+
message(STATUS "Sub-module nmodl missing : running git submodule update --init --recursive")
18+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --
19+
${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl
20+
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR})
21+
else()
22+
message(STATUS "Using nmodl submodule from ${NMODL_PROJ}")
23+
endif()
24+
25+
add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/nmodl)
26+

CMake/packages/Findlikwid.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Using likwid:
1515
#
1616
# ::
17-
# set(LIKWID_ROOT "" CACHE PATH "Path likwid performance monitoring and benchmarking suite")
17+
# set(LIKWID_DIR "" CACHE PATH "Path likwid performance monitoring and benchmarking suite")
1818
# find_package(likwid REQUIRED)
1919
# include_directories(${likwid_INCLUDE_DIRS})
2020
# target_link_libraries(foo ${likwid_LIBRARIES})
@@ -27,8 +27,8 @@
2727
# likwid_INCLUDE - list of required include directories
2828
# likwid_LIBRARIES - list of required library directories
2929

30-
find_path(likwid_INCLUDE_DIRS "likwid.h" HINTS "${LIKWID_ROOT}/include")
31-
find_library(likwid_LIBRARIES likwid HINTS "${LIKWID_ROOT}/lib")
30+
find_path(likwid_INCLUDE_DIRS "likwid.h" HINTS "${LIKWID_DIR}/include")
31+
find_library(likwid_LIBRARIES likwid HINTS "${LIKWID_DIR}/lib")
3232

3333
# Checks 'REQUIRED', 'QUIET' and versions.
3434
include(FindPackageHandleStandardArgs)

CMake/packages/Findnmodl.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Using nmodl:
1515
#
1616
# ::
17-
# set(CORENRN_NMODL_ROOT "" CACHE PATH "Path nmodl source-to-source compiler root")
17+
# set(CORENRN_NMODL_DIR "" CACHE PATH "Path to nmodl source-to-source compiler installation")
1818
# find_package(nmodl REQUIRED)
1919
# include_directories(${nmodl_INCLUDE_DIRS})
2020
# target_link_libraries(foo ${nmodl_LIBRARIES})
@@ -29,16 +29,16 @@
2929

3030

3131
# UNIX paths are standard, no need to write.
32-
find_program(nmodl_BINARY NAMES nmodl
33-
HINTS "${CORENRN_NMODL_ROOT}/bin" QUIET)
32+
find_program(nmodl_BINARY NAMES nmodl${CMAKE_EXECUTABLE_SUFFIX}
33+
HINTS "${CORENRN_NMODL_DIR}/bin" QUIET)
3434

35-
find_path(nmodl_INCLUDE "nmodl/fast_math.ispc" HINTS "${CORENRN_NMODL_ROOT}/include")
36-
find_path(nmodl_PYTHONPATH "nmodl/__init__.py" HINTS "${CORENRN_NMODL_ROOT}/lib/python")
35+
find_path(nmodl_INCLUDE "nmodl/fast_math.ispc" HINTS "${CORENRN_NMODL_DIR}/include")
36+
find_path(nmodl_PYTHONPATH "nmodl/__init__.py" HINTS "${CORENRN_NMODL_DIR}/lib/python")
3737

3838
# Checks 'REQUIRED', 'QUIET' and versions.
3939
include(FindPackageHandleStandardArgs)
4040

4141
find_package_handle_standard_args(nmodl
4242
FOUND_VAR nmodl_FOUND
4343
REQUIRED_VARS nmodl_BINARY nmodl_INCLUDE nmodl_PYTHONPATH)
44-
44+

CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ option(CORENRN_ENABLE_CUDA_UNIFIED_MEMORY "Enable CUDA unified memory support" O
6363
option(CORENRN_ENABLE_UNIT_TESTS "Enable unit tests execution" ON)
6464
option(CORENRN_ENABLE_GPU "Enable GPU support using OpenACC" OFF)
6565

66-
set(CORENRN_NMODL_ROOT "" CACHE PATH "Path nmodl source-to-source compiler root")
67-
set(LIKWID_ROOT "" CACHE PATH "Path to likwid performance analysis suite")
66+
set(CORENRN_NMODL_DIR "" CACHE PATH "Path to nmodl source-to-source compiler installation")
67+
set(LIKWID_DIR "" CACHE PATH "Path to likwid performance analysis suite")
6868

6969
set(CORENRN_FRONTEND_C_COMPILER gcc CACHE FILEPATH "C compiler for building mod2c [frontend]")
7070
set(CORENRN_FRONTEND_CXX_COMPILER g++ CACHE FILEPATH "C++ compiler for building mod2c [frontend]")
@@ -152,23 +152,25 @@ endif()
152152
# NMODL specific options
153153
# =============================================================================
154154
if(CORENRN_ENABLE_NMODL)
155-
find_package(nmodl REQUIRED)
156-
include_directories(${nmodl_INCLUDE})
157-
158-
# copy to make nrnivmodl-core work from build as well instal directory
159-
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
160-
configure_file(${nmodl_BINARY} ${CORENRN_NMODL_BINARY} COPYONLY)
161-
162-
# path to python interface
163-
set(ENV{PYTHONPATH} "${nmodl_PYTHONPATH}:$ENV{PYTHONPATH}")
164-
set(CORENRN_NMODL_PYTHONPATH $ENV{PYTHONPATH})
165-
155+
find_package(nmodl)
156+
if (nmodl_FOUND)
157+
set(CORENRN_NMODL_BINARY ${nmodl_BINARY})
158+
set(CORENRN_NMODL_INCLUDE ${nmodl_INCLUDE})
159+
# path to python interface
160+
set(ENV{PYTHONPATH} "${nmodl_PYTHONPATH}:$ENV{PYTHONPATH}")
161+
set(CORENRN_NMODL_PYTHONPATH $ENV{PYTHONPATH})
162+
else()
163+
include(AddNmodlSubmodule)
164+
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
165+
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
166+
endif()
167+
include_directories(${CORENRN_NMODL_INCLUDE})
166168
set(CORENRN_NMODL_FLAGS "" CACHE STRING "Extra NMODL options such as passes")
167169
separate_arguments(NMODL_EXTRA_FLAGS_LIST UNIX_COMMAND "${CORENRN_NMODL_FLAGS}")
168170
else()
169-
# use mod2c if nmodl not enabled
170171
include(AddMod2cSubmodule)
171172
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/mod2c_core${CMAKE_EXECUTABLE_SUFFIX})
173+
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
172174
endif()
173175

174176

@@ -230,7 +232,7 @@ if(cmake_generator_tolower MATCHES "makefile")
230232
message(STATUS "OpenMP | ${CORENRN_ENABLE_OPENMP}")
231233
message(STATUS "NMODL | ${CORENRN_ENABLE_NMODL}")
232234
if(CORENRN_ENABLE_NMODL)
233-
message(STATUS " PATH | ${nmodl_BINARY}")
235+
message(STATUS " PATH | ${CORENRN_NMODL_BINARY}")
234236
message(STATUS " ISPC | ${CORENRN_ENABLE_ISPC}")
235237
else()
236238
message(STATUS "MOD2C | ${MOD2C_PROJ}")

coreneuron/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ set_target_properties(coreneuron corenrnmech scopmath
184184
add_custom_command(TARGET coreneuron
185185
POST_BUILD
186186
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -i
187-
-I${CORENEURON_PROJECT_SOURCE_DIR}
187+
"-I${CORENEURON_PROJECT_SOURCE_DIR} -I${CORENRN_NMODL_INCLUDE}"
188+
-n ${CORENRN_NMODL_BINARY}
188189
${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod
189190
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
190191
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/special-core

coreneuron/utils/file_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3333
#include <errno.h>
3434

3535
#if defined(MINGW)
36-
#define mkdir(dir_name, permission) _mkdir(dir_name)
36+
#define mkdir(dir_name, permission) _mkdir(dir_name)
3737
#endif
3838

3939
/* adapted from : gist@jonathonreinhart/mkdir_p.c */

external/nmodl

Submodule nmodl added at 86fc52d

extra/nrnivmodl-core

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ set -e
88
APP_NAME=$(basename $0)
99
_PARENT="$(dirname $BASH_SOURCE)/.."
1010
ROOTDIR=$(perl -e "use Cwd 'abs_path'; print abs_path('$_PARENT')")
11-
MAKE_OPTIONS="MECH_NAME MECH_VERSION OUTPUT INCFLAGS LINKFLAGS MODS_PATH VERBOSE"
11+
MAKE_OPTIONS="NMODL_BINARY MECH_VERSION OUTPUT INCFLAGS LINKFLAGS MODS_PATH VERBOSE"
1212
PARALLELISM=4
1313

1414
while getopts "n:v:o:i:l:p:hV" OPT; do
1515
case "$OPT" in
1616
n)
17-
params_MECH_NAME="$OPTARG";;
17+
params_NMODL_BINARY="$OPTARG";;
1818
v)
1919
params_MECH_VERSION="$OPTARG";;
2020
o)
@@ -30,7 +30,7 @@ while getopts "n:v:o:i:l:p:hV" OPT; do
3030
h)
3131
echo "$APP_NAME [options, ...] [mods_path]"
3232
echo "Options:"
33-
echo " -n <name> Optionally add mech name to library, as suffix"
33+
echo " -n <binary> NMODL code generation compiler path"
3434
echo " -v <version> Set libcorenrnmech version (default: 0.0)"
3535
echo " -o <output_dir> Set the output dir (default: <arch>-core)"
3636
echo " -i <incl_flags> Definitions passed to the compiler, typically '-I dir..'"

extra/nrnivmodl_core_makefile.in

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# Mod files are looked up in the cwd, unless MODS_PATH is set
55

66
# Mechanisms version are by default 0.0, but should be overriden
7-
MECH_NAME =
7+
88
MECH_VERSION = 0.0
99
MODS_PATH = .
1010
OUTPUT = @CMAKE_HOST_SYSTEM_PROCESSOR@
1111
DESTDIR =
12-
12+
NMODL_BINARY =
1313
# Coreneuron dirs
1414
bindir := $(ROOT)/bin
1515
libdir := $(ROOT)/lib
@@ -18,7 +18,7 @@ datadir:= $(ROOT)/share/coreneuron
1818
datadir_mod2c := $(ROOT)/share/mod2c
1919

2020
# Binary of MOD2C/NMODL depending on what was activated
21-
nmodl_binary_path := $(bindir)/@nmodl_binary_name@
21+
nmodl_binary_path = $(if $(NMODL_BINARY),$(NMODL_BINARY), $(bindir)/@nmodl_binary_name@)
2222

2323
# Additional variables set in CMAKE usable here
2424
# - @CORENRN_COMPILE_DEFS
@@ -45,7 +45,7 @@ CXX_LINK_SHARED = $(CXX) $(CXXFLAGS) @CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS@ @CM
4545

4646
ISPC = @CMAKE_ISPC_COMPILER@
4747
ISPC_FLAGS = @CMAKE_ISPC_FLAGS@
48-
ISPC_COMPILE = $(ISPC) $(ISPC_FLAGS) -I$(incdir) -I@nmodl_INCLUDE@
48+
ISPC_COMPILE = $(ISPC) $(ISPC_FLAGS) -I$(incdir)
4949

5050
# Variables used in the "ARTIFICIAL_CELL" detection
5151
mod_c_srcs_path =
@@ -91,8 +91,7 @@ dimplic_c = $(MODC_DIR)/_dimplic.cpp
9191
dimplic_o = $(OBJS_DIR)/_dimplic.o
9292

9393
special = $(OUTPUT)/special-core
94-
LIB_SUFFIX_ = $(if $(MECH_NAME),_$(MECH_NAME),)
95-
coremech_libname = corenrnmech$(LIB_SUFFIX_).$(MECH_VERSION)
94+
coremech_libname = corenrnmech.$(MECH_VERSION)
9695
coremech_lib = $(OUTPUT)/lib$(coremech_libname)@CMAKE_SHARED_LIBRARY_SUFFIX@
9796

9897
# If no DESTDIR (we are probably just building) we use $ORIGIN (@loader_path in OSX)

0 commit comments

Comments
 (0)