Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions coreneuron/apps/corenrn_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ corenrn_parameters::corenrn_parameters(){
->check(CLI::Range(0., 1e9));
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)
->check(CLI::Range(-1000., 1000.));
sub_config -> add_option("-x, --extracon", this->extracon, "Number of extra random connections in each thread to other duplicate models.")
->check(CLI::Range(0, 10'000'000));
sub_config -> add_option("-z, --multiple", this->multiple, "Model duplication factor. Model size is normal size * multiple")
->check(CLI::Range(1, 10'000'000));
sub_config -> add_option("--mindelay", this->mindelay, "Maximum integration interval (likely reduced by minimum NetCon delay).", true)
->check(CLI::Range(0., 1e9));
sub_config -> add_option("--report-buffer-size", this->report_buff_size, "Size in MB of the report buffer.")
Expand Down Expand Up @@ -162,8 +158,6 @@ std::ostream& operator<<(std::ostream& os, const corenrn_parameters& corenrn_par
<< "--prcellgid=" << corenrn_param.prcellgid << std::endl
<< "--forwardskip=" << corenrn_param.forwardskip << std::endl
<< "--celsius=" << corenrn_param.celsius << std::endl
<< "--extracon=" << corenrn_param.extracon << std::endl
<< "--multiple=" << corenrn_param.multiple << std::endl
<< "--mindelay=" << corenrn_param.mindelay << std::endl
<< "--report-buffer-size=" << corenrn_param.report_buff_size << std::endl
<< std::endl
Expand Down
2 changes: 0 additions & 2 deletions coreneuron/apps/corenrn_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ struct corenrn_parameters {
unsigned spkcompress=0; /// Spike Compression
unsigned cell_interleave_permute=0; /// Cell interleaving permutation
unsigned nwarp=0; /// Number of warps to balance for cell_interleave_permute == 2
unsigned multiple=1; /// Model duplication factor
unsigned extracon=0; /// Number of extra random connections in each thread to other duplicate models.
unsigned report_buff_size=report_buff_size_default; ///Size in MB of the report buffer.
int seed=-1; /// Initialization seed for random number generator (int)

Expand Down
16 changes: 4 additions & 12 deletions coreneuron/apps/main1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ void nrn_init_and_load_data(int argc,
use_solve_interleave = true;
}

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

if (!corenrn_param.reportfilepath.empty()) {
if (corenrn_param.multiple > 1) {
if (nrnmpi_myid == 0)
printf("\n WARNING! : Can't enable reports with model duplications feature! \n");
} else {
configs = create_report_configurations(corenrn_param.reportfilepath.c_str(),
corenrn_param.outpath.c_str(),
spikes_population_name);
reports_needs_finalize = configs.size();
}
configs = create_report_configurations(corenrn_param.reportfilepath.c_str(),
corenrn_param.outpath.c_str(),
spikes_population_name);
reports_needs_finalize = configs.size();
}

// initializationa and loading functions moved to separate
Expand Down
2 changes: 1 addition & 1 deletion coreneuron/io/nrn_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static void write_phase2(NrnThread& nt, FileHandlerWrap& fh) {
}
}

int nnetcon = nt.n_netcon - nrn_setup_extracon;
int nnetcon = nt.n_netcon;

int* output_vindex = new int[nt.n_presyn];
double* output_threshold = new double[nt.ncell];
Expand Down
61 changes: 8 additions & 53 deletions coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,6 @@ int (*nrn2core_all_spike_vectors_return_)(std::vector<double>& spikevec, std::ve
// stored in the nt.presyns array and nt.netcons array respectively
namespace coreneuron {
extern corenrn_parameters corenrn_param;
int nrn_setup_multiple = 1; /* default */
int nrn_setup_extracon = 0; /* default */

// nrn_setup_extracon extra connections per NrnThread.
// i.e. nrn_setup_extracon * nrn_setup_multiple * nrn_nthread
// extra connections on this process.
// The targets of the connections on a NrnThread are randomly selected
// (with replacement) from the set of ProbAMPANMDA_EMS on the thread.
// (This synapse type is not strictly appropriate to be used as
// a generalized synapse with multiple input streams since some of its
// range variables store quantities that should be stream specific
// and therefore should be stored in the NetCon weight vector. But it
// might be good enough for our purposes. In any case, we'd like to avoid
// creating new POINT_PROCESS instances with all the extra complexities
// involved in adjusting the data arrays.)
// The nrn_setup_extracon value is used to allocate the appropriae
// amount of extra space for NrnThread.netcons and NrnThread.weights
//
// The most difficult problem is to augment the rank wide inputpresyn_ list.
// We wish to randomly choose source gids for the extracon NetCons from the
// set of gids not in "multiple" instance of the model the NrnThread is a
// member of. We need to take into account the possibilty of multiple
// NrnThread in multiple "multiple" instances having extra NetCon with the
// same source gid. That some of the source gids may be already be
// associated with already existing PreSyn on this rank is a minor wrinkle.
// This is done between phase1 and phase2 during the call to
// determine_inputpresyn().

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

/* read files.dat file and distribute cellgroups to all mpi ranks */
void nrn_read_filesdat(int& ngrp, int*& grp, int multiple, int*& imult, const char* filesdat) {
void nrn_read_filesdat(int& ngrp, int*& grp, const char* filesdat) {
patstimtype = nrn_get_mechtype("PatternStim");
if (corenrn_embedded) {
ngrp = corenrn_embedded_nthread;
nrn_assert(multiple == 1);
grp = new int[ngrp + 1];
imult = new int[ngrp + 1];
(*nrn2core_group_ids_)(grp);
for (int i = 0; i <= ngrp; ++i) {
imult[i] = 0;
}
return;
}

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

ngrp = 0;
grp = new int[iNumFiles * multiple / nrnmpi_numprocs + 1];
imult = new int[iNumFiles * multiple / nrnmpi_numprocs + 1];
grp = new int[iNumFiles / nrnmpi_numprocs + 1];

// irerate over gids in files.dat
for (int iNum = 0; iNum < iNumFiles * multiple; ++iNum) {
for (int iNum = 0; iNum < iNumFiles; ++iNum) {
int iFile;

nrn_assert(fscanf(fp, "%d\n", &iFile) == 1);
if ((iNum % nrnmpi_numprocs) == nrnmpi_myid) {
grp[ngrp] = iFile;
imult[ngrp] = iNum / iNumFiles;
ngrp++;
}
if ((iNum + 1) % iNumFiles == 0) {
// re-read file for each multiple (skipping the two header lines)
rewind(fp);
nrn_assert(fscanf(fp, "%*s\n") == 0);
nrn_assert(fscanf(fp, "%*d\n") == 0);
}
}

fclose(fp);
Expand Down Expand Up @@ -448,11 +408,9 @@ void nrn_setup(const char* filesdat,

int ngroup;
int* gidgroups;
int* imult;
nrn_read_filesdat(ngroup, gidgroups, nrn_setup_multiple, imult, filesdat);
nrn_read_filesdat(ngroup, gidgroups, filesdat);
UserParams userParams(ngroup,
gidgroups,
imult,
datpath,
strlen(restore_path) == 0 ? datpath : restore_path);

Expand Down Expand Up @@ -497,7 +455,6 @@ void nrn_setup(const char* filesdat,

// gap junctions
if (nrn_have_gaps) {
assert(nrn_setup_multiple == 1);
nrn_partrans::transfer_thread_data_ = new nrn_partrans::TransferThreadData[nrn_nthread];
nrn_partrans::setup_info_ = new nrn_partrans::SetupInfo[userParams.ngroup];
if (!corenrn_embedded) {
Expand All @@ -522,9 +479,9 @@ void nrn_setup(const char* filesdat,
NrnThread& nt = *n;
{
#ifdef _OPENMP
p1.populate(nt, 0, mut);
p1.populate(nt, mut);
#else
p1.populate(nt, 0);
p1.populate(nt);
#endif
}
});
Expand Down Expand Up @@ -565,7 +522,6 @@ void nrn_setup(const char* filesdat,

model_size();
delete[] userParams.gidgroups;
delete[] userParams.imult;

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

void read_phasegap(NrnThread& nt, UserParams& userParams) {
nrn_assert(userParams.imult[nt.id] == 0);
nrn_partrans::SetupInfo& si = nrn_partrans::setup_info_[nt.id];
si.ntar = 0;
si.nsrc = 0;
Expand Down Expand Up @@ -903,9 +858,9 @@ void read_phase1(NrnThread& nt, UserParams& userParams) {

{ // Protect gid2in, gid2out and neg_gid2out
#ifdef _OPENMP
p1.populate(nt, userParams.imult[nt.id], mut);
p1.populate(nt, mut);
#else
p1.populate(nt, userParams.imult[nt.id]);
p1.populate(nt);
#endif
}
}
Expand Down
1 change: 1 addition & 0 deletions coreneuron/io/output_spikes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#ifndef output_spikes_h
#define output_spikes_h

#include <string>
#include <vector>
#include <utility>
namespace coreneuron {
Expand Down
84 changes: 4 additions & 80 deletions coreneuron/io/phase1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,93 +43,19 @@ void Phase1::read_direct(int thread_id) {
delete[] netcon_srcgid;
}

void Phase1::shift_gids(int imult) {
// maxgid is the maxgid to have the different multiple in the same gid space.
int maxgid = 0x7fffffff / nrn_setup_multiple;
// this value is the beginning of the new cluster of gids.
// the correct cluster is choose with imult.
int offset_gids = imult * maxgid; // offset for each gid

// offset the (non-negative) gids according to multiple
// make sure everything fits into gid space.
for (auto& gid: this->output_gids) {
if (gid >= 0) {
nrn_assert(gid < maxgid);
gid += offset_gids;
}
}

for (auto& srcgid: this->netcon_srcgids) {
if (srcgid >= 0) {
nrn_assert(srcgid < maxgid);
srcgid += offset_gids;
}
}
}

void Phase1::add_extracon(NrnThread& nt, int imult) {
int maxgid = 0x7fffffff / nrn_setup_multiple;
if (nrn_setup_extracon <= 0) {
return;
}

// very simplistic
// Use this threads positive source gids - zz in nt.netcon order as the
// source gids for extracon.
// The edge cases are:
// The 0th duplicate uses uses source gids for the last duplicate.
// If there are fewer positive source gids than extracon, then keep
// rotating through the nt.netcon .
// If there are no positive source gids, use a source gid of -1.
// Would not be difficult to modify so that random positive source was
// used, and/or random connect to another duplicate.
// Note that we increment the nt.n_netcon at the end of this function.
int sidoffset = 0; // how much to increment the corresponding positive gid
// like ring connectivity
if (imult > 0) {
sidoffset = -maxgid;
} else if (nrn_setup_multiple > 1) {
sidoffset = (nrn_setup_multiple - 1) * maxgid;
}
// set up the extracon srcgid_
int* nc_srcgid = netcon_srcgid[nt.id];
int j = 0; // rotate through the n_netcon netcon_srcgid
for (int i = 0; i < nrn_setup_extracon; ++i) {
int sid = -1;
for (int k = 0; k < nt.n_netcon; ++k) {
// potentially rotate j through the entire n_netcon but no further
sid = nc_srcgid[j];
j = (j + 1) % nt.n_netcon;
if (sid >= 0) {
break;
}
}
if (sid < 0) { // only connect to real cells.
sid = -1;
} else {
sid += sidoffset;
}
nc_srcgid[nt.n_netcon + i] = sid;
}
// finally increment the n_netcon
nt.n_netcon += nrn_setup_extracon;
}

#ifdef _OPENMP
void Phase1::populate(NrnThread& nt, int imult, OMP_Mutex& mut) {
void Phase1::populate(NrnThread& nt, OMP_Mutex& mut) {
#else
void Phase1::populate(NrnThread& nt, int imult) {
void Phase1::populate(NrnThread& nt) {
#endif
nt.n_presyn = this->output_gids.size();
nt.n_netcon = this->netcon_srcgids.size();

shift_gids(imult);

netcon_srcgid[nt.id] = new int[nt.n_netcon + nrn_setup_extracon];
netcon_srcgid[nt.id] = new int[nt.n_netcon];
std::copy(this->netcon_srcgids.begin(), this->netcon_srcgids.end(),
netcon_srcgid[nt.id]);

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

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

++ps;
}

add_extracon(nt, imult);
}

} // namespace coreneuron
7 changes: 2 additions & 5 deletions coreneuron/io/phase1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ class Phase1 {
void read_file(FileHandler& F);
void read_direct(int thread_id);
#ifdef _OPENMP
void populate(NrnThread& nt, int imult, OMP_Mutex& mut);
void populate(NrnThread& nt, OMP_Mutex& mut);
#else
void populate(NrnThread& nt, int imult);
void populate(NrnThread& nt);
#endif

private:
void shift_gids(int imult);
void add_extracon(NrnThread& nt, int imult);

std::vector<int> output_gids;
std::vector<int> netcon_srcgids;
};
Expand Down
Loading