Test to expose bug in array variables.#2779
Conversation
|
I tried to debug the issue, when compiling a MOD file called We can see void allocate_data_in_mechanism_nrn_init() {
_nrn_skip_initmodel = true;
for (int i = 0; i < nrn_nthread; ++i) { // could be parallel
NrnThread& nt = nrn_threads[i];
for (NrnThreadMembList* tml = nt.tml; tml; tml = tml->next) {
Memb_list* ml = tml->ml;
mod_f_t s = corenrn.get_memb_func(tml->index).initialize;
if (s) {
(*s)(&nt, ml, tml->index);
}
}
}
_nrn_skip_initmodel = false;
}https://github.com/neuronsimulator/nrn/blob/17be061e031701736cb03a5088b7ddf253a069a4/src/coreneuron/sim/finitialize.cpp#L21-L38?plain=1 void Phase2::populate(NrnThread& nt, const UserParams& userParams) {
// ...
auto& nrn_prop_param_size_ = corenrn.get_prop_param_size();
auto& nrn_prop_dparam_size_ = corenrn.get_prop_dparam_size();
// ...
for (auto tml = nt.tml; tml; tml = tml->next) {
Memb_list* ml = tml->ml;
int type = tml->index;
int layout = corenrn.get_mech_data_layout()[type];
int n = ml->nodecount;
int sz = nrn_prop_param_size_[type];
offset = nrn_soa_byte_align(offset);
ml->data = nt._data + offset;
offset += nrn_soa_padded_size(n, layout) * sz;
}
// ...
}
So we now need to hunt down how void hoc_register_prop_size(int type, int psize, int dpsize) {
// ...
corenrn.get_prop_param_size()[type] = psize;
corenrn.get_prop_dparam_size()[type] = dpsize;
// ...
}https://github.com/neuronsimulator/nrn/blob/17be061e031701736cb03a5088b7ddf253a069a4/src/coreneuron/mechanism/register_mech.cpp#L192-L206?plain=1 hoc_register_prop_size(mech_type, float_variables_size(), int_variables_size());with static inline int float_variables_size() {
return 23;
} |
|
We can see it crash here: in a manner that would be consistent with the bug, e.g. a SEGFAULT. |
|
@pramodk I think this is the type of test we were thinking of. Please let me know if you see anything wrong with the test. |
|
✔️ d3920b5 -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
|
This looks suspicious, because data pads the number of rows: nrn/src/coreneuron/io/nrn_setup.cpp Line 981 in 17be061 |
the test LGTM. (Sorry, somehow this |
d3920b5 to
e5cf000
Compare
This comment has been minimized.
This comment has been minimized.
e0b5fe1 to
9c4a888
Compare
This comment has been minimized.
This comment has been minimized.
b80b332 to
8d538f0
Compare
|
Please retry analysis of this Pull-Request directly on SonarCloud |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
be7ae9b to
231b8ba
Compare
This comment has been minimized.
This comment has been minimized.
231b8ba to
7cc612d
Compare
This comment has been minimized.
This comment has been minimized.
7cc612d to
a48a578
Compare
|
✔️ a48a578 -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
dc98a6f to
e9989ef
Compare
pramodk
left a comment
There was a problem hiding this comment.
(good to merge after submodule update)
nrnhines
left a comment
There was a problem hiding this comment.
I think that matching old comments to the current api between NEURON and CoreNEURON can be left to a subsequent PR.
|
✔️ b59524a -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
These are the code generation changes required for:
neuronsimulator/nrn#2779
The solution is to fill `nrn_prop_param_size` with the number of
doubles, not number of variables.
These are the code generation changes required for:
neuronsimulator/nrn#2779
The solution is to fill `nrn_prop_param_size` with the number of
doubles, not number of variables.
This comment has been minimized.
This comment has been minimized.
* Fix array variables.
These are the code generation changes required for:
neuronsimulator/nrn#2779
The solution is to fill `nrn_prop_param_size` with the number of
doubles, not number of variables.
This comment has been minimized.
This comment has been minimized.
|
✔️ 4b74073 -> Azure artifacts URL |
This should affect copying data from CoreNEURON to NRN. If a GPU is used, the data can be permuted. When copying back it should be permuted back.
c2fa237 to
3f3221c
Compare
|
While reviewing my own code before suggesting to merge, I noticed that there was a "TODO fix". The comment was there because at the time I was hoping that the code was unused. I think that's wrong, because I've pushed a commit to address the issue: 3f3221c |
|
✔️ 3f3221c -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
fa18d6d to
0faf5f5
Compare
|
Please retry analysis of this Pull-Request directly on SonarCloud |
|
✔️ 0faf5f5 -> Azure artifacts URL |
|
@nrnhines @pramodk please read: #2779 (comment). It explains a recent change and there's one more commit which is clean up of that change. I think the PR is now ready to merge. |
that certainly make sense! Good to merge! 🚀 |
* Fix array variables.
These are the code generation changes required for:
#2779
The solution is to fill `nrn_prop_param_size` with the number of
doubles, not number of variables.
NMODL Repo SHA: BlueBrain/nmodl@f6821ce




This test exposes a bug in how data is copied between NEURON and CoreNEURON.
It must include (at least) one MOD file with array range variables. It must check that the copy of these array range variables received by CoreNEURON is correct.
The suspected bug is that an array range variable with M elements is sometimes 1 and sometimes M "floating point variables"; and somehow this is done inconsistently.