Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit b240992

Browse files
authored
Fix issue with progress bar not showing in gap junction simulations (#254)
* Fixes issue with progressbar not instantiated when running sim with nrn_fixed_step_minimal - Moved block of code calling nrn_fixed_step_minimal from netcvode to fadvance_core - Added instantiation and update of progressbar for it - Update progressbar every 5 steps
1 parent 5f1c036 commit b240992

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

coreneuron/network/netcvode.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -576,26 +576,12 @@ void SelfEvent::pr(const char* s, double tt, NetCvode*) {
576576
}
577577

578578
void ncs2nrn_integrate(double tstop) {
579-
double ts;
580-
int n = (int)((tstop - nrn_threads->_t) / dt + 1e-9);
579+
int total_sim_steps = static_cast<int>((tstop - nrn_threads->_t) / dt + 1e-9);
581580

582-
if (n > 3 && !nrn_have_gaps) {
583-
nrn_fixed_step_group_minimal(n);
581+
if (total_sim_steps > 3 && !nrn_have_gaps) {
582+
nrn_fixed_step_group_minimal(total_sim_steps);
584583
} else {
585-
#if NRNMPI
586-
ts = tstop - dt;
587-
nrn_assert(nrn_threads->_t <= tstop);
588-
// It may very well be the case that we do not advance at all
589-
while (nrn_threads->_t <= ts) {
590-
#else
591-
ts = tstop - .5 * dt;
592-
while (nrn_threads->_t < ts) {
593-
#endif
594-
nrn_fixed_step_minimal();
595-
596-
if (stoprun)
597-
break;
598-
}
584+
nrn_fixed_single_steps_minimal(total_sim_steps, tstop);
599585
}
600586

601587
// handle all the pending flag=1 self events

coreneuron/sim/fadvance_core.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,36 @@ void finalize_progress_bar() {
108108
}
109109
}
110110

111-
void nrn_fixed_step_group_minimal(int n) {
112-
static int step = 0;
111+
void nrn_fixed_single_steps_minimal(int total_sim_steps, double tstop) {
112+
const int progressbar_update_interval = 5;
113+
static int current_steps = 0;
114+
initialize_progress_bar(total_sim_steps);
115+
#if NRNMPI
116+
double updated_tstop = tstop - dt;
117+
nrn_assert(nrn_threads->_t <= tstop);
118+
// It may very well be the case that we do not advance at all
119+
while (nrn_threads->_t <= updated_tstop) {
120+
#else
121+
double updated_tstop = tstop - .5 * dt;
122+
while (nrn_threads->_t < updated_tstop) {
123+
#endif
124+
nrn_fixed_step_minimal();
125+
if (stoprun) {
126+
break;
127+
}
128+
current_steps++;
129+
if (!(current_steps % progressbar_update_interval)) {
130+
update_progress_bar(current_steps, nrn_threads[0]._t);
131+
}
132+
}
133+
finalize_progress_bar();
134+
}
135+
136+
void nrn_fixed_step_group_minimal(int total_sim_steps) {
137+
static int current_steps = 0;
113138
dt2thread(dt);
114139
nrn_thread_table_check();
115-
step_group_n = n;
140+
step_group_n = total_sim_steps;
116141
step_group_begin = 0;
117142
step_group_end = 0;
118143
initialize_progress_bar(step_group_n);
@@ -129,7 +154,7 @@ void nrn_fixed_step_group_minimal(int n) {
129154
if (stoprun) {
130155
break;
131156
}
132-
step++;
157+
current_steps++;
133158
step_group_begin = step_group_end;
134159
update_progress_bar(step_group_end, nrn_threads[0]._t);
135160
}

coreneuron/sim/multicore.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ extern void nrn_solve_minimal(NrnThread*);
170170
extern void nrncore2nrn_send_init();
171171
extern void* setup_tree_matrix_minimal(NrnThread*);
172172
extern void nrncore2nrn_send_values(NrnThread*);
173-
extern void nrn_fixed_step_group_minimal(int n);
173+
extern void nrn_fixed_step_group_minimal(int total_sim_steps);
174+
extern void nrn_fixed_single_steps_minimal(int total_sim_steps, double tstop);
174175
extern void nrn_fixed_step_minimal(void);
175176
extern void nrn_finitialize(int setv, double v);
176177
extern void nrn_mk_table_check(void);

extra/instrumentation.tau

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ BEGIN_INCLUDE_LIST
3737
void coreneuron::nrn_finitialize(int, double)
3838
void coreneuron::nrn_fixed_step_group(int)
3939
void coreneuron::nrn_fixed_step_group_minimal(int)
40+
void coreneuron::nrn_fixed_single_steps_minimal(int, double)
4041
void coreneuron::nrn_flush_reports(double)
4142
void coreneuron::nrn_lhs(coreneuron::NrnThread *)
4243
void coreneuron::nrn_multithread_job(void *(*)(coreneuron::NrnThread *))

0 commit comments

Comments
 (0)