Skip to content

Commit

Permalink
Remove NEOSIM related code (#2877)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeplf committed Jun 21, 2024
1 parent 9dd489c commit 891e0ad
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 179 deletions.
3 changes: 1 addition & 2 deletions docs/hoc/modelspec/programmatic/network/netcon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ NetCon
the overhead of threshold detection at every time step.

The source may be a NULLObject. In this case events can only occur by
calling :hoc:func:`event` from hoc. (It is also used by NEOSIM to implement
its own delivery system.)
calling :hoc:func:`event` from hoc.

A source used by multiple NetCon instances is shared by those instances
to allow faster threshold detection (ie on a per source basis instead
Expand Down
3 changes: 1 addition & 2 deletions docs/python/modelspec/programmatic/network/netcon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ NetCon
the overhead of threshold detection at every time step.

The source may be ``None``. In this case events can only occur by
calling :func:`event` from Python. (It is also used by NEOSIM to implement
its own delivery system.)
calling :func:`event` from Python.

A source used by multiple NetCon instances is shared by those instances
to allow faster threshold detection (ie on a per source basis instead
Expand Down
27 changes: 5 additions & 22 deletions share/lib/hoc/netbild/netgui.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ proc save_hoc_templates() {local i
}
}

proc save_hoc_data() { local i, j, hasneo
proc save_hoc_data() { local i, j
$o1.printf("\n//Network specification interface\n\n")
$o1.printf("objref cells, nclist, netcon\n")
$o1.printf("{cells = new List() nclist = new List()}\n\n")
Expand All @@ -871,33 +871,16 @@ $o1.printf(" netcon.weight = $4 netcon.delay = $5\n")
$o1.printf(" }\n")
$o1.printf(" nclist.append(netcon)\n return nclist.count - 1\n}\n\n")

if (name_declared("NeoSim")) {
hasneo = 1
}else{
hasneo = 0
}
if (hasneo) {
ncappend = "ns.new_connection"
$o1.printf("//Network instantiation through the NeoSim Interface\n")
$o1.printf("objref ns\n")
$o1.printf("{ns = new NeoSim()}\n\n")
}else{
ncappend = "nc_append"
$o1.printf("//Network instantiation\n\n")
}
ncappend = "nc_append"
$o1.printf("//Network instantiation\n\n")

for i=0, net.sources.count-1 {
tobj = net.sources.object(i).cell
tobj.name(tstr)
$o1.printf(" /* %s */", tstr)
tobj.type.classname(tstr)
if (hasneo) {
$o1.printf(" ns.new_cell(\"%s\",\t%g,\t %g, 0)\n",\
tstr, tobj.x, tobj.y)
}else{
$o1.printf(" cell_append(new %s(),\t%g,\t %g, 0)\n",\
tstr, tobj.x, tobj.y)
}
$o1.printf(" cell_append(new %s(),\t%g,\t %g, 0)\n",\
tstr, tobj.x, tobj.y)
}

for i=0, net.targets.count-1 {
Expand Down
13 changes: 0 additions & 13 deletions src/ivoc/ivocmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ static OptionDesc options[] = {{"-dismissbutton", "*dismiss_button", OptionValue
{"-hidewinio", "*showwinio", OptionValueImplicit, "off"},
{"-isatty", "*isatty", OptionValueImplicit, "1"},
{"-notatty", "*isatty", OptionValueImplicit, "-1"},
{"-neosim", "*neosim", OptionValueImplicit, "on"},
{"-bbs_nhost", "*bbs_nhost", OptionValueNext},
{"-NSTACK", "*NSTACK", OptionValueNext},
{"-NFRAME", "*NFRAME", OptionValueNext},
Expand Down Expand Up @@ -222,7 +221,6 @@ const char* path_prefix_to_libnrniv() {

int ivocmain(int, const char**, const char**);
int ivocmain_session(int, const char**, const char**, int start_session);
int (*p_neosim_main)(int, const char**, const char**);
extern int nrn_global_argc;
extern const char** nrn_global_argv;
int always_false;
Expand Down Expand Up @@ -747,17 +745,6 @@ int ivocmain_session(int argc, const char** argv, const char** env, int start_se
} else {
return 0;
}
#if HAVE_IV
if (session && session->style()->value_is_on("neosim")) {
if (p_neosim_main) {
(*p_neosim_main)(argc, argv, env);
} else {
printf(
"neosim not available.\nModify nrn/src/nrniv/Imakefile and remove "
"nrniv/$CPU/netcvode.o\n");
}
}
#endif
PR_PROFILE
#if defined(USE_PYTHON)
if (use_python_interpreter) {
Expand Down
8 changes: 0 additions & 8 deletions src/nrncvode/cvodeobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,6 @@ void Cvode::cvode_constructor() {
ctd_ = nullptr;
tqitem_ = nullptr;
mem_ = nullptr;
#if NEOSIMorNCS
neosim_self_events_ = nullptr;
#endif
initialize_ = false;
can_retreat_ = false;
tstop_begin_ = 0.;
Expand Down Expand Up @@ -838,11 +835,6 @@ void Cvode::atolvec_alloc(int i) {
}

Cvode::~Cvode() {
#if NEOSIMorNCS
if (neosim_self_events_) {
delete neosim_self_events_;
}
#endif
if (daspk_) {
delete daspk_;
}
Expand Down
4 changes: 1 addition & 3 deletions src/nrncvode/cvodeobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ class Cvode {

public:
bool structure_change_;
#if USENEOSIM
TQueue* neosim_self_events_;
#endif

public:
CvodeThreadData* ctd_;
NrnThread* nth_; // for lvardt
Expand Down
129 changes: 2 additions & 127 deletions src/nrncvode/netcvode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,6 @@ void* nrn_presyn_netcon(PreSyn* ps, int i) {
return ps->dil_[i];
}

#if USENEOSIM
void neosim2nrn_advance(void*, void*, double);
void neosim2nrn_deliver(void*, void*);
void (*p_nrn2neosim_send)(void*, double);
static void* neosim_entity_;
#endif

void ncs2nrn_integrate(double tstop);
extern void (*nrn_allthread_handle)();
static void allthread_handle_callback() {
Expand Down Expand Up @@ -1491,12 +1484,6 @@ void NetCvode::alloc_list() {
}
}
empty_ = false;
#if USENEOSIM
if (p_nrn2neosim_send)
for (i = 0; i < nlist_; ++i) {
p.lcv_[i].neosim_self_events_ = new TQueue();
}
#endif
}

bool NetCvode::init_global() {
Expand Down Expand Up @@ -2272,17 +2259,7 @@ void NetCvode::move_event(TQItem* q, double tnew, NrnThread* nt) {
tnew);
}
#endif
#if USENEOSIM
// only self events move
if (neosim_entity_) {
assert(0);
// cvode_instance->neosim_self_events_->move(q, tnew);
} else {
p[tid].tqe_->move(q, tnew);
}
#else
p[tid].tqe_->move(q, tnew);
#endif
}

void NetCvode::remove_event(TQItem* q, int tid) {
Expand Down Expand Up @@ -2310,16 +2287,7 @@ void nrn_net_send(Datum* v, double* weight, Point_process* pnt, double td, doubl
hoc_execerror("net_send delay < 0", 0);
}
TQItem* q;
#if USENEOSIM
if (neosim_entity_) {
assert(0);
// cvode_instance->neosim_self_events_->insert(td, se);
} else {
q = net_cvode_instance->event(td, se, nt);
}
#else
q = net_cvode_instance->event(td, se, nt);
#endif
if (flag == 1.0) {
*v = q;
}
Expand Down Expand Up @@ -2379,15 +2347,7 @@ void net_event(Point_process* pnt, double time) {
ps->pr(buf, time, net_cvode_instance);
hoc_execerror("net_event time < t", 0);
}
#if USENEOSIM
if (neosim_entity_) {
(*p_nrn2neosim_send)(neosim_entity_, nt_t);
} else {
#endif
ps->send(time, net_cvode_instance, ps->nt_);
#if USENEOSIM
}
#endif
ps->send(time, net_cvode_instance, ps->nt_);
}
}

Expand Down Expand Up @@ -2593,28 +2553,13 @@ void NetCvode::null_event(double tt) {
if (tt - nt->_t < 0) {
return;
}
#if USENEOSIM
if (neosim_entity_) {
// ignore for neosim. There is no appropriate cvode_instance
// cvode_instance->neosim_self_events_->insert(nt_t + delay, null_event_);
} else {
event(tt, null_event_, nt);
}
#else
event(tt, null_event_, nt);
#endif
}

void NetCvode::hoc_event(double tt, const char* stmt, Object* ppobj, int reinit, Object* pyact) {
if (!ppobj && tt - nt_t < 0) {
return;
}
#if USENEOSIM
if (neosim_entity_) {
// ignore for neosim. There is no appropriate cvode_instance
// cvode_instance->neosim_self_events_->insert(nt_t + delay, null_event_);
} else
#endif
{
NrnThread* nt = nrn_threads;
if (nrn_nthread > 1 && (!cvode_active_ || localstep())) {
Expand Down Expand Up @@ -2769,16 +2714,6 @@ void NetCvode::clear_events() {
HocEvent::reclaim();
allthread_hocevents_->clear();
nrn_allthread_handle = nullptr;
#if USENEOSIM
if (p_nrn2neosim_send)
for (i = 0; i < nlist_; ++i) {
TQueue* tq = p.lcv_[i].neosim_self_events_;
while (tq->least()) {
tq->remove(tq->least());
}
// and have already been reclaimed by SelfEvent::reclaim()
}
#endif
if (!MUTCONSTRUCTED) {
MUTCONSTRUCT(1);
}
Expand Down Expand Up @@ -3629,58 +3564,6 @@ void NetCvode::retreat(double t, Cvode* cv) {
#endif
}

#if USENEOSIM

bool neosim_deliver_self_events(TQueue* tqe, double til);
bool neosim_deliver_self_events(TQueue* tqe, double til) {
bool b;
TQItem* q;
DiscreteEvent* d;
b = false;
while (tqe->least_t() <= til + .5e-8) {
b = true;
q = tqe->least();
t = q->t_;
d = (DiscreteEvent*) q->data_;
assert(d->type() == SelfEventType);
tqe->remove(q);
d->deliver(t, net_cvode_instance);
}
}

void neosim2nrn_advance(void* e, void* v, double tout) {
neosim_entity_ = e;
NetCon* d = (NetCon*) v;
TQueue* tqe;

// now can integrate to tout since it is guaranteed there will
// be no further real events to this cell before tout.
// but we must handle self events. The implementation is
// analogous to the NetCvode::solve with single and tout
Cvode* cv = (Cvode*) d->target_->nvi_; // so self event from INITIAL block
tqe = cv->neosim_self_events_;
// not a bug even if there is no BREAKPOINT block. I.e.
// artificial cells will work.
t = cv->time();
while (tout > t) {
do {
cv->check_deliver();
} while (neosim_deliver_self_events(tqe, t));
cv->solve();
}
cv->interpolate(tout);
cv->check_deliver();
}

void neosim2nrn_deliver(void* e, void* v) {
neosim_entity_ = e;
NetCon* d = (NetCon*) v;
Cvode* cv = (Cvode*) d->target_->nvi_;
d->deliver(cv->t_, net_cvode_instance);
}

#endif

// parallel global variable time-step
int NetCvode::pgvts(double tstop) {
int err = NVI_SUCCESS;
Expand Down Expand Up @@ -5314,15 +5197,7 @@ void ConditionEvent::check(NrnThread* nt, double tt, double teps) {
if (flag_ == false) {
flag_ = true;
valthresh_ = 0.;
#if USENEOSIM
if (neosim_entity_) {
(*p_nrn2neosim_send)(neosim_entity_, tt);
} else {
#endif
send(tt + teps, net_cvode_instance, nt);
#if USENEOSIM
}
#endif
send(tt + teps, net_cvode_instance, nt);
}
} else {
flag_ = false;
Expand Down
2 changes: 0 additions & 2 deletions src/nrncvode/nrnneosm.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* define to 1 if allowing NEOSIM */
#cmakedefine USENEOSIM @USENEOSIM@
/* define to 1 if allowing NCS */
#cmakedefine USENCS @USENCS@
/* define to 1 (default) if Observer is a base class of DiscreteEvent */
Expand Down

0 comments on commit 891e0ad

Please sign in to comment.