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

Commit 5fb8978

Browse files
author
Nicolas Cornu
authored
Remove extracon and multiple, fix #291 (#360)
Extra-connection and module duplication functionality was added to scale model for benchmarking. Over last few years we haven't used this functionality as it's often easy to just scale the model and BBP model's are already big. Hence no need to carry the old code.
1 parent e96624e commit 5fb8978

File tree

16 files changed

+49
-364
lines changed

16 files changed

+49
-364
lines changed

coreneuron/apps/corenrn_parameters.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ corenrn_parameters::corenrn_parameters(){
8989
->check(CLI::Range(0., 1e9));
9090
sub_config -> add_option("-l, --celsius", this->celsius, "Temperature in degC. The default value is set in defaults.dat or else is 34.0.", true)
9191
->check(CLI::Range(-1000., 1000.));
92-
sub_config -> add_option("-x, --extracon", this->extracon, "Number of extra random connections in each thread to other duplicate models.")
93-
->check(CLI::Range(0, 10'000'000));
94-
sub_config -> add_option("-z, --multiple", this->multiple, "Model duplication factor. Model size is normal size * multiple")
95-
->check(CLI::Range(1, 10'000'000));
9692
sub_config -> add_option("--mindelay", this->mindelay, "Maximum integration interval (likely reduced by minimum NetCon delay).", true)
9793
->check(CLI::Range(0., 1e9));
9894
sub_config -> add_option("--report-buffer-size", this->report_buff_size, "Size in MB of the report buffer.")
@@ -162,8 +158,6 @@ std::ostream& operator<<(std::ostream& os, const corenrn_parameters& corenrn_par
162158
<< "--prcellgid=" << corenrn_param.prcellgid << std::endl
163159
<< "--forwardskip=" << corenrn_param.forwardskip << std::endl
164160
<< "--celsius=" << corenrn_param.celsius << std::endl
165-
<< "--extracon=" << corenrn_param.extracon << std::endl
166-
<< "--multiple=" << corenrn_param.multiple << std::endl
167161
<< "--mindelay=" << corenrn_param.mindelay << std::endl
168162
<< "--report-buffer-size=" << corenrn_param.report_buff_size << std::endl
169163
<< std::endl

coreneuron/apps/corenrn_parameters.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ struct corenrn_parameters {
7575
unsigned spkcompress=0; /// Spike Compression
7676
unsigned cell_interleave_permute=0; /// Cell interleaving permutation
7777
unsigned nwarp=0; /// Number of warps to balance for cell_interleave_permute == 2
78-
unsigned multiple=1; /// Model duplication factor
79-
unsigned extracon=0; /// Number of extra random connections in each thread to other duplicate models.
8078
unsigned report_buff_size=report_buff_size_default; ///Size in MB of the report buffer.
8179
int seed=-1; /// Initialization seed for random number generator (int)
8280

coreneuron/apps/main1.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ void nrn_init_and_load_data(int argc,
242242
use_solve_interleave = true;
243243
}
244244

245-
// pass by flag so existing tests do not need a changed nrn_setup prototype.
246-
nrn_setup_multiple = corenrn_param.multiple;
247-
nrn_setup_extracon = corenrn_param.extracon;
248245
// multisend options
249246
use_multisend_ = corenrn_param.multisend ? 1 : 0;
250247
n_multisend_interval = corenrn_param.ms_subint;
@@ -478,15 +475,10 @@ extern "C" int run_solve_core(int argc, char** argv) {
478475
}
479476

480477
if (!corenrn_param.reportfilepath.empty()) {
481-
if (corenrn_param.multiple > 1) {
482-
if (nrnmpi_myid == 0)
483-
printf("\n WARNING! : Can't enable reports with model duplications feature! \n");
484-
} else {
485-
configs = create_report_configurations(corenrn_param.reportfilepath.c_str(),
486-
corenrn_param.outpath.c_str(),
487-
spikes_population_name);
488-
reports_needs_finalize = configs.size();
489-
}
478+
configs = create_report_configurations(corenrn_param.reportfilepath.c_str(),
479+
corenrn_param.outpath.c_str(),
480+
spikes_population_name);
481+
reports_needs_finalize = configs.size();
490482
}
491483

492484
// initializationa and loading functions moved to separate

coreneuron/io/nrn_checkpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static void write_phase2(NrnThread& nt, FileHandlerWrap& fh) {
372372
}
373373
}
374374

375-
int nnetcon = nt.n_netcon - nrn_setup_extracon;
375+
int nnetcon = nt.n_netcon;
376376

377377
int* output_vindex = new int[nt.n_presyn];
378378
double* output_threshold = new double[nt.ncell];

coreneuron/io/nrn_setup.cpp

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,6 @@ int (*nrn2core_all_spike_vectors_return_)(std::vector<double>& spikevec, std::ve
161161
// stored in the nt.presyns array and nt.netcons array respectively
162162
namespace coreneuron {
163163
extern corenrn_parameters corenrn_param;
164-
int nrn_setup_multiple = 1; /* default */
165-
int nrn_setup_extracon = 0; /* default */
166-
167-
// nrn_setup_extracon extra connections per NrnThread.
168-
// i.e. nrn_setup_extracon * nrn_setup_multiple * nrn_nthread
169-
// extra connections on this process.
170-
// The targets of the connections on a NrnThread are randomly selected
171-
// (with replacement) from the set of ProbAMPANMDA_EMS on the thread.
172-
// (This synapse type is not strictly appropriate to be used as
173-
// a generalized synapse with multiple input streams since some of its
174-
// range variables store quantities that should be stream specific
175-
// and therefore should be stored in the NetCon weight vector. But it
176-
// might be good enough for our purposes. In any case, we'd like to avoid
177-
// creating new POINT_PROCESS instances with all the extra complexities
178-
// involved in adjusting the data arrays.)
179-
// The nrn_setup_extracon value is used to allocate the appropriae
180-
// amount of extra space for NrnThread.netcons and NrnThread.weights
181-
//
182-
// The most difficult problem is to augment the rank wide inputpresyn_ list.
183-
// We wish to randomly choose source gids for the extracon NetCons from the
184-
// set of gids not in "multiple" instance of the model the NrnThread is a
185-
// member of. We need to take into account the possibilty of multiple
186-
// NrnThread in multiple "multiple" instances having extra NetCon with the
187-
// same source gid. That some of the source gids may be already be
188-
// associated with already existing PreSyn on this rank is a minor wrinkle.
189-
// This is done between phase1 and phase2 during the call to
190-
// determine_inputpresyn().
191164

192165
#ifdef _OPENMP
193166
static OMP_Mutex mut;
@@ -208,17 +181,12 @@ std::vector<NetCon*> netcon_in_presyn_order_;
208181
std::vector<int*> netcon_srcgid;
209182

210183
/* read files.dat file and distribute cellgroups to all mpi ranks */
211-
void nrn_read_filesdat(int& ngrp, int*& grp, int multiple, int*& imult, const char* filesdat) {
184+
void nrn_read_filesdat(int& ngrp, int*& grp, const char* filesdat) {
212185
patstimtype = nrn_get_mechtype("PatternStim");
213186
if (corenrn_embedded) {
214187
ngrp = corenrn_embedded_nthread;
215-
nrn_assert(multiple == 1);
216188
grp = new int[ngrp + 1];
217-
imult = new int[ngrp + 1];
218189
(*nrn2core_group_ids_)(grp);
219-
for (int i = 0; i <= ngrp; ++i) {
220-
imult[i] = 0;
221-
}
222190
return;
223191
}
224192

@@ -251,25 +219,17 @@ void nrn_read_filesdat(int& ngrp, int*& grp, int multiple, int*& imult, const ch
251219
}
252220

253221
ngrp = 0;
254-
grp = new int[iNumFiles * multiple / nrnmpi_numprocs + 1];
255-
imult = new int[iNumFiles * multiple / nrnmpi_numprocs + 1];
222+
grp = new int[iNumFiles / nrnmpi_numprocs + 1];
256223

257224
// irerate over gids in files.dat
258-
for (int iNum = 0; iNum < iNumFiles * multiple; ++iNum) {
225+
for (int iNum = 0; iNum < iNumFiles; ++iNum) {
259226
int iFile;
260227

261228
nrn_assert(fscanf(fp, "%d\n", &iFile) == 1);
262229
if ((iNum % nrnmpi_numprocs) == nrnmpi_myid) {
263230
grp[ngrp] = iFile;
264-
imult[ngrp] = iNum / iNumFiles;
265231
ngrp++;
266232
}
267-
if ((iNum + 1) % iNumFiles == 0) {
268-
// re-read file for each multiple (skipping the two header lines)
269-
rewind(fp);
270-
nrn_assert(fscanf(fp, "%*s\n") == 0);
271-
nrn_assert(fscanf(fp, "%*d\n") == 0);
272-
}
273233
}
274234

275235
fclose(fp);
@@ -448,11 +408,9 @@ void nrn_setup(const char* filesdat,
448408

449409
int ngroup;
450410
int* gidgroups;
451-
int* imult;
452-
nrn_read_filesdat(ngroup, gidgroups, nrn_setup_multiple, imult, filesdat);
411+
nrn_read_filesdat(ngroup, gidgroups, filesdat);
453412
UserParams userParams(ngroup,
454413
gidgroups,
455-
imult,
456414
datpath,
457415
strlen(restore_path) == 0 ? datpath : restore_path);
458416

@@ -497,7 +455,6 @@ void nrn_setup(const char* filesdat,
497455

498456
// gap junctions
499457
if (nrn_have_gaps) {
500-
assert(nrn_setup_multiple == 1);
501458
nrn_partrans::transfer_thread_data_ = new nrn_partrans::TransferThreadData[nrn_nthread];
502459
nrn_partrans::setup_info_ = new nrn_partrans::SetupInfo[userParams.ngroup];
503460
if (!corenrn_embedded) {
@@ -522,9 +479,9 @@ void nrn_setup(const char* filesdat,
522479
NrnThread& nt = *n;
523480
{
524481
#ifdef _OPENMP
525-
p1.populate(nt, 0, mut);
482+
p1.populate(nt, mut);
526483
#else
527-
p1.populate(nt, 0);
484+
p1.populate(nt);
528485
#endif
529486
}
530487
});
@@ -565,7 +522,6 @@ void nrn_setup(const char* filesdat,
565522

566523
model_size();
567524
delete[] userParams.gidgroups;
568-
delete[] userParams.imult;
569525

570526
if (nrnmpi_myid == 0 && !corenrn_param.is_quiet()) {
571527
printf(" Setup Done : %.2lf seconds \n", nrn_wtime() - time);
@@ -593,7 +549,6 @@ void setup_ThreadData(NrnThread& nt) {
593549
}
594550

595551
void read_phasegap(NrnThread& nt, UserParams& userParams) {
596-
nrn_assert(userParams.imult[nt.id] == 0);
597552
nrn_partrans::SetupInfo& si = nrn_partrans::setup_info_[nt.id];
598553
si.ntar = 0;
599554
si.nsrc = 0;
@@ -903,9 +858,9 @@ void read_phase1(NrnThread& nt, UserParams& userParams) {
903858

904859
{ // Protect gid2in, gid2out and neg_gid2out
905860
#ifdef _OPENMP
906-
p1.populate(nt, userParams.imult[nt.id], mut);
861+
p1.populate(nt, mut);
907862
#else
908-
p1.populate(nt, userParams.imult[nt.id]);
863+
p1.populate(nt);
909864
#endif
910865
}
911866
}

coreneuron/io/output_spikes.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
2929
#ifndef output_spikes_h
3030
#define output_spikes_h
3131

32+
#include <string>
3233
#include <vector>
3334
#include <utility>
3435
namespace coreneuron {

coreneuron/io/phase1.cpp

Lines changed: 4 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -43,93 +43,19 @@ void Phase1::read_direct(int thread_id) {
4343
delete[] netcon_srcgid;
4444
}
4545

46-
void Phase1::shift_gids(int imult) {
47-
// maxgid is the maxgid to have the different multiple in the same gid space.
48-
int maxgid = 0x7fffffff / nrn_setup_multiple;
49-
// this value is the beginning of the new cluster of gids.
50-
// the correct cluster is choose with imult.
51-
int offset_gids = imult * maxgid; // offset for each gid
52-
53-
// offset the (non-negative) gids according to multiple
54-
// make sure everything fits into gid space.
55-
for (auto& gid: this->output_gids) {
56-
if (gid >= 0) {
57-
nrn_assert(gid < maxgid);
58-
gid += offset_gids;
59-
}
60-
}
61-
62-
for (auto& srcgid: this->netcon_srcgids) {
63-
if (srcgid >= 0) {
64-
nrn_assert(srcgid < maxgid);
65-
srcgid += offset_gids;
66-
}
67-
}
68-
}
69-
70-
void Phase1::add_extracon(NrnThread& nt, int imult) {
71-
int maxgid = 0x7fffffff / nrn_setup_multiple;
72-
if (nrn_setup_extracon <= 0) {
73-
return;
74-
}
75-
76-
// very simplistic
77-
// Use this threads positive source gids - zz in nt.netcon order as the
78-
// source gids for extracon.
79-
// The edge cases are:
80-
// The 0th duplicate uses uses source gids for the last duplicate.
81-
// If there are fewer positive source gids than extracon, then keep
82-
// rotating through the nt.netcon .
83-
// If there are no positive source gids, use a source gid of -1.
84-
// Would not be difficult to modify so that random positive source was
85-
// used, and/or random connect to another duplicate.
86-
// Note that we increment the nt.n_netcon at the end of this function.
87-
int sidoffset = 0; // how much to increment the corresponding positive gid
88-
// like ring connectivity
89-
if (imult > 0) {
90-
sidoffset = -maxgid;
91-
} else if (nrn_setup_multiple > 1) {
92-
sidoffset = (nrn_setup_multiple - 1) * maxgid;
93-
}
94-
// set up the extracon srcgid_
95-
int* nc_srcgid = netcon_srcgid[nt.id];
96-
int j = 0; // rotate through the n_netcon netcon_srcgid
97-
for (int i = 0; i < nrn_setup_extracon; ++i) {
98-
int sid = -1;
99-
for (int k = 0; k < nt.n_netcon; ++k) {
100-
// potentially rotate j through the entire n_netcon but no further
101-
sid = nc_srcgid[j];
102-
j = (j + 1) % nt.n_netcon;
103-
if (sid >= 0) {
104-
break;
105-
}
106-
}
107-
if (sid < 0) { // only connect to real cells.
108-
sid = -1;
109-
} else {
110-
sid += sidoffset;
111-
}
112-
nc_srcgid[nt.n_netcon + i] = sid;
113-
}
114-
// finally increment the n_netcon
115-
nt.n_netcon += nrn_setup_extracon;
116-
}
117-
11846
#ifdef _OPENMP
119-
void Phase1::populate(NrnThread& nt, int imult, OMP_Mutex& mut) {
47+
void Phase1::populate(NrnThread& nt, OMP_Mutex& mut) {
12048
#else
121-
void Phase1::populate(NrnThread& nt, int imult) {
49+
void Phase1::populate(NrnThread& nt) {
12250
#endif
12351
nt.n_presyn = this->output_gids.size();
12452
nt.n_netcon = this->netcon_srcgids.size();
12553

126-
shift_gids(imult);
127-
128-
netcon_srcgid[nt.id] = new int[nt.n_netcon + nrn_setup_extracon];
54+
netcon_srcgid[nt.id] = new int[nt.n_netcon];
12955
std::copy(this->netcon_srcgids.begin(), this->netcon_srcgids.end(),
13056
netcon_srcgid[nt.id]);
13157

132-
nt.netcons = new NetCon[nt.n_netcon + nrn_setup_extracon];
58+
nt.netcons = new NetCon[nt.n_netcon];
13359
nt.presyns_helper = (PreSynHelper*)ecalloc_align(nt.n_presyn, sizeof(PreSynHelper));
13460

13561
nt.presyns = new PreSyn[nt.n_presyn];
@@ -177,8 +103,6 @@ void Phase1::populate(NrnThread& nt, int imult) {
177103

178104
++ps;
179105
}
180-
181-
add_extracon(nt, imult);
182106
}
183107

184108
} // namespace coreneuron

coreneuron/io/phase1.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ class Phase1 {
1414
void read_file(FileHandler& F);
1515
void read_direct(int thread_id);
1616
#ifdef _OPENMP
17-
void populate(NrnThread& nt, int imult, OMP_Mutex& mut);
17+
void populate(NrnThread& nt, OMP_Mutex& mut);
1818
#else
19-
void populate(NrnThread& nt, int imult);
19+
void populate(NrnThread& nt);
2020
#endif
2121

2222
private:
23-
void shift_gids(int imult);
24-
void add_extracon(NrnThread& nt, int imult);
25-
2623
std::vector<int> output_gids;
2724
std::vector<int> netcon_srcgids;
2825
};

0 commit comments

Comments
 (0)