CoreNEURON
netcon.hpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================.
7 */
8 
9 #pragma once
10 
11 #include "coreneuron/mpi/nrnmpi.h"
12 
13 #undef check
14 #if MAC
15 #define NetCon nrniv_Dinfo
16 #endif
17 namespace coreneuron {
18 class PreSyn;
19 class InputPreSyn;
20 class TQItem;
21 struct NrnThread;
22 struct Point_process;
23 class NetCvode;
24 
25 #define DiscreteEventType 0
26 #define TstopEventType 1
27 #define NetConType 2
28 #define SelfEventType 3
29 #define PreSynType 4
30 #define NetParEventType 7
31 #define InputPreSynType 20
32 
33 struct DiscreteEvent {
34  DiscreteEvent() = default;
35  virtual ~DiscreteEvent() = default;
36  virtual void send(double deliverytime, NetCvode*, NrnThread*);
37  virtual void deliver(double t, NetCvode*, NrnThread*);
38  virtual int type() const {
39  return DiscreteEventType;
40  }
41  virtual bool require_checkpoint() {
42  return true;
43  }
44  virtual void pr(const char*, double t, NetCvode*);
45 };
46 
47 class NetCon: public DiscreteEvent {
48  public:
49  bool active_{};
50  double delay_{1.0};
52  union {
54  int srcgid_; // only to help InputPreSyn during setup
55  // before weights are read and stored. Saves on transient
56  // memory requirements by avoiding storage of all group file
57  // netcon_srcgid lists. ie. that info is copied into here.
58  } u;
59 
60  NetCon() = default;
61  virtual ~NetCon() = default;
62  virtual void send(double sendtime, NetCvode*, NrnThread*) override;
63  virtual void deliver(double, NetCvode* ns, NrnThread*) override;
64  virtual int type() const override {
65  return NetConType;
66  }
67  virtual void pr(const char*, double t, NetCvode*) override;
68 };
69 
70 class SelfEvent: public DiscreteEvent {
71  public:
72  double flag_;
74  void** movable_; // actually a TQItem**
76 
77  SelfEvent() = default;
78  virtual ~SelfEvent() = default;
79  virtual void deliver(double, NetCvode*, NrnThread*) override;
80  virtual int type() const override {
81  return SelfEventType;
82  }
83 
84  virtual void pr(const char*, double t, NetCvode*) override;
85 
86  private:
88 };
89 
91  public:
92  // condition detection factored out of PreSyn for re-use
93  ConditionEvent() = default;
94  virtual ~ConditionEvent() = default;
95  virtual bool check(NrnThread*);
96  virtual double value(NrnThread*) {
97  return -1.;
98  }
99 
100  int flag_{}; // true when below, false when above. (changed from bool to int to avoid cray acc
101  // bug(?))
102 };
103 
104 class PreSyn: public ConditionEvent {
105  public:
106 #if NRNMPI
107  unsigned char localgid_{}; // compressed gid for spike transfer
108 #endif
109  int nc_index_{}; // replaces dil_, index into global NetCon** netcon_in_presyn_order_
110  int nc_cnt_{}; // how many netcon starting at nc_index_
112  int gid_{-1};
113  double threshold_{10.};
114  int thvar_index_{-1}; // >=0 points into NrnThread._actual_v
116 
117  PreSyn() = default;
118  virtual ~PreSyn() = default;
119  virtual void send(double sendtime, NetCvode*, NrnThread*) override;
120  virtual void deliver(double, NetCvode*, NrnThread*) override;
121  virtual int type() const override {
122  return PreSynType;
123  }
124 
125  virtual double value(NrnThread*) override;
126  void record(double t);
127 #if NRN_MULTISEND
128  int multisend_index_{-1};
129 #endif
130 };
131 
132 class InputPreSyn: public DiscreteEvent {
133  public:
134  int nc_index_{-1}; // replaces dil_, index into global NetCon** netcon_in_presyn_order_
135  int nc_cnt_{}; // how many netcon starting at nc_index_
136 
137  InputPreSyn() = default;
138  virtual ~InputPreSyn() = default;
139  virtual void send(double sendtime, NetCvode*, NrnThread*) override;
140  virtual void deliver(double, NetCvode*, NrnThread*) override;
141  virtual int type() const override {
142  return InputPreSynType;
143  }
144 #if NRN_MULTISEND
145  int multisend_phase2_index_{-1};
146 #endif
147 };
148 
149 class NetParEvent: public DiscreteEvent {
150  public:
151  int ithread_; // for pr()
152  double wx_, ws_; // exchange time and "spikes to Presyn" time
153 
154  NetParEvent();
155  virtual ~NetParEvent() = default;
156  virtual void send(double, NetCvode*, NrnThread*) override;
157  virtual void deliver(double, NetCvode*, NrnThread*) override;
158  virtual int type() const override {
159  return NetParEventType;
160  }
161 
162  virtual void pr(const char*, double t, NetCvode*) override;
163 };
164 } // namespace coreneuron
coreneuron::NetCon::delay_
double delay_
Definition: netcon.hpp:50
coreneuron::ConditionEvent::flag_
int flag_
Definition: netcon.hpp:100
coreneuron::NetCon::~NetCon
virtual ~NetCon()=default
coreneuron::ConditionEvent::~ConditionEvent
virtual ~ConditionEvent()=default
coreneuron::NetParEvent::~NetParEvent
virtual ~NetParEvent()=default
coreneuron::NetParEvent::deliver
virtual void deliver(double, NetCvode *, NrnThread *) override
Definition: netpar.cpp:121
coreneuron::NetCon::NetCon
NetCon()=default
coreneuron::ConditionEvent::check
virtual bool check(NrnThread *)
Definition: netcvode.cpp:350
coreneuron::Point_process
Definition: mechanism.hpp:35
NetConType
#define NetConType
Definition: netcon.hpp:27
coreneuron::InputPreSyn::nc_cnt_
int nc_cnt_
Definition: netcon.hpp:135
coreneuron::ConditionEvent::ConditionEvent
ConditionEvent()=default
coreneuron::NetParEvent::ws_
double ws_
Definition: netcon.hpp:152
coreneuron::PreSyn::threshold_
double threshold_
Definition: netcon.hpp:113
coreneuron::PreSyn::send
virtual void send(double sendtime, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:409
coreneuron::SelfEvent::flag_
double flag_
Definition: netcon.hpp:72
coreneuron::NetParEvent::wx_
double wx_
Definition: netcon.hpp:152
coreneuron::NetCon::u
union coreneuron::NetCon::@0 u
coreneuron::PreSyn::output_index_
int output_index_
Definition: netcon.hpp:111
coreneuron::NetParEvent::NetParEvent
NetParEvent()
Definition: netpar.cpp:112
coreneuron::SelfEvent::call_net_receive
void call_net_receive(NetCvode *)
Definition: netcvode.cpp:471
coreneuron::InputPreSyn::InputPreSyn
InputPreSyn()=default
coreneuron
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
Definition: corenrn_parameters.cpp:12
coreneuron::SelfEvent::~SelfEvent
virtual ~SelfEvent()=default
coreneuron::SelfEvent::type
virtual int type() const override
Definition: netcon.hpp:80
coreneuron::NetCon::srcgid_
int srcgid_
Definition: netcon.hpp:54
coreneuron::t
double t
Definition: register_mech.cpp:22
coreneuron::ConditionEvent::value
virtual double value(NrnThread *)
Definition: netcon.hpp:96
coreneuron::PreSyn
Definition: netcon.hpp:104
coreneuron::NetParEvent::ithread_
int ithread_
Definition: netcon.hpp:151
coreneuron::DiscreteEvent::type
virtual int type() const
Definition: netcon.hpp:38
coreneuron::DiscreteEvent
Definition: netcon.hpp:33
DiscreteEventType
#define DiscreteEventType
Definition: netcon.hpp:25
coreneuron::NetCon
Definition: netcon.hpp:47
coreneuron::NetParEvent::type
virtual int type() const override
Definition: netcon.hpp:158
coreneuron::NetCon::send
virtual void send(double sendtime, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:372
SelfEventType
#define SelfEventType
Definition: netcon.hpp:28
coreneuron::NrnThread
Definition: multicore.hpp:75
coreneuron::SelfEvent::deliver
virtual void deliver(double, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:464
coreneuron::PreSyn::~PreSyn
virtual ~PreSyn()=default
PreSynType
#define PreSynType
Definition: netcon.hpp:29
coreneuron::NetParEvent
Definition: netcon.hpp:149
coreneuron::PreSyn::value
virtual double value(NrnThread *) override
Definition: netcvode.cpp:521
coreneuron::NetCon::deliver
virtual void deliver(double, NetCvode *ns, NrnThread *) override
Definition: netcvode.cpp:379
coreneuron::NetCon::weight_index_
int weight_index_
Definition: netcon.hpp:53
coreneuron::NetParEvent::send
virtual void send(double, NetCvode *, NrnThread *) override
Definition: netpar.cpp:117
coreneuron::PreSyn::thvar_index_
int thvar_index_
Definition: netcon.hpp:114
coreneuron::DiscreteEvent::send
virtual void send(double deliverytime, NetCvode *, NrnThread *)
Definition: netcvode.cpp:362
coreneuron::DiscreteEvent::~DiscreteEvent
virtual ~DiscreteEvent()=default
coreneuron::PreSyn::PreSyn
PreSyn()=default
coreneuron::PreSyn::nc_index_
int nc_index_
Definition: netcon.hpp:109
coreneuron::PreSyn::nc_cnt_
int nc_cnt_
Definition: netcon.hpp:110
coreneuron::PreSyn::type
virtual int type() const override
Definition: netcon.hpp:121
coreneuron::DiscreteEvent::DiscreteEvent
DiscreteEvent()=default
coreneuron::InputPreSyn::nc_index_
int nc_index_
Definition: netcon.hpp:134
coreneuron::SelfEvent
Definition: netcon.hpp:70
coreneuron::PreSyn::deliver
virtual void deliver(double, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:456
coreneuron::PreSyn::pntsrc_
Point_process * pntsrc_
Definition: netcon.hpp:115
coreneuron::SelfEvent::target_
Point_process * target_
Definition: netcon.hpp:73
coreneuron::SelfEvent::pr
virtual void pr(const char *, double t, NetCvode *) override
Definition: netcvode.cpp:483
coreneuron::InputPreSyn
Definition: netcon.hpp:132
coreneuron::ConditionEvent
Definition: netcon.hpp:90
coreneuron::NetCon::active_
bool active_
Definition: netcon.hpp:49
coreneuron::InputPreSyn::send
virtual void send(double sendtime, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:442
coreneuron::SelfEvent::SelfEvent
SelfEvent()=default
coreneuron::DiscreteEvent::pr
virtual void pr(const char *, double t, NetCvode *)
Definition: netcvode.cpp:368
coreneuron::NetParEvent::pr
virtual void pr(const char *, double t, NetCvode *) override
Definition: netpar.cpp:128
coreneuron::PreSyn::gid_
int gid_
Definition: netcon.hpp:112
coreneuron::InputPreSyn::~InputPreSyn
virtual ~InputPreSyn()=default
coreneuron::InputPreSyn::type
virtual int type() const override
Definition: netcon.hpp:141
coreneuron::NetCvode
Definition: netcvode.hpp:59
NetParEventType
#define NetParEventType
Definition: netcon.hpp:30
coreneuron::NetCon::pr
virtual void pr(const char *, double t, NetCvode *) override
Definition: netcvode.cpp:400
coreneuron::NetCon::type
virtual int type() const override
Definition: netcon.hpp:64
coreneuron::InputPreSyn::deliver
virtual void deliver(double, NetCvode *, NrnThread *) override
Definition: netcvode.cpp:460
nrnmpi.h
coreneuron::PreSyn::record
void record(double t)
Definition: netcvode.cpp:341
coreneuron::NetCon::target_
Point_process * target_
Definition: netcon.hpp:51
coreneuron::SelfEvent::movable_
void ** movable_
Definition: netcon.hpp:74
InputPreSynType
#define InputPreSynType
Definition: netcon.hpp:31
coreneuron::DiscreteEvent::deliver
virtual void deliver(double t, NetCvode *, NrnThread *)
Definition: netcvode.cpp:366
coreneuron::DiscreteEvent::require_checkpoint
virtual bool require_checkpoint()
Definition: netcon.hpp:41
coreneuron::SelfEvent::weight_index_
int weight_index_
Definition: netcon.hpp:75