From 2b3790827a15510aa6b18146bc01597a568b332b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 21 Jan 2019 14:58:12 +0100 Subject: [PATCH] further s/trace/profile/ cleanups --- include/simgrid/kernel/resource/Resource.hpp | 13 ++--- include/simgrid/s4u/Link.hpp | 15 ++---- src/surf/trace_mgr.cpp | 50 ++++++++++---------- src/surf/trace_mgr.hpp | 2 +- 4 files changed, 34 insertions(+), 46 deletions(-) diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index ecfd29d182..fa581d1800 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -52,7 +52,7 @@ public: /** @brief returns the current load due to activities (in flops per second, byte per second or similar) * - * The load due to external usages modeled by trace files is ignored.*/ + * The load due to external usages modeled by profile files is ignored.*/ virtual double get_load(); /** @brief Check if the current Resource is active */ @@ -63,15 +63,12 @@ public: virtual void turn_on(); /** @brief Turn off the current Resource */ virtual void turn_off(); - /** @brief setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ + /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */ virtual void set_state_profile(profile::Profile* profile); #ifndef DOXYGEN XBT_ATTRIB_DEPRECATED_v325("Please use Resource::set_state_profile()") virtual void set_state_trace( - profile::Profile* profile) - { - set_state_profile(profile); - } + profile::Profile* profile) { set_state_profile(profile); } #endif private: @@ -92,8 +89,8 @@ public: protected: struct Metric { double peak; /**< The peak of the metric, ie its max value */ - double scale; /**< Current availability of the metric according to the traces, in [0,1] */ - profile::Event* event; /**< The associated trace event associated to the metric */ + double scale; /**< Current availability of the metric according to the profiles, in [0,1] */ + profile::Event* event; /**< The associated profile event associated to the metric */ }; }; } // namespace resource diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index 8029280cf3..735321aad4 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -151,22 +151,13 @@ public: /** @deprecated */ XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_state_profile()") void setStateTrace( - simgrid::kernel::profile::Profile* trace) - { - set_state_profile(trace); - } + simgrid::kernel::profile::Profile* profile) {set_state_profile(profile); } /** @deprecated */ XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth_profile()") void setBandwidthTrace( - simgrid::kernel::profile::Profile* trace) - { - set_bandwidth_profile(trace); - } + simgrid::kernel::profile::Profile* profile) { set_bandwidth_profile(profile); } /** @deprecated */ XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency_profile()") void setLatencyTrace( - simgrid::kernel::profile::Profile* trace) - { - set_latency_profile(trace); - } + simgrid::kernel::profile::Profile* profile) { set_latency_profile(profile); } #endif }; } diff --git a/src/surf/trace_mgr.cpp b/src/surf/trace_mgr.cpp index cc0873df00..d84999c855 100644 --- a/src/surf/trace_mgr.cpp +++ b/src/surf/trace_mgr.cpp @@ -124,20 +124,20 @@ namespace profile { /** @brief Registers a new trace into the future event set, and get an iterator over the integrated trace */ Event* FutureEvtSet::add_trace(Profile* profile, resource::Resource* resource) { - Event* trace_iterator = new Event(); - trace_iterator->profile = profile; - trace_iterator->idx = 0; - trace_iterator->resource = resource; - trace_iterator->free_me = false; + Event* event = new Event(); + event->profile = profile; + event->idx = 0; + event->resource = resource; + event->free_me = false; - xbt_assert((trace_iterator->idx < profile->event_list.size()), "Your trace should have at least one event!"); + xbt_assert((event->idx < profile->event_list.size()), "Your profile should have at least one event!"); - heap_.emplace(0.0 /* start time */, trace_iterator); + heap_.emplace(0.0 /* start time */, event); - return trace_iterator; + return event; } -/** @brief returns the date of the next occurring event (pure function) */ +/** @brief returns the date of the next occurring event */ double FutureEvtSet::next_date() const { return heap_.empty() ? -1.0 : heap_.top().first; @@ -152,27 +152,27 @@ Event* FutureEvtSet::pop_leq(double date, double* value, resource::Resource** re if (heap_.empty()) return nullptr; - Event* trace_iterator = heap_.top().second; + Event* event = heap_.top().second; heap_.pop(); - Profile* trace = trace_iterator->profile; - *resource = trace_iterator->resource; + Profile* profile = event->profile; + *resource = event->resource; - DatedValue dateVal = trace->event_list.at(trace_iterator->idx); + DatedValue dateVal = profile->event_list.at(event->idx); *value = dateVal.value_; - if (trace_iterator->idx < trace->event_list.size() - 1) { - heap_.emplace(event_date + dateVal.date_, trace_iterator); - trace_iterator->idx++; + if (event->idx < profile->event_list.size() - 1) { + heap_.emplace(event_date + dateVal.date_, event); + event->idx++; } else if (dateVal.date_ > 0) { /* Last element. Shall we loop? */ - heap_.emplace(event_date + dateVal.date_, trace_iterator); - trace_iterator->idx = 1; /* idx=0 is a placeholder to store when events really start */ - } else { /* If we don't loop, we don't need this trace_event anymore */ - trace_iterator->free_me = true; + heap_.emplace(event_date + dateVal.date_, event); + event->idx = 1; /* idx=0 is a placeholder to store when events really start */ + } else { /* If we don't loop, we don't need this event anymore */ + event->free_me = true; } - return trace_iterator; + return event; } } // namespace profile } // namespace kernel @@ -184,10 +184,10 @@ void tmgr_finalize() trace_list.clear(); } -void tmgr_trace_event_unref(simgrid::kernel::profile::Event** trace_event) +void tmgr_trace_event_unref(simgrid::kernel::profile::Event** event) { - if ((*trace_event)->free_me) { - delete *trace_event; - *trace_event = nullptr; + if ((*event)->free_me) { + delete *event; + *event = nullptr; } } diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index 087f21118b..1e749dedf4 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -93,7 +93,7 @@ public: virtual ~FutureEvtSet(); double next_date() const; Event* pop_leq(double date, double* value, resource::Resource** resource); - Event* add_trace(Profile* trace, resource::Resource* resource); + Event* add_trace(Profile* profile, resource::Resource* resource); private: typedef std::pair Qelt; -- 2.20.1