ROSS
ross-gvt-internal.h
Go to the documentation of this file.
1#ifndef INC_ross_gvt_h
2#define INC_ross_gvt_h
3
4#include "ross-types.h"
5#include "tw-opts.h"
6#include "stdbool.h"
7
8/*
9 * Initialize the GVT library and parse options.
10 */
11
12/* setup the GVT library (config cmd line args, etc) */
13extern const tw_optdef *tw_gvt_setup(void);
14
15/* start the GVT library (init vars, etc) */
16extern void tw_gvt_start(void);
17extern void tw_gvt_finish(void);
18
19/*
20 * GVT computation is broken into two stages:
21 * stage 1: determine if GVT computation should be started
22 * stage 2: compute GVT
23 */
24extern void tw_gvt_step1(tw_pe *);
25extern void tw_gvt_step1_realtime(tw_pe *);
26extern void tw_gvt_step2(tw_pe *);
27
28/*
29 * Provide a mechanism to force a GVT computation outside of the
30 * GVT interval (optional)
31 */
32extern void tw_gvt_force_update(void);
33extern void tw_gvt_force_update_realtime(void);
34
35/* Set the PE GVT value */
36extern int tw_gvt_set(tw_pe * pe, tw_stime LVT);
37
38/* Returns true if GVT in progress, false otherwise */
39static inline int tw_gvt_inprogress(tw_pe * pe);
40
41/* Statistics collection and printing function */
42extern void tw_gvt_stats(FILE * F);
43
44/* Function to be injected/executed at every GVT. The function receives the current PE and a boolean indicating if the simulation has no more events to process in the queue */
45extern void (*g_tw_gvt_hook) (tw_pe * pe, bool is_queue_empty);
46/* Trigger `g_tw_gvt_hook` at a specific time (it even works in Sequential
47 * mode). This function should only be called before tw_run or inside
48 * g_tw_gvt_hook. It's behaviour is undefined if called anywhere else,
49 * specially during event processing. */
51#ifdef USE_RAND_TIEBREAKER
53#endif
54/* Trigger GVT hook every N GVT comptutations. Like `tw_trigger_gvt_hook_at`,
55 * this function has to be called at before `tw_run` or inside the GVT hook
56 * function. Calling this function will disable `tw_trigger_gvt_hook_at`
57 */
58void tw_trigger_gvt_hook_every(int num_gvt_calls);
59/* Calling this function will enable the user to trigger the GVT hook
60 * `tw_trigger_gvt_hook_now` as an event is processed. Like
61 * `tw_trigger_gvt_hook_at`, this function has to be called at the start of the
62 * simulation or inside g_tw_gvt_hook
63 */
65/* It will pause the simulation and force a gvt hook call. Basically, this does
66 * something similar to doing `tw_trigger_gvt_hook_at(now)` on all PEs with
67 * `now * == tw_now(lp of the caller)`. Ofc, this function should be called only
68 * when processing an event, thus it is complementary to
69 * `tw_trigger_gvt_hook_at`. This function will only work if
70 * `tw_trigger_gvt_hook_when_model_calls` have been called before on all PEs
71 */
73// Reversing (removing) LP call to trigger GVT hook
75
77 GVT_HOOK_STATUS_disabled = 0, // The gvt hook will not be called
78 GVT_HOOK_STATUS_timestamp, // GVT called: At a specific time stamp (`tw_trigger_gvt_hook_at` has to be called every single time gvt hook is called)
79 GVT_HOOK_STATUS_every_n_gvt, // GVT called: Every N gvt operations (is set once, no need to call `tw_trigger_gvt_hook_every` again within gvt hook)
80 GVT_HOOK_STATUS_model_call, // GVT called: Whenever the user calls `tw_trigger_gvt_hook_now` (within the event being processed)
81};
82
83// Holds one timestamp at which to trigger the arbitrary function
84struct gvt_hook_trigger {
86 union {
87 // GVT_HOOK_TYPE_timestamp and GVT_HOOK_STATUS_model_call
88 struct {
89#ifdef USE_RAND_TIEBREAKER
91#else
93#endif
94 };
95 // GVT_HOOK_TYPE_every_n_gvt
96 struct {
97 int starting_at;
98 int nums;
100 };
101};
102
104
105#endif
tw_pe * pe
Definition avl_tree.c:10
double tw_stime
Definition ross-base.h:39
void tw_trigger_gvt_hook_at_event_sig(tw_event_sig time)
void tw_gvt_start(void)
GVT_HOOK_STATUS
@ GVT_HOOK_STATUS_disabled
@ GVT_HOOK_STATUS_timestamp
@ GVT_HOOK_STATUS_every_n_gvt
void tw_gvt_step2(tw_pe *)
struct gvt_hook_trigger g_tw_gvt_hook_trigger
void tw_gvt_force_update(void)
void tw_gvt_finish(void)
void tw_trigger_gvt_hook_at(tw_stime time)
static int tw_gvt_inprogress(tw_pe *pe)
void tw_gvt_force_update_realtime(void)
void tw_trigger_gvt_hook_every(int num_gvt_calls)
void tw_gvt_stats(FILE *F)
int tw_gvt_set(tw_pe *pe, tw_stime LVT)
void(* g_tw_gvt_hook)(tw_pe *pe, bool is_queue_empty)
void tw_gvt_step1(tw_pe *)
const tw_optdef * tw_gvt_setup(void)
void tw_gvt_step1_realtime(tw_pe *)
struct tw_event_sig tw_event_sig
GVT_HOOK_STATUS
@ GVT_HOOK_STATUS_model_call
void tw_trigger_gvt_hook_now_rev(tw_lp *)
void tw_trigger_gvt_hook_when_model_calls(void)
void tw_trigger_gvt_hook_now(tw_lp *)
Definition of ROSS basic types.
enum GVT_HOOK_STATUS status
struct gvt_hook_trigger::@377021027272141330026060276165107160176224344221::@372056273241073034047236247155006051243204004030 every_n_gvt
LP State Structure.
Definition ross-types.h:336
Holds the entire PE state.
Definition ross-types.h:416