Skip to content

Commit

Permalink
References for 'BlueBrain/nmodl#1414'.
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed Sep 4, 2024
1 parent 331cbd3 commit 440eafd
Show file tree
Hide file tree
Showing 59 changed files with 2,588 additions and 444 deletions.
27 changes: 20 additions & 7 deletions at_time/neuron/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ namespace neuron {
_ml_arg.nodecount
};
}
static example_NodeData make_node_data_example(Prop * _prop) {
static std::vector<int> node_index{0};
Node* _node = _nrn_mechanism_access_node(_prop);
return example_NodeData {
node_index.data(),
&_nrn_mechanism_access_voltage(_node),
&_nrn_mechanism_access_d(_node),
&_nrn_mechanism_access_rhs(_node),
1
};
}

void nrn_destructor_example(Prop* _prop) {
Datum* _ppvar = _nrn_mechanism_access_dparam(_prop);
}
Expand All @@ -145,7 +157,7 @@ namespace neuron {
hoc_retpushx(1.);
}
/* Mechanism procedures and functions */
inline double f_example(_nrn_mechanism_cache_range& _lmc, example_Instance& inst, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt, double _lx);
inline double f_example(_nrn_mechanism_cache_range& _lmc, example_Instance& inst, example_NodeData& node_data, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt, double _lx);


/** connect global (scalar) variables to hoc -- */
Expand Down Expand Up @@ -187,7 +199,8 @@ namespace neuron {
_thread = _extcall_thread.data();
nt = nrn_threads;
auto inst = make_instance_example(_lmc);
_r = f_example(_lmc, inst, id, _ppvar, _thread, nt, *getarg(1));
auto node_data = make_node_data_example(_local_prop);
_r = f_example(_lmc, inst, node_data, id, _ppvar, _thread, nt, *getarg(1));
hoc_retpushx(_r);
}
static double _npy_f(Prop* _prop) {
Expand All @@ -196,19 +209,20 @@ namespace neuron {
Datum* _thread;
NrnThread* nt;
_nrn_mechanism_cache_instance _lmc{_prop};
size_t const id{};
size_t const id = 0;
_ppvar = _nrn_mechanism_access_dparam(_prop);
_thread = _extcall_thread.data();
nt = nrn_threads;
auto inst = make_instance_example(_lmc);
_r = f_example(_lmc, inst, id, _ppvar, _thread, nt, *getarg(1));
auto node_data = make_node_data_example(_prop);
_r = f_example(_lmc, inst, node_data, id, _ppvar, _thread, nt, *getarg(1));
return(_r);
}


inline double f_example(_nrn_mechanism_cache_range& _lmc, example_Instance& inst, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt, double _lx) {
inline double f_example(_nrn_mechanism_cache_range& _lmc, example_Instance& inst, example_NodeData& node_data, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt, double _lx) {
double ret_f = 0.0;
auto v = inst.v_unused[id];
auto v = node_data.node_voltages[node_data.nodeindices[id]];
ret_f = at_time(nt, _lx);
return ret_f;
}
Expand All @@ -224,7 +238,6 @@ namespace neuron {
auto* _ppvar = _ml_arg->pdata[id];
int node_id = node_data.nodeindices[id];
auto v = node_data.node_voltages[node_id];
inst.v_unused[id] = v;
}
}

Expand Down
27 changes: 20 additions & 7 deletions constant/neuron/constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ namespace neuron {
_ml_arg.nodecount
};
}
static constant_mod_NodeData make_node_data_constant_mod(Prop * _prop) {
static std::vector<int> node_index{0};
Node* _node = _nrn_mechanism_access_node(_prop);
return constant_mod_NodeData {
node_index.data(),
&_nrn_mechanism_access_voltage(_node),
&_nrn_mechanism_access_d(_node),
&_nrn_mechanism_access_rhs(_node),
1
};
}

void nrn_destructor_constant_mod(Prop* _prop) {
Datum* _ppvar = _nrn_mechanism_access_dparam(_prop);
}
Expand All @@ -146,7 +158,7 @@ namespace neuron {
hoc_retpushx(1.);
}
/* Mechanism procedures and functions */
inline double foo_constant_mod(_nrn_mechanism_cache_range& _lmc, constant_mod_Instance& inst, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt);
inline double foo_constant_mod(_nrn_mechanism_cache_range& _lmc, constant_mod_Instance& inst, constant_mod_NodeData& node_data, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt);


/** connect global (scalar) variables to hoc -- */
Expand Down Expand Up @@ -188,7 +200,8 @@ namespace neuron {
_thread = _extcall_thread.data();
nt = nrn_threads;
auto inst = make_instance_constant_mod(_lmc);
_r = foo_constant_mod(_lmc, inst, id, _ppvar, _thread, nt);
auto node_data = make_node_data_constant_mod(_local_prop);
_r = foo_constant_mod(_lmc, inst, node_data, id, _ppvar, _thread, nt);
hoc_retpushx(_r);
}
static double _npy_foo(Prop* _prop) {
Expand All @@ -197,19 +210,20 @@ namespace neuron {
Datum* _thread;
NrnThread* nt;
_nrn_mechanism_cache_instance _lmc{_prop};
size_t const id{};
size_t const id = 0;
_ppvar = _nrn_mechanism_access_dparam(_prop);
_thread = _extcall_thread.data();
nt = nrn_threads;
auto inst = make_instance_constant_mod(_lmc);
_r = foo_constant_mod(_lmc, inst, id, _ppvar, _thread, nt);
auto node_data = make_node_data_constant_mod(_prop);
_r = foo_constant_mod(_lmc, inst, node_data, id, _ppvar, _thread, nt);
return(_r);
}


inline double foo_constant_mod(_nrn_mechanism_cache_range& _lmc, constant_mod_Instance& inst, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt) {
inline double foo_constant_mod(_nrn_mechanism_cache_range& _lmc, constant_mod_Instance& inst, constant_mod_NodeData& node_data, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* nt) {
double ret_foo = 0.0;
auto v = inst.v_unused[id];
auto v = node_data.node_voltages[node_data.nodeindices[id]];
ret_foo = inst.global->a;
return ret_foo;
}
Expand All @@ -225,7 +239,6 @@ namespace neuron {
auto* _ppvar = _ml_arg->pdata[id];
int node_id = node_data.nodeindices[id];
auto v = node_data.node_voltages[node_id];
inst.v_unused[id] = v;
}
}

Expand Down
4 changes: 4 additions & 0 deletions function/coreneuron/artificial_functions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[NMODL] [error] :: Code incompatibility detected
[NMODL] [error] :: Cannot translate mod file to .cpp file
[NMODL] [error] :: Fix the following errors and try again
[NMODL] [error] :: Code Incompatibility :: "gbl" variable found at [4.12-14] should be defined as a RANGE variable instead of GLOBAL to enable backend transformations
4 changes: 4 additions & 0 deletions function/coreneuron/non_threadsafe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[NMODL] [error] :: Code incompatibility detected
[NMODL] [error] :: Cannot translate mod file to .cpp file
[NMODL] [error] :: Fix the following errors and try again
[NMODL] [error] :: Code Incompatibility :: "gbl" variable found at [4.12-14] should be defined as a RANGE variable instead of GLOBAL to enable backend transformations
4 changes: 4 additions & 0 deletions function/coreneuron/point_non_threadsafe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[NMODL] [error] :: Code incompatibility detected
[NMODL] [error] :: Cannot translate mod file to .cpp file
[NMODL] [error] :: Fix the following errors and try again
[NMODL] [error] :: Code Incompatibility :: "gbl" variable found at [4.12-14] should be defined as a RANGE variable instead of GLOBAL to enable backend transformations
Loading

0 comments on commit 440eafd

Please sign in to comment.