NEURON
cell_group.h
Go to the documentation of this file.
1 #ifndef NRN_CELL_GROUP_H
2 #define NRN_CELL_GROUP_H
3 
4 #include "datum_indices.h"
5 #include <vector>
6 #include <map>
7 #include <cstddef>
8 #include <cassert>
9 #include "section.h"
10 
11 class PreSyn;
12 class NetCon;
13 class NrnThread;
14 
15 typedef std::pair<int, Memb_list*> MlWithArtItem;
16 typedef std::vector<MlWithArtItem> MlWithArt;
17 typedef std::map<double*, int> PVoid2Int;
18 typedef std::vector<std::map<int, Memb_list*>> Deferred_Type2ArtMl;
19 
20 class CellGroup {
21  public:
22  CellGroup();
23  virtual ~CellGroup();
25  int group_id;
26  // PreSyn, NetCon, target info
27  int n_presyn; // real first
28  int n_output; // real + art with gid
30  int ndiam; // > 0 only if diam semantics in use.
31  int n_mech;
33  // following three are parallel arrays
34  PreSyn** output_ps; // n_presyn of these, real are first, tml order for acell.
35  int* output_gid; // n_presyn of these, -(type + 1000*index) if no gid
36  int* output_vindex; // n_presyn of these. >=0 if associated with voltage, -(type + 1000*index)
37  // for acell.
38  int n_netcon; // all that have targets associated with this threads Point_process.
40  int* netcon_srcgid; // -(type + 1000*index) refers to acell with no gid
41  // -1 means the netcon has no source
42  std::vector<int> netcon_negsrcgid_tid; // if some srcgid above are negative,
43  // need to know their thread id for Phase1::read_direct. Entries here only
44  // for negative srcgid in the order of netcon_srcgid and if nrn_nthread > 1.
47  // Datum.pval info
48  int ntype;
51 
52  static CellGroup* mk_cellgroups(CellGroup*); // gid, PreSyn, NetCon, Point_process relation.
53  static void datumtransform(CellGroup*); // Datum.pval to int
54  static void datumindex_fill(int, CellGroup&, DatumIndices&, Memb_list*); // helper
55  static void mk_cgs_netcon_info(CellGroup* cgs);
56  static void mk_tml_with_art(CellGroup*);
57  static size_t get_mla_rankbytes(CellGroup*);
58  static void clean_art(CellGroup*);
59 
60  static void setup_nrn_has_net_event();
61  static inline void clear_artdata2index() {
62  artdata2index_.clear();
63  }
64 
65  static inline void clean_deferred_type2artml() {
66  for (auto& th: deferred_type2artml_) {
67  for (auto& p: th) {
68  Memb_list* ml = p.second;
69  if (ml->data) {
70  delete[] ml->data;
71  }
72  if (ml->pdata) {
73  delete[] ml->pdata;
74  }
75  delete ml;
76  }
77  }
78  deferred_type2artml_.clear();
79  }
80 
82  static std::vector<NetCon**> deferred_netcons;
83  static void defer_clean_netcons(CellGroup*);
84  static void clean_deferred_netcons();
85 
86  private:
88 
89  static int* has_net_event_;
90 
91  static inline int nrncore_art2index(double* d) {
92  assert(artdata2index_.find(d) != artdata2index_.end());
93  return artdata2index_[d];
94  }
95 
96  static inline int nrn_has_net_event(int type) {
97  return has_net_event_[type];
98  }
99 
100  public:
101  static inline int nrncore_pntindex_for_queue(double* d, int tid, int type) {
102  Memb_list* ml = nrn_threads[tid]._ml_list[type];
103  if (ml) {
104  assert(d >= ml->data[0] &&
105  d < (ml->data[0] + (ml->nodecount * nrn_prop_param_size_[type])));
106  return (d - ml->data[0]) / nrn_prop_param_size_[type];
107  }
108  return nrncore_art2index(d);
109  }
110 };
111 
112 #endif // NRN_CELL_GROUP_H
short type
Definition: cabvars.h:9
std::vector< std::map< int, Memb_list * > > Deferred_Type2ArtMl
Definition: cell_group.h:18
std::vector< MlWithArtItem > MlWithArt
Definition: cell_group.h:16
std::pair< int, Memb_list * > MlWithArtItem
Definition: cell_group.h:13
std::map< double *, int > PVoid2Int
Definition: cell_group.h:17
int group_id
Definition: cell_group.h:25
static void clean_deferred_netcons()
int n_real_output
Definition: cell_group.h:29
static std::vector< NetCon ** > deferred_netcons
Definition: cell_group.h:82
static void mk_cgs_netcon_info(CellGroup *cgs)
Definition: cell_group.cpp:377
int * ml_vdata_offset
Definition: cell_group.h:32
static void clean_deferred_type2artml()
Definition: cell_group.h:65
static PVoid2Int artdata2index_
Definition: cell_group.h:87
static void clear_artdata2index()
Definition: cell_group.h:61
int n_mech
Definition: cell_group.h:31
static int nrncore_pntindex_for_queue(double *d, int tid, int type)
Definition: cell_group.h:101
static void defer_clean_netcons(CellGroup *)
int * output_vindex
Definition: cell_group.h:36
NetCon ** netcons
Definition: cell_group.h:39
static int * has_net_event_
Definition: cell_group.h:89
int * netcon_srcgid
Definition: cell_group.h:40
virtual ~CellGroup()
Definition: cell_group.cpp:40
static CellGroup * mk_cellgroups(CellGroup *)
Definition: cell_group.cpp:63
static int nrn_has_net_event(int type)
Definition: cell_group.h:96
static void clean_art(CellGroup *)
Definition: cell_group.cpp:619
Memb_list ** type2ml
Definition: cell_group.h:24
int * output_gid
Definition: cell_group.h:35
static void datumindex_fill(int, CellGroup &, DatumIndices &, Memb_list *)
Definition: cell_group.cpp:215
std::vector< int > netcon_negsrcgid_tid
Definition: cell_group.h:42
int ntype
Definition: cell_group.h:48
PreSyn ** output_ps
Definition: cell_group.h:34
int n_presyn
Definition: cell_group.h:27
static void mk_tml_with_art(CellGroup *)
Definition: cell_group.cpp:495
MlWithArt mlwithart
Definition: cell_group.h:50
static void setup_nrn_has_net_event()
Definition: cell_group.cpp:645
static size_t get_mla_rankbytes(CellGroup *)
Definition: cell_group.cpp:571
static void datumtransform(CellGroup *)
Definition: cell_group.cpp:173
int n_netcon
Definition: cell_group.h:38
static Deferred_Type2ArtMl deferred_type2artml_
Definition: cell_group.h:81
int * netcon_pnttype
Definition: cell_group.h:45
int * netcon_pntindex
Definition: cell_group.h:46
static int nrncore_art2index(double *d)
Definition: cell_group.h:91
DatumIndices * datumindices
Definition: cell_group.h:49
int n_output
Definition: cell_group.h:28
int ndiam
Definition: cell_group.h:30
Definition: netcon.h:83
Definition: netcon.h:255
VEC * cgs(MTX_FN A, void *A_params, VEC *b, VEC *r0, double tol, VEC *x)
Definition: conjgrad.c:179
#define assert(ex)
Definition: hocassrt.h:32
NrnThread * nrn_threads
Definition: multicore.cpp:47
int * nrn_prop_param_size_
Definition: init.cpp:140
size_t p
int nodecount
Definition: nrnoc_ml.h:18
double ** data
Definition: nrnoc_ml.h:14
Datum ** pdata
Definition: nrnoc_ml.h:15
Represent main neuron object computed by single thread.
Definition: multicore.h:58
Memb_list ** _ml_list
Definition: multicore.h:63