MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Typedefs | Enumerations | Functions
hci.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HCIManager
 
struct  HCIAction
 

Typedefs

typedef struct HCIManager HCIManager
 
typedef struct HCIAction HCIAction
 

Enumerations

enum  HCIActionType {
  HCI_NO_ACTION = 0 , HCI_STOP = 1 , HCI_TIMEOUT = 2 , HCI_AUTO_CHECKPOINT = 3 ,
  HCI_CHECKPOINT = 4 , HCI_TERMINATE = 5 , HCI_IOCTL = 6
}
 

Functions

void hci_init (HCIManager *manager, char *prefix, double TimeLimitCPU, double AutoCheckPointTime, int FOFEnabled)
 
void hci_action_init (HCIAction *action)
 
int hci_query (HCIManager *manager, HCIAction *action)
 
void hci_override_now (HCIManager *manager, double now)
 

Typedef Documentation

◆ HCIAction

typedef struct HCIAction HCIAction

◆ HCIManager

typedef struct HCIManager HCIManager

Enumeration Type Documentation

◆ HCIActionType

Enumerator
HCI_NO_ACTION 
HCI_STOP 
HCI_TIMEOUT 
HCI_AUTO_CHECKPOINT 
HCI_CHECKPOINT 
HCI_TERMINATE 
HCI_IOCTL 

Definition at line 20 of file hci.h.

20  {
21  HCI_NO_ACTION = 0,
22  HCI_STOP = 1,
23  HCI_TIMEOUT = 2,
25  HCI_CHECKPOINT = 4,
26  HCI_TERMINATE = 5,
27  HCI_IOCTL = 6,
28 };
@ HCI_TERMINATE
Definition: hci.h:26
@ HCI_AUTO_CHECKPOINT
Definition: hci.h:24
@ HCI_IOCTL
Definition: hci.h:27
@ HCI_CHECKPOINT
Definition: hci.h:25
@ HCI_TIMEOUT
Definition: hci.h:23
@ HCI_NO_ACTION
Definition: hci.h:21
@ HCI_STOP
Definition: hci.h:22

Function Documentation

◆ hci_action_init()

void hci_action_init ( HCIAction action)

Definition at line 38 of file hci.c.

39 {
40  action->type = HCI_NO_ACTION;
41  action->write_snapshot = 0;
42  action->write_fof = 0;
43 }
enum HCIActionType type
Definition: hci.h:32
int write_snapshot
Definition: hci.h:33
int write_fof
Definition: hci.h:34

References HCI_NO_ACTION, HCIAction::type, HCIAction::write_fof, and HCIAction::write_snapshot.

Referenced by hci_query(), and run().

Here is the caller graph for this function:

◆ hci_init()

void hci_init ( HCIManager manager,
char *  prefix,
double  TimeLimitCPU,
double  AutoCheckPointTime,
int  FOFEnabled 
)

Definition at line 25 of file hci.c.

26 {
30 
31  manager->WallClockTimeLimit = WallClockTimeLimit;
32  manager->AutoCheckPointTime = AutoCheckPointTime;
33  manager->FOFEnabled = FOFEnabled;
35 }
static double hci_now(HCIManager *manager)
Definition: hci.c:11
double timer_query_begin
Definition: hci.h:12
char * prefix
Definition: hci.h:6
double timer_begin
Definition: hci.h:13
double AutoCheckPointTime
Definition: hci.h:9
double WallClockTimeLimit
Definition: hci.h:11
double LongestTimeBetweenQueries
Definition: hci.h:10
int FOFEnabled
Definition: hci.h:7
char prefix[1024]
Definition: test_hci.c:13
HCIManager manager[1]
Definition: test_hci.c:37

References HCIManager::AutoCheckPointTime, HCIManager::FOFEnabled, hci_now(), HCIManager::LongestTimeBetweenQueries, manager, HCIManager::prefix, prefix, HCIManager::timer_begin, HCIManager::timer_query_begin, and HCIManager::WallClockTimeLimit.

Referenced by run(), test_hci_auto_checkpoint(), test_hci_auto_checkpoint2(), test_hci_checkpoint(), test_hci_no_action(), test_hci_stop(), test_hci_terminate(), and test_hci_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hci_override_now()

void hci_override_now ( HCIManager manager,
double  now 
)

Definition at line 48 of file hci.c.

49 {
50  manager->_now = now;
51  manager->OVERRIDE_NOW = 1;
52 }
double _now
Definition: hci.h:17
int OVERRIDE_NOW
Definition: hci.h:16

References HCIManager::_now, manager, and HCIManager::OVERRIDE_NOW.

Referenced by test_hci_auto_checkpoint(), test_hci_auto_checkpoint2(), test_hci_checkpoint(), test_hci_no_action(), test_hci_stop(), test_hci_terminate(), and test_hci_timeout().

Here is the caller graph for this function:

◆ hci_query()

int hci_query ( HCIManager manager,
HCIAction action 
)

Definition at line 152 of file hci.c.

153 {
154  hci_action_init(action);
155 
156  /* measure time since last query */
158 
159  /* Check whether we need to interrupt the run */
160 
161  char * request;
162 
163  /* Will we run out of time by the query ? highest priority.
164  */
165  if(hci_query_timeout(manager, &request)) {
166  message(0, "HCI: Stopping due to TimeLimitCPU, dumping a CheckPoint.\n");
167  action->type = HCI_TIMEOUT;
168  action->write_snapshot = 1;
169  if(manager->FOFEnabled)
170  action->write_fof = 1;
171  return 1;
172  }
173 
174  if(hci_query_filesystem(manager, "reconfigure", &request))
175  {
176  /* FIXME: This is not implemented
177  * it shall reread the configuration file and update the parameters of
178  * the module listed in the request.
179  * see the comment about update_IO_params
180  * */
181  message(0, "HCI: updating io parameters, this is not supported yet.\n");
182  myfree(request);
183  return 0;
184  }
185 
186  if(hci_query_filesystem(manager, "checkpoint", &request))
187  {
188  message(0, "HCI: human controlled stop with checkpoint at next PM.\n");
189  action->type = HCI_CHECKPOINT;
190  /* will write checkpoint in this PM timestep */
191  action->write_snapshot = 1;
192  /* Write fof as well*/
193  if(manager->FOFEnabled)
194  action->write_fof = 1;
195  myfree(request);
197  return 0;
198  }
199 
200  /* Is the stop-file present? If yes, interrupt the run with a snapshot. */
201  if(hci_query_filesystem(manager, "stop", &request))
202  {
203  /* will write checkpoint in this PM timestep, then stop */
204  action->type = HCI_STOP;
205  action->write_snapshot = 1;
206  myfree(request);
207  return 1;
208  }
209 
210  /* Is the terminate-file present? If yes, interrupt the run immediately. */
211  if(hci_query_filesystem(manager, "terminate", &request))
212  {
213  message(0, "HCI: human triggered termination.\n");
214  /* the caller shall take care of immediate termination.
215  * This action is better than KILL as it avoids corrupt/incomplete snapshot files.*/
216  action->type = HCI_TERMINATE;
217  action->write_snapshot = 0;
218  myfree(request);
219  return 1;
220  }
221 
222  /* lower priority */
223  if(hci_query_auto_checkpoint(manager, &request))
224  {
225  message(0, "HCI: Auto checkpoint due to AutoCheckPointTime.\n");
226  action->type = HCI_AUTO_CHECKPOINT;
227  /* Write when the PM timestep completes*/
228  action->write_snapshot = 1;
229  if(manager->FOFEnabled)
230  action->write_fof = 1;
232  return 0;
233  }
234 
235  message(0, "HCI: Nothing happened. \n");
236  return 0;
237 }
void message(int where, const char *fmt,...)
Definition: endrun.c:175
static void hci_update_query_timer(HCIManager *manager)
Definition: hci.c:62
static double hci_get_elapsed_time(HCIManager *manager)
Definition: hci.c:55
static int hci_query_timeout(HCIManager *manager, char **request)
Definition: hci.c:112
int hci_query_filesystem(HCIManager *manager, const char *filename, char **request)
Definition: hci.c:77
static int hci_query_auto_checkpoint(HCIManager *manager, char **request)
Definition: hci.c:134
void hci_action_init(HCIAction *action)
Definition: hci.c:38
#define myfree(x)
Definition: mymalloc.h:19
double TimeLastCheckPoint
Definition: hci.h:8

References HCIManager::FOFEnabled, hci_action_init(), HCI_AUTO_CHECKPOINT, HCI_CHECKPOINT, hci_get_elapsed_time(), hci_query_auto_checkpoint(), hci_query_filesystem(), hci_query_timeout(), HCI_STOP, HCI_TERMINATE, HCI_TIMEOUT, hci_update_query_timer(), manager, message(), myfree, HCIManager::TimeLastCheckPoint, HCIAction::type, HCIAction::write_fof, and HCIAction::write_snapshot.

Referenced by run(), test_hci_auto_checkpoint(), test_hci_auto_checkpoint2(), test_hci_checkpoint(), test_hci_no_action(), test_hci_stop(), test_hci_terminate(), and test_hci_timeout().

Here is the call graph for this function:
Here is the caller graph for this function: