1 /* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "simgrid/forward.h"
10 #include "xbt/sysdep.h"
15 /* Iterator within a trace */
27 } // namespace resource
29 } // namespace simgrid
30 typedef simgrid::kernel::resource::TraceEvent* tmgr_trace_event_t;
31 extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set* future_evt_set;
34 * \brief Free a trace event structure
36 * This function frees a trace_event if it can be freed, ie, if it has the free_me flag set to 1.
37 * This flag indicates whether the structure is still used somewhere or not.
38 * When the structure is freed, the argument is set to nullptr
40 XBT_PUBLIC void tmgr_trace_event_unref(tmgr_trace_event_t* trace_event);
42 XBT_PUBLIC void tmgr_finalize();
44 XBT_PUBLIC tmgr_trace_t tmgr_trace_new_from_file(std::string filename);
45 XBT_PUBLIC tmgr_trace_t tmgr_trace_new_from_string(std::string id, std::string input, double periodicity);
48 /** @brief Modeling of the availability profile (due to an external load) or the churn
50 * There is 4 main concepts in this module:
51 * - #simgrid::trace_mgr::DatedValue: a pair <timestamp, value> (both are of type double)
52 * - #simgrid::trace_mgr::trace: a list of dated values
53 * - #simgrid::trace_mgr::trace_event: links a given trace to a given SimGrid resource.
54 * A Cpu for example has 2 kinds of events: state (ie, is it ON/OFF) and speed,
55 * while a link has 3 iterators: state, bandwidth and latency.
56 * - #simgrid::trace_mgr::future_evt_set: makes it easy to find the next occuring event of all traces
59 class XBT_PUBLIC DatedValue {
63 explicit DatedValue() = default;
64 explicit DatedValue(double d, double v) : date_(d), value_(v) {}
65 bool operator==(DatedValue e2);
66 bool operator!=(DatedValue e2) { return not(*this == e2); }
68 std::ostream& operator<<(std::ostream& out, const DatedValue& e);
70 /** @brief A trace_iterator links a trace to a resource */
71 class XBT_PUBLIC trace_event {
74 /** @brief A trace is a set of timed values, encoding the value that a variable takes at what time *
76 * It is useful to model dynamic platforms, where an external load that makes the resource availability change over time.
77 * To model that, you have to set several traces per resource: one for the on/off state and one for each numerical value (computational speed, bandwidth and latency).
79 class XBT_PUBLIC trace {
81 /** Creates an empty trace */
85 std::vector<DatedValue> event_list;
88 /** @brief Future Event Set (collection of iterators over the traces)
89 * That's useful to quickly know which is the next occurring event in a set of traces. */
90 class XBT_PUBLIC future_evt_set {
93 virtual ~future_evt_set();
94 double next_date() const;
95 tmgr_trace_event_t pop_leq(double date, double* value, simgrid::kernel::resource::Resource** resource);
96 tmgr_trace_event_t add_trace(tmgr_trace_t trace, simgrid::kernel::resource::Resource * resource);
99 typedef std::pair<double, tmgr_trace_event_t> Qelt;
100 std::priority_queue<Qelt, std::vector<Qelt>, std::greater<Qelt>> heap_;
103 }} // namespace simgrid::trace_mgr
105 #endif /* SURF_TMGR_H */