ROSS
crv-state.h
Go to the documentation of this file.
1#ifndef INC_check_revent_state_check
2#define INC_check_revent_state_check
3
4#include "ross-types.h"
5#include <stdbool.h>
6#include <stdio.h>
7
8typedef void (*save_checkpoint_state_f) (void * into, void const * from);
9typedef void (*clean_checkpoint_state_f) (void * state);
10typedef bool (*check_states_f) (void * current_state, void const * before_state);
11typedef void (*print_lpstate_f) (FILE *, char const * prefix, void * state);
12typedef void (*print_checkpoint_state_f) (FILE *, char const * prefix, void * state);
13typedef void (*print_event_f) (FILE *, char const * prefix, void * lp_state, void * event_msg);
14
15/*
16 * Interface to implement in order to get tighter control over the
17 * SEQUENTIAL_ROLLBACK_CHECK synchronization option.
18 *
19 * SEQUENTIAL_ROLLBACK_CHECK allows to run check if all reversible
20 * computations have been properly implemented. By default, there is
21 * no need to use this interface in order to run SEQUENTIAL_ROLLBACK_CHECK.
22 *
23 * If save_lp is not implemented, then the LP struct will be save into the
24 * LP checkpoint.
25 *
26 * Often, it is best to start by implementing print_lp.
27 *
28 * Only the `lptype` is mandatory, everything else can be NULL or zero.
29 */
30typedef struct crv_checkpointer {
32 size_t sz_storage; // Size of the LP checkpoint to save (can be different from actual LP size)
33 save_checkpoint_state_f save_lp; // Copies LP state into LP checkpoint
34 clean_checkpoint_state_f clean_lp; // Cleans LP checkpoint (do not call free). Only to be used if there is something to clean as a result of saving checkpoint earlier
35 check_states_f check_lps; // Checks if the current LP state is the same as the checkpoint state
36 print_lpstate_f print_lp; // Prints the state of the LP in a human readable way
37 print_checkpoint_state_f print_checkpoint; // Prints the state of the LP checkpoint in a human readable way
38 print_event_f print_event; // Prints the contents of the message the LP processes
40
41
42// Adding LP checkpointer
44
45
46/*
47 * Internal struct, not to be modified by model developer.
48 */
54
55size_t crv_init_checkpoints(void);
59 tw_lp * clp,
60 tw_event * cev,
61 crv_lpstate_checkpoint_internal const * before_state,
62 char const * before_msg,
63 char const * after_msg
64);
65
66#endif
void crv_clean_lpstate(crv_lpstate_checkpoint_internal *state, tw_lp const *clp)
Definition crv-state.c:189
void crv_copy_lpstate(crv_lpstate_checkpoint_internal *into, tw_lp const *clp)
Definition crv-state.c:176
void(* clean_checkpoint_state_f)(void *state)
Definition crv-state.h:9
void(* print_checkpoint_state_f)(FILE *, char const *prefix, void *state)
Definition crv-state.h:12
void crv_check_lpstates(tw_lp *clp, tw_event *cev, crv_lpstate_checkpoint_internal const *before_state, char const *before_msg, char const *after_msg)
Definition crv-state.c:105
size_t crv_init_checkpoints(void)
Definition crv-state.c:47
bool(* check_states_f)(void *current_state, void const *before_state)
Definition crv-state.h:10
void crv_add_custom_state_checkpoint(crv_checkpointer *)
Definition crv-state.c:14
void(* print_lpstate_f)(FILE *, char const *prefix, void *state)
Definition crv-state.h:11
void(* save_checkpoint_state_f)(void *into, void const *from)
Definition crv-state.h:8
void(* print_event_f)(FILE *, char const *prefix, void *lp_state, void *event_msg)
Definition crv-state.h:13
void(* clean_checkpoint_state_f)(void *state)
Definition crv-state.h:9
void(* print_checkpoint_state_f)(FILE *, char const *prefix, void *state)
Definition crv-state.h:12
bool(* check_states_f)(void *current_state, void const *before_state)
Definition crv-state.h:10
void(* print_lpstate_f)(FILE *, char const *prefix, void *state)
Definition crv-state.h:11
void(* save_checkpoint_state_f)(void *into, void const *from)
Definition crv-state.h:8
void(* print_event_f)(FILE *, char const *prefix, void *lp_state, void *event_msg)
Definition crv-state.h:13
print_checkpoint_state_f print_checkpoint
Definition crv-state.h:37
print_event_f print_event
Definition crv-state.h:38
save_checkpoint_state_f save_lp
Definition crv-state.h:33
size_t sz_storage
Definition crv-state.h:32
print_lpstate_f print_lp
Definition crv-state.h:36
check_states_f check_lps
Definition crv-state.h:35
tw_lptype * lptype
Definition crv-state.h:31
clean_checkpoint_state_f clean_lp
Definition crv-state.h:34
Event Stucture.
Definition ross-types.h:277
LP State Structure.
Definition ross-types.h:336
Function Pointers for ROSS Event Handlers.
Definition ross-types.h:97