48 namespace fs = std::filesystem;
67 if (!getenv(
"OMP_NUM_THREADS")) {
68 omp_set_num_threads(nthread);
79 char* first = strdup(args.c_str());
80 const char* sep =
" ";
83 char* token = strtok(first, sep);
86 token = strtok(
nullptr, sep);
93 first = strdup(args.c_str());
94 token = strtok(first, sep);
95 for (
int i = 0; token;
i++) {
97 token = strtok(
nullptr, sep);
127 (*nrn2core_get_trajectory_requests_)(
128 tid, bsize, n_pr, vpr, n_trajec, types, indices, pvars, varrays);
138 tr->
gather =
new double*[n_trajec];
141 for (
int i = 0;
i < n_trajec; ++
i) {
154 bool is_mapping_needed,
155 bool run_setup_cleanup) {
156 #if defined(NRN_FEEXCEPT)
175 #if CORENEURON_ENABLE_GPU
178 "compiled with CORENEURON_ENABLE_GPU does not allow the combination of "
179 "--cell-permute=2 and "
185 "compiled with OpenACC/CUDA does not allow the combination of --cuda-interface and "
194 nrnmpi_check_threading_support();
213 }
else if (
dt == -1000.) {
223 }
else if (
celsius == -1000.) {
250 " WARNING : GPU execution requires --cell-permute type 1 or 2. Setting it to 1.\n");
290 std::cout <<
" Start time (t) = " <<
t << std::endl << std::endl;
318 (*nrn2core_part2_clean_)();
344 if (prcellgid >= 0) {
345 std::string prcellname{compute_gpu ?
"acc_gpu" :
"cpu"};
347 prcellname +=
"_init";
362 dt = forwardskip * 0.1;
370 if (prcellgid >= 0) {
401 std::unique_ptr<ReportHandler> report_handler;
402 if (config.
format ==
"SONATA") {
403 report_handler = std::make_unique<SonataReportHandler>(spikes_info);
406 printf(
" WARNING : Report name '%s' has unknown format: '%s'.\n",
412 return report_handler;
425 #if NRNMPI && defined(NRNMPI_DYNAMICLOAD)
426 static void* load_dynamic_mpi(
const std::string& libname) {
431 std::string err_msg = std::string(
"Could not open dynamic MPI library: ") +
error +
"\n";
432 throw std::runtime_error(err_msg);
447 #ifdef NRNMPI_DYNAMICLOAD
452 throw std::runtime_error(
453 "For dynamic MPI support you must pass '--mpi-lib "
454 "/path/libcorenrnmpi_<name>.<suffix>` argument!\n");
459 static bool mpi_lib_loaded =
false;
460 if (!mpi_lib_loaded) {
463 mpi_lib_loaded =
true;
472 #ifdef CORENEURON_ENABLE_GPU
495 std::vector<ReportConfiguration> configs;
496 std::vector<std::unique_ptr<ReportHandler>> report_handlers;
498 bool reports_needs_finalize =
false;
513 reports_needs_finalize = !configs.empty();
527 fs::create_directories(output_dir);
545 printf(
"Error: Stop time (%lf) < Start time (%lf), restoring from checkpoint? \n",
563 double min_report_dt = INT_MAX;
564 for (
size_t i = 0;
i < configs.size();
i++) {
567 if (report_handler) {
568 report_handler->create_report(configs[
i],
dt, tstop, delay);
569 report_handlers.push_back(
std::move(report_handler));
571 if (configs[
i].report_dt < min_report_dt) {
572 min_report_dt = configs[
i].report_dt;
581 if (!configs.empty()) {
637 (*nrn2core_all_weights_return_)(
weights);
650 if (reports_needs_finalize) {
static void nrnmpi_barrier()
std::string get_restore_path() const
double restore_time() const
todo : need to broadcast this rather than all reading a double
nrn_pragma_acc(routine seq) nrn_pragma_omp(declare target) philox4x32_ctr_t coreneuron_random123_philox4x32_helper(coreneuron nrn_pragma_omp(end declare target) namespace coreneuron
Provide a helper function in global namespace that is declared target for OpenMP offloading to functi...
DLFCN_EXPORT void * dlopen(const char *file, int mode)
DLFCN_EXPORT char * dlerror(void)
void nrn_feenableexcept()
int run_solve_core(int argc, char **argv)
void(* nrn2core_part2_clean_)()
void set_openmp_threads(int nthread)
If "export OMP_NUM_THREADS=n" is not set then omp by default sets the number of threads equal to the ...
const char * corenrn_version()
void mk_mech_init(int argc, char **argv)
initialize standard mechanisms from coreneuron
char * prepare_args(int &argc, char **&argv, std::string &args)
Convert char* containing arguments from neuron to char* argv[] for coreneuron command line argument p...
Function prototypes for the functions providing information about simulator memory usage.
void move(Item *q1, Item *q2, Item *q3)
static void phase_end(const char *name)
static void start_profile()
static void stop_profile()
static void phase_begin(const char *name)
void delete_gap_indices_from_device()
void copy_gap_indices_to_device()
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
static void trajectory_return()
void nrn_init_and_load_data(int argc, char *argv[], CheckPoints &checkPoints, bool is_mapping_needed, bool run_setup_cleanup)
void nrn_finitialize(int setv, double v)
void nrn_set_extra_thread0_vdata()
bool nrn_use_bin_queue_
Flag to use the bin queue.
void handle_forward_skip(double forwardskip, int prcellgid)
int prcellstate(int gid, const char *suffix)
void report_cell_stats()
Reports global cell statistics of the simulation.
void core2nrn_data_return()
copy data back to NEURON.
void nrn_setup(const char *filesdat, bool is_mapping_needed, CheckPoints &checkPoints, bool run_setup_cleanup, const char *datpath, const char *restore_path, double *mindelay)
void get_nrn_trajectory_requests(int bsize)
bool nrn_have_gaps
variables defined in coreneuron library
void cnrn_target_delete(std::string_view file, int line, T *h_ptr, std::size_t len=1)
int nrn_set_timeout(int timeout)
void update_nrnthreads_on_host(NrnThread *threads, int nthreads)
void update(NrnThread *_nt)
T * cnrn_target_copyin(std::string_view file, int line, const T *h_ptr, std::size_t len=1)
void report_mem_usage(const char *message, bool all_ranks)
Reports current memory usage of the simulator to stdout.
void nrn_fixed_step_minimal()
int interleave_permute_type
bool use_solve_interleave
void set_globals(const char *path, bool cli_global_seed, int cli_global_seed_value)
void BBS_netpar_solve(double tstop)
void delete_trajectory_requests(NrnThread &nt)
const char * bbcore_write_version
void call_prcellstate_for_prcellgid(int prcellgid, int compute_gpu, int is_init)
std::unique_ptr< ReportHandler > create_report_handler(const ReportConfiguration &config, const SpikesInfo &spikes_info)
void set_report_buffer_size(int n)
void mk_spikevec_buffer(int sz)
nrn_pragma_acc(routine seq) int vector_capacity(void *v)
void nrnran123_destroy_global_state_on_device()
std::vector< ReportConfiguration > create_report_configurations(const std::string &filename, const std::string &output_dir, SpikesInfo &spikes_info)
mpi_manager_t & mpi_manager()
void delete_nrnthreads_on_device(NrnThread *threads, int nthreads)
Cleanup device memory that is being tracked by the OpenACC runtime.
void setup_report_engine(double dt_report, double mindelay)
in the current implementation, we call flush during every spike exchange interval.
void dt2thread(double adt)
void nrnran123_initialise_global_state_on_device()
void setup_nrnthreads_on_device(NrnThread *threads, int nthreads)
void allocate_data_in_mechanism_nrn_init()
void output_spikes(const char *outpath, const SpikesInfo &spikes_info)
double * legacy_index2pointer(int mtype, int index, NrnThread &nt)
void direct_mode_initialize()
All state from NEURON necessary to continue a run.
void clear_spike_vectors()
std::string cnrn_version()
corenrn_parameters corenrn_param
Printing method.
void update_weights_from_gpu(NrnThread *threads, int nthreads)
Copy weights from GPU to CPU.
void nrn_mkPatternStim(const char *fname, double tstop)
int nrnmpi_spike_compress(int nspike, bool gid_compress, int xchng_meth)
handle_interface< non_owning_identifier< storage > > handle
Non-owning handle to a Mechanism instance.
std::string to_string(const T &obj)
void(* nrn2core_all_weights_return_)(std::vector< double * > &weights)
void(* nrn2core_get_trajectory_requests_)(int tid, int &bsize, int &n_pr, void **&vpr, int &n_trajec, int *&types, int *&indices, double **&pvars, double **&varrays)
bool corenrn_embedded
--> Coreneuron
void(* nrn2core_trajectory_return_)(int tid, int n_pr, int bsize, int vecsz, void **vpr, double t)
Function declarations for the cell statistics.
void nrnmpi_init(int nrnmpi_under_nrncontrol, int *pargc, char ***pargv)
TrajectoryRequests * trajec_requests
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.
static constexpr int report_buff_size_default
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.
double forwardskip
Initial voltage used for nrn_finitialize(1, v_init).
unsigned cell_interleave_permute
Spike Compression.
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.
double tstop
Verbosity-level.
bool gpu
Enable pthread/openmp.
std::string patternstim
Maximum integration interval (likely reduced by minimum NetCon delay).
unsigned report_buff_size
Number of gpus to use per node.
unsigned ms_phases
Gid of cell for prcellstate.
bool skip_mpi_finalize
Enable MPI flag.
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.
void reset()
Runs the CLI11_PARSE macro.
void resolve_symbols(void *dlsym_handle)
static std::string to_string()
return version string (version + git id) as a string