NEURON
test_cmdline_interface.cpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================.
7 */
9 
10 #include <catch2/catch_test_macros.hpp>
11 
12 #include <cfloat>
13 
14 using namespace coreneuron;
15 
16 TEST_CASE("cmdline_interface") {
17  const char* argv[] = {
18 
19  "nrniv-core",
20 
21  "--mpi",
22 
23  "--dt",
24  "0.02",
25 
26  "--tstop",
27  "0.1",
28 #ifdef CORENEURON_ENABLE_GPU
29  "--gpu",
30 #endif
31  "--cell-permute",
32  "2",
33 
34  "--nwarp",
35  "8",
36 
37  "-d",
38  "./",
39 
40  "--voltage",
41  "-32",
42 
43  "--threading",
44 
45  "--ms-phases",
46  "1",
47 
48  "--ms-subintervals",
49  "2",
50 
51  "--multisend",
52 
53  "--spkcompress",
54  "32",
55 
56  "--binqueue",
57 
58  "--spikebuf",
59  "100",
60 
61  "--prcellgid",
62  "12",
63 
64  "--forwardskip",
65  "0.02",
66 
67  "--celsius",
68  "25.12",
69 
70  "--mindelay",
71  "0.1",
72 
73  "--dt_io",
74  "0.2"};
75  constexpr int argc = sizeof argv / sizeof argv[0];
76 
77  corenrn_parameters corenrn_param_test;
78 
79  corenrn_param_test.parse(argc, const_cast<char**>(argv)); // discarding const as CLI11
80  // interface is not const
81 
82  REQUIRE(corenrn_param_test.seed == -1); // testing default value
83 
84  REQUIRE(corenrn_param_test.spikebuf == 100);
85 
86  REQUIRE(corenrn_param_test.threading == true);
87 
88  REQUIRE(corenrn_param_test.dt == 0.02);
89 
90  REQUIRE(corenrn_param_test.tstop == 0.1);
91 
92  REQUIRE(corenrn_param_test.prcellgid == 12);
93 #ifdef CORENEURON_ENABLE_GPU
94  REQUIRE(corenrn_param_test.gpu == true);
95 #else
96  REQUIRE(corenrn_param_test.gpu == false);
97 #endif
98  REQUIRE(corenrn_param_test.dt_io == 0.2);
99 
100  REQUIRE(corenrn_param_test.forwardskip == 0.02);
101 
102  REQUIRE(corenrn_param_test.celsius == 25.12);
103 
104  REQUIRE(corenrn_param_test.mpi_enable == true);
105 
106  REQUIRE(corenrn_param_test.cell_interleave_permute == 2);
107 
108  REQUIRE(corenrn_param_test.voltage == -32);
109 
110  REQUIRE(corenrn_param_test.nwarp == 8);
111 
112  REQUIRE(corenrn_param_test.multisend == true);
113 
114  REQUIRE(corenrn_param_test.mindelay == 0.1);
115 
116  REQUIRE(corenrn_param_test.ms_phases == 1);
117 
118  REQUIRE(corenrn_param_test.ms_subint == 2);
119 
120  REQUIRE(corenrn_param_test.spkcompress == 32);
121 
122  REQUIRE(corenrn_param_test.multisend == true);
123 
124  // Reset all parameters to their default values.
125  corenrn_param_test.reset();
126 
127  // Should match a default-constructed set of parameters.
128  REQUIRE(corenrn_param_test.voltage == corenrn_parameters{}.voltage);
129 
130  // Everything has its default value, and the first `false` says not to
131  // include default values in the output, so this should be empty
132  REQUIRE(corenrn_param_test.config_to_str(false, false).empty());
133 }
static int argc
Definition: inithoc.cpp:45
static char ** argv
Definition: inithoc.cpp:46
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
bool threading
Use Multisend spike exchange instead of Allgather.
double mindelay
Forward skip to TIME.
double voltage
Temperature in degC.
int seed
Size in MB of the report buffer.
unsigned ms_subint
Number of multisend phases, 1 or 2.
double forwardskip
Initial voltage used for nrn_finitialize(1, v_init).
unsigned cell_interleave_permute
Spike Compression.
int prcellgid
Internal buffer used on every rank for spikes.
bool mpi_enable
Initialization seed for random number generator (int)
unsigned nwarp
Cell interleaving permutation.
bool multisend
Skip MPI finalization.
unsigned spkcompress
Number of multisend interval. 1 or 2.
double dt
Stop time of simulation in msec.
double dt_io
Timestep to use in msec.
unsigned ms_phases
Gid of cell for prcellstate.
double celsius
I/O timestep to use in msec for reports.
void parse(int argc, char *argv[])
Destructor defined in .cpp where CLI11 types are complete.
std::string config_to_str(bool default_also=false, bool write_description=false) const
Return a string summarising the current parameter values.
void reset()
Runs the CLI11_PARSE macro.
TEST_CASE("cmdline_interface")