1 /* Copyright (c) 2004-2019. 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 */
19 /** @brief Links a profile to a resource */
24 resource::Resource* resource;
28 } // namespace resource
30 } // namespace simgrid
31 extern XBT_PRIVATE simgrid::kernel::profile::FutureEvtSet 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(simgrid::kernel::profile::Event** trace_event);
42 XBT_PUBLIC void tmgr_finalize();
44 XBT_PUBLIC simgrid::kernel::profile::Profile* tmgr_trace_new_from_file(std::string filename);
45 XBT_PUBLIC simgrid::kernel::profile::Profile* tmgr_trace_new_from_string(std::string id, std::string input,
52 /** @brief Modeling of the availability profile (due to an external load) or the churn
54 * There is 4 main concepts in this module:
55 * - #simgrid::kernel::profile::DatedValue: a pair <timestamp, value> (both are of type double)
56 * - #simgrid::kernel::profile::Profile: a list of dated values
57 * - #simgrid::kernel::profile::Event: links a given trace to a given SimGrid resource.
58 * A Cpu for example has 2 kinds of events: state (ie, is it ON/OFF) and speed,
59 * while a link has 3 iterators: state, bandwidth and latency.
60 * - #simgrid::kernel::profile::FutureEvtSet: makes it easy to find the next occuring event of all profiles
62 class XBT_PUBLIC DatedValue {
66 explicit DatedValue() = default;
67 explicit DatedValue(double d, double v) : date_(d), value_(v) {}
68 bool operator==(DatedValue e2);
69 bool operator!=(DatedValue e2) { return not(*this == e2); }
71 std::ostream& operator<<(std::ostream& out, const DatedValue& e);
73 /** @brief A profile is a set of timed values, encoding the value that a variable takes at what time
75 * It is useful to model dynamic platforms, where an external load that makes the resource availability change over
76 * time. To model that, you have to set several profiles per resource: one for the on/off state and one for each
77 * numerical value (computational speed, bandwidth and/or latency).
79 class XBT_PUBLIC Profile {
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 FutureEvtSet {
93 virtual ~FutureEvtSet();
94 double next_date() const;
95 Event* pop_leq(double date, double* value, resource::Resource** resource);
96 Event* add_trace(Profile* profile, resource::Resource* resource);
99 typedef std::pair<double, Event*> Qelt;
100 std::priority_queue<Qelt, std::vector<Qelt>, std::greater<Qelt>> heap_;
103 } // namespace profile
104 } // namespace kernel
105 } // namespace simgrid
107 #endif /* SURF_PMGR_H */