SST/macro
event_map.h
Go to the documentation of this file.
1 /*
2  * This file is part of SST/macroscale:
3  * The macroscale architecture simulator from the SST suite.
4  * Copyright (c) 2009 Sandia Corporation.
5  * This software is distributed under the BSD License.
6  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7  * the U.S. Government retains certain rights in this software.
8  * For more information, see the LICENSE file in the top
9  * SST/macroscale directory.
10  */
11 
12 #ifndef SSTMAC_BACKENDS_NATIVE_EVENTMAP_H_INCLUDED
13 #define SSTMAC_BACKENDS_NATIVE_EVENTMAP_H_INCLUDED
14 
16 
21 #include <cassert>
22 #include <map>
23 
24 namespace sstmac {
25 namespace native {
26 
27 /**
28  * An event manager that relies on the eventcontainer template base class
29  * to manage events with a multimap template parameter.
30  */
31 class event_map :
32  public event_container
33 {
34 
35  public:
37 
38  ~event_map() throw ();
39 
40  void
41  clear(timestamp zero_time = timestamp(0));
42 
43  void
45 
46  bool
47  empty() const {
48  return queue_.empty();
49  }
50 
51  protected:
53 
56 
57  void
59 
60  protected:
61  struct event_compare {
63  bool neq = lhs->time() != rhs->time();
64  if (neq) return lhs->time() < rhs->time();
65 
66  neq = lhs->src_location() != rhs->src_location();
67  if (neq) return lhs->src_location() < rhs->src_location();
68 
69 #if SSTMAC_SANITY_CHECK
70  assert(lhs->seqnum() != rhs->seqnum());
71 #endif
72  return lhs->seqnum() < rhs->seqnum();
73  }
74  };
75  typedef std::set<event_queue_entry*, event_compare> queue_t;
76  queue_t queue_;
77 
78 };
79 
80 }
81 } // end of namespace sstmac
82 
83 #endif
84 
uint32_t seqnum() const
Definition: sst_event.h:113
void cancel_all_messages(event_loc_id mod)
std::set< event_queue_entry *, event_compare > queue_t
Definition: event_map.h:75
event_map(parallel_runtime *rt)
Definition: event_map.h:36
void clear(timestamp zero_time=timestamp(0))
Clear all events and set time back to a zero of your choice.
An event manager base class using standard containers.
timestamp time() const
Definition: sst_event.h:98
An event manager that relies on the eventcontainer template base class to manage events with a multim...
Definition: event_map.h:31
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
void add_event(event_queue_entry *ev)
Called by schedule. Child class must implement.
event_queue_entry * pop_next_event()
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
bool empty() const
Definition: event_map.h:47
bool operator()(event_queue_entry *lhs, event_queue_entry *rhs)
Definition: event_map.h:62
event_loc_id src_location() const
Definition: sst_event.h:123
Definition: sst_event.h:67