NEURON
cell_group.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "datum_indices.h"
4 #include <vector>
5 #include <map>
6 #include <cstddef>
7 #include <cassert>
8 #include "section.h"
9 
10 class PreSyn;
11 class NetCon;
12 struct NrnThread;
13 
14 typedef std::pair<int, Memb_list*> MlWithArtItem;
15 typedef std::vector<MlWithArtItem> MlWithArt;
16 typedef std::vector<std::map<int, Memb_list*>> Deferred_Type2ArtMl;
17 
18 class CellGroup {
19  public:
20  CellGroup();
21  virtual ~CellGroup();
23  int group_id;
25  // PreSyn, NetCon, target info
26  int n_presyn; // real first
27  int n_output; // real + art with gid
28  int n_real_output; // up to nt.end outputs for the n_real_cells.
29  int ndiam; // > 0 only if diam semantics in use.
30  int n_mech;
32  // following three are parallel arrays
33  std::vector<PreSyn*> output_ps; // n_presyn of these, real are first, tml order for acell.
34  std::vector<int> output_gid; // n_presyn of these, -(type + 1000*index) if no gid
35  std::vector<int> output_vindex; // n_presyn of these. >=0 if associated with voltage,
36  // -(type + 1000*index) for acell.
37  int n_netcon; // all that have targets associated with this threads Point_process.
38  std::vector<NetCon*> netcons;
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 void mk_cellgroups(neuron::model_sorted_token const& cache_token,
52  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(neuron::model_sorted_token const& cache_token, CellGroup* cgs);
56  static void mk_tml_with_art(neuron::model_sorted_token const& cache_token, 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 clean_deferred_type2artml() {
62  for (auto& th: deferred_type2artml_) {
63  for (auto& p: th) {
64  Memb_list* ml = p.second;
65  if (ml->pdata) {
66  delete[] ml->pdata;
67  }
68  delete ml;
69  }
70  }
71  deferred_type2artml_.clear();
72  }
73 
75  static std::vector<std::vector<NetCon*>> deferred_netcons;
76  static void defer_clean_netcons(CellGroup*);
77  static void clean_deferred_netcons();
78 
79  private:
80  static int* has_net_event_;
81  static inline int nrn_has_net_event(int type) {
82  return has_net_event_[type];
83  }
84 
85  public:
86  static inline int nrncore_pntindex_for_queue(Prop* p, int tid, int type) {
87  assert(p->_type == type);
88  auto const sorted_token = nrn_ensure_model_data_are_sorted();
89  return p->id().current_row() - sorted_token.thread_cache(tid).mechanism_offset.at(type);
90  }
91 };
std::vector< std::map< int, Memb_list * > > Deferred_Type2ArtMl
Definition: cell_group.h:16
std::vector< MlWithArtItem > MlWithArt
Definition: cell_group.h:15
std::pair< int, Memb_list * > MlWithArtItem
Definition: cell_group.h:12
static void mk_cgs_netcon_info(neuron::model_sorted_token const &cache_token, CellGroup *cgs)
Definition: cell_group.cpp:373
std::vector< NetCon * > netcons
Definition: cell_group.h:38
int group_id
Definition: cell_group.h:23
std::vector< int > output_vindex
Definition: cell_group.h:35
static void clean_deferred_netcons()
int n_real_output
Definition: cell_group.h:28
int * ml_vdata_offset
Definition: cell_group.h:31
static void clean_deferred_type2artml()
Definition: cell_group.h:61
static void mk_tml_with_art(neuron::model_sorted_token const &cache_token, CellGroup *)
Definition: cell_group.cpp:480
std::vector< int > output_gid
Definition: cell_group.h:34
int n_mech
Definition: cell_group.h:30
static void defer_clean_netcons(CellGroup *)
static int * has_net_event_
Definition: cell_group.h:80
static int nrncore_pntindex_for_queue(Prop *p, int tid, int type)
Definition: cell_group.h:86
int * netcon_srcgid
Definition: cell_group.h:39
virtual ~CellGroup()
Definition: cell_group.cpp:37
static int nrn_has_net_event(int type)
Definition: cell_group.h:81
static void clean_art(CellGroup *)
Definition: cell_group.cpp:596
Memb_list ** type2ml
Definition: cell_group.h:22
static void datumindex_fill(int, CellGroup &, DatumIndices &, Memb_list *)
Definition: cell_group.cpp:247
static std::vector< std::vector< NetCon * > > deferred_netcons
Definition: cell_group.h:75
std::vector< int > netcon_negsrcgid_tid
Definition: cell_group.h:41
int ntype
Definition: cell_group.h:47
int n_presyn
Definition: cell_group.h:26
MlWithArt mlwithart
Definition: cell_group.h:49
static void setup_nrn_has_net_event()
Definition: cell_group.cpp:622
static size_t get_mla_rankbytes(CellGroup *)
Definition: cell_group.cpp:552
static void datumtransform(CellGroup *)
Definition: cell_group.cpp:205
int n_real_cell
Definition: cell_group.h:24
static void mk_cellgroups(neuron::model_sorted_token const &cache_token, CellGroup *)
Definition: cell_group.cpp:52
std::vector< PreSyn * > output_ps
Definition: cell_group.h:33
int n_netcon
Definition: cell_group.h:37
static Deferred_Type2ArtMl deferred_type2artml_
Definition: cell_group.h:74
int * netcon_pnttype
Definition: cell_group.h:44
int * netcon_pntindex
Definition: cell_group.h:45
DatumIndices * datumindices
Definition: cell_group.h:48
int n_output
Definition: cell_group.h:27
int ndiam
Definition: cell_group.h:29
Definition: netcon.h:87
Definition: netcon.h:258
#define assert(ex)
Definition: hocassrt.h:24
neuron::model_sorted_token nrn_ensure_model_data_are_sorted()
Ensure neuron::container::* data are sorted.
Definition: treeset.cpp:2182
size_t p
short type
Definition: cabvars.h:10
A view into a set of mechanism instances.
Definition: nrnoc_ml.h:34
Datum ** pdata
Definition: nrnoc_ml.h:75
Represent main neuron object computed by single thread.
Definition: multicore.h:58
Definition: section.h:231