52 static bool serial_simulation_complete =
false;
53 static bool *serial_completed_simulation;
55 void SerialScheduleNewEvent(
unsigned int rcv,
simtime_t stamp,
56 unsigned int event_type,
void *event_content,
57 unsigned int event_size)
64 rootsim_error(
true,
"LP %d is trying to send events in the past. Current time: %f, scheduled time: %f\n",
68 set_gid(receiver, rcv);
69 size_t size =
sizeof(
msg_t) + event_size;
70 event = rsalloc(size);
71 bzero(event,
sizeof(
msg_t));
73 event->receiver = receiver;
74 event->timestamp = stamp;
76 event->type = event_type;
77 event->size = event_size;
78 memcpy(event->event_content, event_content, event_size);
81 calqueue_put(stamp, event);
84 void serial_init(
void)
88 rootsim_error(
true,
"You must specify the total number of Logical Processes\n");
94 serial_completed_simulation = rsalloc(
sizeof(
bool) *
n_prc_tot);
95 bzero(serial_completed_simulation,
sizeof(
bool) *
n_prc_tot);
107 void serial_simulation(
void)
109 timer serial_event_execution;
110 timer serial_gvt_timer;
112 bool new_termination_decision;
113 unsigned int completed = 0;
116 unsigned long long hash1, hash2;
120 timer_start(serial_gvt_timer);
124 while (!serial_simulation_complete) {
128 event = (
msg_t *) calqueue_get();
130 rootsim_error(
true,
"No events to process!\n");
133 current = find_lp_by_gid(event->receiver);
138 if (event->
size > 0) {
139 hash1 = XXH64(event->event_content, event->
size,
current);
143 timer_start(serial_event_execution);
146 }
else if (&topology_settings){
147 ProcessEventTopology();
150 event->type, event->event_content,
154 statistics_post_data_serial(STAT_EVENT, 1.0);
155 statistics_post_data_serial(STAT_EVENT_TIME, timer_value_seconds(serial_event_execution));
158 if (event->
size > 0) {
159 hash2 = XXH64(event->event_content, event->
size,
current);
162 if (hash1 != hash2) {
163 printf(
"hash1 = %llu, hash2= %llu\n", hash1, hash2);
164 rootsim_error(
true,
"Error, LP %d has modified the payload of event %d during its processing. Aborting...\n",
180 serial_completed_simulation[
event->receiver.to_int] =
true;
182 serial_simulation_complete =
true;
192 if(serial_completed_simulation[event->receiver.
to_int] != new_termination_decision) {
193 if(new_termination_decision) {
202 serial_completed_simulation[
event->receiver.to_int] = new_termination_decision;
205 serial_simulation_complete =
true;
212 serial_simulation_complete =
true;
217 timer_restart(serial_gvt_timer);
msg_t * bound
Pointer to the last correctly processed event.
#define likely(exp)
Optimize the branch as likely taken.
void statistics_start(void)
void ProcessEventABM(void)
int check_termination_mode
Check termination strategy: standard or incremental.
Core ROOT-Sim functionalities.
ROOT-Sim header for model development.
unsigned int to_int
The GID numerical value.
The ROOT-Sim scheduler main module header.
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
Consistent and Committed Global State.
struct _msg_t msg_t
Message Type definition.
double simtime_t
This defines the type with whom timestamps are represented.
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
__thread msg_t * current_evt
Memory Manager main header.
bool(* OnGVT)(unsigned int me, void *snapshot)
unsigned int size
Unique identifier of the message, used for rendez-vous events.
int simulation_time
Wall-clock-time based termination predicate.
Calendar Queue Implementation.
GID_t gid
Global ID of the LP.
void simulation_shutdown(int code)
#define INIT
This is the message code which is sent by the simulation kernel upon startup.
unsigned int n_prc_tot
Total number of logical processes running in the simulation.
int gvt_time_period
Wall-Clock time to wait before executiong GVT operations.
void * current_base_pointer
The current state base pointer (updated by SetState())
#define unlikely(exp)
Optimize the branch as likely not taken.