1 #include <../../nrnconf.h>
12 #define nrnoc_fadvance_c
13 #include "utils/profile/profiler_interface.h"
48 #if !defined(NRNMPI) || NRNMPI == 0
53 extern double chkarg(
int,
double low,
double high);
74 #define NONVINT_ODE_COUNT 5
77 #define CTBEGIN double wt = nrnmpi_wtime()
78 #define CTADD nth->_ctime += nrnmpi_wtime() - wt
84 #define ELIMINATE_T_ROUNDOFF 0
85 #if ELIMINATE_T_ROUNDOFF
94 double nrn_ndt_, nrn_tbase_, nrn_dt_;
96 if (
dt != nrn_dt_ ||
t != nrn_tbase_ + nrn_ndt_ * nrn_dt_) {
98 Printf(
"nrn_chk_ndt t=%g dt=%g old nrn_tbase_=%g nrn_ndt_=%g nrn_dt_=%g\n",
191 static void batch_open(
char*
name,
double tstop,
double tstep,
const char* comment) {
203 "%s\nbatch_run from t = %g to %g in steps of %g with dt = %g\n",
235 double tstop, tstep, tnext;
239 tstop =
chkarg(1, 0., 1e20);
240 tstep =
chkarg(2, 0., 1e20);
326 #if ELIMINATE_T_ROUNDOFF
347 (*nrnmpi_v_transfer_)();
361 (*nrnmpi_v_transfer_)();
368 (*nrn_allthread_handle)();
381 #if ELIMINATE_T_ROUNDOFF
390 for (
i = 1;
i <
n; ++
i) {
396 (*nrn_allthread_handle)();
415 (*nrn_allthread_handle)();
425 (*nrn_allthread_handle)();
438 auto*
const nth = &nt;
440 nth->_stop_stepping = 0;
444 if (nth->_stop_stepping) {
448 nth->_stop_stepping = 0;
458 auto*
const nth = &nt;
466 #if ELIMINATE_T_ROUNDOFF
468 nt.
_t = nrn_tbase_ + nt.nrn_ndt_ * nrn_dt_;
470 nt.
_t += .5 * nt.
_dt;
503 auto*
const nth = &nt;
505 #if ELIMINATE_T_ROUNDOFF
507 nth->_t = nrn_tbase_ + nth->nrn_ndt_ * nrn_dt_;
509 nth->_t += .5 * nth->_dt;
529 #if ELIMINATE_T_ROUNDOFF
531 nth->
_t = nrn_tbase_ + nth->nrn_ndt_ * nrn_dt_;
533 nth->
_t += .5 * nth->
_dt;
575 auto*
const _nt = &nt;
581 for (
i = i1;
i < i2; ++
i) {
585 for (
i = i1;
i < i2; ++
i) {
597 (*nrnthread_vi_compute_)(_nt);
611 constexpr
int i1 = 0;
612 auto const i3 = _nt->
end;
619 for (
int i = i1;
i < i3; ++
i) {
620 vec_sav_rhs[
i] = (vec_sav_d[
i] *
vec_rhs[
i] + vec_sav_rhs[
i]) * vec_area[
i] * 0.01;
634 constexpr
auto i1 = 0;
639 for (
int i = i1;
i < i3; ++
i) {
640 vec_sav_rhs[
i] = (
vec_rhs[
i] + vec_sav_rhs[
i]) * vec_area[
i] * 0.01;
676 for (
i = 1;
i <=
n; ++
i) {
681 for (inode = 0; inode < _nt->
end; ++inode) {
683 Printf(
"%d %g %g %g %g\n",
693 for (inode = 0; inode <
sec->nnode; ++inode) {
694 nd =
sec->pnode[inode];
695 Printf(
"%d %d %g %g %g %g\n",
714 id = (int)
chkarg(2, 1., 4.);
746 for (
auto* tml = nt.
tml; tml; tml = tml->
next) {
752 memb_func[tml->index].state(sorted_token, &nt, tml->ml, tml->index);
758 hoc_warning(
"errno set during calculation of states",
nullptr);
771 "%d errno=%d at t=%g during call to mechanism %s\n",
816 #if ELIMINATE_T_ROUNDOFF
837 auto const vec_v = _nt->node_voltage_storage();
838 std::fill_n(vec_v, _nt->end,
v);
844 (*nrnthread_vi_compute_)(_nt);
853 (*nrnthread_v_transfer_)(_nt);
871 for (tml = nt->
tml; tml; tml = tml->
next) {
886 ml.set_storage_offset(0);
891 hoc_warning(
"errno set during call to INITIAL block", (
char*) 0);
933 (*nrn_allthread_handle)();
994 for (
int i = 0;
i < ml->nodecount; ++
i) {
995 f(ml->nodelist[
i], ml->pdata[
i], ml->_thread, &nt, ml,
i, cache_token);
1011 rval = (*func)(method, size, pd1, pd2, tid);
1039 for (
size_t i = 0;
i <
n; ++
i) {
1053 int rval = (*nrn_nonvint_block)(method, size, pd1, pd2, tid);
void setup_topology(void)
Node * node_exact(Section *sec, double x)
like node_index but give proper node when x is 0 or 1 as well as in between
short * nrn_is_artificial_
void nrn_update_2d(NrnThread *nt)
static void * nrn_ms_bksub_through_triang(NrnThread *)
void(* nrnthread_vi_compute_)(NrnThread *nt)
void(* nrn_multisplit_setup_)()
static std::vector< NonVintBlockItem > nonvint_block_list
static double ** batch_var
double chkarg(int, double low, double high)
void nrn_calc_fast_imem(NrnThread *_nt)
static int step_group_end
int unset_nonvint_block(NonVintBlockItem func)
static void nonvint(neuron::model_sorted_token const &, NrnThread &)
void * nrn_multisplit_reduce_solve(NrnThread *)
void nrn_update_voltage(neuron::model_sorted_token const &sorted_token, NrnThread &nt)
void nrn_fixed_step_group(neuron::model_sorted_token const &cache_token, int n)
void nrncvode_set_t(double t)
int set_nonvint_block(NonVintBlockItem func)
static void * nrn_ms_bksub(NrnThread *)
void nrn_print_matrix(NrnThread *_nt)
int nrn_nonvint_block_exe(int method, int size, double *pd1, double *pd2, int tid)
void nrn_daspk_init_step(double tt, double dteps, int upd)
int nrn_nonvint_block_helper(int method, int size, double *pd1, double *pd2, int tid)
void(* nrn_allthread_handle)()
void nrn_solve(NrnThread *)
int state_discon_allowed_
int(* NonVintBlockItem)(int method, int size, double *pd1, double *pd2, int tid)
static void nrn_fixed_step_thread(neuron::model_sorted_token const &, NrnThread &)
void * nrn_multisplit_triang(NrnThread *)
static void * nrn_ms_reduce_solve(NrnThread *)
void nrn_fixed_step(neuron::model_sorted_token const &cache_token)
void nrn_calc_fast_imem_fixedstep_init(NrnThread *_nt)
static int step_group_begin
void * nrn_multisplit_bksub(NrnThread *)
void nrn_fixed_step_lastpart(neuron::model_sorted_token const &cache_token, NrnThread &nt)
void nrn_ba(neuron::model_sorted_token const &cache_token, NrnThread &nt, int bat)
void verify_structure(void)
void nrn_finitialize(int setv, double v)
void nrn_extra_scatter_gather(int direction, int tid)
static void dt2thread(double adt)
static void * nrn_ms_treeset_through_triang(NrnThread *)
#define NONVINT_ODE_COUNT
static void batch_close()
void(* nrnthread_v_transfer_)(NrnThread *nt)
int nrn_errno_check(int i)
static void daspk_init_step_thread(neuron::model_sorted_token const &cache_token, NrnThread &nt)
static void nrn_fixed_step_group_thread(neuron::model_sorted_token const &, NrnThread &)
void(* nrnmpi_v_transfer_)()
neuron::opaque_model_sorted_token nrn_ensure_model_data_are_sorted_opaque()
void nrn_fihexec(int type)
int hoc_errno_check(void)
double * hoc_val_pointer(const char *s)
void hoc_retpushx(double x)
double * hoc_pgetarg(int narg)
void long_difus_solve(neuron::model_sorted_token const &sorted_token, int method, NrnThread &nt)
void(*)(Node *, Datum *, Datum *, NrnThread *, Memb_list *, std::size_t, neuron::model_sorted_token const &) nrn_bamech_t
#define ITERATE(itm, lst)
void move(Item *q1, Item *q2, Item *q3)
auto for_threads(NrnThread *threads, int num_threads)
double * nrn_classicalNodeA(Node *nd)
double * nrn_classicalNodeB(Node *nd)
static void phase_end(const char *name)
static void phase_begin(const char *name)
phase
Reading phase number.
void nrn_spike_exchange(NrnThread *nt)
void fixed_play_continuous(NrnThread *nt)
void second_order_cur(NrnThread *_nt, int secondorder)
void nrn_thread_table_check()
void hoc_execerror(const char *s1, const char *s2)
void * erealloc(void *ptr, size_t size)
void * ecalloc(size_t n, size_t size)
void deliver_net_events(NrnThread *nt)
void nrn_deliver_events(NrnThread *nt)
void nrn_spike_exchange_init()
void nrn_multithread_job(F &&job, Args &&... args)
void hoc_warning(const char *s1, const char *s2)
In mechanism libraries, cannot use auto const token = nrn_ensure_model_data_are_sorted(); because the...
int interleave_permute_type
void solve_interleaved(int ith)
Solve the Hines matrices based on the interleave_permute_type (1 or 2).
nonvintblock_extern int(* nrn_nonvint_block)(int method, int length, double *pd1, double *pd2, int tid)
#define nrn_nonvint_block_init(tid)
#define nrn_nonvint_block_fixed_step_solve(tid)
void setup_tree_matrix(neuron::model_sorted_token const &sorted_token, NrnThread &nt)
void nrn_seg_or_x_arg(int iarg, Section **psec, double *px)
neuron::model_sorted_token nrn_ensure_model_data_are_sorted()
Ensure neuron::container::* data are sorted.
void cvode_fadvance(double tstop)
void nrn_solver_prepare()
void fixed_record_continuous(neuron::model_sorted_token const &cache_token, NrnThread &nt)
void nrndae_update(NrnThread *_nt)
int const size_t const size_t n
std::vector< Memb_func > memb_func
void nrn_capacity_current(neuron::model_sorted_token const &sorted_token, NrnThread *_nt, Memb_list *ml)
std::vector< Memb_list > memb_list
int spGetSize(char *eMatrix, BOOLEAN External)
void spPrint(char *, int, int, int)
A view into a set of mechanism instances.
struct NrnThreadBAList * next
Represent main neuron object computed by single thread.
double * node_sav_d_storage()
NrnThreadBAList * tbl[BEFORE_AFTER_SIZE]
double & actual_rhs(std::size_t row)
double * node_sav_rhs_storage()
double * node_rhs_storage()
double * node_area_storage()
double * node_voltage_storage()
struct NrnThreadMembList * next
~opaque_model_sorted_token()
opaque_model_sorted_token(model_sorted_token &&)
int Printf(const char *fmt, Args... args)