diff --git a/coreneuron/network/netcvode.cpp b/coreneuron/network/netcvode.cpp index 64a817ecb..efa8ffde7 100644 --- a/coreneuron/network/netcvode.cpp +++ b/coreneuron/network/netcvode.cpp @@ -576,26 +576,12 @@ void SelfEvent::pr(const char* s, double tt, NetCvode*) { } void ncs2nrn_integrate(double tstop) { - double ts; - int n = (int)((tstop - nrn_threads->_t) / dt + 1e-9); + int total_sim_steps = static_cast((tstop - nrn_threads->_t) / dt + 1e-9); - if (n > 3 && !nrn_have_gaps) { - nrn_fixed_step_group_minimal(n); + if (total_sim_steps > 3 && !nrn_have_gaps) { + nrn_fixed_step_group_minimal(total_sim_steps); } else { -#if NRNMPI - ts = tstop - dt; - nrn_assert(nrn_threads->_t <= tstop); - // It may very well be the case that we do not advance at all - while (nrn_threads->_t <= ts) { -#else - ts = tstop - .5 * dt; - while (nrn_threads->_t < ts) { -#endif - nrn_fixed_step_minimal(); - - if (stoprun) - break; - } + nrn_fixed_single_steps_minimal(total_sim_steps, tstop); } // handle all the pending flag=1 self events diff --git a/coreneuron/sim/fadvance_core.cpp b/coreneuron/sim/fadvance_core.cpp index 59fd9ba44..d53034fc0 100644 --- a/coreneuron/sim/fadvance_core.cpp +++ b/coreneuron/sim/fadvance_core.cpp @@ -108,11 +108,36 @@ void finalize_progress_bar() { } } -void nrn_fixed_step_group_minimal(int n) { - static int step = 0; +void nrn_fixed_single_steps_minimal(int total_sim_steps, double tstop) { + const int progressbar_update_interval = 5; + static int current_steps = 0; + initialize_progress_bar(total_sim_steps); +#if NRNMPI + double updated_tstop = tstop - dt; + nrn_assert(nrn_threads->_t <= tstop); + // It may very well be the case that we do not advance at all + while (nrn_threads->_t <= updated_tstop) { +#else + double updated_tstop = tstop - .5 * dt; + while (nrn_threads->_t < updated_tstop) { +#endif + nrn_fixed_step_minimal(); + if (stoprun) { + break; + } + current_steps++; + if (!(current_steps % progressbar_update_interval)) { + update_progress_bar(current_steps, nrn_threads[0]._t); + } + } + finalize_progress_bar(); +} + +void nrn_fixed_step_group_minimal(int total_sim_steps) { + static int current_steps = 0; dt2thread(dt); nrn_thread_table_check(); - step_group_n = n; + step_group_n = total_sim_steps; step_group_begin = 0; step_group_end = 0; initialize_progress_bar(step_group_n); @@ -129,7 +154,7 @@ void nrn_fixed_step_group_minimal(int n) { if (stoprun) { break; } - step++; + current_steps++; step_group_begin = step_group_end; update_progress_bar(step_group_end, nrn_threads[0]._t); } diff --git a/coreneuron/sim/multicore.hpp b/coreneuron/sim/multicore.hpp index 2782060ef..ca6a55d79 100644 --- a/coreneuron/sim/multicore.hpp +++ b/coreneuron/sim/multicore.hpp @@ -170,7 +170,8 @@ extern void nrn_solve_minimal(NrnThread*); extern void nrncore2nrn_send_init(); extern void* setup_tree_matrix_minimal(NrnThread*); extern void nrncore2nrn_send_values(NrnThread*); -extern void nrn_fixed_step_group_minimal(int n); +extern void nrn_fixed_step_group_minimal(int total_sim_steps); +extern void nrn_fixed_single_steps_minimal(int total_sim_steps, double tstop); extern void nrn_fixed_step_minimal(void); extern void nrn_finitialize(int setv, double v); extern void nrn_mk_table_check(void); diff --git a/extra/instrumentation.tau b/extra/instrumentation.tau index 31ade623b..b2dbde064 100644 --- a/extra/instrumentation.tau +++ b/extra/instrumentation.tau @@ -37,6 +37,7 @@ BEGIN_INCLUDE_LIST void coreneuron::nrn_finitialize(int, double) void coreneuron::nrn_fixed_step_group(int) void coreneuron::nrn_fixed_step_group_minimal(int) + void coreneuron::nrn_fixed_single_steps_minimal(int, double) void coreneuron::nrn_flush_reports(double) void coreneuron::nrn_lhs(coreneuron::NrnThread *) void coreneuron::nrn_multithread_job(void *(*)(coreneuron::NrnThread *))