From: Martin Quinson Date: Mon, 21 Jan 2019 10:43:19 +0000 (+0100) Subject: start renaming tmgr trace into profile X-Git-Tag: v3_22~521 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0d08efd41a22b0813a99a3c206152d2edcbf3f00 start renaming tmgr trace into profile --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index a90be5078b..7f8dc6c625 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -134,7 +134,6 @@ class Action; class Model; class Resource; class NetworkModel; -class TraceEvent; class LinkImpl; class NetworkAction; } @@ -145,6 +144,11 @@ class NetPoint; class NetZoneImpl; class RouteCreationArgs; } +namespace profile { +class Event; +class FutureEvtSet; +class Profile; +} // namespace profile } // namespace kernel namespace simix { class Host; @@ -161,10 +165,6 @@ namespace surf { namespace mc { class CommunicationDeterminismChecker; } -namespace trace_mgr { - class trace; - class future_evt_set; -} namespace vm { class VMModel; class VirtualMachineImpl; @@ -181,7 +181,6 @@ typedef simgrid::s4u::Storage s4u_Storage; typedef simgrid::s4u::NetZone s4u_NetZone; typedef simgrid::s4u::VirtualMachine s4u_VM; typedef boost::intrusive_ptr smx_activity_t; -typedef simgrid::trace_mgr::trace* tmgr_trace_t; typedef simgrid::kernel::context::Context* smx_context_t; typedef simgrid::kernel::actor::ActorImpl* smx_actor_t; diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index 78e22bde41..6e1119ebcb 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -45,7 +45,7 @@ public: bool operator==(const Resource& other) const; /** @brief Apply an event of external load event to that resource */ - virtual void apply_event(TraceEvent* event, double value) = 0; + virtual void apply_event(profile::Event* event, double value) = 0; /** @brief Check if the current Resource is used (if it currently serves an action) */ virtual bool is_used() = 0; @@ -64,7 +64,7 @@ public: /** @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. */ - virtual void set_state_trace(tmgr_trace_t trace); + virtual void set_state_trace(profile::Profile* trace); private: std::string name_; @@ -79,13 +79,13 @@ private: kernel::lmm::Constraint* const constraint_ = nullptr; public: - TraceEvent* state_event_ = nullptr; + profile::Event* state_event_ = nullptr; 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] */ - TraceEvent* event; /**< The associated trace event associated to the metric */ + profile::Event* event; /**< The associated trace event associated to the metric */ }; }; } // namespace resource diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index 24a901b166..fbac2c0f9d 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -65,12 +65,15 @@ public: void* get_data(); /** Should be used only from the C interface. Prefer extensions in C++ */ void set_data(void* d); - void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain - boolean values. */ - void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to - external load). Trace must contain percentages (value between 0 and 1). */ - void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to - external load). Trace must contain absolute values */ + void set_state_trace( + kernel::profile::Profile* trace); /*< setup the trace file with states events (ON or OFF). Trace must contain + boolean values. */ + void set_bandwidth_trace( + kernel::profile::Profile* trace); /*< setup the trace file with bandwidth events (peak speed changes due to + external load). Trace must contain percentages (value between 0 and 1). */ + void set_latency_trace( + kernel::profile::Profile* trace); /*< setup the trace file with latency events (peak latency changes due to + external load). Trace must contain absolute values */ const char* get_property(std::string key); void set_property(std::string key, std::string value); @@ -130,11 +133,23 @@ public: XBT_ATTRIB_DEPRECATED_v323("Please use Link::set_data()") void setData(void* d) {set_data(d);} /** @deprecated */ - XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_state_trace()") void setStateTrace(tmgr_trace_t trace) {set_state_trace(trace);} + XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_state_trace()") void setStateTrace( + simgrid::kernel::profile::Profile* trace) + { + set_state_trace(trace); + } /** @deprecated */ - XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth_trace()") void setBandwidthTrace(tmgr_trace_t trace) {set_bandwidth_trace(trace);} + XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth_trace()") void setBandwidthTrace( + simgrid::kernel::profile::Profile* trace) + { + set_bandwidth_trace(trace); + } /** @deprecated */ - XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency_trace()") void setLatencyTrace(tmgr_trace_t trace) {set_latency_trace(trace);} + XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency_trace()") void setLatencyTrace( + simgrid::kernel::profile::Profile* trace) + { + set_latency_trace(trace); + } #endif }; } diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 05aa688d05..d01924138f 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -63,7 +63,7 @@ bool Resource::operator==(const Resource& other) const return name_ == other.name_; } -void Resource::set_state_trace(tmgr_trace_t trace) +void Resource::set_state_trace(profile::Profile* trace) { xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname()); diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index f51ffb2314..32d98e89db 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -87,15 +87,15 @@ void Link::set_data(void* d) simgrid::simix::simcall([this, d]() { this->pimpl_->set_data(d); }); } -void Link::set_state_trace(tmgr_trace_t trace) +void Link::set_state_trace(kernel::profile::Profile* trace) { simgrid::simix::simcall([this, trace]() { this->pimpl_->set_state_trace(trace); }); } -void Link::set_bandwidth_trace(tmgr_trace_t trace) +void Link::set_bandwidth_trace(kernel::profile::Profile* trace) { simgrid::simix::simcall([this, trace]() { this->pimpl_->set_bandwidth_trace(trace); }); } -void Link::set_latency_trace(tmgr_trace_t trace) +void Link::set_latency_trace(kernel::profile::Profile* trace) { simgrid::simix::simcall([this, trace]() { this->pimpl_->set_latency_trace(trace); }); } diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index 9604ecb8c8..c709305076 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -74,7 +74,7 @@ bool StorageImpl::is_used() return false; } -void StorageImpl::apply_event(tmgr_trace_event_t /*event*/, double /*value*/) +void StorageImpl::apply_event(kernel::profile::Event* /*event*/, double /*value*/) { THROW_UNIMPLEMENTED; } diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index 7ee634bf26..182b9e24bd 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -78,7 +78,7 @@ public: /** @brief Check if the Storage is used (if an action currently uses its resources) */ bool is_used() override; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(simgrid::kernel::profile::Event* event, double value) override; void turn_on() override; void turn_off() override; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index bb878130a7..899546c65b 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -115,7 +115,7 @@ void CpuCas01::on_speed_change() Cpu::on_speed_change(); } -void CpuCas01::apply_event(tmgr_trace_event_t event, double value) +void CpuCas01::apply_event(kernel::profile::Event* event, double value) { if (event == speed_.event) { /* TODO (Hypervisor): do the same thing for constraint_core[i] */ diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 473d14f7b9..7d076d4dc9 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -37,7 +37,7 @@ class CpuCas01 : public Cpu { public: CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector* speed_per_pstate, int core); ~CpuCas01() override; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(simgrid::kernel::profile::Event* event, double value) override; CpuAction* execution_start(double size) override; CpuAction* execution_start(double size, int requested_cores) override; CpuAction* sleep(double duration) override; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index ac0d208155..0784446bdb 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -134,7 +134,7 @@ int Cpu::get_core_count() return core_count_; } -void Cpu::set_speed_trace(tmgr_trace_t trace) +void Cpu::set_speed_trace(kernel::profile::Profile* trace) { xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", host_->get_cname()); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index bd2bf49b4f..1f2be7993e 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -148,7 +148,7 @@ public: /*< @brief Setup the trace file with availability events (peak speed changes due to external load). * Trace must contain relative values (ratio between 0 and 1) */ - virtual void set_speed_trace(tmgr_trace_t trace); + virtual void set_speed_trace(kernel::profile::Profile* trace); protected: Metric speed_ = {1.0, 0, nullptr}; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 77fbd5d37e..34eaa72dc4 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -19,15 +19,15 @@ namespace surf { * Trace * *********/ -CpuTiTrace::CpuTiTrace(tmgr_trace_t speedTrace) +CpuTiProfile::CpuTiProfile(kernel::profile::Profile* profile) { double integral = 0; double time = 0; int i = 0; - nb_points_ = speedTrace->event_list.size() + 1; + nb_points_ = profile->event_list.size() + 1; time_points_ = new double[nb_points_]; integral_ = new double[nb_points_]; - for (auto const& val : speedTrace->event_list) { + for (auto const& val : profile->event_list) { time_points_[i] = time; integral_[i] = integral; integral += val.date_ * val.value_; @@ -38,7 +38,7 @@ CpuTiTrace::CpuTiTrace(tmgr_trace_t speedTrace) integral_[i] = integral; } -CpuTiTrace::~CpuTiTrace() +CpuTiProfile::~CpuTiProfile() { delete[] time_points_; delete [] integral_; @@ -46,7 +46,7 @@ CpuTiTrace::~CpuTiTrace() CpuTiTmgr::~CpuTiTmgr() { - delete trace_; + delete profile_; } /** @@ -81,12 +81,12 @@ double CpuTiTmgr::integrate(double a, double b) int b_index = static_cast(floor(b / last_time_)); if (a_index > b_index) { /* Same chunk */ - return trace_->integrate_simple(a - (a_index - 1) * last_time_, b - (b_index)*last_time_); + return profile_->integrate_simple(a - (a_index - 1) * last_time_, b - (b_index)*last_time_); } - double first_chunk = trace_->integrate_simple(a - (a_index - 1) * last_time_, last_time_); + double first_chunk = profile_->integrate_simple(a - (a_index - 1) * last_time_, last_time_); double middle_chunk = (b_index - a_index) * total_; - double last_chunk = trace_->integrate_simple(0.0, b - (b_index)*last_time_); + double last_chunk = profile_->integrate_simple(0.0, b - (b_index)*last_time_); XBT_DEBUG("first_chunk=%.2f middle_chunk=%.2f last_chunk=%.2f\n", first_chunk, middle_chunk, last_chunk); @@ -99,7 +99,7 @@ double CpuTiTmgr::integrate(double a, double b) * @param a Initial point * @param b Final point */ -double CpuTiTrace::integrate_simple(double a, double b) +double CpuTiProfile::integrate_simple(double a, double b) { return integrate_simple_point(b) - integrate_simple_point(a); } @@ -108,7 +108,7 @@ double CpuTiTrace::integrate_simple(double a, double b) * @brief Auxiliary function to compute the integral at point a. * @param a point */ -double CpuTiTrace::integrate_simple_point(double a) +double CpuTiProfile::integrate_simple_point(double a) { double integral = 0; double a_aux = a; @@ -175,9 +175,9 @@ double CpuTiTmgr::solve(double a, double amount) double amount_till_end = integrate(reduced_a, last_time_); if (amount_till_end > reduced_amount) { - reduced_b = trace_->solve_simple(reduced_a, reduced_amount); + reduced_b = profile_->solve_simple(reduced_a, reduced_amount); } else { - reduced_b = last_time_ + trace_->solve_simple(0.0, reduced_amount - amount_till_end); + reduced_b = last_time_ + profile_->solve_simple(0.0, reduced_amount - amount_till_end); } /* Re-map to the original b and amount */ @@ -191,7 +191,7 @@ double CpuTiTmgr::solve(double a, double amount) * @param amount Amount of flops * @return The date when amount is available. */ -double CpuTiTrace::solve_simple(double a, double amount) +double CpuTiProfile::solve_simple(double a, double amount) { double integral_a = integrate_simple_point(a); int ind = binary_search(integral_, integral_a + amount, 0, nb_points_ - 1); @@ -212,8 +212,8 @@ double CpuTiTrace::solve_simple(double a, double amount) double CpuTiTmgr::get_power_scale(double a) { double reduced_a = a - floor(a / last_time_) * last_time_; - int point = trace_->binary_search(trace_->time_points_, reduced_a, 0, trace_->nb_points_ - 1); - trace_mgr::DatedValue val = speed_trace_->event_list.at(point); + int point = profile_->binary_search(profile_->time_points_, reduced_a, 0, profile_->nb_points_ - 1); + kernel::profile::DatedValue val = speed_profile_->event_list.at(point); return val.value_; } @@ -224,13 +224,13 @@ double CpuTiTmgr::get_power_scale(double a) * @param value Percentage of CPU speed available (useful to fixed tracing) * @return Integration trace structure */ -CpuTiTmgr::CpuTiTmgr(tmgr_trace_t speed_trace, double value) : speed_trace_(speed_trace) +CpuTiTmgr::CpuTiTmgr(kernel::profile::Profile* speed_profile, double value) : speed_profile_(speed_profile) { double total_time = 0.0; - trace_ = 0; + profile_ = 0; /* no availability file, fixed trace */ - if (not speed_trace) { + if (not speed_profile) { type_ = Type::FIXED; value_ = value; XBT_DEBUG("No availability trace. Constant value = %f", value); @@ -238,21 +238,21 @@ CpuTiTmgr::CpuTiTmgr(tmgr_trace_t speed_trace, double value) : speed_trace_(spee } /* only one point available, fixed trace */ - if (speed_trace->event_list.size() == 1) { + if (speed_profile->event_list.size() == 1) { type_ = Type::FIXED; - value_ = speed_trace->event_list.front().value_; + value_ = speed_profile->event_list.front().value_; return; } type_ = Type::DYNAMIC; /* count the total time of trace file */ - for (auto const& val : speed_trace->event_list) + for (auto const& val : speed_profile->event_list) total_time += val.date_; - trace_ = new CpuTiTrace(speed_trace); + profile_ = new CpuTiProfile(speed_profile); last_time_ = total_time; - total_ = trace_->integrate_simple(0, total_time); + total_ = profile_->integrate_simple(0, total_time); XBT_DEBUG("Total integral %f, last_time %f ", total_, last_time_); } @@ -266,7 +266,7 @@ CpuTiTmgr::CpuTiTmgr(tmgr_trace_t speed_trace, double value) : speed_trace_(spee * @param high Upper bound to search in array * @return Index of point */ -int CpuTiTrace::binary_search(double* array, double a, int low, int high) +int CpuTiProfile::binary_search(double* array, double a, int low, int high) { xbt_assert(low < high, "Wrong parameters: low (%d) should be smaller than high (%d)", low, high); @@ -367,20 +367,20 @@ CpuTi::~CpuTi() set_modified(false); delete speed_integrated_trace_; } -void CpuTi::set_speed_trace(tmgr_trace_t trace) +void CpuTi::set_speed_trace(kernel::profile::Profile* profile) { delete speed_integrated_trace_; - speed_integrated_trace_ = new CpuTiTmgr(trace, speed_.scale); + speed_integrated_trace_ = new CpuTiTmgr(profile, speed_.scale); /* add a fake trace event if periodicity == 0 */ - if (trace && trace->event_list.size() > 1) { - trace_mgr::DatedValue val = trace->event_list.back(); + if (profile && profile->event_list.size() > 1) { + kernel::profile::DatedValue val = profile->event_list.back(); if (val.date_ < 1e-12) - speed_.event = future_evt_set.add_trace(new simgrid::trace_mgr::trace(), this); + speed_.event = future_evt_set.add_trace(new simgrid::kernel::profile::Profile(), this); } } -void CpuTi::apply_event(tmgr_trace_event_t event, double value) +void CpuTi::apply_event(kernel::profile::Event* event, double value) { if (event == speed_.event) { XBT_DEBUG("Speed changed in trace! New fixed value: %f", value); diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 457ebcca43..2a4435b800 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -23,12 +23,12 @@ class XBT_PRIVATE CpuTi; /********* * Trace * *********/ -class CpuTiTrace { +class CpuTiProfile { public: - explicit CpuTiTrace(tmgr_trace_t speedTrace); - CpuTiTrace(const CpuTiTrace&) = delete; - CpuTiTrace& operator=(const CpuTiTrace&) = delete; - ~CpuTiTrace(); + explicit CpuTiProfile(kernel::profile::Profile* profile); + CpuTiProfile(const CpuTiProfile&) = delete; + CpuTiProfile& operator=(const CpuTiProfile&) = delete; + ~CpuTiProfile(); double integrate_simple(double a, double b); double integrate_simple_point(double a); @@ -48,7 +48,7 @@ class CpuTiTmgr { public: explicit CpuTiTmgr(double value) : type_(Type::FIXED), value_(value){}; - CpuTiTmgr(tmgr_trace_t speed_trace, double value); + CpuTiTmgr(kernel::profile::Profile* speed_profile, double value); CpuTiTmgr(const CpuTiTmgr&) = delete; CpuTiTmgr& operator=(const CpuTiTmgr&) = delete; ~CpuTiTmgr(); @@ -65,8 +65,8 @@ private: double last_time_ = 0.0; /*< Integral interval last point (discrete time) */ double total_ = 0.0; /*< Integral total between 0 and last_pointn */ - CpuTiTrace *trace_ = nullptr; - tmgr_trace_t speed_trace_ = nullptr; + CpuTiProfile* profile_ = nullptr; + kernel::profile::Profile* speed_profile_ = nullptr; }; /********** @@ -103,15 +103,15 @@ public: CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, std::vector* speed_per_pstate, int core); ~CpuTi() override; - void set_speed_trace(tmgr_trace_t trace) override; + void set_speed_trace(kernel::profile::Profile* profile) override; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(kernel::profile::Event* event, double value) override; void update_actions_finish_time(double now); void update_remaining_amount(double now); bool is_used() override; CpuAction *execution_start(double size) override; - simgrid::kernel::resource::Action* execution_start(double size, int requested_cores) override + kernel::resource::Action* execution_start(double size, int requested_cores) override { THROW_UNIMPLEMENTED; return nullptr; diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index f5caa3ad5f..f7679d2756 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -318,7 +318,7 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam simgrid::s4u::Link::on_creation(this->piface_); } -void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) +void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value) { /* Find out which of my iterators was triggered, and react accordingly */ if (triggered == bandwidth_.event) { diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index f011036a0b..cd576d6e94 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -48,7 +48,7 @@ public: NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency, s4u::Link::SharingPolicy policy, lmm::System* system); virtual ~NetworkCm02Link() = default; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(kernel::profile::Event* event, double value) override; void set_bandwidth(double value) override; void set_latency(double value) override; }; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 48d0f5e8b5..a552f54ea6 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -145,13 +145,13 @@ void LinkImpl::on_bandwidth_change() s4u::Link::on_bandwidth_change(this->piface_); } -void LinkImpl::set_bandwidth_trace(tmgr_trace_t trace) +void LinkImpl::set_bandwidth_trace(profile::Profile* trace) { xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", get_cname()); bandwidth_.event = future_evt_set.add_trace(trace, this); } -void LinkImpl::set_latency_trace(tmgr_trace_t trace) +void LinkImpl::set_latency_trace(profile::Profile* trace) { xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", get_cname()); latency_.event = future_evt_set.add_trace(trace, this); diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index ba134a0ae3..7419f0b1d6 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -147,12 +147,13 @@ public: void on_bandwidth_change(); - virtual void set_bandwidth_trace( - tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). - Trace must contain percentages (value between 0 and 1). */ - virtual void set_latency_trace( - tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). - Trace must contain absolute values */ + virtual void set_bandwidth_trace(kernel::profile::Profile* trace); /*< setup the trace file with bandwidth events + (peak speed changes due to external load). Trace must + contain percentages (value between 0 and 1). */ + virtual void + set_latency_trace(kernel::profile::Profile* trace); /*< setup the trace file with latency events (peak + latency changes due to external load). Trace must contain + absolute values */ Metric latency_ = {1.0, 0, nullptr}; Metric bandwidth_ = {1.0, 0, nullptr}; diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index a2ddc80587..b2a18776d6 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -277,15 +277,15 @@ LinkNS3::LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwid LinkNS3::~LinkNS3() = default; -void LinkNS3::apply_event(tmgr_trace_event_t event, double value) +void LinkNS3::apply_event(profile::Event* event, double value) { THROW_UNIMPLEMENTED; } -void LinkNS3::set_bandwidth_trace(tmgr_trace_t trace) +void LinkNS3::set_bandwidth_trace(profile::Profile* profile) { xbt_die("The NS3 network model doesn't support bandwidth traces"); } -void LinkNS3::set_latency_trace(tmgr_trace_t trace) +void LinkNS3::set_latency_trace(profile::Profile* profile) { xbt_die("The NS3 network model doesn't support latency traces"); } diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 3f91e963ea..26ef8f13d6 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -34,11 +34,11 @@ public: explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency); ~LinkNS3(); - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(simgrid::kernel::profile::Event* event, double value) override; void set_bandwidth(double value) override { THROW_UNIMPLEMENTED; } void set_latency(double value) override { THROW_UNIMPLEMENTED; } - void set_bandwidth_trace(tmgr_trace_t trace) override; - void set_latency_trace(tmgr_trace_t trace) override; + void set_bandwidth_trace(profile::Profile* profile) override; + void set_latency_trace(profile::Profile* profile) override; }; /********** diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 674c35d961..acda211363 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -314,7 +314,7 @@ bool LinkL07::is_used() return get_model()->get_maxmin_system()->constraint_used(get_constraint()); } -void CpuL07::apply_event(tmgr_trace_event_t triggered, double value) +void CpuL07::apply_event(kernel::profile::Event* triggered, double value) { XBT_DEBUG("Updating cpu %s (%p) with value %g", get_cname(), this, value); if (triggered == speed_.event) { @@ -337,7 +337,7 @@ void CpuL07::apply_event(tmgr_trace_event_t triggered, double value) } } -void LinkL07::apply_event(tmgr_trace_event_t triggered, double value) +void LinkL07::apply_event(kernel::profile::Event* triggered, double value) { XBT_DEBUG("Updating link %s (%p) with value=%f", get_cname(), this, value); if (triggered == bandwidth_.event) { diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 398510ac0e..8cb8d64c1a 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -71,12 +71,12 @@ public: class CpuL07 : public Cpu { public: - CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector* speed_per_pstate, int core); + CpuL07(CpuL07Model* model, s4u::Host* host, std::vector* speed_per_pstate, int core); ~CpuL07() override; bool is_used() override; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(kernel::profile::Event* event, double value) override; kernel::resource::Action* execution_start(double size) override; - simgrid::kernel::resource::Action* execution_start(double size, int requested_cores) override + kernel::resource::Action* execution_start(double size, int requested_cores) override { THROW_UNIMPLEMENTED; return nullptr; @@ -93,7 +93,7 @@ public: s4u::Link::SharingPolicy policy); ~LinkL07() override; bool is_used() override; - void apply_event(tmgr_trace_event_t event, double value) override; + void apply_event(kernel::profile::Event* event, double value) override; void set_bandwidth(double value) override; void set_latency(double value) override; }; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 4e5a096b60..570ba54e24 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -656,15 +656,15 @@ void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostl as_cluster->private_links_.insert({netpoint->id(), {linkUp->get_impl(), linkDown->get_impl()}}); } -void sg_platf_new_trace(simgrid::kernel::routing::TraceCreationArgs* trace) +void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* profile) { - tmgr_trace_t tmgr_trace; - if (not trace->file.empty()) { - tmgr_trace = tmgr_trace_new_from_file(trace->file); + simgrid::kernel::profile::Profile* mgr_profile; + if (not profile->file.empty()) { + mgr_profile = tmgr_trace_new_from_file(profile->file); } else { - xbt_assert(not trace->pc_data.empty(), "Trace '%s' must have either a content, or point to a file on disk.", - trace->id.c_str()); - tmgr_trace = tmgr_trace_new_from_string(trace->id, trace->pc_data, trace->periodicity); + xbt_assert(not profile->pc_data.empty(), "Trace '%s' must have either a content, or point to a file on disk.", + profile->id.c_str()); + mgr_profile = tmgr_trace_new_from_string(profile->id, profile->pc_data, profile->periodicity); } - traces_set_list.insert({trace->id, tmgr_trace}); + traces_set_list.insert({profile->id, mgr_profile}); } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index c244b538b0..0a12d8578c 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -21,7 +21,7 @@ extern double NOW; void surf_presolve() { double next_event_date = -1.0; - tmgr_trace_event_t event = nullptr; + simgrid::kernel::profile::Event* event = nullptr; double value = -1.0; simgrid::kernel::resource::Resource* resource = nullptr; @@ -47,7 +47,7 @@ double surf_solve(double max_date) double model_next_action_end = -1.0; double value = -1.0; simgrid::kernel::resource::Resource* resource = nullptr; - tmgr_trace_event_t event = nullptr; + simgrid::kernel::profile::Event* event = nullptr; if (max_date > 0.0) { xbt_assert(max_date > NOW,"You asked to simulate up to %f, but that's in the past already", max_date); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index abb8f9638a..f0bc6939b3 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -30,7 +30,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke std::vector all_existing_models; /* to destroy models correctly */ -simgrid::trace_mgr::future_evt_set future_evt_set; +simgrid::kernel::profile::FutureEvtSet future_evt_set; std::vector surf_path; /** set of hosts for which one want to be notified if they ever restart. */ std::set watched_hosts; diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 7723ee09e3..d21e3dd5a9 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -27,7 +27,7 @@ extern XBT_PRIVATE double sg_latency_factor; extern XBT_PRIVATE double sg_bandwidth_factor; extern XBT_PRIVATE double sg_weight_S_parameter; extern XBT_PRIVATE std::vector surf_path; -extern XBT_PRIVATE std::unordered_map traces_set_list; +extern XBT_PRIVATE std::unordered_map traces_set_list; extern XBT_PRIVATE std::set watched_hosts; static inline void double_update(double* variable, double value, double precision) diff --git a/src/surf/trace_mgr.cpp b/src/surf/trace_mgr.cpp index 1b204a89e6..cc0873df00 100644 --- a/src/surf/trace_mgr.cpp +++ b/src/surf/trace_mgr.cpp @@ -19,16 +19,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf, "Surf trace management"); -namespace tmgr = simgrid::trace_mgr; - -static std::unordered_map trace_list; +static std::unordered_map trace_list; static inline bool doubleEq(double d1, double d2) { return fabs(d1 - d2) < 0.0001; } namespace simgrid { -namespace trace_mgr { +namespace kernel { +namespace profile { bool DatedValue::operator==(DatedValue e2) { @@ -40,36 +39,37 @@ std::ostream& operator<<(std::ostream& out, const DatedValue& e) return out; } -trace::trace() +Profile::Profile() { /* Add the first fake event storing the time at which the trace begins */ - tmgr::DatedValue val(0, -1); + DatedValue val(0, -1); event_list.push_back(val); } -trace::~trace() = default; -future_evt_set::future_evt_set() = default; -future_evt_set::~future_evt_set() +Profile::~Profile() = default; +FutureEvtSet::FutureEvtSet() = default; +FutureEvtSet::~FutureEvtSet() { while (not heap_.empty()) { delete heap_.top().second; heap_.pop(); } } -} -} +} // namespace profile +} // namespace kernel +} // namespace simgrid -tmgr_trace_t tmgr_trace_new_from_string(std::string name, std::string input, double periodicity) +simgrid::kernel::profile::Profile* tmgr_trace_new_from_string(std::string name, std::string input, double periodicity) { int linecount = 0; - tmgr_trace_t trace = new simgrid::trace_mgr::trace(); - tmgr::DatedValue* last_event = &(trace->event_list.back()); + simgrid::kernel::profile::Profile* trace = new simgrid::kernel::profile::Profile(); + simgrid::kernel::profile::DatedValue* last_event = &(trace->event_list.back()); xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name.c_str()); std::vector list; boost::split(list, input, boost::is_any_of("\n\r")); for (auto val : list) { - tmgr::DatedValue event; + simgrid::kernel::profile::DatedValue event; linecount++; boost::trim(val); if (val[0] == '#' || val[0] == '\0' || val[0] == '%') // pass comments @@ -103,7 +103,7 @@ tmgr_trace_t tmgr_trace_new_from_string(std::string name, std::string input, dou return trace; } -tmgr_trace_t tmgr_trace_new_from_file(std::string filename) +simgrid::kernel::profile::Profile* tmgr_trace_new_from_file(std::string filename) { xbt_assert(not filename.empty(), "Cannot parse a trace from an empty filename"); xbt_assert(trace_list.find(filename) == trace_list.end(), "Refusing to define trace %s twice", filename.c_str()); @@ -117,20 +117,20 @@ tmgr_trace_t tmgr_trace_new_from_file(std::string filename) return tmgr_trace_new_from_string(filename, buffer.str(), -1); } +namespace simgrid { +namespace kernel { +namespace profile { /** @brief Registers a new trace into the future event set, and get an iterator over the integrated trace */ -tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t trace, - kernel::resource::Resource* resource) +Event* FutureEvtSet::add_trace(Profile* profile, resource::Resource* resource) { - tmgr_trace_event_t trace_iterator = nullptr; - - trace_iterator = new simgrid::kernel::resource::TraceEvent(); - trace_iterator->trace = trace; + Event* trace_iterator = new Event(); + trace_iterator->profile = profile; trace_iterator->idx = 0; trace_iterator->resource = resource; trace_iterator->free_me = false; - xbt_assert((trace_iterator->idx < trace->event_list.size()), "Your trace should have at least one event!"); + xbt_assert((trace_iterator->idx < profile->event_list.size()), "Your trace should have at least one event!"); heap_.emplace(0.0 /* start time */, trace_iterator); @@ -138,14 +138,13 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t tr } /** @brief returns the date of the next occurring event (pure function) */ -double simgrid::trace_mgr::future_evt_set::next_date() const +double FutureEvtSet::next_date() const { return heap_.empty() ? -1.0 : heap_.top().first; } /** @brief Retrieves the next occurring event, or nullptr if none happens before date */ -tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, double* value, - kernel::resource::Resource** resource) +Event* FutureEvtSet::pop_leq(double date, double* value, resource::Resource** resource) { double event_date = next_date(); if (event_date > date) @@ -153,13 +152,13 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, doub if (heap_.empty()) return nullptr; - tmgr_trace_event_t trace_iterator = heap_.top().second; + Event* trace_iterator = heap_.top().second; heap_.pop(); - tmgr_trace_t trace = trace_iterator->trace; + Profile* trace = trace_iterator->profile; *resource = trace_iterator->resource; - tmgr::DatedValue dateVal = trace->event_list.at(trace_iterator->idx); + DatedValue dateVal = trace->event_list.at(trace_iterator->idx); *value = dateVal.value_; @@ -175,7 +174,9 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, doub return trace_iterator; } - +} // namespace profile +} // namespace kernel +} // namespace simgrid void tmgr_finalize() { for (auto const& kv : trace_list) @@ -183,7 +184,7 @@ void tmgr_finalize() trace_list.clear(); } -void tmgr_trace_event_unref(tmgr_trace_event_t* trace_event) +void tmgr_trace_event_unref(simgrid::kernel::profile::Event** trace_event) { if ((*trace_event)->free_me) { delete *trace_event; diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index acb5ae6d56..087f21118b 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -3,8 +3,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef SURF_TMGR_H -#define SURF_TMGR_H +#ifndef SURF_PMGR_H +#define SURF_PMGR_H #include "simgrid/forward.h" #include "xbt/sysdep.h" @@ -15,20 +15,20 @@ /* Iterator within a trace */ namespace simgrid { namespace kernel { -namespace resource { -class TraceEvent { +namespace profile { +/** @brief Links a profile to a resource */ +class Event { public: - tmgr_trace_t trace; + Profile* profile; unsigned int idx; - Resource* resource; + resource::Resource* resource; bool free_me; }; } // namespace resource } // namespace kernel } // namespace simgrid -typedef simgrid::kernel::resource::TraceEvent* tmgr_trace_event_t; -extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set future_evt_set; +extern XBT_PRIVATE simgrid::kernel::profile::FutureEvtSet future_evt_set; /** * @brief Free a trace event structure @@ -37,25 +37,28 @@ extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set future_evt_set; * This flag indicates whether the structure is still used somewhere or not. * When the structure is freed, the argument is set to nullptr */ -XBT_PUBLIC void tmgr_trace_event_unref(tmgr_trace_event_t* trace_event); +XBT_PUBLIC void tmgr_trace_event_unref(simgrid::kernel::profile::Event** trace_event); XBT_PUBLIC void tmgr_finalize(); -XBT_PUBLIC tmgr_trace_t tmgr_trace_new_from_file(std::string filename); -XBT_PUBLIC tmgr_trace_t tmgr_trace_new_from_string(std::string id, std::string input, double periodicity); +XBT_PUBLIC simgrid::kernel::profile::Profile* tmgr_trace_new_from_file(std::string filename); +XBT_PUBLIC simgrid::kernel::profile::Profile* tmgr_trace_new_from_string(std::string id, std::string input, + double periodicity); namespace simgrid { +namespace kernel { +namespace profile { + /** @brief Modeling of the availability profile (due to an external load) or the churn * * There is 4 main concepts in this module: - * - #simgrid::trace_mgr::DatedValue: a pair (both are of type double) - * - #simgrid::trace_mgr::trace: a list of dated values - * - #simgrid::trace_mgr::trace_event: links a given trace to a given SimGrid resource. + * - #simgrid::kernel::profile::DatedValue: a pair (both are of type double) + * - #simgrid::kernel::profile::Profile: a list of dated values + * - #simgrid::kernel::profile::Event: links a given trace to a given SimGrid resource. * A Cpu for example has 2 kinds of events: state (ie, is it ON/OFF) and speed, * while a link has 3 iterators: state, bandwidth and latency. - * - #simgrid::trace_mgr::future_evt_set: makes it easy to find the next occuring event of all traces + * - #simgrid::kernel::profile::FutureEvtSet: makes it easy to find the next occuring event of all profiles */ -namespace trace_mgr { class XBT_PUBLIC DatedValue { public: double date_ = 0; @@ -67,39 +70,38 @@ public: }; std::ostream& operator<<(std::ostream& out, const DatedValue& e); -/** @brief A trace_iterator links a trace to a resource */ -class XBT_PUBLIC trace_event { -}; - -/** @brief A trace is a set of timed values, encoding the value that a variable takes at what time * +/** @brief A profile is a set of timed values, encoding the value that a variable takes at what time * - * It is useful to model dynamic platforms, where an external load that makes the resource availability change over time. - * 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). + * It is useful to model dynamic platforms, where an external load that makes the resource availability change over + * time. To model that, you have to set several profiles per resource: one for the on/off state and one for each + * numerical value (computational speed, bandwidth and/or latency). */ -class XBT_PUBLIC trace { +class XBT_PUBLIC Profile { public: /** Creates an empty trace */ - explicit trace(); - virtual ~trace(); -//private: + explicit Profile(); + virtual ~Profile(); + // private: std::vector event_list; }; /** @brief Future Event Set (collection of iterators over the traces) * That's useful to quickly know which is the next occurring event in a set of traces. */ -class XBT_PUBLIC future_evt_set { +class XBT_PUBLIC FutureEvtSet { public: - future_evt_set(); - virtual ~future_evt_set(); + FutureEvtSet(); + virtual ~FutureEvtSet(); double next_date() const; - tmgr_trace_event_t pop_leq(double date, double* value, simgrid::kernel::resource::Resource** resource); - tmgr_trace_event_t add_trace(tmgr_trace_t trace, simgrid::kernel::resource::Resource * resource); + Event* pop_leq(double date, double* value, resource::Resource** resource); + Event* add_trace(Profile* trace, resource::Resource* resource); private: - typedef std::pair Qelt; + typedef std::pair Qelt; std::priority_queue, std::greater> heap_; }; -}} // namespace simgrid::trace_mgr +} // namespace profile +} // namespace kernel +} // namespace simgrid -#endif /* SURF_TMGR_H */ +#endif /* SURF_PMGR_H */ diff --git a/src/surf/trace_mgr_test.cpp b/src/surf/trace_mgr_test.cpp index 719dc9dcd6..064b2a1d0a 100644 --- a/src/surf/trace_mgr_test.cpp +++ b/src/surf/trace_mgr_test.cpp @@ -19,7 +19,6 @@ bool init_unit_test(); // boost sometimes forget to give this prototype (NetBSD #include namespace utf = boost::unit_test; -namespace tmgr = simgrid::trace_mgr; XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager"); @@ -27,7 +26,7 @@ double thedate; class MockedResource : public simgrid::kernel::resource::Resource { public: explicit MockedResource() : simgrid::kernel::resource::Resource(nullptr, "fake", nullptr) {} - void apply_event(tmgr_trace_event_t event, double value) override + void apply_event(simgrid::kernel::profile::Event* event, double value) override { XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", thedate, value, event->idx); tmgr_trace_event_unref(&event); @@ -35,30 +34,30 @@ public: bool is_used() override { return true; } }; -static void trace2vector(const char* str, std::vector* whereto) +static void trace2vector(const char* str, std::vector* whereto) { - simgrid::trace_mgr::trace* trace = tmgr_trace_new_from_string("TheName", str, 0); + simgrid::kernel::profile::Profile* trace = tmgr_trace_new_from_string("TheName", str, 0); XBT_VERB("---------------------------------------------------------"); XBT_VERB("data>>\n%s<event_list) XBT_VERB("event: d:%lg v:%lg", evt.date_, evt.value_); MockedResource daResource; - simgrid::trace_mgr::future_evt_set fes; - tmgr_trace_event_t insertedIt = fes.add_trace(trace, &daResource); + simgrid::kernel::profile::FutureEvtSet fes; + simgrid::kernel::profile::Event* insertedIt = fes.add_trace(trace, &daResource); while (fes.next_date() <= 20.0 && fes.next_date() >= 0) { thedate = fes.next_date(); double value; simgrid::kernel::resource::Resource* res; - tmgr_trace_event_t it = fes.pop_leq(thedate, &value, &res); + simgrid::kernel::profile::Event* it = fes.pop_leq(thedate, &value, &res); if (it == nullptr) continue; BOOST_CHECK_EQUAL(it, insertedIt); // Check that we find what we've put if (value >= 0) { res->apply_event(it, value); - whereto->push_back(tmgr::DatedValue(thedate, value)); + whereto->push_back(simgrid::kernel::profile::DatedValue(thedate, value)); } else { XBT_DEBUG("%.1f: ignore an event (idx: %u)\n", thedate, it->idx); } @@ -75,76 +74,76 @@ BOOST_AUTO_TEST_CASE(no_evt_noloop) { }*/ BOOST_AUTO_TEST_CASE(one_evt_noloop) { - std::vector got; + std::vector got; trace2vector("9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_noloop) { - std::vector got; + std::vector got; trace2vector("3.0 1.0\n" "9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(3, 1)); - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(3, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(three_evt_noloop) { - std::vector got; + std::vector got; trace2vector("3.0 1.0\n" "5.0 2.0\n" "9.0 3.0\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(3, 1)); - want.push_back(tmgr::DatedValue(5, 2)); - want.push_back(tmgr::DatedValue(9, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(3, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(5, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(9, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_loop) { - std::vector got; + std::vector got; trace2vector("1.0 1.0\n" "3.0 3.0\n" "LOOPAFTER 2\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(1, 1)); - want.push_back(tmgr::DatedValue(3, 3)); - want.push_back(tmgr::DatedValue(6, 1)); - want.push_back(tmgr::DatedValue(8, 3)); - want.push_back(tmgr::DatedValue(11, 1)); - want.push_back(tmgr::DatedValue(13, 3)); - want.push_back(tmgr::DatedValue(16, 1)); - want.push_back(tmgr::DatedValue(18, 3)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(1, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(3, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(6, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(8, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(11, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(13, 3)); + want.push_back(simgrid::kernel::profile::DatedValue(16, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(18, 3)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } BOOST_AUTO_TEST_CASE(two_evt_start0_loop) { - std::vector got; + std::vector got; trace2vector("0.0 1\n" "5.0 2\n" "LOOPAFTER 5\n", &got); - std::vector want; - want.push_back(tmgr::DatedValue(0, 1)); - want.push_back(tmgr::DatedValue(5, 2)); - want.push_back(tmgr::DatedValue(10, 1)); - want.push_back(tmgr::DatedValue(15, 2)); - want.push_back(tmgr::DatedValue(20, 1)); + std::vector want; + want.push_back(simgrid::kernel::profile::DatedValue(0, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(5, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(10, 1)); + want.push_back(simgrid::kernel::profile::DatedValue(15, 2)); + want.push_back(simgrid::kernel::profile::DatedValue(20, 1)); BOOST_CHECK_EQUAL_COLLECTIONS(want.begin(), want.end(), got.begin(), got.end()); } diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 38894b4e8c..750de26a9d 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -37,8 +37,8 @@ struct HostCreationArgs { std::vector speed_per_pstate; int pstate = 0; int core_amount = 0; - tmgr_trace_t speed_trace = nullptr; - tmgr_trace_t state_trace = nullptr; + profile::Profile* speed_trace = nullptr; + profile::Profile* state_trace = nullptr; const char* coord = nullptr; std::unordered_map* properties = nullptr; }; @@ -54,10 +54,10 @@ class LinkCreationArgs { public: std::string id; double bandwidth = 0; - tmgr_trace_t bandwidth_trace = nullptr; + profile::Profile* bandwidth_trace = nullptr; double latency = 0; - tmgr_trace_t latency_trace = nullptr; - tmgr_trace_t state_trace = nullptr; + profile::Profile* latency_trace = nullptr; + profile::Profile* state_trace = nullptr; simgrid::s4u::Link::SharingPolicy policy = simgrid::s4u::Link::SharingPolicy::FATPIPE; std::unordered_map* properties = nullptr; }; @@ -69,8 +69,8 @@ public: double bw_in; double bw_out; std::string coord; - tmgr_trace_t speed_trace; - tmgr_trace_t state_trace; + profile::Profile* speed_trace; + profile::Profile* state_trace; }; class RouteCreationArgs { @@ -144,7 +144,7 @@ public: std::string name; }; -class TraceCreationArgs { +class ProfileCreationArgs { public: std::string id; std::string file; @@ -201,7 +201,7 @@ XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a rou XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute -XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::TraceCreationArgs* trace); +XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace); XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type); diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 19f190909c..49375092fb 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -23,7 +23,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); /* Trace related stuff */ -XBT_PRIVATE std::unordered_map traces_set_list; +XBT_PRIVATE std::unordered_map traces_set_list; XBT_PRIVATE std::unordered_map trace_connect_list_host_avail; XBT_PRIVATE std::unordered_map trace_connect_list_host_speed; XBT_PRIVATE std::unordered_map trace_connect_list_link_avail; @@ -101,10 +101,10 @@ void parse_platform_file(std::string file) /* Do the actual parsing */ parse_status = surf_parse(); - /* connect all traces relative to hosts */ + /* connect all profiles relative to hosts */ for (auto const& elm : trace_connect_list_host_avail) { xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); - tmgr_trace_t trace = traces_set_list.at(elm.first); + simgrid::kernel::profile::Profile* trace = traces_set_list.at(elm.first); simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str()); xbt_assert(host, "Host %s undefined", elm.second.c_str()); @@ -115,7 +115,7 @@ void parse_platform_file(std::string file) for (auto const& elm : trace_connect_list_host_speed) { xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); - tmgr_trace_t trace = traces_set_list.at(elm.first); + simgrid::kernel::profile::Profile* trace = traces_set_list.at(elm.first); simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str()); xbt_assert(host, "Host %s undefined", elm.second.c_str()); @@ -126,7 +126,7 @@ void parse_platform_file(std::string file) for (auto const& elm : trace_connect_list_link_avail) { xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); - tmgr_trace_t trace = traces_set_list.at(elm.first); + simgrid::kernel::profile::Profile* trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::by_name(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); @@ -135,7 +135,7 @@ void parse_platform_file(std::string file) for (auto const& elm : trace_connect_list_link_bw) { xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); - tmgr_trace_t trace = traces_set_list.at(elm.first); + simgrid::kernel::profile::Profile* trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::by_name(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); link->set_bandwidth_trace(trace); @@ -143,7 +143,7 @@ void parse_platform_file(std::string file) for (auto const& elm : trace_connect_list_link_lat) { xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str()); - tmgr_trace_t trace = traces_set_list.at(elm.first); + simgrid::kernel::profile::Profile* trace = traces_set_list.at(elm.first); sg_link_t link = simgrid::s4u::Link::by_name(elm.second.c_str()); xbt_assert(link, "Link %s undefined", elm.second.c_str()); link->set_latency_trace(trace); diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index ee1855423e..0448bd70eb 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -777,7 +777,7 @@ void ETag_surfxml_bypassZoneRoute() } void ETag_surfxml_trace(){ - simgrid::kernel::routing::TraceCreationArgs trace; + simgrid::kernel::routing::ProfileCreationArgs trace; trace.id = A_surfxml_trace_id; trace.file = A_surfxml_trace_file;