|
openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
|
Represents the ionic model and plug-in (IMP) data structure. More...
#include <ION_IF.h>
Public Member Functions | |
| IonIfBase (const IonType &type, Target target, node_count_t num_node, const std::vector< std::reference_wrapper< IonType >> &plugins) | |
| Constructor for IonIfBase. More... | |
| virtual | ~IonIfBase () |
| Virtual destructor declaration. More... | |
| const IonType & | get_type () const |
| Gets this IMP's model type. More... | |
| node_count_t | get_num_node () const |
| Gets the number of nodes handled by this IMP. More... | |
| std::size_t | get_num_threads () const |
| Gets the number of threads used for running this IMP. More... | |
| IonIfBase * | parent () const |
| Gets the parent IMP. More... | |
| void | set_parent (IonIfBase *parent) |
| std::vector< IonIfBase * > & | plugins () |
| Returns a vector containing the plugins of this IMP. More... | |
| uint32_t | get_reqdat () const |
| Gets the data flags for this IMP's required data. More... | |
| uint32_t | get_moddat () const |
| Gets the data flags for this IMP's modified data. More... | |
| void | set_moddat (uint32_t data) |
| Set the data flag for this IMP's modified data. More... | |
| cell_geom & | cgeom () |
| Gets the cell geometry data. More... | |
| float | get_dt () const |
| Gets the basic integration time step. More... | |
| void | set_dt (float dt) |
| Sets the basic integration time step. More... | |
| ts & | get_tstp () |
| Gets the time stepper. More... | |
| virtual void * | get_sv_address ()=0 |
| Gets the raw address of the state variables for this IMP. More... | |
| virtual std::size_t | get_sv_size () const =0 |
| Gets the size of the structure this IMP uses for state variables. More... | |
| std::vector< LUT > & | tables () |
| Gets the array of state variables. More... | |
| LUT * | tables_d () const |
| Gets an array of LUTs. More... | |
| size_t | get_n_tables_d () const |
| Gets the size of the array returned by IonIf::tables_d. More... | |
| Target | get_target () const |
| virtual void | set_target (Target target) |
| void | initialize_params () |
| Initializes user modifiable parameters with default values defined in the respective ionic models. More... | |
| virtual void | initialize (double dt, GlobalData_t **impdat) |
| Initializes lookup table and state variable tables. More... | |
| void | compute (node_index_t start, node_index_t end, GlobalData_t **data) |
| Perform ionic model computation for 1 time step. More... | |
| char * | fill_buf (char *buf, int *n, opencarp::Salt_list *l) const |
| Appends the state variables to a buffer. More... | |
| 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. More... | |
| 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. More... | |
| void | get_sv_layout (std::vector< std::pair< int, int >> &fields) const |
| Describes the per-node memory layout of this IMP's state variables. More... | |
| template<class Fn > | |
| 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. More... | |
| size_t | get_sv_per_node_size () const |
| Size in bytes of one node's de-interleaved state-variable record. More... | |
| uint64_t | sv_fingerprint () const |
| Fingerprint of this IMP's state-variable layout. More... | |
| int | dump_luts (bool zipped) |
| Dumps array of LUTs to file. More... | |
| void | destroy_luts () |
| Destroys array of LUTs. More... | |
| void | tune (const char *im_par, const char *plugs, const char *plug_par) |
| Tunes specific IMP parameters from files. More... | |
| int | read_svs (FILE *file) |
| Reads state variable values for one cell from a file. More... | |
| int | write_svs (FILE *file, node_index_t node) |
| virtual void | copy_SVs_from (IonIfBase &other, bool alloc)=0 |
| Copies the state variables of an IMP. More... | |
| void | copy_plugins_from (IonIfBase &other) |
| Copies the plugins of an IMP. More... | |
| void | for_each (const std::function< void(IonIfBase &)> &consumer) |
Executes the consumer functions on this IMP and each of its plugins. More... | |
Public Attributes | |
| int | miifIdx |
| imp index within miif More... | |
| Target | _target |
| execution target for this IMP More... | |
Protected Attributes | |
| ts | _tstp |
| control time stepping More... | |
Represents the ionic model and plug-in (IMP) data structure.
| limpet::IonIfBase::IonIfBase | ( | const IonType & | type, |
| Target | target, | ||
| node_count_t | num_node, | ||
| const std::vector< std::reference_wrapper< IonType >> & | plugins | ||
| ) |
|
virtual |
|
inline |
| void limpet::IonIfBase::compute | ( | node_index_t | start, |
| node_index_t | end, | ||
| GlobalData_t ** | data | ||
| ) |
Perform ionic model computation for 1 time step.
Calls the compute functon if this IonIf's type with this IonIf's target.
Definition at line 271 of file ION_IF.cc.
| void limpet::IonIfBase::copy_plugins_from | ( | IonIfBase & | other | ) |
Copies the plugins of an IMP.
A new IonIf object is allocated for each plugin and the state variables are copies with a call to IonIf::copy_SVs_from.
| other | IMP to copy the plugins from |
|
pure virtual |
Copies the state variables of an IMP.
| other | where the values are copied from |
| alloc | true to allocate memory and copy IIF |
Implemented in limpet::IonIf< T >.
| void limpet::IonIfBase::destroy_luts | ( | ) |
| int limpet::IonIfBase::dump_luts | ( | bool | zipped | ) |
| char * limpet::IonIfBase::fill_buf | ( | char * | buf, |
| int * | n, | ||
| opencarp::Salt_list * | l | ||
| ) | const |
| void limpet::IonIfBase::for_each | ( | const std::function< void(IonIfBase &)> & | consumer | ) |
|
inline |
Visits each state-variable field of one node, in storage order.
Resolves the data-layout-optimized address of local node node (block node/vec_size, lane nodevec_size, using THIS model's own dlo_vector_size() so a plugin is addressed with its own vector width) and invokes fn(field_ptr, field_size) for every field in fields. Shared by the checkpoint dump (gather) and restore (scatter) so the two cannot drift out of lockstep.
| node | local node index |
| fields | offset/size pairs from get_sv_layout |
| fn | callback invoked as fn(char* field_ptr, size_t field_size) |
Definition at line 469 of file ION_IF.h.
| float limpet::IonIfBase::get_dt | ( | ) | const |
| uint32_t limpet::IonIfBase::get_moddat | ( | ) | const |
| size_t limpet::IonIfBase::get_n_tables_d | ( | ) | const |
Gets the size of the array returned by IonIf::tables_d.
| node_count_t limpet::IonIfBase::get_num_node | ( | ) | const |
| std::size_t limpet::IonIfBase::get_num_threads | ( | ) | const |
| uint32_t limpet::IonIfBase::get_reqdat | ( | ) | const |
|
pure virtual |
Gets the raw address of the state variables for this IMP.
TODO: This is needed for now as many functions (write and read functions) and plugins (using the get_sv_offset function) still use the raw address of the SV table. This can be changed by rewriting the code that calls this function and by writing better tools that get_sv_offset for parent models.
Implemented in limpet::IonIf< T >.
| void limpet::IonIfBase::get_sv_layout | ( | std::vector< std::pair< int, int >> & | fields | ) | const |
Describes the per-node memory layout of this IMP's state variables.
Fills fields with one (byte offset, element size) pair per state variable, as reported by IonType::get_sv_offset. Under data-layout optimization the offset is the start of the variable's lane array within a block and the size is the size of a single lane (e.g. 4 for a float, regardless of vector width). Iterating these pairs and reading lane k of each field gathers one node's complete state.
| [out] | fields | offset/size pairs, one per state variable |
Definition at line 342 of file ION_IF.cc.
| size_t limpet::IonIfBase::get_sv_per_node_size | ( | ) | const |
Size in bytes of one node's de-interleaved state-variable record.
Sum of the per-lane field sizes from get_sv_layout (the model's own state only, excluding plugins). Equals get_sv_size() / dlo_vector_size() when the block holds no padding. This is the per-node record size used by the format >= 3 dump.
Definition at line 350 of file ION_IF.cc.
|
pure virtual |
Gets the size of the structure this IMP uses for state variables.
TODO: This is also needed for calling code to be able to use IonIfBase::get_sv_address as it returns a void pointer.
Implemented in limpet::IonIf< T >.
|
inline |
| ts & limpet::IonIfBase::get_tstp | ( | ) |
| const IonType & limpet::IonIfBase::get_type | ( | ) | const |
|
virtual |
Initializes lookup table and state variable tables.
| dt | time step |
| impdat | data |
passing dt is no longer required
Reimplemented in limpet::IonIf< T >.
Definition at line 238 of file ION_IF.cc.
| void limpet::IonIfBase::initialize_params | ( | ) |
| IonIfBase * limpet::IonIfBase::parent | ( | ) | const |
| std::vector< IonIfBase * > & limpet::IonIfBase::plugins | ( | ) |
| int limpet::IonIfBase::read_svs | ( | FILE * | file | ) |
| node_count_t limpet::IonIfBase::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.
The data is verified to make sure it belongs to the expected type of IMP.
| in | output file |
| n | number of nodes |
| pos | partitioned node numbers |
| mask | global region mask ordered canonically |
| offset | file offset to SV info canonically ordered |
| impinfo | IMP information |
| node_count_t limpet::IonIfBase::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.
Unlike IonIfBase::restore, which reads whole data-layout-optimized SoA blocks keyed by the block leader, this reads one contiguous, de-interleaved record per node keyed by the node's own canonical id and scatters each state-variable field back into its lane. This makes restore independent of the partitioning used to write the checkpoint. Generic in dlo_vector_size() (= 1 when DLO is disabled).
| in | input file |
| n | number of local nodes |
| pos | partitioned node numbers |
| mask | global region mask ordered canonically |
| offset | per-node file offsets, canonically ordered |
| impinfo | IMP information |
| loc2canon | local-to-canonical node map |
| void limpet::IonIfBase::set_dt | ( | float | dt | ) |
| void limpet::IonIfBase::set_moddat | ( | uint32_t | data | ) |
|
virtual |
Reimplemented in limpet::IonIf< T >.
Definition at line 221 of file ION_IF.cc.
| uint64_t limpet::IonIfBase::sv_fingerprint | ( | ) | const |
Fingerprint of this IMP's state-variable layout.
A hash of the ordered (field name, per-lane size, type) tuples from get_sv_layout. It does not depend on the vector width or on byte offsets, so it is identical for DLO and non-DLO builds of the same model but changes if a state variable is renamed, retyped, or reordered. Stored in the format >= 3 dump header and checked on restore so a checkpoint written against a different model revision is skipped instead of silently misread field-for-field.
Definition at line 357 of file ION_IF.cc.
| std::vector< LUT > & limpet::IonIfBase::tables | ( | ) |
|
inline |
Gets an array of LUTs.
| void limpet::IonIfBase::tune | ( | const char * | im_par, |
| const char * | plugs, | ||
| const char * | plug_par | ||
| ) |
Tunes specific IMP parameters from files.
For each IMP, a comma separated list of expressions is specified. Each expression is of the form
parameter[+|-|=|/|*][-]###[.[###][e|E[-|+]###][%]
which specifies a float optionally preceded by * or + or - or / or = and optionally followed by a % (float is expressed as a percent of the default value). The meanings of the flags are
Plugins and their respective parameters must be specified in the same order
| im_par | comma separated list of IM specific parameters |
| plugs | plugins specified in colon separated list |
| plug_par | colon separated list of comma separated lists specifiying parameters for each plugin |
| int limpet::IonIfBase::write_svs | ( | FILE * | file, |
| node_index_t | node | ||
| ) |
| Target limpet::IonIfBase::_target |
|
protected |