NEURON
multicore.h
Go to the documentation of this file.
1 #ifndef multicore_h
2 #define multicore_h
3 
4 /*
5 Starts from Hubert Eichner's modifications but incorporates a
6 significant refactorization. The best feature of Hubert's original
7 code is retained. I.e. the user level structures remain unchanged
8 and the vectors, e.g v_node, are ordered so that each thread uses
9 a contiguous region. We take this even further by changing rootnodecount
10 to nrn_global_ncell and ordering the rootnodes so they appear in the proper
11 place in the lists instead of all at the beginning. This means
12 most of the user level for i=0,rootnode-1 loops have to be
13 changed to iterate over all the nrn_thread_t.ncell. But underneath the
14 VECTORIZE part, most functions are given an ithread argument and none ever
15 get outside the array portions specified by the nrn_thread_t.
16 This means that the thread parallelization can be handled at the level
17 of fadvance() and a network sim can take advantage of the minimum
18 netcon delay interval
19 
20 The main caveat with threads is that mod files should not use pointers
21 that cross thread data boundaries. ie. gap junctions should use the
22 ParallelContext methods.
23 
24 */
25 
26 /* now included by section.h since this has take over the v_node,
27 actual_v, etc.
28 */
29 
30 #include <membfunc.h>
31 
32 
33 typedef struct NrnThreadMembList{ /* patterned after CvMembList in cvodeobj.h */
36  int index;
38 
39 typedef struct NrnThreadBAList {
40  Memb_list* ml; /* an item in the NrnThreadMembList */
44 
45 typedef struct _nrn_Fast_Imem {
46  double* _nrn_sav_rhs;
47  double* _nrn_sav_d;
49 
50 
51 /**
52  * \class NrnThread
53  * \brief Represent main neuron object computed by single thread
54  *
55  * NrnThread represent collection of cells or part of a cell computed
56  * by single thread within NEURON process.
57  */
58 typedef struct NrnThread {
59  double _t;
60  double _dt;
61  double cj;
64  int ncell; /* analogous to old rootnodecount */
65  int end; /* 1 + position of last in v_node array. Now v_node_count. */
66  int id; /* this is nrn_threads[id] */
67  int _stop_stepping; /* delivered an all thread HocEvent */
68  int _ecell_child_cnt; /* see _ecell_children below */
69 
70  double* _actual_rhs;
71  double* _actual_d;
72  double* _actual_a;
73  double* _actual_b;
74  double* _actual_v;
75  double* _actual_area;
79  char* _sp13mat; /* handle to general sparse matrix */
80  Memb_list* _ecell_memb_list; /* normally nil */
81  Node** _ecell_children; /* nodes with no extcell but parent has it */
83  void* _vcv; /* replaces old cvode_instance and nrn_cvode_ */
84 
85 #if 1
86  double _ctime; /* computation time in seconds (using nrnmpi_wtime) */
87 #endif
88 
89  NrnThreadBAList* tbl[BEFORE_AFTER_SIZE]; /* wasteful since almost all empty */
90  hoc_List* roots; /* ncell of these */
91  Object* userpart; /* the SectionList if this is a user defined partition */
92 
93 } NrnThread;
94 
95 
96 extern int nrn_nthread;
97 extern NrnThread* nrn_threads;
98 extern void nrn_thread_error(const char*);
99 extern void nrn_multithread_job(void*(*)(NrnThread*));
100 extern void nrn_onethread_job(int, void*(*)(NrnThread*));
101 extern void nrn_wait_for_threads();
102 extern void nrn_thread_table_check();
103 
104 #define FOR_THREADS(nt) for (nt = nrn_threads; nt < nrn_threads + nrn_nthread; ++nt)
105 
106 // olupton 2022-01-31: could add a _NrnThread typedef here for .mod file
107 // backwards compatibility if needed.
108 
109 #endif
Node ** _ecell_children
Definition: multicore.h:81
Memb_list ** _ml_list
Definition: multicore.h:63
double * _actual_d
Definition: multicore.h:71
int _stop_stepping
Definition: multicore.h:67
struct NrnThreadMembList NrnThreadMembList
void nrn_onethread_job(int, void *(*)(NrnThread *))
Memb_list * ml
Definition: multicore.h:40
void nrn_thread_table_check()
Definition: multicore.cpp:1050
struct NrnThreadMembList * next
Definition: multicore.h:34
double * _nrn_sav_d
Definition: multicore.h:47
int _ecell_child_cnt
Definition: multicore.h:68
int * _v_parent_index
Definition: multicore.h:76
Node ** _v_parent
Definition: multicore.h:78
Represent main neuron object computed by single thread.
Definition: multicore.h:58
double * _actual_rhs
Definition: multicore.h:70
void nrn_thread_error(const char *)
Definition: multicore.cpp:453
struct NrnThread NrnThread
Object * userpart
Definition: multicore.h:91
#define BEFORE_AFTER_SIZE
Definition: membfunc.h:78
_nrn_Fast_Imem * _nrn_fast_imem
Definition: multicore.h:82
struct NrnThreadBAList NrnThreadBAList
int id
Definition: multicore.h:66
double _dt
Definition: multicore.h:60
int ncell
Definition: multicore.h:64
void nrn_multithread_job(void *(*)(NrnThread *))
Node ** _v_node
Definition: multicore.h:77
Memb_list * ml
Definition: multicore.h:35
Memb_list * _ecell_memb_list
Definition: multicore.h:80
hoc_List * roots
Definition: multicore.h:90
double * _nrn_sav_rhs
Definition: multicore.h:46
NrnThread * nrn_threads
Definition: multicore.cpp:45
struct _nrn_Fast_Imem _nrn_Fast_Imem
char * _sp13mat
Definition: multicore.h:79
double * _actual_a
Definition: multicore.h:72
int end
Definition: multicore.h:65
double _t
Definition: multicore.h:59
BAMech * bam
Definition: multicore.h:41
Definition: hocdec.h:226
void * _vcv
Definition: multicore.h:83
int nrn_nthread
Definition: multicore.cpp:44
double cj
Definition: multicore.h:61
double * _actual_area
Definition: multicore.h:75
double _ctime
Definition: multicore.h:86
NrnThreadMembList * tml
Definition: multicore.h:62
void nrn_wait_for_threads()
Definition: multicore.cpp:1132
Definition: section.h:132
double * _actual_b
Definition: multicore.h:73
double * _actual_v
Definition: multicore.h:74
struct NrnThreadBAList * next
Definition: multicore.h:42