Exemple #1
0
nrn_daspk_init_step(double tt, double dteps, int upd){
	int i;
	double dtsav = nrn_threads->_dt;
	int so = secondorder;
	dt = dteps;
	t = tt;
	secondorder = 0;
	dt2thread(dteps);
	nrn_thread_table_check();
	_upd = upd;
	nrn_multithread_job(daspk_init_step_thread);
	dt = dtsav;
	secondorder = so;
	dt2thread(dtsav);
	nrn_thread_table_check();
}
Exemple #2
0
void nrn_finitialize(int setv, double v) {
	int i;
	NrnThread* _nt;

	t = 0.;
	dt2thread(-1.);
	nrn_thread_table_check();
	clear_event_queue();
	nrn_spike_exchange_init();
#if VECTORIZE
	nrn_play_init(); /* Vector.play */
        ///Play events should be executed before initializing events
	for (i=0; i < nrn_nthread; ++i) {
		nrn_deliver_events(nrn_threads + i); /* The play events at t=0 */
	}
	if (setv) {
          for (_nt = nrn_threads; _nt < nrn_threads + nrn_nthread; ++_nt) {
            for (i=0; i < _nt->end; ++i) {
			VEC_V(i) = v;
            }
          }
        }
	for (i=0; i < nrn_nthread; ++i) {
		nrn_ba(nrn_threads + i, BEFORE_INITIAL);
	}
	/* the INITIAL blocks are ordered so that mechanisms that write
	   concentrations are after ions and before mechanisms that read
	   concentrations.
	*/
	/* the memblist list in NrnThread is already so ordered */
	for (i=0; i < nrn_nthread; ++i) {
		NrnThread* nt = nrn_threads + i;
		NrnThreadMembList* tml;
		for (tml = nt->tml; tml; tml = tml->next) {
			mod_f_t s = memb_func[tml->index].initialize;
			if (s) {
				(*s)(nt, tml->ml, tml->index);
			}
		}
	}
#endif

	init_net_events();
	for (i = 0; i < nrn_nthread; ++i) {
		nrn_ba(nrn_threads + i, AFTER_INITIAL);
	}
	for (i=0; i < nrn_nthread; ++i) {
		nrn_deliver_events(nrn_threads + i); /* The INITIAL sent events at t=0 */
	}
        for (i=0; i < nrn_nthread; ++i) {
            setup_tree_matrix_minimal(nrn_threads + i);
        }
	for (i=0; i < nrn_nthread; ++i) {
		nrn_deliver_events(nrn_threads + i); /* The record events at t=0 */
	}
#if NRNMPI
	nrn_spike_exchange(nrn_threads);
#endif
}
Exemple #3
0
void nrn_fixed_step() {
	int i;
#if ELIMINATE_T_ROUNDOFF
	nrn_chk_ndt();
#endif
	if (t != nrn_threads->_t) {
		dt2thread(-1.);
	}else{
		dt2thread(dt);
	}
	nrn_thread_table_check();
	if (nrn_multisplit_setup_) {
		nrn_multithread_job(nrn_ms_treeset_through_triang);
		if (!nrn_allthread_handle) {
			nrn_multithread_job(nrn_ms_reduce_solve);
			nrn_multithread_job(nrn_ms_bksub);
			/* see comment below */
			if (nrnthread_v_transfer_) {
				if (nrnmpi_v_transfer_) {
					(*nrnmpi_v_transfer_)();
				}
				nrn_multithread_job(nrn_fixed_step_lastpart);
			}
		}
	}else{
		nrn_multithread_job(nrn_fixed_step_thread);
/* if there is no nrnthread_v_transfer then there cannot be
   a nrnmpi_v_transfer and lastpart
   will be done in above call.
*/
		if (nrnthread_v_transfer_) {
			if (nrnmpi_v_transfer_) {
				(*nrnmpi_v_transfer_)();
			}
			nrn_multithread_job(nrn_fixed_step_lastpart);
		}
	}
	t = nrn_threads[0]._t;
	if (nrn_allthread_handle) { (*nrn_allthread_handle)(); }
}
Exemple #4
0
void nrn_fixed_step_group(int n) {
	int i;
#if ELIMINATE_T_ROUNDOFF
	nrn_chk_ndt();
#endif
	dt2thread(dt);
	nrn_thread_table_check();
	if (nrn_multisplit_setup_) {
		int b = 0;
		nrn_multithread_job(nrn_ms_treeset_through_triang);
		step_group_n = 0; /* abort at bksub flag */
		for (i=1; i < n; ++i) {
			nrn_multithread_job(nrn_ms_reduce_solve);
			nrn_multithread_job(nrn_ms_bksub_through_triang);
			if (step_group_n) {
				step_group_n = 0;
				if (nrn_allthread_handle) {
					(*nrn_allthread_handle)();
				}
				/* aborted step at bksub, so if not stopped
				   must do the triang*/
				b = 1;
				if (!stoprun) {
					nrn_multithread_job(nrn_ms_treeset_through_triang);
				}
			}
			if (stoprun) { break; }
			b = 0;
		}
		if (!b) {
			nrn_multithread_job(nrn_ms_reduce_solve);
			nrn_multithread_job(nrn_ms_bksub);
		}
		if (nrn_allthread_handle) { (*nrn_allthread_handle)(); }
	}else{
		step_group_n = n;
		step_group_begin = 0;
		step_group_end = 0;
		while(step_group_end < step_group_n) {
/*printf("step_group_end=%d step_group_n=%d\n", step_group_end, step_group_n);*/
			nrn_multithread_job(nrn_fixed_step_group_thread);
			if (nrn_allthread_handle) { (*nrn_allthread_handle)(); }
			if (stoprun) { break; }
			step_group_begin = step_group_end;
		}
	}
	t = nrn_threads[0]._t;
}
Exemple #5
0
fcurrent()
{
	int i;
	if (tree_changed) {
		setup_topology();
	}
	if (v_structure_change) {
		v_setup_vectors();
	}
	if (diam_changed) {
		recalc_diam();
	}

	dt2thread(-1.);
	nrn_thread_table_check();
	state_discon_allowed_ = 0;
	nrn_multithread_job(setup_tree_matrix);
	state_discon_allowed_ = 1;
	ret(1.);
}