NEURON
mod2c_core_thread.hpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================
7 */
8 
9 #pragma once
10 
14 
15 namespace coreneuron {
16 
17 #define CNRN_FLAT_INDEX_IML_ROW(i) ((i) * (_cntml_padded) + (_iml))
18 
19 #define _threadargscomma_ _iml, _cntml_padded, _p, _ppvar, _thread, _nt, _ml, _v,
20 #define _threadargsprotocomma_ \
21  int _iml, int _cntml_padded, double *_p, Datum *_ppvar, ThreadDatum *_thread, NrnThread *_nt, \
22  Memb_list *_ml, double _v,
23 #define _threadargs_ _iml, _cntml_padded, _p, _ppvar, _thread, _nt, _ml, _v
24 #define _threadargsproto_ \
25  int _iml, int _cntml_padded, double *_p, Datum *_ppvar, ThreadDatum *_thread, NrnThread *_nt, \
26  Memb_list *_ml, double _v
27 
28 struct Elm {
29  unsigned row; /* Row location */
30  unsigned col; /* Column location */
31  double* value; /* The value SOA _cntml_padded of them*/
32  struct Elm* r_up; /* Link to element in same column */
33  struct Elm* r_down; /* in solution order */
34  struct Elm* c_left; /* Link to left element in same row */
35  struct Elm* c_right; /* in solution order (see getelm) */
36 };
37 
38 struct Item {
39  Elm* elm{};
40  unsigned norder{}; /* order of a row */
41  Item* next{};
42  Item* prev{};
43 };
44 
45 using List = Item; /* list of mixed items */
46 
47 struct SparseObj { /* all the state information */
48  Elm** rowst{}; /* link to first element in row (solution order)*/
49  Elm** diag{}; /* link to pivot element in row (solution order)*/
50  void* elmpool{}; /* no interthread cache line sharing for elements */
51  unsigned neqn{}; /* number of equations */
52  unsigned _cntml_padded{}; /* number of instances */
53  unsigned* varord{}; /* row and column order for pivots */
54  double* rhs{}; /* initially- right hand side finally - answer */
55  unsigned* ngetcall{}; /* per instance counter for number of calls to _getelm */
56  int phase{}; /* 0-solution phase; 1-count phase; 2-build list phase */
57  int numop{};
58  unsigned coef_list_size{};
59  double** coef_list{}; /* pointer to (first instance) value in _getelm order */
60  /* don't really need the rest */
61  int nroworder{}; /* just for freeing */
62  Item** roworder{}; /* roworder[i] is pointer to order item for row i.
63  Does not have to be in orderlist */
64  List* orderlist{}; /* list of rows sorted by norder
65  that haven't been used */
66  int do_flag{};
67 };
68 
69 extern void _nrn_destroy_sparseobj_thread(SparseObj* so);
70 
71 // derived from nrn/src/scopmath/euler.c
72 // updated for aos/soa layout index
73 template <typename F>
74 int euler_thread(int neqn, int* var, int* der, F fun, _threadargsproto_) {
75  double const dt{_nt->_dt};
76  /* calculate the derivatives */
77  fun(_threadargs_); // std::invoke in C++17
78  /* update dependent variables */
79  for (int i = 0; i < neqn; i++) {
81  }
82  return 0;
83 }
84 
85 template <typename F>
86 int derivimplicit_thread(int n, int* slist, int* dlist, F fun, _threadargsproto_) {
87  fun(_threadargs_); // std::invoke in C++17
88  return 0;
89 }
90 
91 void nrn_sparseobj_copyto_device(SparseObj* so);
92 void nrn_sparseobj_delete_from_device(SparseObj* so);
93 
94 } // namespace coreneuron
#define i
Definition: md1redef.h:19
double var(InputIterator begin, InputIterator end)
Definition: ivocvect.h:108
#define neqn
Definition: lineq.h:3
#define CNRN_FLAT_INDEX_IML_ROW(i)
#define _threadargsproto_
#define _threadargs_
struct Item Item
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
void nrn_sparseobj_copyto_device(SparseObj *so)
void _nrn_destroy_sparseobj_thread(SparseObj *so)
int derivimplicit_thread(int n, int *slist, int *dlist, F fun, _threadargsproto_)
void nrn_sparseobj_delete_from_device(SparseObj *so)
int euler_thread(int neqn, int *var, int *der, F fun, _threadargsproto_)
int const size_t const size_t n
Definition: nrngsl.h:10
struct Elm * c_right
Definition: lineq.h:17