NEURON
corenrn_parameters.hpp
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 */
8 #pragma once
9 #include <cstdint> // std::uint32_t
10 #include <memory>
11 #include <ostream>
12 #include <string>
13 
14 /**
15  * \class corenrn_parameters
16  * \brief Parses and contains Command Line parameters for Core Neuron
17  *
18  * This structure contains all the parameters that CoreNeuron fetches
19  * from the Command Line. It uses the CLI11 libraries to parse these parameters
20  * and saves them in an internal public structure. Each parameter can be
21  * accessed or written freely. By default the constructor instantiates a
22  * CLI11 object and initializes it for CoreNeuron use.
23  * This object is freely accessible from any point of the program.
24  * An ostream method is also provided to print out all the parameters that
25  * CLI11 parse.
26  * Please keep in mind that, due to the nature of the subcommands in CLI11,
27  * the command line parameters for subcategories NEED to be come before the relative
28  * parameter. e.g. --mpi --gpu gpu --nwarp
29  * Also single dash long options are not supported anymore (-mpi -> --mpi).
30  */
31 
32 namespace CLI {
33 struct App;
34 }
35 
36 namespace coreneuron {
37 
39  enum verbose_level : std::uint32_t {
40  NONE = 0,
41  ERROR = 1,
42  INFO = 2,
44  DEFAULT = INFO
45  };
46 
47  static constexpr int report_buff_size_default = 4;
48  static constexpr char const* default_dat_filename = "files.dat";
49 
50  unsigned spikebuf = 100'000; /// Internal buffer used on every rank for spikes
51  int prcellgid = -1; /// Gid of cell for prcellstate
52  unsigned ms_phases = 2; /// Number of multisend phases, 1 or 2
53  unsigned ms_subint = 2; /// Number of multisend interval. 1 or 2
54  unsigned spkcompress = 0; /// Spike Compression
55  unsigned cell_interleave_permute = 0; /// Cell interleaving permutation
56  unsigned nwarp = 65536; /// Number of warps to balance for cell_interleave_permute == 2
57  unsigned num_gpus = 0; /// Number of gpus to use per node
58  unsigned report_buff_size = report_buff_size_default; /// Size in MB of the report buffer.
59  int seed = -1; /// Initialization seed for random number generator (int)
60 
61  bool mpi_enable = false; /// Enable MPI flag.
62  bool skip_mpi_finalize = false; /// Skip MPI finalization
63  bool multisend = false; /// Use Multisend spike exchange instead of Allgather.
64  bool threading = false; /// Enable pthread/openmp
65  bool gpu = false; /// Enable GPU computation.
66  bool cuda_interface = false; /// Enable CUDA interface (default is the OpenACC interface).
67  /// Branch of the code is executed through CUDA kernels instead of
68  /// OpenACC regions.
69  bool binqueue = false; /// Use bin queue.
70 
71  bool show_version = false; /// Print version and exit.
72 
73  bool model_stats = false; /// Print mechanism counts and model size after initialization
74 
75  verbose_level verbose{verbose_level::DEFAULT}; /// Verbosity-level
76 
77  double tstop = 100; /// Stop time of simulation in msec
78  double dt = -1000.0; /// Timestep to use in msec
79  double dt_io = 0.1; /// I/O timestep to use in msec
80  double dt_report; /// I/O timestep to use in msec for reports
81  double celsius = -1000.0; /// Temperature in degC.
82  double voltage = -65.0; /// Initial voltage used for nrn_finitialize(1, v_init).
83  double forwardskip = 0.; /// Forward skip to TIME.
84  double mindelay = 10.; /// Maximum integration interval (likely reduced by minimum NetCon
85  /// delay).
86 
87  std::string patternstim; /// Apply patternstim using the specified spike file.
88  std::string datpath = "."; /// Directory path where .dat files
89  std::string outpath = "."; /// Directory where spikes will be written
90  std::string filesdat{}; /// Name of file containing list of gids dat files read in
91  std::string restorepath; /// Restore simulation from provided checkpoint directory.
92  std::string reportfilepath; /// Reports configuration file.
93  std::string checkpointpath; /// Enable checkpoint and specify directory to store related files.
94  std::string writeParametersFilepath; /// Write parameters to this file
95  std::string mpi_lib; /// Name of CoreNEURON MPI library to load dynamically.
96 };
97 
99  corenrn_parameters(); /// Constructor that initializes the CLI11 app.
100  ~corenrn_parameters(); /// Destructor defined in .cpp where CLI11 types are complete.
101 
102  void parse(int argc, char* argv[]); /// Runs the CLI11_PARSE macro.
103 
104  /** @brief Reset all parameters to their default values.
105  *
106  * Unfortunately it is awkward to support `x = corenrn_parameters{}`
107  * because `app` holds pointers to members of `corenrn_parameters`.
108  */
109  void reset();
110 
111  inline bool is_quiet() {
112  return verbose == verbose_level::NONE;
113  }
114 
115  /** @brief Return a string summarising the current parameter values.
116  *
117  * This forwards to the CLI11 method of the same name. Returns a string that
118  * could be read in as a config of the current values of the App.
119  *
120  * @param default_also Include any defaulted arguments.
121  * @param write_description Include option descriptions and the App description.
122  */
123  std::string config_to_str(bool default_also = false, bool write_description = false) const;
124 
125  private:
126  // CLI app that performs CLI parsing. std::unique_ptr avoids having to
127  // include CLI11 headers from CoreNEURON headers, and therefore avoids
128  // CoreNEURON having to install CLI11 when using it from a submodule.
129  std::unique_ptr<CLI::App> m_app;
130 };
131 
132 std::ostream& operator<<(std::ostream& os,
133  const corenrn_parameters& corenrn_param); /// Printing method.
134 
135 extern corenrn_parameters corenrn_param; /// Declaring global corenrn_parameters object for this
136  /// instance of CoreNeuron.
137 extern int nrn_nobanner_; /// Global no banner setting
138 
139 } // namespace coreneuron
static int argc
Definition: inithoc.cpp:45
static char ** argv
Definition: inithoc.cpp:46
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
int nrn_nobanner_
Declaring global corenrn_parameters object for this instance of CoreNeuron.
corenrn_parameters corenrn_param
Printing method.
std::ostream & operator<<(std::ostream &os, const corenrn_parameters &corenrn_param)
bool threading
Use Multisend spike exchange instead of Allgather.
double mindelay
Forward skip to TIME.
std::string restorepath
Name of file containing list of gids dat files read in.
double voltage
Temperature in degC.
std::string reportfilepath
Restore simulation from provided checkpoint directory.
std::string filesdat
Directory where spikes will be written.
int seed
Size in MB of the report buffer.
std::string outpath
Directory path where .dat files.
bool binqueue
Enable CUDA interface (default is the OpenACC interface).
unsigned ms_subint
Number of multisend phases, 1 or 2.
bool model_stats
Print version and exit.
double forwardskip
Initial voltage used for nrn_finitialize(1, v_init).
unsigned cell_interleave_permute
Spike Compression.
double dt_report
I/O timestep to use in msec.
verbose_level verbose
Print mechanism counts and model size after initialization.
bool cuda_interface
Enable GPU computation.
int prcellgid
Internal buffer used on every rank for spikes.
bool mpi_enable
Initialization seed for random number generator (int)
std::string datpath
Apply patternstim using the specified spike file.
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.
std::string patternstim
Maximum integration interval (likely reduced by minimum NetCon delay).
unsigned report_buff_size
Number of gpus to use per node.
double dt_io
Timestep to use in msec.
unsigned ms_phases
Gid of cell for prcellstate.
unsigned num_gpus
Number of warps to balance for cell_interleave_permute == 2.
double celsius
I/O timestep to use in msec for reports.
std::string mpi_lib
Write parameters to this file.
std::string writeParametersFilepath
Enable checkpoint and specify directory to store related files.
std::string checkpointpath
Reports configuration file.
static constexpr char const * default_dat_filename
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.
~corenrn_parameters()
Constructor that initializes the CLI11 app.
void reset()
Runs the CLI11_PARSE macro.
std::unique_ptr< CLI::App > m_app