openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
ION_IF.h
Go to the documentation of this file.
1 
18 #ifndef IONIC_IF_H
19 #define IONIC_IF_H
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stddef.h>
25 #include <stdexcept>
26 #include "LUT.h"
27 #include "ODEint.h"
28 #include <math.h>
29 #include <assert.h>
30 #include <memory>
31 #include <functional>
32 #include <vector>
33 #include <utility>
34 #ifdef _OPENMP
35 #include <omp.h>
36 #endif
37 #ifdef HAS_CUDA_MODEL
38 #include <cuda_runtime.h>
39 #endif
40 #ifdef HAS_ROCM_MODEL
41 #include <hip/hip_runtime.h>
42 #endif
43 
44 #include "basics.h"
45 #include "target.h"
46 
47 #ifdef I
48 #undef I
49 #endif
50 
51 namespace limpet {
52 
53 #ifndef M_PI //C99 does not define M_PI
54 #define M_PI 3.14159265358979323846264338327
55 #endif
56 
57 //Defines used in Slava's LIMPET model '
58 #define heav(x) ( (x)<0 ? 0 : 1)
59 #define sign(x) ( (x)<0 ? -1 : 1 )
60 #define square(x) ((x)*(x))
61 #define cube(x) ((x)*(x)*(x))
62 
63 // MPI message tags used in the IMP world
64 #define MPI_RESTORE_IMP_POLL_BUFSIZE_TAG 10
65 #define MPI_RESTORE_IMP_SNDRCV_BUFFER_TAG 11
66 #define MPI_DUMP_IMP_POLL_BUFSIZE_TAG 20
67 #define MPI_DUMP_IMP_SNDRCV_BUFFER_TAG 21
68 #define MPI_DUMP_SVS_POLL_BUFSIZE_TAG 30
69 #define MPI_DUMP_SVS_SNDRCV_BUFFER_TAG 31
70 
77 struct tc_grp {
78  float dt;
79  int skp;
80  int rat;
81  int update;
82 };
83 
88 struct ts {
89  int cnt;
90  int ng;
92 };
93 
94 
97 struct SV_TAB {
98  int svSize;
99  int numSeg;
100  void *y;
103 };
104 
115 #define NDEF 0
116 struct cell_geom {
117  float SVratio=NDEF;
118  float v_cell=NDEF;
119  float a_cap=NDEF;
120  float fr_myo=NDEF;
121  float sl_i2c=NDEF;
122 };
123 
124 }
125 #include "ion_type.h"
126 namespace limpet {
127 
128 struct IMPinfo {
129  char *name;
130  int sz;
131  int nplug;
133  bool compatible;
134  int map;
135  int offset;
136  uint64_t fingerprint;
137 };
138 
142 class IonIfBase {
143 private:
144  // Information about the model type.
145  const IonType& _type;
146  node_count_t _num_node;
147  IonIfBase* _parent;
148  std::vector<IonIfBase*> _plugins;
149  uint32_t _reqdat;
151  uint32_t _moddat;
153 public:
154  int miifIdx;
156 protected:
158 private:
159  cell_geom _cgeom;
160  float dt;
161  std::vector<LUT> _tables;
162  LUT * _tables_d = nullptr;
163  size_t _n_tables_d = 0;
164  GlobalData_t **ldata = nullptr;
170  struct sv_field { std::string name; int off; int sz; int type; };
171  mutable std::vector<sv_field> _sv_layout;
172  mutable bool _sv_layout_valid = false;
173 
175  const std::vector<sv_field>& sv_layout() const;
176 
177 public:
186  IonIfBase(const IonType& type, Target target, node_count_t num_node, const std::vector<std::reference_wrapper<IonType>>& plugins);
187 
191  virtual ~IonIfBase();
192 
199  const IonType& get_type() const;
200 
206  node_count_t get_num_node() const;
207 
213  std::size_t get_num_threads() const;
214 
220  IonIfBase* parent() const;
221 
222  // VERY UNRECOMMENDED TO CALL, THIS IS ONLY USED FOR AN UGLY HACK.
223  void set_parent(IonIfBase* parent);
224 
230  std::vector<IonIfBase*>& plugins();
231 
237  uint32_t get_reqdat() const;
238 
244  uint32_t get_moddat() const;
245 
251  void set_moddat(uint32_t data);
252 
258 #if defined HAS_CUDA_MODEL || defined HAS_ROCM_MODEL
259  __device__ __host__
260 #endif
262  return this->_cgeom;
263  }
264 
270  float get_dt() const;
271 
277  void set_dt(float dt);
278 
279 
285  ts& get_tstp();
286 
296  virtual void *get_sv_address() = 0;
297 
304  virtual std::size_t get_sv_size() const = 0;
305 
312 //#if defined HAS_CUDA_MODEL || defined HAS_ROCM_MODEL
313 // __device__ __host__
314 //#endif
315 // SV_TAB& sv_tab() {
316 // return this->_sv_tab;
317 // }
318 
325  std::vector<LUT>& tables();
326 
334 #if defined HAS_CUDA_MODEL || defined HAS_ROCM_MODEL
335  __device__ __host__
336 #endif
337  LUT *tables_d() const {
338  return this->_tables_d;
339  }
340 
347  size_t get_n_tables_d() const;
348 
349 #if defined HAS_GPU_MODEL
350  __device__ __host__
351 #endif
352  Target get_target() const {
353  return this->_target;
354  };
355 
356  virtual void set_target(Target target);
357 
362  void initialize_params();
363 
375  virtual void initialize(double dt, GlobalData_t **impdat);
376 
384  void compute(node_index_t start, node_index_t end, GlobalData_t** data);
385 
397  char* fill_buf(char *buf, int* n, opencarp::Salt_list *l) const;
398 
415  size_t *offset, IMPinfo *impinfo, const global_node_index_t* loc2canon);
416 
438  IIF_Mask_t *mask, size_t *offset, IMPinfo *impinfo,
439  const global_node_index_t* loc2canon);
440 
452  void get_sv_layout(std::vector<std::pair<int, int>>& fields) const;
453 
468  template <class Fn>
469  void for_each_sv_field(node_index_t node, const std::vector<std::pair<int, int>>& fields, Fn&& fn) {
470  const std::size_t vec_size = this->get_type().dlo_vector_size();
471  char* block_base = static_cast<char*>(this->get_sv_address())
472  + (static_cast<std::size_t>(node) / vec_size) * this->get_sv_size();
473  const std::size_t lane = static_cast<std::size_t>(node) % vec_size;
474  for (const auto& f : fields)
475  fn(block_base + f.first + lane * static_cast<std::size_t>(f.second),
476  static_cast<std::size_t>(f.second));
477  }
478 
486  size_t get_sv_per_node_size() const;
487 
498  uint64_t sv_fingerprint() const;
499 
507  int dump_luts(bool zipped);
508 
512  void destroy_luts();
513 
540  void tune(const char *im_par, const char *plugs, const char *plug_par);
541 
549  int read_svs(FILE* file);
550 
551  int write_svs(FILE* file, node_index_t node);
552 
562  virtual void copy_SVs_from(IonIfBase& other, bool alloc) = 0;
563 
572  void copy_plugins_from(IonIfBase& other);
573 
580  void for_each(const std::function<void(IonIfBase&)>& consumer);
581 };
582 
593 template<typename T>
594 class IonIf : public IonIfBase {
602  struct has_rosenbrock_type {};
603  struct has_rosenbrock_vector_type {};
604  struct no_rosenbrock_type {};
605  public:
617  template<typename S>
618  class LimpetArray {
619  static constexpr bool is_void = std::is_void<S>::value;
622  S *_data;
623  std::size_t _size; //<! size of the SV array
624  bool _allocated = false;
625  Target _target;
626  public:
627 
631  LimpetArray() : _size(0), _target(Target::UNKNOWN) {
632  }
633 
640  LimpetArray(Target target, std::size_t size) : _size(size),
641  _target(target) {
642  this->allocate(target, size);
643  }
644 
649  // Check if memory was allocated, if it's the case, deallocate on the
650  // corresponding target
651  if (!is_void && _allocated) {
652  deallocate_on_target<S>(this->_target, this->_data);
653  }
654  }
655 
662  void allocate(Target target, std::size_t size) {
663  this->_size = size;
664  this->_target = target;
665  if (!is_void){
666  bool do_zero = false;
667  this->_data = allocate_on_target<S>(this->_target, this->_size, do_zero);
668  this->_allocated = true;
669  }
670  }
671 
678  template<typename Type = S>
679  typename std::enable_if<!std::is_void<Type>::value, std::size_t>::type get_element_size() const {
680  return sizeof(Type);
681  }
682 
683  template<typename Type = S>
684  typename std::enable_if<std::is_void<Type>::value, std::size_t>::type get_element_size() const {
685  return 0;
686  }
687 
693 #ifdef HAS_GPU_MODEL
694  __device__ __host__
695 #endif
696  S *data() const {
697  static_assert(!is_void, "The LimpetArray class can't be used with type 'void'");
698  return this->_data;
699  }
700 
706 #ifdef HAS_GPU_MODEL
707  __device__ __host__
708 #endif
709  std::size_t size() const {
710  static_assert(!is_void, "The LimpetArray class can't be used with type 'void'");
711  return this->_size;
712  }
713 
720  bool is_allocated() const {
721  return this->_allocated;
722  }
723 
731  if (this == &other) {
732  return *this;
733  }
734  this->_target = other._target;
735  this->_data = other._data;
736  this->_size = other._size;
737  if (other._allocated) {
738  this->_allocated = true;
739  other._allocated = false;
740  }
741  return *this;
742  }
743  };
744  private:
745  using SvTab = LimpetArray<typename T::state_type>;
746  using PrivateTab = LimpetArray<typename T::private_type>;
747  using PrivateVectorTab = LimpetArray<typename T::private_type_vector>;
748 
755  using rosenbrock_usage = typename std::conditional<std::is_void<typename T::private_type>::value, no_rosenbrock_type, typename std::conditional<std::is_void<typename T::private_type_vector>::value, has_rosenbrock_type, has_rosenbrock_vector_type>::type>::type;
756 
757  // These fields are C-style arrays because they need to be accessible from device code
758  SvTab _sv_tabs[Target::N_TARGETS];
759  typename T::params_type* _params[Target::N_TARGETS] = {nullptr};
760  PrivateTab _ion_private[Target::N_TARGETS];
761  PrivateVectorTab _ion_private_vector;
762  size_t private_sz;
763  public:
764 
772  IonIf(const IonType &type, Target target, node_count_t num_node, const
773  std::vector<std::reference_wrapper<IonType>>& plugins) : IonIfBase(type,
774  target, num_node, plugins) {
775  this->allocate_model_data();
776  }
777 
783  ~IonIf() {
784  for (int i = 0; i < Target::N_TARGETS; ++i) {
785  if (this->_params[i] != nullptr) {
786  deallocate_on_target((Target) i, this->_params[i]);
787  }
788  }
789  }
790 
796 #ifdef HAS_GPU_MODEL
797  __device__ __host__
798 #endif
799  typename T::params_type *params() const {
800  return this->_params[this->get_target()];
801  }
802 
808 #ifdef HAS_GPU_MODEL
809  __device__ __host__
810 #endif
812  return this->_sv_tabs[this->get_target()];
813  }
814 
821 #ifdef HAS_GPU_MODEL
822  __device__ __host__
823 #endif
825  return this->_ion_private[this->get_target()];
826  }
827 
829  if (this->get_target() != Target::MLIR_CPU) {
830  throw std::logic_error("the vectorized ion private structure can only be used with the MLIR_CPU (vectorized CPU) target");
831  }
832  return this->_ion_private_vector;
833  }
834 
840  void * get_sv_address() override {
841  return (void *) this->_sv_tabs[this->get_target()].data();
842  }
843 
849  std::size_t get_sv_size() const override {
850  return sizeof(typename T::state_type);
851  }
852 
861  void set_target(Target target) override {
862  Target old_target = this->get_target();
863  IonIfBase::set_target(target);
864  this->allocate_model_data();
865  memcpy(this->sv_tab().data(), this->_sv_tabs[old_target].data(), this->sv_tab().size());
866  // TODO: Copy ion private data for Rosenbrock, making transformations as necessary between
867  // vectorized and non-vectorized structures
868  // memcpy(this->ion_private().data(), this->_ion_private[old_target].data(), this->ion_private().size());
869  memcpy(this->params(), this->_params[old_target], sizeof(typename T::params_type));
870  }
871 
876  std::size_t vec_size = this->get_type().dlo_vector_size();
877  if (!this->_sv_tabs[this->get_target()].is_allocated())
878  this->_sv_tabs[this->get_target()] =
879  SvTab(this->get_target(), (this->get_num_node() + vec_size - 1) / vec_size);
880  if (!this->_ion_private[this->get_target()].is_allocated())
881  this->_ion_private[this->get_target()] = PrivateTab(this->get_target(), this->get_num_threads());
882  // The private vector structure is always made for the vectorized CPU target
883  if (!this->_ion_private_vector.is_allocated() && this->get_target() == Target::MLIR_CPU)
884  this->_ion_private_vector = PrivateVectorTab(this->get_target(), this->get_num_threads());
885  if (this->_params[this->get_target()] == nullptr)
886  this->_params[this->get_target()] = allocate_on_target<typename T::params_type>(this->get_target(), 1, true);
887  }
888 
898  void initialize(double dt, GlobalData_t **impdat) override {
899  IonIfBase::initialize(dt, impdat);
900  this->init_ion_private(rosenbrock_usage {});
901  }
902 
917  void copy_SVs_from(IonIfBase& other_base, bool alloc) override {
918  IonIf<T>& other = static_cast<IonIf<T>&>(other_base);
919  int tcg_size = other.get_tstp().ng * sizeof(tc_grp);
920 
921  if (this->get_num_node() != other.get_num_node()) {
922  throw std::logic_error("cannot copy SVs if both IMPs don't handle the same amount of cells");
923  }
924 
925  memcpy(this->sv_tab().data(), other.sv_tab().data(), sizeof(typename T::state_type) * other.sv_tab().size());
926  // Only copy memory when the model actually defines a private type
927  this->copy_ion_private(other, rosenbrock_usage {});
928  memcpy(this->get_tstp().tcg, other.get_tstp().tcg, tcg_size);
929  }
930 
939  void copy_ion_private(IonIf<T>& other, has_rosenbrock_vector_type) {
940  if (this->get_target() == Target::MLIR_CPU) {
941  memcpy(this->ion_private_vector().data(), other.ion_private_vector().data(), sizeof(typename T::private_type_vector) * other.ion_private_vector().size());
942  }
943  else {
944  memcpy(this->ion_private().data(), other.ion_private().data(), sizeof(typename T::private_type) * other.ion_private().size());
945  }
946  }
947 
956  void copy_ion_private(IonIf<T>& other, has_rosenbrock_type) {
957  memcpy(this->ion_private().data(), other.ion_private().data(), sizeof(typename T::private_type) * other.ion_private().size());
958  }
959 
965  void copy_ion_private(IonIf<T>& other, no_rosenbrock_type) { }
966 
972  void init_ion_private(has_rosenbrock_vector_type) {
973  // We need to fill the vector version of the private data for vectorized CPU
974  if (this->get_target() == Target::MLIR_CPU) {
975  for (std::size_t i = 0; i < this->ion_private_vector().size(); ++i) {
976  this->ion_private_vector().data()[i].node_number = 0;
977  this->ion_private_vector().data()[i].IF = this;
978  }
979  }
980  else {
981  for (std::size_t i = 0; i < this->ion_private().size(); ++i) {
982  this->ion_private().data()[i].node_number = 0;
983  this->ion_private().data()[i].IF = this;
984  }
985  }
986  }
987 
993  void init_ion_private(has_rosenbrock_type) {
994  for (std::size_t i = 0; i < this->ion_private().size(); ++i) {
995  this->ion_private().data()[i].node_number = 0;
996  this->ion_private().data()[i].IF = this;
997  }
998  }
999 
1006  void init_ion_private(no_rosenbrock_type) { }
1007 };
1008 
1009 /*
1010  function prototypes
1011  */
1012 
1013 void initialize_ts(ts *tstp, int ng, int *skp, double dt);
1014 void update_ts(ts *tstp);
1015 void SV_alloc( SV_TAB *psv, int numSeg, int struct_size );
1016 void SV_free( SV_TAB *psv );
1017 void free_sv_table( void * );
1018 void print_IMPs(void);
1019 bool flag_set( const char *flags, const char *target );
1020 void print_models(bool );
1021 float modify_param( float a, char *expr );
1022 int process_param_mod( char *pstr, char *par, char *mod );
1023 char* get_typename(int type);
1024 bool verify_flags( const char *flags, const char* given );
1025 int load_ionic_module(const char*);
1026 char *get_next_list( char *lst, char delimiter );
1027 
1028 // Functions for getting SVs in sv_init.c
1030 
1031 #include "ION_IF_sv.h"
1032 
1033 #define CHANGE_PARAM( T, P, V, F ) do { \
1034  ((T##_Params *)P)->V = modify_param( ((T##_Params *)P)->V, F ); \
1035  log_msg( _nc_logf,0, 0, " %-20s modifier: %-15s value: %g",\
1036  #V,F,(float)((T##_Params *)P)->V);} while (0)
1037 
1038 } // namespace limpet
1039 
1040 #endif
#define NDEF
definition of cell geometry
Definition: ION_IF.h:115
Basic utility structs and functions, mostly IO related.
Represents the ionic model and plug-in (IMP) data structure.
Definition: ION_IF.h:142
virtual void initialize(double dt, GlobalData_t **impdat)
Initializes lookup table and state variable tables.
Definition: ION_IF.cc:238
void tune(const char *im_par, const char *plugs, const char *plug_par)
Tunes specific IMP parameters from files.
Definition: ION_IF.cc:448
Target _target
execution target for this IMP
Definition: ION_IF.h:155
void set_parent(IonIfBase *parent)
Definition: ION_IF.cc:181
node_count_t restore_per_node(opencarp::FILE_SPEC in, node_count_t n, const node_index_t *pos, IIF_Mask_t *mask, size_t *offset, IMPinfo *impinfo, const global_node_index_t *loc2canon)
Reads in the state variables for an IMP from a per-node (format >= 3) dump.
Definition: ION_IF.cc:373
virtual void set_target(Target target)
Definition: ION_IF.cc:221
const IonType & get_type() const
Gets this IMP's model type.
Definition: ION_IF.cc:145
virtual void copy_SVs_from(IonIfBase &other, bool alloc)=0
Copies the state variables of an IMP.
char * fill_buf(char *buf, int *n, opencarp::Salt_list *l) const
Appends the state variables to a buffer.
Definition: ION_IF.cc:275
float get_dt() const
Gets the basic integration time step.
Definition: ION_IF.cc:201
int read_svs(FILE *file)
Reads state variable values for one cell from a file.
Definition: ION_IF.cc:495
void for_each_sv_field(node_index_t node, const std::vector< std::pair< int, int >> &fields, Fn &&fn)
Visits each state-variable field of one node, in storage order.
Definition: ION_IF.h:469
std::vector< LUT > & tables()
Gets the array of state variables.
Definition: ION_IF.cc:213
ts _tstp
control time stepping
Definition: ION_IF.h:157
std::vector< IonIfBase * > & plugins()
Returns a vector containing the plugins of this IMP.
Definition: ION_IF.cc:185
int dump_luts(bool zipped)
Dumps array of LUTs to file.
Definition: ION_IF.cc:421
void get_sv_layout(std::vector< std::pair< int, int >> &fields) const
Describes the per-node memory layout of this IMP's state variables.
Definition: ION_IF.cc:342
void compute(node_index_t start, node_index_t end, GlobalData_t **data)
Perform ionic model computation for 1 time step.
Definition: ION_IF.cc:271
virtual ~IonIfBase()
Virtual destructor declaration.
Definition: ION_IF.cc:134
int write_svs(FILE *file, node_index_t node)
Definition: ION_IF.cc:502
size_t get_sv_per_node_size() const
Size in bytes of one node's de-interleaved state-variable record.
Definition: ION_IF.cc:350
uint64_t sv_fingerprint() const
Fingerprint of this IMP's state-variable layout.
Definition: ION_IF.cc:357
void set_moddat(uint32_t data)
Set the data flag for this IMP's modified data.
Definition: ION_IF.cc:197
void set_dt(float dt)
Sets the basic integration time step.
Definition: ION_IF.cc:205
ts & get_tstp()
Gets the time stepper.
Definition: ION_IF.cc:209
void for_each(const std::function< void(IonIfBase &)> &consumer)
Executes the consumer functions on this IMP and each of its plugins.
Definition: ION_IF.cc:517
size_t get_n_tables_d() const
Gets the size of the array returned by IonIf::tables_d.
Definition: ION_IF.cc:217
IonIfBase * parent() const
Gets the parent IMP.
Definition: ION_IF.cc:177
void destroy_luts()
Destroys array of LUTs.
Definition: ION_IF.cc:440
Target get_target() const
Definition: ION_IF.h:352
node_count_t restore(opencarp::FILE_SPEC in, node_count_t n, const node_index_t *pos, IIF_Mask_t *mask, size_t *offset, IMPinfo *impinfo, const global_node_index_t *loc2canon)
Reads in the state variables for an IMP.
Definition: ION_IF.cc:288
uint32_t get_moddat() const
Gets the data flags for this IMP's modified data.
Definition: ION_IF.cc:193
int miifIdx
imp index within miif
Definition: ION_IF.h:154
virtual std::size_t get_sv_size() const =0
Gets the size of the structure this IMP uses for state variables.
void copy_plugins_from(IonIfBase &other)
Copies the plugins of an IMP.
Definition: ION_IF.cc:506
virtual void * get_sv_address()=0
Gets the raw address of the state variables for this IMP.
void initialize_params()
Initializes user modifiable parameters with default values defined in the respective ionic models.
Definition: ION_IF.cc:230
IonIfBase(const IonType &type, Target target, node_count_t num_node, const std::vector< std::reference_wrapper< IonType >> &plugins)
Constructor for IonIfBase.
Definition: ION_IF.cc:117
uint32_t get_reqdat() const
Gets the data flags for this IMP's required data.
Definition: ION_IF.cc:189
node_count_t get_num_node() const
Gets the number of nodes handled by this IMP.
Definition: ION_IF.cc:149
std::size_t get_num_threads() const
Gets the number of threads used for running this IMP.
Definition: ION_IF.cc:153
LUT * tables_d() const
Gets an array of LUTs.
Definition: ION_IF.h:337
cell_geom & cgeom()
Gets the cell geometry data.
Definition: ION_IF.h:261
Utility class for handling arrays of data used by IMPs.
Definition: ION_IF.h:618
~LimpetArray()
Destroy a limpet array.
Definition: ION_IF.h:648
LimpetArray & operator=(LimpetArray &&other)
Move assignement operator.
Definition: ION_IF.h:730
LimpetArray()
Default constructor with no allocated data.
Definition: ION_IF.h:631
LimpetArray(Target target, std::size_t size)
Constructs a LimpetArray.
Definition: ION_IF.h:640
std::enable_if< std::is_void< Type >::value, std::size_t >::type get_element_size() const
Definition: ION_IF.h:684
bool is_allocated() const
Returns whether data has been allocated for this LimpetArray.
Definition: ION_IF.h:720
std::size_t size() const
Gets the sizee of the array.
Definition: ION_IF.h:709
std::enable_if<!std::is_void< Type >::value, std::size_t >::type get_element_size() const
Get the size of a single element (size of type S)
Definition: ION_IF.h:679
S * data() const
Gets a pointer to the underlying data.
Definition: ION_IF.h:696
void allocate(Target target, std::size_t size)
Allocate the array on the given target.
Definition: ION_IF.h:662
Child class of IonIfBase specialized for each ionic model type.
Definition: ION_IF.h:594
IonIf(const IonType &type, Target target, node_count_t num_node, const std::vector< std::reference_wrapper< IonType >> &plugins)
Constructs an IonIf object.
Definition: ION_IF.h:772
PrivateTab & ion_private()
Gets the ion private LimpetArray for the current target.
Definition: ION_IF.h:824
SvTab & sv_tab()
Gets the SV LimpetArray for the current target.
Definition: ION_IF.h:811
void copy_ion_private(IonIf< T > &other, has_rosenbrock_vector_type)
Copy the ion private array from other.
Definition: ION_IF.h:939
T::params_type * params() const
Gets a pointer to the parameter structure for the current target.
Definition: ION_IF.h:799
void copy_ion_private(IonIf< T > &other, no_rosenbrock_type)
This function does nothing (overload of copy_ion_private(IonIf<T>&, has_rosenbrock_type)).
Definition: ION_IF.h:965
PrivateVectorTab & ion_private_vector()
Definition: ION_IF.h:828
void initialize(double dt, GlobalData_t **impdat) override
Override of the initialization function to add the initialization of the private structures.
Definition: ION_IF.h:898
void init_ion_private(has_rosenbrock_vector_type)
Initialize private data.
Definition: ION_IF.h:972
~IonIf()
Destroy the IMP.
Definition: ION_IF.h:783
void * get_sv_address() override
Gets the raw address of the SV array for the current target.
Definition: ION_IF.h:840
void allocate_model_data()
Allocate memory for the IMP data for the current target.
Definition: ION_IF.h:875
void copy_ion_private(IonIf< T > &other, has_rosenbrock_type)
Copy the ion private array from other.
Definition: ION_IF.h:956
void init_ion_private(has_rosenbrock_type)
Initialize private data.
Definition: ION_IF.h:993
void init_ion_private(no_rosenbrock_type)
Doesn't do anything.
Definition: ION_IF.h:1006
void copy_SVs_from(IonIfBase &other_base, bool alloc) override
Copy state and private variables from another IMP.
Definition: ION_IF.h:917
std::size_t get_sv_size() const override
Gets the size of a SV structure.
Definition: ION_IF.h:849
void set_target(Target target) override
Set a new execution target for this IMP.
Definition: ION_IF.h:861
Abstract class representing an ionic model type.
Definition: ion_type.h:59
virtual size_t dlo_vector_size() const =0
Gets the vector size when using data layout optimization (DLO).
void(* SVputfcn)(IonIfBase &, node_index_t, int, GlobalData_t)
Definition: ion_type.h:49
char * get_typename(int type)
int process_param_mod(char *pstr, char *par, char *mod)
void SV_alloc(SV_TAB *psv, int numSeg, int struct_size)
SVputfcn getPutSV(SVgetfcn)
int load_ionic_module(const char *)
Target
enum that represents different targets to run ionic models on.
Definition: target.h:45
@ UNKNOWN
special value to handle unknown targets
Definition: target.h:47
@ N_TARGETS
a token to indicate the maximum number of targets
Definition: target.h:52
@ MLIR_CPU
vectorized CPU code generated with MLIR
Definition: target.h:49
bool flag_set(const char *flags, const char *target)
Definition: ION_IF.cc:657
SF_real GlobalData_t
Definition: limpet_types.h:27
void print_IMPs(void)
bool verify_flags(const char *flags, const char *given)
Definition: ION_IF.cc:635
GlobalData_t(* SVgetfcn)(IonIfBase &, node_index_t, int)
Definition: ion_type.h:48
void deallocate_on_target(Target target, T *ptr)
Utility function for deallocating memory on a target. See TargetAllocator.
Definition: target.h:318
void SV_free(SV_TAB *psv)
void print_models(bool)
void update_ts(ts *ptstp)
Definition: ION_IF.cc:566
opencarp::local_index_t node_count_t
Definition: limpet_types.h:29
char * get_next_list(char *lst, char delimiter)
Definition: ION_IF.cc:612
void free_sv_table(void *)
float modify_param(float a, char *expr)
char IIF_Mask_t
Definition: ion_type.h:50
opencarp::global_index_t global_node_index_t
Definition: limpet_types.h:30
opencarp::local_index_t node_index_t
Definition: limpet_types.h:28
void initialize_ts(Target target, ts *tstp, int ng, int *skp, double dt)
Definition: ION_IF.cc:537
V mod(const V &a, const V &b)
Definition: signals.h:50
int offset
offset into node data
Definition: ION_IF.h:135
int sz
storage required
Definition: ION_IF.h:130
char * name
IMP name.
Definition: ION_IF.h:129
int map
which plugin does this IMO match
Definition: ION_IF.h:134
IMPinfo * plug
plugins
Definition: ION_IF.h:132
bool compatible
does IM match stored IM
Definition: ION_IF.h:133
int nplug
number of plugins
Definition: ION_IF.h:131
uint64_t fingerprint
saved SV-layout fingerprint (format >= 3; 0 otherwise)
Definition: ION_IF.h:136
lookup table structure
Definition: LUT.h:46
array of stat variable structures
Definition: ION_IF.h:97
int svSize
size of structure holding SV's for a node
Definition: ION_IF.h:98
int numSeg
number of unknowns
Definition: ION_IF.h:99
void * y
Definition: ION_IF.h:100
float fr_myo
volume of myoplasm
Definition: ION_IF.h:120
float sl_i2c
convert sl-currents in uA/cm^2 to mM/L without valence
Definition: ION_IF.h:121
float SVratio
single cell surface-to-volume ratio (per um)
Definition: ION_IF.h:117
float v_cell
cell volume
Definition: ION_IF.h:118
float a_cap
capacitive cell surface
Definition: ION_IF.h:119
time constant groups
Definition: ION_IF.h:77
int update
Definition: ION_IF.h:81
float dt
Definition: ION_IF.h:78
time stepper
Definition: ION_IF.h:88
int cnt
Definition: ION_IF.h:89
int ng
Definition: ION_IF.h:90
tc_grp * tcg
Definition: ION_IF.h:91
saltatory list – memory is allocated in chunks
Definition: basics.h:59
File descriptor struct.
Definition: basics.h:135
Defines valid targets for an ionic model to run on and an allocator for allocating memory on a specif...