class Model;
class Resource;
class NetworkModel;
-class TraceEvent;
class LinkImpl;
class NetworkAction;
}
class NetZoneImpl;
class RouteCreationArgs;
}
+namespace profile {
+class Event;
+class FutureEvtSet;
+class Profile;
+} // namespace profile
} // namespace kernel
namespace simix {
class Host;
namespace mc {
class CommunicationDeterminismChecker;
}
-namespace trace_mgr {
- class trace;
- class future_evt_set;
-}
namespace vm {
class VMModel;
class VirtualMachineImpl;
typedef simgrid::s4u::NetZone s4u_NetZone;
typedef simgrid::s4u::VirtualMachine s4u_VM;
typedef boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> 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;
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;
/** @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_;
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
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);
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
};
}
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());
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); });
}
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;
}
/** @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;
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] */
public:
CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector<double>* 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;
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());
/*< @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};
* 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_;
integral_[i] = integral;
}
-CpuTiTrace::~CpuTiTrace()
+CpuTiProfile::~CpuTiProfile()
{
delete[] time_points_;
delete [] integral_;
CpuTiTmgr::~CpuTiTmgr()
{
- delete trace_;
+ delete profile_;
}
/**
int b_index = static_cast<int>(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);
* @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);
}
* @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;
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 */
* @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);
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_;
}
* @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);
}
/* 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_);
}
* @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);
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);
/*********
* 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);
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();
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;
};
/**********
CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, std::vector<double>* 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;
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) {
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;
};
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);
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};
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");
}
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;
};
/**********
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) {
}
}
-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) {
class CpuL07 : public Cpu {
public:
- CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core);
+ CpuL07(CpuL07Model* model, s4u::Host* host, std::vector<double>* 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;
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;
};
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});
}
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;
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);
std::vector<simgrid::kernel::resource::Model*> 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<std::string> surf_path;
/** set of hosts for which one want to be notified if they ever restart. */
std::set<std::string> watched_hosts;
extern XBT_PRIVATE double sg_bandwidth_factor;
extern XBT_PRIVATE double sg_weight_S_parameter;
extern XBT_PRIVATE std::vector<std::string> surf_path;
-extern XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
+extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
extern XBT_PRIVATE std::set<std::string> watched_hosts;
static inline void double_update(double* variable, double value, double precision)
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf, "Surf trace management");
-namespace tmgr = simgrid::trace_mgr;
-
-static std::unordered_map<std::string, tmgr::trace*> trace_list;
+static std::unordered_map<std::string, simgrid::kernel::profile::Profile*> 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)
{
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<std::string> 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
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());
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);
}
/** @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)
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_;
return trace_iterator;
}
-
+} // namespace profile
+} // namespace kernel
+} // namespace simgrid
void tmgr_finalize()
{
for (auto const& kv : trace_list)
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;
/* 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"
/* 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
* 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 <timestamp, value> (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 <timestamp, value> (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;
};
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<DatedValue> 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<double, tmgr_trace_event_t> Qelt;
+ typedef std::pair<double, Event*> Qelt;
std::priority_queue<Qelt, std::vector<Qelt>, std::greater<Qelt>> heap_;
};
-}} // namespace simgrid::trace_mgr
+} // namespace profile
+} // namespace kernel
+} // namespace simgrid
-#endif /* SURF_TMGR_H */
+#endif /* SURF_PMGR_H */
#include <cmath>
namespace utf = boost::unit_test;
-namespace tmgr = simgrid::trace_mgr;
XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager");
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);
bool is_used() override { return true; }
};
-static void trace2vector(const char* str, std::vector<tmgr::DatedValue>* whereto)
+static void trace2vector(const char* str, std::vector<simgrid::kernel::profile::DatedValue>* 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<<data\n", str);
for (auto const& evt : trace->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);
}
}*/
BOOST_AUTO_TEST_CASE(one_evt_noloop)
{
- std::vector<tmgr::DatedValue> got;
+ std::vector<simgrid::kernel::profile::DatedValue> got;
trace2vector("9.0 3.0\n", &got);
- std::vector<tmgr::DatedValue> want;
- want.push_back(tmgr::DatedValue(9, 3));
+ std::vector<simgrid::kernel::profile::DatedValue> 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<tmgr::DatedValue> got;
+ std::vector<simgrid::kernel::profile::DatedValue> got;
trace2vector("3.0 1.0\n"
"9.0 3.0\n",
&got);
- std::vector<tmgr::DatedValue> want;
- want.push_back(tmgr::DatedValue(3, 1));
- want.push_back(tmgr::DatedValue(9, 3));
+ std::vector<simgrid::kernel::profile::DatedValue> 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<tmgr::DatedValue> got;
+ std::vector<simgrid::kernel::profile::DatedValue> got;
trace2vector("3.0 1.0\n"
"5.0 2.0\n"
"9.0 3.0\n",
&got);
- std::vector<tmgr::DatedValue> want;
- want.push_back(tmgr::DatedValue(3, 1));
- want.push_back(tmgr::DatedValue(5, 2));
- want.push_back(tmgr::DatedValue(9, 3));
+ std::vector<simgrid::kernel::profile::DatedValue> 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<tmgr::DatedValue> got;
+ std::vector<simgrid::kernel::profile::DatedValue> got;
trace2vector("1.0 1.0\n"
"3.0 3.0\n"
"LOOPAFTER 2\n",
&got);
- std::vector<tmgr::DatedValue> 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<simgrid::kernel::profile::DatedValue> 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<tmgr::DatedValue> got;
+ std::vector<simgrid::kernel::profile::DatedValue> got;
trace2vector("0.0 1\n"
"5.0 2\n"
"LOOPAFTER 5\n",
&got);
- std::vector<tmgr::DatedValue> 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<simgrid::kernel::profile::DatedValue> 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());
}
std::vector<double> 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<std::string, std::string>* properties = nullptr;
};
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<std::string, std::string>* properties = nullptr;
};
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 {
std::string name;
};
-class TraceCreationArgs {
+class ProfileCreationArgs {
public:
std::string id;
std::string file;
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);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
/* Trace related stuff */
-XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
+XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_host_avail;
XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_host_speed;
XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link_avail;
/* 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());
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());
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());
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);
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);
}
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;