Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 6691e99

Browse files
nrnhinespramodk
andauthored
Allow multiple gids per cell that reference different voltages. (#829)
* Allow multiple gid for a cell (no more than on per PreSyn) * data version 1.6 updated for integration ring and ring_gap * checkpoint updated for data format 1.6 * nt.n_presyn is no longer needs to be nt.ncell - so allocate presyns only if we have non-zero presyns - note that non-zero length allocations aren't nullptr * fix for ispc: add missing n_real_output field in NrnThread for ISPC (and minor reformating) Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
1 parent 3bafde0 commit 6691e99

32 files changed

+48
-30
lines changed

coreneuron/io/nrn2core_direct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern int (*nrn2core_get_dat1_)(int tid,
3333
std::vector<int>& netcon_negsrcgid_tid);
3434

3535
extern int (*nrn2core_get_dat2_1_)(int tid,
36+
int& n_real_cell,
3637
int& ngid,
3738
int& n_real_gid,
3839
int& nnode,

coreneuron/io/nrn_checkpoint.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ void CheckPoints::write_phase2(NrnThread& nt) const {
131131
}
132132
}
133133

134+
fh << nt.ncell << " ncell\n";
134135
fh << n_outputgid << " ngid\n";
135136
#if CHKPNTDEBUG
136137
assert(ntc.n_outputgids == n_outputgid);
137138
#endif
138139

139-
fh << nt.ncell << " n_real_gid\n";
140+
fh << nt.n_real_output << " n_real_output\n";
140141
fh << nt.end << " nnode\n";
141142
fh << ((nt._actual_diam == nullptr) ? 0 : nt.end) << " ndiam\n";
142143
int nmech = 0;
@@ -316,7 +317,7 @@ void CheckPoints::write_phase2(NrnThread& nt) const {
316317
int nnetcon = nt.n_netcon;
317318

318319
int* output_vindex = new int[nt.n_presyn];
319-
double* output_threshold = new double[nt.ncell];
320+
double* output_threshold = new double[nt.n_real_output];
320321
for (int i = 0; i < nt.n_presyn; ++i) {
321322
PreSyn* ps = nt.presyns + i;
322323
if (ps->thvar_index_ >= 0) {
@@ -327,8 +328,8 @@ void CheckPoints::write_phase2(NrnThread& nt) const {
327328
assert(ps->pntsrc_ == nullptr);
328329
output_threshold[i] = ps->threshold_;
329330
output_vindex[i] = pinv_nt[ps->thvar_index_];
330-
} else if (i < nt.ncell) { // real cell without a presyn
331-
output_threshold[i] = 0.0; // the way it was set in nrnbbcore_write.cpp
331+
} else if (i < nt.n_real_output) { // real cell without a presyn
332+
output_threshold[i] = 0.0; // the way it was set in nrnbbcore_write.cpp
332333
output_vindex[i] = -1;
333334
} else {
334335
Point_process* pnt = ps->pntsrc_;
@@ -347,12 +348,12 @@ void CheckPoints::write_phase2(NrnThread& nt) const {
347348
}
348349
}
349350
fh.write_array<int>(output_vindex, nt.n_presyn);
350-
fh.write_array<double>(output_threshold, nt.ncell);
351+
fh.write_array<double>(output_threshold, nt.n_real_output);
351352
#if CHKPNTDEBUG
352353
for (int i = 0; i < nt.n_presyn; ++i) {
353354
assert(ntc.output_vindex[i] == output_vindex[i]);
354355
}
355-
for (int i = 0; i < nt.ncell; ++i) {
356+
for (int i = 0; i < nt.n_real_output; ++i) {
356357
assert(ntc.output_threshold[i] == output_threshold[i]);
357358
}
358359
#endif

coreneuron/io/nrn_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void (*nrn2core_all_weights_return_)(std::vector<double*>& weights);
102102
// for the negative gids in netcon_srcgid (in that order) the source thread.
103103
//
104104
// <firstgid>_2.dat
105-
// n_output n_real_output, nnode
105+
// n_real_cell, n_output, n_real_output, nnode
106106
// ndiam - 0 if no mechanism has dparam with diam semantics, or nnode
107107
// nmech - includes artcell mechanisms
108108
// for the nmech tml mechanisms

coreneuron/io/phase1.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ void Phase1::populate(NrnThread& nt, OMP_Mutex& mut) {
6767
coreneuron::nrnthreads_netcon_negsrcgid_tid[nt.id] = this->netcon_negsrcgid_tid;
6868

6969
nt.netcons = new NetCon[nt.n_netcon];
70-
nt.presyns_helper = (PreSynHelper*) ecalloc_align(nt.n_presyn, sizeof(PreSynHelper));
7170

72-
nt.presyns = new PreSyn[nt.n_presyn];
71+
if (nt.n_presyn) {
72+
nt.presyns_helper = (PreSynHelper*) ecalloc_align(nt.n_presyn, sizeof(PreSynHelper));
73+
nt.presyns = new PreSyn[nt.n_presyn];
74+
}
75+
7376
PreSyn* ps = nt.presyns;
7477
/// go through all presyns
7578
for (auto& gid: this->output_gids) {

coreneuron/io/phase2.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#endif
2525

2626
int (*nrn2core_get_dat2_1_)(int tid,
27+
int& n_real_cell,
2728
int& ngid,
2829
int& n_real_gid,
2930
int& nnode,
@@ -107,6 +108,7 @@ inline void mech_data_layout_transform(T* data, int cnt, int sz, int layout) {
107108
}
108109

109110
void Phase2::read_file(FileHandler& F, const NrnThread& nt) {
111+
n_real_cell = F.read_int();
110112
n_output = F.read_int();
111113
n_real_output = F.read_int();
112114
n_node = F.read_int();
@@ -256,6 +258,7 @@ void Phase2::read_direct(int thread_id, const NrnThread& nt) {
256258
int* nodecounts_ = nullptr;
257259
int n_weight;
258260
(*nrn2core_get_dat2_1_)(thread_id,
261+
n_real_cell,
259262
n_output,
260263
n_real_output,
261264
n_node,
@@ -915,8 +918,9 @@ void Phase2::populate(NrnThread& nt, const UserParams& userParams) {
915918
NrnThreadChkpnt& ntc = nrnthread_chkpnt[nt.id];
916919
ntc.file_id = userParams.gidgroups[nt.id];
917920

918-
nt.ncell = n_real_output;
921+
nt.ncell = n_real_cell;
919922
nt.end = n_node;
923+
nt.n_real_output = n_real_output;
920924

921925
#if CHKPNTDEBUG
922926
ntc.n_outputgids = n_output;
@@ -1221,14 +1225,15 @@ void Phase2::populate(NrnThread& nt, const UserParams& userParams) {
12211225
node_permute(output_vindex.data(), nt.n_presyn, nt._permute);
12221226
}
12231227
#if CHKPNTDEBUG
1224-
ntc.output_threshold = new double[nt.ncell];
1225-
memcpy(ntc.output_threshold, output_threshold.data(), nt.ncell * sizeof(double));
1228+
ntc.output_threshold = new double[n_real_output];
1229+
memcpy(ntc.output_threshold, output_threshold.data(), n_real_output * sizeof(double));
12261230
#endif
1231+
12271232
for (int i = 0; i < nt.n_presyn; ++i) { // real cells
12281233
PreSyn* ps = nt.presyns + i;
12291234

12301235
int ix = output_vindex[i];
1231-
if (ix == -1 && i < nt.ncell) { // real cell without a presyn
1236+
if (ix == -1 && i < n_real_output) { // real cell without a presyn
12321237
continue;
12331238
}
12341239
if (ix < 0) {
@@ -1256,7 +1261,7 @@ void Phase2::populate(NrnThread& nt, const UserParams& userParams) {
12561261
// initial net_send_buffer size about 1% of number of presyns
12571262
// nt._net_send_buffer_size = nt.ncell/100 + 1;
12581263
// but, to avoid reallocation complexity on GPU ...
1259-
nt._net_send_buffer_size = nt.ncell;
1264+
nt._net_send_buffer_size = n_real_output;
12601265
nt._net_send_buffer = (int*) ecalloc_align(nt._net_send_buffer_size, sizeof(int));
12611266

12621267
int nnetcon = nt.n_netcon;

coreneuron/io/phase2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Phase2 {
8989
NrnThreadChkpnt& ntc);
9090
void set_vec_play(NrnThread& nt, NrnThreadChkpnt& ntc);
9191

92+
int n_real_cell;
9293
int n_output;
9394
int n_real_output;
9495
int n_node;

coreneuron/mechanism/nrnoc_ml.ispc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,22 @@ struct NrnThread {
104104
NetCon* uniform netcons;
105105
double* uniform weights;
106106

107-
uniform int n_pntproc, n_presyn, n_input_presyn, n_netcon, n_weight;
107+
uniform int n_pntproc;
108+
uniform int n_weight;
109+
uniform int n_netcon;
110+
uniform int n_input_presyn;
111+
uniform int n_presyn;
112+
uniform int n_real_output;
108113

109114
uniform int ncell;
110115
uniform int end;
111116
uniform int id;
112117
uniform int _stop_stepping;
113118
uniform int n_vecplay;
114119

115-
uniform unsigned int64 _ndata, _nidata, _nvdata;
120+
uniform unsigned int64 _ndata;
121+
uniform unsigned int64 _nidata;
122+
uniform unsigned int64 _nvdata;
116123
double* uniform _data;
117124
int* uniform _idata;
118125

coreneuron/network/netcvode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ void NetCvode::check_thresh(NrnThread* nt) { // for default method
539539
nt [0:1], presyns_helper [0:nt->n_presyn], presyns [0:nt->n_presyn], actual_v [0:nt->end])
540540
copy(net_send_buf_count) if (nt->compute_gpu) async(nt->stream_id))
541541
nrn_pragma_omp(target teams distribute parallel for map(tofrom: net_send_buf_count) if(nt->compute_gpu))
542-
for (int i = 0; i < nt->ncell; ++i) {
542+
for (int i = 0; i < nt->n_real_output; ++i) {
543543
PreSyn* ps = presyns + i;
544544
PreSynHelper* psh = presyns_helper + i;
545545
int idx = 0;

coreneuron/sim/multicore.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ struct NrnThread: public MemoryManaged {
9090
int n_weight = 0;
9191
int n_netcon = 0;
9292
int n_input_presyn = 0;
93-
int n_presyn = 0; // only for model_size
93+
int n_presyn = 0; // only for model_size
94+
int n_real_output = 0; // for checking their thresholds.
9495

9596
int ncell = 0; /* analogous to old rootnodecount */
9697
int end = 0; /* 1 + position of last in v_node array. Now v_node_count. */

coreneuron/utils/nrnoc_aux.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ int v_structure_change;
2121
int diam_changed;
2222
#define MAXERRCOUNT 5
2323
int hoc_errno_count;
24-
const char* bbcore_write_version = "1.5"; // Generalize POINTER transfer to allow pointing to any
25-
// RANGE variable
24+
const char* bbcore_write_version = "1.6"; // Allow multiple gid and PreSyn per real cell.
2625

2726
char* pnt_name(Point_process* pnt) {
2827
return corenrn.get_memb_func(pnt->_type).sym;

0 commit comments

Comments
 (0)