NEURON
netcvode.h
Go to the documentation of this file.
1 #ifndef netcvode_h
2 #define netcvode_h
3 
4 #define PRINT_EVENT 1
5 
6 #include "mymath.h"
7 #include "tqueue.h"
8 #include <vector>
9 
10 struct NrnThread;
11 class PreSyn;
12 class HocDataPaths;
13 class PreSynTable;
14 class NetCon;
15 class DiscreteEvent;
16 class TQItemPool;
17 class SelfEventPool;
18 class SelfEvent;
19 class hoc_Item;
20 class PlayRecord;
21 class PlayRecList;
22 class IvocVect;
23 class BAMechList;
24 class MaxStateTable;
25 class HTList;
26 // nrn_nthread vectors of HTList* for fixed step method
27 // Thread segregated HTList* of all the CVode.CvodeThreadData.HTList*
28 // Interior vector needed because of the chance of local variable time step.
29 // Practically it will always have length <= 1.
30 using HTListList = std::vector<std::vector<HTList*>>;
31 class NetCvode;
32 class MaxStateItem;
33 class CvodeThreadData;
34 class HocEvent;
35 class HocEventList;
36 struct BAMech;
37 struct Section;
38 struct InterThreadEvent;
39 
41 public:
43  virtual ~NetCvodeThreadData();
44  void interthread_send(double, DiscreteEvent*, NrnThread*);
45  void enqueue(NetCvode*, NrnThread*);
46  TQueue* tq_; // for lvardt
47  Cvode* lcv_; // for lvardt
49  hoc_Item* psl_thr_; //for presyns with fixed step threshold checking
50  SelfEventPool* sepool_;
51  TQItemPool* tpool_;
53  SelfQueue* selfqueue_;
54  MUTDEC
55  int nlcv_;
56  int ite_cnt_;
57  int ite_size_;
60 };
61 
62 class NetCvode {
63 public:
64  NetCvode(bool single=true);
65  virtual ~NetCvode();
66  int solve(double t);
67  void statistics(int);
68  void spike_stat();
69  void re_init(double t0 = 0.);
70  int cellindex();
71  void states();
72  void dstates();
73  int fun(double t, double* y, double* ydot);
74  void error_weights();
75  void acor();
76  const char* statename(int, int style=1);
77  void localstep(bool); bool localstep();
78  bool is_local();
79  void use_daspk(bool); bool use_daspk();
80  void move_event(TQItem*, double, NrnThread*);
81  void remove_event(TQItem*, int threadid);
82  TQItem* event(double tdeliver, DiscreteEvent*, NrnThread*);
83 #if BBTQ == 3 || BBTQ == 4
84  TQItem* fifo_event(double tdeliver, DiscreteEvent*, NrnThread*);
85 #endif
86 #if BBTQ == 5
87  TQItem* bin_event(double tdeliver, DiscreteEvent*, NrnThread*);
88 #endif
89  void send2thread(double, DiscreteEvent*, NrnThread*);
90  void null_event(double);
91  void tstop_event(double);
92  void handle_tstop_event(double, NrnThread* nt);
93  void hoc_event(double, const char* hoc_stmt, Object* ppobj = nil, int reinit = 0, Object* pyact=nil);
94  NetCon* install_deliver(double* psrc, Section* ssrc, Object* osrc,
95  Object* target, double threshold, double delay,
96  double weight
97  );
98  void presyn_disconnect(PreSyn*);
99  void check_thresh(NrnThread*);
100  void deliver_net_events(NrnThread*); // for default staggered time step method
101  void deliver_events(double til, NrnThread*); // for initialization events
102  void solver_prepare();
103  void clear_events();
104  void init_events();
105  void print_event_queue();
106  void event_queue_info();
107  void vec_event_store();
108  void local_retreat(double, Cvode*);
109  void retreat(double, Cvode*);
110  Object** netconlist();
111  int owned_by_thread(double*);
112  PlayRecord* playrec_uses(void*);
113  void playrec_add(PlayRecord*);
114  void playrec_remove(PlayRecord*);
115  int playrec_item(PlayRecord*);
116  PlayRecord* playrec_item(int);
117  PlayRecList* playrec_list() { return prl_;}
118  void simgraph_remove();
119  // fixed step continuous play and record
120  PlayRecList* fixed_play_;
121  PlayRecList* fixed_record_;
122  void vecrecord_add(); // hoc interface functions
123  void vec_remove();
124  void record_init();
125  void play_init();
128  static double eps(double x) { return eps_*Math::abs(x); }
129  int condition_order() { return condition_order_; }
130  void condition_order(int i) { condition_order_ = i; }
131  TQueue* event_queue(NrnThread* nt);
132  void psl_append(PreSyn*);
133  void recalc_ptrs();
134 public:
135  void rtol(double); double rtol(){return rtol_;}
136  void atol(double); double atol(){return atol_;}
137  double rtol_, atol_;
138  void stiff(int); int stiff(){return stiff_;} // 0 nothing stiff, 1 voltage, 2 mechanisms
139  void maxorder(int); int maxorder(){return maxorder_;}
140  int order(int);
141  void minstep(double); double minstep(){return minstep_;}
142  void maxstep(double); double maxstep(){return maxstep_;}
143  void jacobian(int); int jacobian(){return jacobian_;}
144  void structure_change();
146 // int nlist() { return nlist_; }
147 // Cvode* list() { return list_; }
148  bool initialized_; // for global step solve.
149  void consist_sec_pd(const char*, Section*, double*);
150  double state_magnitudes();
151  Symbol* name2sym(const char*);
152  const char* sym2name(Symbol*);
153  int pgvts(double tstop);
154  void update_ps2nt();
155  void point_receive(int, Point_process*, double*, double);
156  bool deliver_event(double til, NrnThread*); //uses TQueue atomically
157  bool empty_;
158  void delete_list();
159  void delete_list(Cvode*);
160 //private:
161 public:
162  static double eps_;
163  int local_microstep(NrnThread*);
164  int global_microstep();
165  void deliver_least_event(NrnThread*);
166  void evaluate_conditions();
168 
169  int pgvts_event(double& tt);
170  DiscreteEvent* pgvts_least(double& tt, int& op, int& init);
171  int pgvts_cvode(double tt, int op);
172 
173  bool init_global();
174  void alloc_list();
175  void del_cv_memb_list();
176  void del_cv_memb_list(Cvode*);
177  void distribute_dinfo(int*, int);
178  void playrec_setup();
179  void fill_global_ba(NrnThread*, int, BAMechList**);
180  void fill_local_ba(int*, NetCvodeThreadData&);
181  void fill_local_ba_cnt(int, int*, NetCvodeThreadData&);
182  BAMechList* cvbml(int, BAMech*, Cvode*);
183  void maxstate_analyse();
184  void maxstate_analyze_1(int, Cvode&, MaxStateItem*, CvodeThreadData&);
185  void fornetcon_prepare();
187  double maxstate_analyse(Symbol*, double*);
188  void p_construct(int);
189  void ps_thread_link(PreSyn*);
190  MaxStateTable* mst_;
191 private:
192  int maxorder_, jacobian_, stiff_;
193  double maxstep_, minstep_;
194 
197  bool single_;
198  PreSynTable* pst_;
199  int pst_cnt_;
201  PlayRecList* prl_;
204 public:
206  void set_CVRhsFn();
207  bool use_partrans();
208  hoc_Item* psl_; //actually a hoc_List
209  HTListList wl_list_; // nrn_nthread of these for faster deliver_net_events when many cvode
210  int pcnt_;
214 public:
215  MUTDEC // only for enqueueing_ so far.
216  void set_enqueueing();
217  double allthread_least_t(int& tid);
218  int solve_when_threads(double);
219  void deliver_events_when_threads(double);
220  int global_microstep_when_threads();
221  void allthread_handle(double, HocEvent*, NrnThread*);
222  void allthread_handle();
223  HocEventList* allthread_hocevents_;
224 };
225 
226 #endif
static double tstop_event(void *v)
Definition: cvodeobj.cpp:423
bool single_
Definition: netcvode.h:197
int condition_order_
Definition: netcvode.h:167
HTListList wl_list_
Definition: netcvode.h:209
int stiff_
Definition: netcvode.h:192
int enqueueing_
Definition: netcvode.h:212
int maxorder()
Definition: netcvode.h:139
InterThreadEvent * inter_thread_events_
Definition: netcvode.h:52
HocDataPaths * hdp_
Definition: netcvode.h:203
order
Definition: multicore.cpp:886
Definition: netcon.h:232
static Object ** netconlist(void *v)
Definition: cvodeobj.cpp:492
double rtol()
Definition: netcvode.h:135
int playrec_change_cnt_
Definition: netcvode.h:200
int use_long_double_
Definition: netcvode.h:213
IvocVect * vec_event_store_
Definition: netcvode.h:202
bool empty_
Definition: netcvode.h:157
double rtol_
Definition: netcvode.h:137
Represent main neuron object computed by single thread.
Definition: multicore.h:58
double minstep_
Definition: netcvode.h:193
static double dstates(void *v)
Definition: cvodeobj.cpp:280
PlayRecList * fixed_play_
Definition: netcvode.h:120
static int abs(int)
Definition: math.cpp:43
int condition_order()
Definition: netcvode.h:129
#define fifo_event
Definition: netcvode.cpp:2596
HocEventList * allthread_hocevents_
Definition: netcvode.h:223
PreSynTable * pst_
Definition: netcvode.h:198
Definition: bbtqueue.h:6
double atol()
Definition: netcvode.h:136
bool initialized_
Definition: netcvode.h:148
static double statistics(void *v)
Definition: cvodeobj.cpp:115
static double re_init(void *v)
Definition: cvodeobj.cpp:158
void init()
Definition: init.cpp:169
void solve(void)
Definition: nonlin.cpp:287
double immediate_deliver_
Definition: netcvode.h:59
int structure_change_cnt_
Definition: netcvode.h:195
PlayRecList * prl_
Definition: netcvode.h:201
SelfQueue * selfqueue_
Definition: netcvode.h:53
#define MUTDEC
Definition: nrnmutdec.h:28
MaxStateTable * mst_
Definition: netcvode.h:190
hoc_Item * psl_
Definition: netcvode.h:208
SelfEventPool * sepool_
Definition: netcvode.h:50
static double eps_
Definition: netcvode.h:162
static double acor(void *v)
Definition: cvodeobj.cpp:297
int matrix_change_cnt_
Definition: netcvode.h:196
void fixed_record_continuous(NrnThread *nt)
Definition: cvodestb.cpp:87
TQueue * tq_
Definition: netcvode.h:46
int jacobian()
Definition: netcvode.h:143
static double use_daspk(void *v)
Definition: cvodeobj.cpp:324
static double event_queue_info(void *v)
Definition: cvodeobj.cpp:480
MUTDEC int nlcv_
Definition: netcvode.h:55
static double error_weights(void *v)
Definition: cvodeobj.cpp:291
Definition: model.h:57
void enqueue(NetCvode *, NrnThread *)
Definition: netcvode.cpp:1167
TQueue * tqe_
Definition: netcvode.h:48
#define nil
Definition: enter-scope.h:36
Definition: netcon.h:82
virtual ~NetCvodeThreadData()
Definition: netcvode.cpp:1113
NetCvodeThreadData * p
Definition: netcvode.h:211
void fixed_play_continuous(NrnThread *nt)
Definition: cvodestb.cpp:81
double maxstep()
Definition: netcvode.h:142
int stiff()
Definition: netcvode.h:138
static void check_thresh(NrnThread *)
static double simgraph_remove(void *v)
Definition: cvodeobj.cpp:412
Definition: htlist.h:35
Cvode * gcv_
Definition: netcvode.h:205
threshold
Definition: extdef.h:3
PlayRecList * fixed_record_
Definition: netcvode.h:121
static double statename(void *v)
Definition: cvodeobj.cpp:303
static double eps(double x)
Definition: netcvode.h:128
int unreffed_event_cnt_
Definition: netcvode.h:58
int pcnt_
Definition: netcvode.h:210
void condition_order(int i)
Definition: netcvode.h:130
int print_event_
Definition: netcvode.h:145
Definition: hocdec.h:226
Definition: cvodeobj.h:75
double minstep()
Definition: netcvode.h:141
void interthread_send(double, DiscreteEvent *, NrnThread *)
Definition: netcvode.cpp:1133
#define i
Definition: md1redef.h:12
int fornetcon_change_cnt_
Definition: netcvode.h:186
TQItemPool * tpool_
Definition: netcvode.h:51
static double state_magnitudes(void *v)
Definition: cvodeobj.cpp:418
void deliver_net_events(NrnThread *)
Definition: cvodestb.cpp:40
hoc_Item * psl_thr_
Definition: netcvode.h:49
PlayRecList * playrec_list()
Definition: netcvode.h:117
std::vector< std::vector< HTList * > > HTListList
Definition: netcvode.h:30
double t
Definition: init.cpp:123
int pst_cnt_
Definition: netcvode.h:199
static double spike_stat(void *v)
Definition: ocbbs.cpp:693
double * states
Definition: rxd.cpp:62