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

Commit fd28045

Browse files
st4rl3ssNicolas Cornupramodkferdonline
authored
Improved Command Line with CLI11 (#179)
* First integration of CLI11 in Coreneuron * CLI11 integrated as ubmodule * Fixed integration tests for new CLI * cn_parameters structure includes constructor and parse function * Removed paths from cmdline_interface tests. * Changed cn_par to corenrn_param to make it clearer * Now program doesn't print empty string parameters * More details on new CLI on README.md * Fixed integration tests for CLI and GPU * Added `--show` option to facilitate debugging. * Fix a free usage when variable is created with new * Adding CORENEURON_VERSION in engine.h and also merging engine and enginemech.h * Use combined int version Co-authored-by: Nicolas Cornu <[email protected]> Co-authored-by: Pramod Kumbhar <[email protected]> Co-authored-by: Fernando Pereira <[email protected]>
1 parent 4c88a1f commit fd28045

28 files changed

+557
-2906
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[submodule "external/mod2c"]
22
path = external/mod2c
33
url = https://github.com/BlueBrain/mod2c
4+
[submodule "external/CLI11"]
5+
path = external/CLI11
6+
url = https://github.com/CLIUtils/CLI11.git
47
[submodule "external/nmodl"]
58
path = external/nmodl
69
url = https://github.com/BlueBrain/nmodl

CMake/AddCLI11Submodule.cmake

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

CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
# =============================================================================
66

77
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
8-
project(coreneuron)
8+
project(coreneuron VERSION 0.18.0)
9+
10+
# It is a bad idea having floating point versions, since macros cant handle them
11+
# We therefore, have version as an int, which is pretty much standard
12+
math(EXPR CORENEURON_VERSION_COMBINED
13+
"${coreneuron_VERSION_MAJOR} * 100 + ${coreneuron_VERSION_MINOR}")
914

1015
# =============================================================================
1116
# CMake common project settings
1217
# =============================================================================
13-
set(VERSION_MAJOR "0")
14-
set(VERSION_MINOR "16")
15-
set(VERSION_PATCH "0")
1618
set(CMAKE_CXX_STANDARD 14)
1719
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1820
set(CMAKE_CXX_EXTENSIONS OFF)
19-
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
2021
set(CMAKE_BUILD_TYPE
2122
RelWithDebInfo
2223
CACHE STRING "Empty or one of Debug, Release, RelWithDebInfo")
@@ -46,6 +47,8 @@ include(ReleaseDebugAutoFlags)
4647
include(CrayPortability)
4748
include(SetRpath)
4849
include(CTest)
50+
include(AddCLI11Submodule)
51+
add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11)
4952

5053
# =============================================================================
5154
# Build options

README.md

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Note that the CUDA Toolkit version should be compatible with PGI compiler instal
9999
You have to run GPU executable with the `--gpu` or `-gpu`. Make sure to enable cell re-ordering mechanism to improve GPU performance using `--cell_permute` option (permutation types : 2 or 1):
100100

101101
```bash
102-
mpirun -n 1 ./bin/nrniv-core -d ../tests/integration/ring -mpi -e 100 --gpu --cell_permute 2
102+
mpirun -n 1 ./bin/nrniv-core --mpi --gpu --tstop 100 --datpath ../tests/integration/ring --cell-permute 2
103103
```
104104

105105
Note that if your model is using Random123 random number generator, you can't use same executable for CPU and GPU runs. We suggest to build separate executable for CPU and GPU simulations. This will be fixed in future releases.
@@ -132,65 +132,26 @@ cmake .. -DCMAKE_CXX_FLAGS="-O3 -g" \
132132

133133
## RUNNING SIMULATION:
134134

135-
Note that the CoreNEURON simulator dependends on NEURON to build the network model: see [NEURON](https://www.neuron.yale.edu/neuron/) documentation for more information. Once you build the model using NEURON, you can launch CoreNEURON on the same or different machine by:
135+
Note that the CoreNEURON simulator depends on NEURON to build the network model: see [NEURON](https://www.neuron.yale.edu/neuron/) documentation for more information. Once you build the model using NEURON, you can launch CoreNEURON on the same or different machine by:
136136

137137
```bash
138138
export OMP_NUM_THREADS=2 #set appropriate value
139-
mpiexec -np 2 build/bin/nrniv-core -e 10 -d /path/to/model/built/by/neuron -mpi
139+
mpiexec -np 2 build/bin/nrniv-core --tstop 10 --datpath /path/to/model/built/by/neuron --mpi
140140
```
141141

142142
[This tutorial](https://github.com/nrnhines/ringtest) provide more information for parallel runs and performance comparison.
143143

144-
In order to see the command line options, you can use:
144+
### Command Line Interface
145145

146-
```bash
147-
/path/to/isntall/directory/nrniv-core --help
148-
-b, --spikebuf ARG Spike buffer size. (100000)
149-
-c, --threading Parallel threads. The default is serial threads.
150-
-d, --datpath ARG Path containing CoreNeuron data files. (.)
151-
-dt, --dt ARG Fixed time step. The default value is set by
152-
defaults.dat or is 0.025.
153-
-e, --tstop ARG Stop time (ms). (100)
154-
-f, --filesdat ARG Name for the distribution file. (files.dat)
155-
-g, --prcellgid ARG Output prcellstate information for the gid NUMBER.
156-
-gpu, --gpu Enable use of GPUs. The default implies cpu only
157-
run.
158-
-h, --help Print a usage message briefly summarizing these
159-
command-line options, then exit.
160-
-k, --forwardskip ARG Forwardskip to TIME
161-
-l, --celsius ARG Temperature in degC. The default value is set in
162-
defaults.dat or else is 34.0.
163-
-mpi Enable MPI. In order to initialize MPI environment
164-
this argument must be specified.
165-
-o, --outpath ARG Path to place output data files. (.)
166-
-p, --pattern ARG Apply patternstim using the specified spike file.
167-
-R, --cell-permute ARG Cell permutation, 0 No; 1 optimise node adjacency; 2
168-
optimize parent adjacency. (1)
169-
-s, --seed ARG Initialization seed for random number generator
170-
(int).
171-
-v, --voltage ARG Initial voltage used for nrn_finitialize(1, v_init).
172-
If 1000, then nrn_finitialize(0,...). (-65.)
173-
-W, --nwarp ARG Number of warps to balance. (0)
174-
-x, --extracon ARG Number of extra random connections in each thread to
175-
other duplicate models (int).
176-
--binqueue Use bin queue.
177-
--checkpoint ARG Enable checkpoint and specify directory to store
178-
related files.
179-
--mindelay ARG Maximum integration interval (likely reduced by
180-
minimum NetCon delay). (10)
181-
--ms-phases ARG Number of multisend phases, 1 or 2. (2)
182-
--ms-subintervals ARG Number of multisend subintervals, 1 or 2. (2)
183-
--multisend Use Multisend spike exchange instead of Allgather.
184-
--read-config ARG Read configuration file filename.
185-
--restore ARG Restore simulation from provided checkpoint
186-
directory.
187-
--show Print args.
188-
--skip-mpi-finalize Do not call mpi finalize.
189-
--spkcompress ARG Spike compression. Up to ARG are exchanged during
190-
MPI_Allgather. (0)
191-
--write-config ARG Write configuration file filename.
192-
```
146+
:warning: :warning: :warning: **In a recent update the command line interface was updated, so please update your scripts accordingly!**
147+
148+
Some details on the new interface:
149+
150+
The new command line interface is based on CLI11. You can find more details by running `coreneuron_exec --help`.
151+
152+
Multiple characters options with single dash (`-gpu`, `-mpi`, `-dt`) are **not** supported anymore. All those options now require a double dash (`--gpu`, `--mpi`, `--dt`), but single characters options still support a single dash (e.g. `-g`).
193153

154+
The format of the configuration options file has changed, regenerate them if there is any problem.
194155

195156
## Results
196157

coreneuron/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# commonly included directories
88
include_directories(utils/randoms
99
${MPI_INCLUDE_PATH}
10-
${CMAKE_CURRENT_BINARY_DIR}
11-
${CORENEURON_PROJECT_SOURCE_DIR})
10+
${CMAKE_BINARY_DIR}/coreneuron
11+
${CMAKE_BINARY_DIR}/include)
1212

1313
# put libraries (e.g. dll) in bin directory
1414
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -20,6 +20,7 @@ file(GLOB_RECURSE CORENEURON_HEADER_FILES "*.h*")
2020
file(GLOB_RECURSE CORENEURON_TEMPLATE_FILES "*.ipp")
2121
file(GLOB CORENEURON_CODE_FILES
2222
"apps/main1.cpp"
23+
"apps/corenrn_parameters.cpp"
2324
"gpu/*.cpp"
2425
"io/*.cpp"
2526
"mechanism/*.cpp"
@@ -173,6 +174,7 @@ target_link_libraries(coreneuron
173174
${CALIPER_LIB}
174175
${CALIPER_MPI_LIB}
175176
${likwid_LIBRARIES})
177+
target_include_directories(coreneuron SYSTEM PRIVATE ${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11/include)
176178

177179
target_link_libraries(corenrnmech scopmath coreneuron)
178180

@@ -229,6 +231,8 @@ configure_file(${DIMPLIC_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/dimplic
229231
configure_file(${ENGINEMECH_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp COPYONLY)
230232

231233
# Make headers avail to build tree
234+
configure_file(engine.h.in ${CMAKE_BINARY_DIR}/include/coreneuron/engine.h @ONLY)
235+
232236
file(GLOB_RECURSE main_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.h *.hpp *.ispc)
233237
foreach(header ${main_headers})
234238
configure_file("${header}" "${CMAKE_BINARY_DIR}/include/coreneuron/${header}" COPYONLY)
@@ -265,8 +269,8 @@ install(TARGETS coreneuron corenrnmech ${link_cudacoreneuron}
265269
install(TARGETS scopmath EXPORT coreneuron DESTINATION lib)
266270

267271
# headers and some standalone code files for nrnivmodl-core
268-
install(DIRECTORY .
269-
DESTINATION include/coreneuron
272+
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/coreneuron
273+
DESTINATION include/
270274
FILES_MATCHING
271275
PATTERN "*.h*"
272276
PATTERN "*.ipp"

coreneuron/apps/coreneuron.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2626
THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29-
#include <coreneuron/enginemech.h>
29+
#include <coreneuron/engine.h>
3030
#include "coreneuron/utils/profile/profiler_interface.h"
3131

3232
int main(int argc, char** argv) {

0 commit comments

Comments
 (0)