Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code change for ion and ion style semantics. Unlimited numbers. #3097

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4232cab
increased maximum number of ions per compartment by using std::bitset…
wthun Aug 22, 2024
5179cc4
changed vector.reserve to vector.resize to initialize std::bitset ele…
wthun Aug 23, 2024
61162e4
cleanup
wthun Aug 23, 2024
25fa1aa
Merge branch 'master' into hines/ions
nrnhines Sep 18, 2024
3c01089
test of high mechanism index ions and mechanisms
nrnhines Sep 19, 2024
7ccc143
Fix formatting
github-actions[bot] Sep 19, 2024
fb2d01a
Merge branch 'master' into master
1uc Sep 20, 2024
fc27477
rename max_length to max_ion
wthun Sep 20, 2024
e36452c
Update src/nrnoc/eion.cpp
wthun Sep 20, 2024
3b5e359
Update src/nrnoc/eion.cpp
wthun Sep 20, 2024
dc47da5
Update src/nrnoc/eion.cpp
wthun Sep 20, 2024
570a9ae
cmake-format
wthun Sep 20, 2024
dc11e93
increased max_ion to 256
wthun Sep 20, 2024
7293b78
Merge remote-tracking branch 'forked/master' into hines/ions
nrnhines Sep 20, 2024
3f5c418
Temporarily adjust test to create 250 ions.
nrnhines Sep 20, 2024
da974c2
Merge branch 'master' into hines/ions
nrnhines Sep 20, 2024
3f213b0
Use generic mod file loader
nrnhines Sep 20, 2024
23071ee
ion_bit_ can have many bits.
nrnhines Sep 20, 2024
6604aab
For bitset single bit, first reset, then set the bit.
nrnhines Sep 20, 2024
0d087b7
Add another mod file to neurondemo that WRITE cai. More testing.
nrnhines Sep 21, 2024
bfc82da
eion.cpp -Wall free
nrnhines Sep 21, 2024
ebf26b1
eion.cpp coverage 100% functions 94% lines
nrnhines Sep 22, 2024
06f9ace
Replace // LCOV_EXCL_END with // LCOV_EXCL_STOP
nrnhines Sep 22, 2024
aea6299
no limit on number of ion mechanisms
nrnhines Sep 23, 2024
aceb0c5
Code change for ion and ion style semantics. Unlimited numbers.
nrnhines Sep 26, 2024
74d6029
Merge branch 'master' into hines/ions
nrnhines Sep 26, 2024
1318a3f
Fix the CI test coverage failure.
nrnhines Sep 30, 2024
a9de3d7
Merge branch 'hines/ions' into hines/ions-unlimited
nrnhines Sep 30, 2024
7223c0c
Merge branch 'hines/ions-unlimited' into hines/ions-unlimited-semantics
nrnhines Sep 30, 2024
3e3358a
Merge branch 'master' into hines/ions-unlimited-semantics
nrnhines Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(HEADER_FILES_TO_INSTALL
nrnoc/md1redef.h
nrnoc/md2redef.h
nrnoc/membdef.h
nrnoc/ion_semantics.h
nrnoc/membfunc.h
nrnoc/multicore.h
nrnoc/multisplit.h
Expand Down
6 changes: 4 additions & 2 deletions src/coreneuron/io/nrn_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cassert>
#include <memory>

#include "nrnoc/ion_semantics.h"
#include "coreneuron/sim/multicore.hpp"
#include "coreneuron/nrniv/nrniv_decl.h"
#include "coreneuron/io/nrn_filehandler.hpp"
Expand Down Expand Up @@ -296,8 +297,9 @@ void CheckPoints::write_phase2(NrnThread& nt) const {
// out into the following function.
d[ix] = nrn_original_aos_index(ptype, d[ix], nt, ml_pinv);
}
} else if (s >= 0 && s < 1000) { // ion
d[ix] = nrn_original_aos_index(s, d[ix], nt, ml_pinv);
} else if (nrn_semantics_is_ion(s)) { // ion
auto type = nrn_semantics_ion_type(s);
d[ix] = nrn_original_aos_index(type, d[ix], nt, ml_pinv);
}
#if CHKPNTDEBUG
if (s != -8) { // WATCH values change
Expand Down
5 changes: 3 additions & 2 deletions src/coreneuron/io/phase2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# =============================================================================
*/

#include "nrnoc/ion_semantics.h"
#include "coreneuron/io/phase2.hpp"
#include "coreneuron/coreneuron.hpp"
#include "coreneuron/sim/multicore.hpp"
Expand Down Expand Up @@ -699,8 +700,8 @@ void Phase2::pdata_relocation(const NrnThread& nt, const std::vector<Memb_func>&
**/
break;
default:
if (s >= 0 && s < 1000) { // ion
int etype = s;
if (nrn_semantics_is_ion(s)) { // ion
int etype = nrn_semantics_ion_type(s);
/* if ion is SoA, must recalculate pdata values */
/* if ion is AoS, have to deal with offset */
Memb_list* eml = nt._ml_list[etype];
Expand Down
9 changes: 5 additions & 4 deletions src/coreneuron/mechanism/register_mech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cstring>

#include "coreneuron/nrnconf.h"
#include "nrnoc/ion_semantics.h"
#include "coreneuron/sim/multicore.hpp"
#include "coreneuron/membrane_definitions.h"
#include "coreneuron/mechanism/eion.hpp"
Expand Down Expand Up @@ -212,7 +213,7 @@ void hoc_register_dparam_semantics(int type, int ix, const char* name) {
xx_ion and #xx_ion which will get
a semantics value of -1, -2, -3,
-4, -5, -6, -7, -8, -9, -10,
type, and type+1000 respectively
2*type, and 2*type+1 respectively
*/
auto& memb_func = corenrn.get_memb_funcs();
if (strcmp(name, "area") == 0) {
Expand Down Expand Up @@ -240,7 +241,7 @@ void hoc_register_dparam_semantics(int type, int ix, const char* name) {
} else {
int i = name[0] == '#' ? 1 : 0;
int etype = nrn_get_mechtype(name + i);
memb_func[type].dparam_semantics[ix] = etype + i * 1000;
memb_func[type].dparam_semantics[ix] = nrn_semantics_from_ion(etype, i);
/* note that if style is needed (i==1), then we are writing a concentration */
if (i) {
ion_write_depend(type, etype);
Expand Down Expand Up @@ -300,8 +301,8 @@ int nrn_mech_depend(int type, int* dependencies) {
int idep = 0;
if (ds)
for (int i = 0; i < dpsize; ++i) {
if (ds[i] > 0 && ds[i] < 1000) {
int deptype = ds[i];
if (nrn_semantics_is_ion(ds[i])) {
int deptype = nrn_semantics_ion_type(ds[i]);
int idepnew = depend_append(idep, dependencies, deptype, type);
if ((idepnew > idep) && !corenrn.get_ion_write_dependency().empty() &&
!corenrn.get_ion_write_dependency()[deptype].empty()) {
Expand Down
5 changes: 3 additions & 2 deletions src/coreneuron/permute/node_permute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ so pdata_m(k, isz) = inew + data_t
#include "coreneuron/nrniv/nrniv_decl.h"
#include "coreneuron/utils/nrn_assert.h"
#include "coreneuron/coreneuron.hpp"
#include "nrnoc/ion_semantics.h"
#else
#include "nrnoc/multicore.h"
#include "oc/nrnassrt.h"
Expand Down Expand Up @@ -333,8 +334,8 @@ static void update_pdata_values(Memb_list* ml, int type, NrnThread& nt) {
nrn_assert(0);
}
}
} else if (s >= 0 && s < 1000) { // ion
int etype = s;
} else if (nrn_semantics_is_ion(s)) { // ion
int etype = nrn_semantics_ion_type(s);
int elayout = corenrn.get_mech_data_layout()[etype];
Memb_list* eml = nt._ml_list[etype];
int edata0 = eml->data - nt._data;
Expand Down
2 changes: 1 addition & 1 deletion src/neuron/cache/mechanism_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void indices_to_cache(short type, Callable callable) {
auto const sem = dparam_semantics[field];
// See https://github.com/neuronsimulator/nrn/issues/2312 for discussion of possible
// extensions to caching.
if ((sem > 0 && sem < 1000) || sem == -1 /* area */ || sem == -9 /* diam */) {
if (nrn_semantics_is_ion(sem) || sem == -1 /* area */ || sem == -9 /* diam */) {
std::invoke(callable, field);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,10 @@ int* datum2int(int type,
}
} else if (etype == -9) {
pdata[jj] = eindex;
} else if (etype > 0 && etype < 1000) { // ion pointer
} else if (nrn_semantics_is_ion(etype)) { // ion pointer
pdata[jj] = eindex;
} else if (etype > 1000 && etype < 2000) { // ionstyle can be explicit instead of
// pointer to int*
} else if (nrn_semantics_is_ionstyle(etype)) {
// ionstyle can be explicit instead of pointer to int*
pdata[jj] = eindex;
} else if (etype == -2) { // an ion and this is the iontype
pdata[jj] = eindex;
Expand Down
6 changes: 3 additions & 3 deletions src/nrniv/nrncore_write/data/cell_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ void CellGroup::datumindex_fill(int ith, CellGroup& cg, DatumIndices& di, Memb_l
}
assert(etype != 0);
// pointer into one of the tml types?
} else if (dmap[j] > 0 && dmap[j] < 1000) { // double* into eion type data
etype = dmap[j];
} else if (nrn_semantics_is_ion(dmap[j])) { // double* into eion type data
etype = nrn_semantics_ion_type(dmap[j]);
Memb_list* eml = cg.type2ml[etype];
assert(eml);
auto* const pval = dparam[j].get<double*>();
auto const legacy_index = eml->legacy_index(pval);
assert(legacy_index >= 0);
eindex = legacy_index;
} else if (dmap[j] > 1000) { // int* into ion dparam[xxx][0]
} else if (nrn_semantics_is_ionstyle(dmap[j])) { // int* into ion dparam[xxx][0]
// store the actual ionstyle
etype = dmap[j];
eindex = *dparam[j].get<int*>();
Expand Down
4 changes: 2 additions & 2 deletions src/nrniv/nrncore_write/data/cell_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CellGroup {
// following three are parallel arrays
std::vector<PreSyn*> output_ps; // n_presyn of these, real are first, tml order for acell.
std::vector<int> output_gid; // n_presyn of these, -(type + 1000*index) if no gid
std::vector<int> output_vindex; // n_presyn of these. >=0 if associated with voltage, -(type +
// 1000*index) for acell.
std::vector<int> output_vindex; // n_presyn of these. >=0 if associated with voltage,
// -(type + 1000*index) for acell.
int n_netcon; // all that have targets associated with this threads Point_process.
std::vector<NetCon*> netcons;
int* netcon_srcgid; // -(type + 1000*index) refers to acell with no gid
Expand Down
4 changes: 2 additions & 2 deletions src/nrnoc/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ namespace {
*/

// name to int map for the negative types
// xx_ion and #xx_ion will get values of type and type+1000 respectively
// xx_ion and #xx_ion will get values of type*2 and type*2+1 respectively
static std::unordered_map<std::string, int> name_to_negint = {{"area", -1},
{"iontype", -2},
{"cvodeieq", -3},
Expand All @@ -785,7 +785,7 @@ int dparam_semantics_to_int(std::string_view name) {
bool const i{name[0] == '#'};
Symbol* s = hoc_lookup(std::string{name.substr(i)}.c_str());
if (s && s->type == MECHANISM) {
return s->subtype + i * 1000;
return s->subtype * 2 + i;
}
throw std::runtime_error("unknown dparam semantics: " + std::string{name});
}
Expand Down
14 changes: 14 additions & 0 deletions src/nrnoc/ion_semantics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

inline int nrn_semantics_from_ion(int type, int i) {
return 2 * type + i;
}
inline bool nrn_semantics_is_ion(int i) {
return i >= 0 && (i & 1) == 0;
}
inline bool nrn_semantics_is_ionstyle(int i) {
return i >= 0 && (i & 1) == 1;
}
inline int nrn_semantics_ion_type(int i) {
return i / 2;
}
1 change: 1 addition & 0 deletions src/nrnoc/membfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern void hoc_register_prop_size(int type, int psize, int dpsize);
#include "nrnoc_ml.h"
#include "oc_ansi.h" // neuron::model_sorted_token
#include "options.h" // EXTRACELLULAR
#include "ion_semantics.h"

#include <string>
#include <type_traits>
Expand Down
Loading