11 #include "pending_heap.h" 12 #include "processed_queue.h" 18 extern CProxy_LPChare
lps;
148 void set_current_event(
Event* e) {
193 virtual void pup(PUP::er &p);
290 if (e1->src_lp != e2->src_lp) {
291 return e1->src_lp < e2->src_lp;
293 return e1->event_id < e2->event_id;
297 void set_current_event(
Event* e) {
owner->set_current_event(e); }
298 Event* get_current_event()
const {
return owner->get_current_event(); }
299 Time get_current_time()
const {
return owner->get_current_time(); }
301 virtual void pup(PUP::er& p) {
313 template <
typename Derived,
typename M,
typename... Ms>
316 static bool registered;
317 static vector<DispatcherBase<Derived>*> dispatchers;
319 template <
typename M1>
320 static void register_msg_type() {
324 template <
typename M1,
typename M2,
typename... M3>
325 static void register_msg_type() {
326 register_msg_type<M1>();
327 register_msg_type<M2, M3...>();
334 register_msg_type<M, Ms...>();
344 dispatchers[e->type_id]->forward(static_cast<Derived*>(
this), e);
351 dispatchers[e->type_id]->reverse(static_cast<Derived*>(
this), e);
358 dispatchers[e->type_id]->commit(static_cast<Derived*>(
this), e);
362 template <
typename Derived,
typename M,
typename... Ms>
363 vector<DispatcherBase<Derived>*>
LP<Derived, M, Ms...>::dispatchers;
365 template <
typename Derived,
typename M,
typename... Ms>
366 bool LP<Derived, M, Ms...>::registered =
false;
void delete_pending(Event *event)
Cancel an event from the pending queue by simply removing it.
Definition: lp.C:481
void reconstruct_pending_event(Event *)
Correclty rebuild pending events when unpacking.
Definition: lp_pup.C:77
void recv_local_event(Event *e)
Regular method for common processing on locally allocated events.
Definition: lp.C:289
virtual void forward(Event *e)
Overridden by LP.
Definition: lp.h:277
void reverse(Event *e)
Called by the Scheduler to reverse execute e during a rollback.
Definition: lp.h:350
vector< LPBase * > lp_structs
A list of all LPs owned by this chare.
Definition: lp.h:95
void recv_remote_event(RemoteEvent *event)
Entry method for receiving a remote event from another chare.
Definition: lp.C:255
int rolled_back_events
Number of events rolled back since last LB.
Definition: lp.h:115
Base class defining basic scheduler functionality.
Definition: scheduler.h:36
virtual void initialize()
Called to initialize LP state and seed initial events.
Definition: lp.h:275
void load_balance()
Tell this chare that we are going to do load balancing.
Definition: lp.C:104
virtual void finalize()
Called to perform any final actions before simulation exit.
Definition: lp.h:283
Definition: pe_queue.h:15
A chare that encapsulates a set of LPStructs and their events.
Definition: lp.h:64
void stop_scheduler()
Stops the Charm++ scheduler and returns control to main.
Definition: lp.C:243
unsigned gid
The global id of this LP.
Definition: lp.h:270
Definition: pending_heap.h:34
int committed_events
Number of events committed since last LB.
Definition: lp.h:114
void forward(Event *e)
Called by the Scheduler to forward execute e.
Definition: lp.h:343
Scheduler * scheduler
A direct pointer to the scheduler managing this LP chare.
Definition: lp.h:102
Base class which defines the interface for defining model LPs.
Definition: lp.h:314
void cancel_event(Event *event)
Cancel an event that should have never been received.
Definition: lp.C:449
LPToken next_token
LPToken whose key is the timestamp of the next event this chare will execute.
Definition: lp.h:71
LPChare * lp
Direct pointer to the LP chare this token represents.
Definition: lp.h:32
LPChare()
Default constructor.
Definition: lp.C:62
A token representing a handle to an LP chare inside the scheduler queues.
Definition: lp.h:30
void init_lps()
Calls init on the array of LP chares (only if we are rank 0), and then starts the charm scheduler on ...
Definition: lp.C:48
uint64_t next_event_id
The next available ID for uniquely identifying events from this LP.
Definition: lp.h:76
Time current_time
Time of most recently executed event.
Definition: lp.h:72
Concrete base class for distributed schedulers.
Definition: scheduler.h:109
void UserSetLBLoad()
Called by the runtime system to get the load of this chare.
Definition: lp.C:161
void reconstruct_causality(Event *, Event **, Event **)
Correctly rebuild causality chains when unpacking.
Definition: lp_pup.C:111
Time ts
A timestamp associated with the LP to be used as a key.
Definition: lp.h:33
int execute_me()
Called during execution to execute the next event owned by this LP.
Definition: lp.C:343
void rollback_me(Time ts)
Do a primary rollback to a given virtual timestamp.
Definition: lp.C:374
virtual bool compare(const Event *e1, const Event *e2)
Called by the scheduler to break ties on events with the same timestamp.
Definition: lp.h:289
AvlTree all_events
A pointer to the PE level AVL tree for hashing remote events.
Definition: lp.h:134
virtual void pup(PUP::er &p)
Pack/unpack this LP chare.
Definition: lp_pup.C:17
LPToken()
Default constructor.
Definition: lp.h:38
RNG rng
The random number generator for this LP.
Definition: lp.h:272
Time min_cancel_q
Minimum time in this LPs cancel queue.
Definition: lp.h:126
Event * current_event
Most recently executed event.
Definition: lp.h:73
void add_to_cancel_q(Event *e)
Add an event to the queue of events to be cancelled later.
Definition: lp.C:469
uint32_t index
The index of this token within the queue/heap.
Definition: lp.h:34
Definition: optimistic.h:10
void ResumeFromSync()
Called by the runtime system to tell this chare we can resume.
Definition: lp.C:109
bool isOptimistic
Set to true if this LP is an optimistic LP.
Definition: lp.h:108
PendingHeap events
All future events received for any of our LPs.
Definition: lp.h:82
Implementation of a CLCG4 random number generator, based on the reversible implementation from ROSS (...
Definition: clcg4.h:14
void commit(Event *e)
Called by the Scheduler when e is committed.
Definition: lp.h:357
uint32_t g_num_msg_types
number of message types
Definition: globals.C:25
#define PE_VALUE(x)
Macro to simplify global variable access.
Definition: globals.h:111
Definition: processed_queue.h:8
LPToken(LPChare *lp)
Constructor called from the LP chare that sets lp at initialization.
Definition: lp.h:44
CProxy_LPChare lps
A readonly declaration for a global lp proxy.
Definition: lp.C:25
void fossil_me(Time gvt)
Called after GVT computation to commit old events.
Definition: lp.C:434
void init()
Called at the start of a simulation to run LP init handlers.
Definition: lp.C:222
virtual void reverse(Event *e)
Overridden by LP.
Definition: lp.h:279
ProcessedQueue processed_events
A flat queue of all events previously processed by our LPs that haven't yet been committed or rolled ...
Definition: lp.h:89
Declares most types used within the simulator and by models.
Event * cancel_q
Queue of events this LP needs to cancel.
Definition: lp.h:125
void recv_anti_event(RemoteEvent *event)
Entry method for receiving and processing an anti event.
Definition: lp.C:314
Non-templated base class for LP, so that the simulator can deal with a single LP base type...
Definition: lp.h:265
virtual void commit(Event *e)
Overridden by LP.
Definition: lp.h:281
LPChare * owner
The LPChare this LP object lives on.
Definition: lp.h:268
void reconstruct_processed_event(Event *, Event **, Event **)
Correctly rebuild processed events when unpacking.
Definition: lp_pup.C:94
int committed_time
Timestamp of most recent committed event.
Definition: lp.h:116
void process_cancel_q()
Process and cancel each event in the cancel queue.
Definition: lp.C:487