openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
bench_utils.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
19 #ifndef _BENCH_UTILS_H
20 #define _BENCH_UTILS_H
21 
22 #include "cmdline.h"
23 #include "restitute.h"
24 
25 namespace limpet {
26 
27 enum TimerIDs {
28  CON_TM_IDX, // IO timer for console output
29  SVD_TM_IDX, // IO timer for state variable output
30  STA_TM_IDX, // IO timer for state saves (checkpointing)
31  SSV_TM_IDX, // IO timer for single state vector saves
32  STM_TM_IDX, // timer for stimulus trigger
33  LIGHT_TM_IDX, // timer for illumination trigger
34  TRACE_TM_IDX, // timer for trace output
35  CLAMP_TM_IDX, // timer for trace output
37  RES_SAVE_TM_IDX, // timer for saving state vectors during restitution
38  N_TIMERS // number of IO Timers we are going to use
39 };
40 
41 #define TIME_OUT 1. // output period for data
42 #define NUMSEG 1 // number of nodes or nodes
43 
44 // STATE VARIABLE DUMPS
45 #define DT_SV_DUMP 1. // output interval for sv dumps
46 
47 // typedefs
48 struct IOCtrl {
49  char w2file;
50  char wbin;
51  char wsplt;
52  char w2stdout;
53  char first;
54 };
55 
56 struct GVEC_DUMP {
57  opencarp::FILE_SPEC hdls[NUM_IMP_DATA_TYPES+1];
58  char* fn[NUM_IMP_DATA_TYPES+1];
59  int dtype[NUM_IMP_DATA_TYPES+1];
60  int n_dumps;
61 };
62 
63 // record statistics on the duration of events
64 #define us_RESOLUTION 1
65 struct event_timing {
66  bool init;
67  double mn;
68  double mx;
69  double avg;
70  double tot;
71  int count;
72 };
73 
74 enum timingIDs {
80 };
81 
83 typedef enum {
94 } DataType;
95 
97 static const char * const data_type_names[] = {
98  "Gatetype",
99  "Real",
100  "float",
101  "char",
102  "int",
103  "double",
104  "short",
105  "GlobalData_t",
106  "long",
107  "bool"
108 };
109 
110 // Gatetype is defined in LIMPET only and typically defined as float
111 // if defined otherwise, the size has to be overruled within LIMPET
112 // in this case the const qualifier has to be removed.
113 #define GATETYPE_SIZE 4
114 #define GLOBALDATA_T_SIZE 8
115 static const int data_type_sizes[] = {
118  sizeof(limpet::Real),
119  sizeof(float),
120  sizeof(char),
121  sizeof(int),
122  sizeof(double),
123  sizeof(short),
125  sizeof(long),
126  sizeof(bool)
127 };
128 
129 
130 int write_dump_header(GVEC_DUMP *gvd, SV_DUMP *svd, const char *ExpID);
131 void open_globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, MULTI_IF *pMIIF, char *base_name, IOCtrl *io);
132 void globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, MULTI_IF *pMIIF, opencarp::timer_manager *tm, IOCtrl *io, int numNode);
133 void close_globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, IOCtrl *io);
134 void dump_all(MULTI_IF *, int, char *, char *, double, double, char *);
135 void update_timing(event_timing *t, double event_duration);
136 void initialize_timings(event_timing *t);
137 double getCellVal(opencarp::sf_vec* v, int ind);
138 void initial_SVs(MULTI_IF *miif, char *SVs, char *imp, char *plgins, int num);
139 void print_param_help(IonType* im, IonTypeList& plugs);
140 float determine_duration(struct gengetopt_args_info *p, TrgList *stim_lst);
141 void determine_stim_list(char *stl, TrgList *trg, bool DIAs);
142 
143 } // namespace limpet
144 
145 #endif
timing for setup phase
Definition: bench_utils.h:75
double Real
Definition: MULTI_ION_IF.h:151
void update_timing(event_timing *t, double event_duration)
Definition: bench_utils.cc:376
void open_globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, MULTI_IF *pMIIF, char *base_name, IOCtrl *io)
Definition: bench_utils.cc:176
void dump_all(MULTI_IF *MIIF, int reg, char *imp, char *plugs, double t, double ddt, char *fout)
Definition: bench_utils.cc:344
double getCellVal(sf_vec *v, int ind)
Definition: bench_utils.cc:392
std::vector< std::reference_wrapper< IonType > > IonTypeList
Definition: ion_type.h:289
void initialize_timings(event_timing *t)
Definition: bench_utils.cc:366
float determine_duration(struct gengetopt_args_info *p, TrgList *stim_lst)
determine time of last stimulus
Definition: bench_utils.cc:503
double avg
average duration of event
Definition: bench_utils.h:69
timing for initialization
Definition: bench_utils.h:76
void print_param_help(IonType *im, IonTypeList &plugs)
Definition: bench_utils.cc:468
timing for main loop (including IO and ODE solve)
Definition: bench_utils.h:77
char wbin
write to file in binary format
Definition: bench_utils.h:50
double mx
maximum duration of event
Definition: bench_utils.h:68
char first
first line of output
Definition: bench_utils.h:53
double tot
total duration of all events
Definition: bench_utils.h:70
DataType
data type IDs
Definition: bench_utils.h:83
int n_dumps
keep track of number of dumped time slices
Definition: bench_utils.h:60
void determine_stim_list(char *stl, TrgList *trg, bool DIAs)
Definition: bench_utils.cc:101
char wsplt
split -> each vector goes into separate file
Definition: bench_utils.h:51
char w2file
write to file
Definition: bench_utils.h:49
void globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, MULTI_IF *pMIIF, timer_manager *tmo, IOCtrl *io, int numNode)
Definition: bench_utils.cc:272
#define GLOBALDATA_T_SIZE
Definition: bench_utils.h:114
int count
number of events counted so far
Definition: bench_utils.h:71
number of benchmark timings we use
Definition: bench_utils.h:79
int write_dump_header(GVEC_DUMP *gvd, SV_DUMP *svd, const char *ExpID)
Definition: bench_utils.cc:135
bool init
initialization flag
Definition: bench_utils.h:66
File descriptor struct.
Definition: basics.h:133
timing for ODE solve
Definition: bench_utils.h:78
void close_globalvec_dump(FILE **fhdls, GVEC_DUMP *gvd, IOCtrl *io)
Definition: bench_utils.cc:315
double mn
minimum duration of event
Definition: bench_utils.h:67
void initial_SVs(MULTI_IF *miif, char *SVs, char *imp, char *plgins, int num)
Definition: bench_utils.cc:412
char w2stdout
turn on/off output to stdout
Definition: bench_utils.h:52
centralize time managment and output triggering
Definition: timer_utils.h:73
#define GATETYPE_SIZE
Definition: bench_utils.h:113