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