40 unsigned char* spikeout_fixed;
42 unsigned char* spikein_fixed;
63 void nrn_timeout(
int);
70 std::vector<std::map<int, InputPreSyn*>> localmaps;
72 static int ocapacity_;
76 static bool use_compress_;
77 static int spfixout_capacity_;
79 static void nrn_spike_exchange_compressed(
NrnThread*);
87 static std::vector<NetParEvent>
npe_;
104 #if nrn_spikebuf_size > 0
133 inline static void sppk(
unsigned char*
c,
int gid) {
139 inline static int spupk(
unsigned char*
c) {
152 std::lock_guard<OMP_Mutex>
lock(
mut);
156 if (idxout_ >= spfixout_capacity_) {
157 spfixout_capacity_ *= 2;
158 spikeout_fixed = (
unsigned char*)
erealloc(spikeout_fixed,
159 spfixout_capacity_ *
sizeof(
unsigned char));
161 spikeout_fixed[
i++] = (
unsigned char) ((firetime -
t_exchange_) *
dt1_ + .5);
162 spikeout_fixed[
i] = localgid;
171 std::lock_guard<OMP_Mutex>
lock(
mut);
176 if (idxout_ >= spfixout_capacity_) {
177 spfixout_capacity_ *= 2;
178 spikeout_fixed = (
unsigned char*)
erealloc(spikeout_fixed,
179 spfixout_capacity_ *
sizeof(
unsigned char));
184 spikeout_fixed[
i++] = (
unsigned char) ((firetime -
t_exchange_) *
dt1_ + .5);
187 sppk(spikeout_fixed +
i, gid);
190 #if nrn_spikebuf_size == 0
192 if (
i >= ocapacity_) {
197 spikeout[
i].
gid = gid;
203 if (
i >= ocapacity_) {
209 spikeout[
i].
gid = gid;
212 spbufout->
gid[
i] = gid;
230 npe_.shrink_to_fit();
255 hoc_execerror(
"usable mindelay is 0",
"(or less than dt for fixed step method)");
274 npe_.shrink_to_fit();
296 #if nrn_spikebuf_size > 0
321 nrn_spike_exchange_compressed(nt);
328 #if nrn_spikebuf_size > 0
333 int n = nrnmpi_spike_exchange(
334 nrnmpi_nin_, spikeout, icapacity, &spikein, ovfl, nout, spbufout, spbufin);
339 tbuf_[itbuf_++] = (
unsigned long) nout;
340 tbuf_[itbuf_++] = (
unsigned long)
n;
351 #if nrn_spikebuf_size > 0
357 for (
int j = 0;
j < nn; ++
j) {
358 auto gid2in_it =
gid2in.find(spbufin[
i].gid[
j]);
359 if (gid2in_it !=
gid2in.end()) {
360 InputPreSyn* ps = gid2in_it->second;
367 for (
int i = 0;
i <
n; ++
i) {
368 auto gid2in_it =
gid2in.find(spikein[
i].gid);
369 if (gid2in_it !=
gid2in.end()) {
370 InputPreSyn* ps = gid2in_it->second;
378 void nrn_spike_exchange_compressed(
NrnThread* nt) {
387 spikeout_fixed[1] = (
unsigned char) (nout & 0xff);
388 spikeout_fixed[0] = (
unsigned char) (nout >> 8);
404 tbuf_[itbuf_++] = (
unsigned long) nout;
405 tbuf_[itbuf_++] = (
unsigned long)
n;
421 int nn = nrnmpi_nin_[
i];
424 if (nn > ag_send_nspike) {
429 std::map<int, InputPreSyn*> gps = localmaps[
i];
430 if (nn > ag_send_nspike) {
431 nnn = ag_send_nspike;
435 int idx = 2 +
i * ag_send_size;
436 for (
j = 0;
j < nnn; ++
j) {
439 int lgid = (int) spikein_fixed[idx];
441 auto gid2in_it = gps.find(lgid);
442 if (gid2in_it != gps.end()) {
443 InputPreSyn* ps = gid2in_it->second;
447 for (;
j < nn; ++
j) {
451 auto gid2in_it = gps.find(lgid);
452 if (gid2in_it != gps.end()) {
453 InputPreSyn* ps = gid2in_it->second;
461 int nn = nrnmpi_nin_[
i];
462 if (nn > ag_send_nspike) {
465 int idx = 2 +
i * ag_send_size;
466 for (
int j = 0;
j < nn; ++
j) {
469 int gid = spupk(spikein_fixed + idx);
471 auto gid2in_it =
gid2in.find(gid);
472 if (gid2in_it !=
gid2in.end()) {
473 InputPreSyn* ps = gid2in_it->second;
480 for (
int i = 0;
i <
n; ++
i) {
484 auto gid2in_it =
gid2in.find(gid);
485 if (gid2in_it !=
gid2in.end()) {
486 InputPreSyn* ps = gid2in_it->second;
501 static void mk_localgid_rep() {
505 for (
const auto& gid2out_elem:
gid2out) {
506 if (gid2out_elem.second->output_index_ >= 0) {
521 int* sbuf =
new int[ngidmax + 1];
527 for (
const auto& gid2out_elem:
gid2out) {
528 if (gid2out_elem.second->output_index_ >= 0) {
529 gid2out_elem.second->localgid_ = (
unsigned char) ngid;
530 sbuf[ngid] = gid2out_elem.second->output_index_;
550 sbuf = rbuf +
i * (ngidmax + 1);
552 for (
int k = 0;
k < ngid; ++
k) {
553 auto gid2in_it =
gid2in.find(
int(sbuf[
k]));
554 if (gid2in_it !=
gid2in.end()) {
555 localmaps[
i][
k] = gid2in_it->second;
579 auto gid2in_it =
gid2in.find(gid);
580 if (gid2in_it !=
gid2in.end()) {
585 }
else if (fake_out) {
586 std::map<int, PreSyn*>::iterator gid2out_it;
587 gid2out_it =
gid2out.find(gid);
588 if (gid2out_it !=
gid2out.end()) {
589 PreSyn* ps = gid2out_it->second;
614 hoc_execerror(
"mindelay is 0",
"(or less than dt for fixed step method)");
644 double mindelay = maxdelay;
654 std::map<PreSyn*, NrnThread*> presynmap;
673 if (!negsrcgid_tid.empty() && gid < -1) {
674 tid = negsrcgid_tid[i_tid++];
684 if (ps && presynmap[ps] == &nt) {
688 if (chk && nc->
delay_ < mindelay) {
698 if (mindelay /
dt > 255) {
757 if (xchng_meth > 0) {
765 if (spikeout_fixed) {
766 free(spikeout_fixed);
767 spikeout_fixed =
nullptr;
771 spikein_fixed =
nullptr;
780 use_compress_ =
false;
782 }
else if (nspike > 0) {
783 use_compress_ =
true;
784 ag_send_nspike = nspike;
791 "Notice: gid compression did not succeed. Probably more than 255 cells on "
801 spikeout_fixed = (
unsigned char*)
emalloc(spfixout_capacity_);
806 return ag_send_nspike;
static void nrnmpi_int_allgather(int *s, int *r, int n)
static void nrnmpi_barrier()
static int nrnmpi_int_allmax(int x)
void deliver_events(double til, NrnThread *)
TQItem * event(double tdeliver, DiscreteEvent *, NrnThread *)
virtual void deliver(double, NetCvode *, NrnThread *) override
virtual void send(double, NetCvode *, NrnThread *) override
virtual void pr(const char *, double t, NetCvode *) override
virtual void send(double sendtime, NetCvode *, NrnThread *) override
#define nrn_spikebuf_size
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
static void alloc_mpi_space()
Allocate space for spikes: 200 structs of {int gid; double time} coming from nrnmpi....
static double usable_mindelay_
void interthread_enqueue(NrnThread *nt)
static std::vector< NetParEvent > npe_
void nrn_spike_exchange(NrnThread *nt)
void nrn_multisend_init()
static double last_maxstep_arg_
std::map< int, InputPreSyn * > gid2in
void nrn2ncs_outputevent(int netcon_output_index, double firetime)
int nrn_set_timeout(int timeout)
void netpar_tid_gid2ps(int tid, int gid, PreSyn **ps, InputPreSyn **psi)
std::vector< std::vector< int > > nrnthreads_netcon_negsrcgid_tid
If a nrnthreads_netcon_srcgid is negative, need to determine the thread when in order to use the corr...
void BBS_netpar_solve(double tstop)
std::vector< int * > nrnthreads_netcon_srcgid
Only for setup vector of netcon source gids.
void hoc_execerror(const char *s1, const char *s2)
void nrn_outputevent(unsigned char, double)
void nrn_multisend_receive(NrnThread *)
void * erealloc(void *ptr, size_t size)
static void * emalloc(size_t size)
double set_mindelay(double maxdelay)
void ncs2nrn_integrate(double tstop)
void nrn_spike_exchange_init()
static bool nrn_need_npe()
void nrn_multithread_job(F &&job, Args &&... args)
NetCvode * net_cvode_instance
void nrn_fake_fire(int gid, double spiketime, int fake_out)
std::map< int, PreSyn * > gid2out
Maps for ouput and input presyns.
corenrn_parameters corenrn_param
Printing method.
int nrnmpi_spike_compress(int nspike, bool gid_compress, int xchng_meth)
#define nrn_assert(x)
assert()-like macro, independent of NDEBUG status
int const size_t const size_t n
static double t_exchange_
static int localgid_size_
static unsigned char * spfixin_ovfl_
void * hoc_Erealloc(void *ptr, std::size_t size)
Represent main neuron object computed by single thread.
int gid[nrn_spikebuf_size]
double spiketime[nrn_spikebuf_size]
bool mpi_enable
Initialization seed for random number generator (int)