};
Model();
+ Model(Model::UpdateAlgo algo);
+
virtual ~Model();
/** @brief Get the set of [actions](@ref Action) in *ready* state */
/** @brief Set the maxmin system of the current Model */
void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
- /**
- * @brief Get the update mechanism of the current Model
- * @see e_UM_t
- */
+ /** @brief Get the update mechanism of the current Model */
UpdateAlgo getUpdateMechanism() const { return update_mechanism_; }
void setUpdateMechanism(UpdateAlgo mechanism) { update_mechanism_ = mechanism; }
virtual void apply_event(TraceEvent* event, double value) = 0;
/** @brief Check if the current Resource is used (if it currently serves an action) */
- virtual bool isUsed() = 0;
+ virtual bool is_used() = 0;
/** @brief returns the current load (in flops per second, byte per second or similar) */
virtual double getLoad();
int getPstatesCount() const;
void setPstate(int pstate_index);
int getPstate();
- void getAttachedStorages(std::vector<const char*> * storages);
+ std::vector<const char*> get_attached_storages();
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages(
+ std::vector<const char*>* storages);
/** Get an associative list [mount point]->[Storage] of all local mount points.
*
#include <functional>
#include <initializer_list>
+#include <map>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <xbt/base.h>
#include <xbt/config.h>
+#include <xbt/sysdep.h>
namespace simgrid {
namespace config {
}
));
}
-
+template <class T, class F>
+typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+bindFlag(T& value, const char* name, const char* description, std::map<T, std::string> valid_values, F callback)
+{
+ declareFlag(name, description, value,
+ std::function<void(const T&)>([&value, name, valid_values, callback](const T& val) {
+ callback(val);
+ bool found = false;
+ for (auto kv : valid_values) {
+ if (kv.first == val)
+ found = true;
+ }
+ if (not found || std::string(val) == "help") {
+ std::string mesg;
+ if (std::string(val) == "help")
+ mesg = std::string("\nPossible values for option ") + name + ":\n";
+ else
+ mesg = std::string("\nInvalid value '") + val + "' for option " + name + ". Possible values:\n";
+ for (auto kv : valid_values)
+ mesg += " - '" + std::string(kv.first) + "': " + kv.second +
+ (kv.first == value ? " <=== DEFAULT" : "") + "\n";
+ xbt_die("%s", mesg.c_str());
+ }
+ value = std::move(val);
+ }));
+}
/** Bind a variable to configuration flag
*
* <pre><code>
* static int x;
- * simgrid::config::bindFlag(a, "x", [](int x) { return return x > 0; });
+ * simgrid::config::bindFlag(a, "x", [](int x) { return x > 0; });
* </code></pre>
*/
// F is a predicate, F : T const& -> bool
declareFlag(name, description, value,
std::function<void(const T&)>([&value, callback](const T& val) {
if (not callback(val))
- throw std::range_error("invalid value");
+ throw std::range_error("invalid value.");
value = std::move(val);
})
);
*
* <pre><code>
* static simgrid::config::flag<int> answer("answer", "Expected answer", 42);
- * static simgrid::config::flag<std::string> name("name", "Ford Prefect", "John Doe");
+ * static simgrid::config::flag<std::string> name("name", "Ford Perfect", "John Doe");
* static simgrid::config::flag<double> gamma("gamma", "Gamma factor", 1.987);
* </code></pre>
*/
simgrid::config::bindFlag(value_, name, desc);
}
+ /* A constructor accepting a callback that will be passed the parameter.
+ * It can either return a boolean (informing whether the parameter is valid), or returning void.
+ */
template<class F>
Flag(const char* name, const char* desc, T value, F callback) : value_(value)
{
simgrid::config::bindFlag(value_, name, desc, std::move(callback));
}
+ /* A constructor accepting a map of valid values -> their description,
+ * and producing an informative error message when an invalid value is passed, or when help is passed as a value.
+ */
+ template <class F>
+ Flag(const char* name, const char* desc, T value, std::map<T, std::string> valid_values, F callback) : value_(value)
+ {
+ simgrid::config::bindFlag(value_, name, desc, std::move(valid_values), std::move(callback));
+ }
+
// No copy:
Flag(Flag const&) = delete;
Flag& operator=(Flag const&) = delete;
void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve()
{
- if (not modified)
+ if (not modified_)
return;
XBT_DEBUG("Variable set : %zu", variable_set.size());
} while (not var_list.empty());
cnst_list.clear();
- modified = true;
+ modified_ = true;
if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
XBT_DEBUG("Fair bottleneck done");
print();
print();
}
- if (not modified)
+ if (not modified_)
return;
/* Initialize lambda. */
void System::var_free(Variable* var)
{
XBT_IN("(sys=%p, var=%p)", this, var);
- modified = true;
+ modified_ = true;
// TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
// update_modified_set, and then remove it..
check_concurrency();
- xbt_mallocator_release(variable_mallocator, var);
+ xbt_mallocator_release(variable_mallocator_, var);
XBT_OUT();
}
System::System(bool selective_update) : selective_update_active(selective_update)
{
- modified = false;
- visited_counter = 1;
-
XBT_DEBUG("Setting selective_update_active flag to %d", selective_update_active);
- variable_mallocator =
- xbt_mallocator_new(65536, System::variable_mallocator_new_f, System::variable_mallocator_free_f, nullptr);
+ if (selective_update)
+ modified_set_ = new kernel::resource::Action::ModifiedSet();
}
System::~System()
while ((cnst = extract_constraint()))
cnst_free(cnst);
- xbt_mallocator_free(variable_mallocator);
+ xbt_mallocator_free(variable_mallocator_);
delete modified_set_;
}
{
XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", this, id, sharing_weight, bound, number_of_constraints);
- Variable* var = static_cast<Variable*>(xbt_mallocator_get(variable_mallocator));
- var->initialize(id, sharing_weight, bound, number_of_constraints, visited_counter - 1);
+ Variable* var = static_cast<Variable*>(xbt_mallocator_get(variable_mallocator_));
+ var->initialize(id, sharing_weight, bound, number_of_constraints, visited_counter_ - 1);
if (sharing_weight)
variable_set.push_front(*var);
else
void System::expand(Constraint* cnst, Variable* var, double consumption_weight)
{
- modified = true;
+ modified_ = true;
// Check if this variable already has an active element in this constraint
// If it does, substract it from the required slack
void System::expand_add(Constraint* cnst, Variable* var, double value)
{
- modified = true;
+ modified_ = true;
check_concurrency();
void System::lmm_solve()
{
- if (modified) {
+ if (modified_) {
XBT_IN("(sys=%p)", this);
/* Compute Usage and store the variables that reach the maximum. If selective_update_active is true, only
* constraints that changed are considered. Otherwise all constraints with active actions are considered.
} while (cnst_light_num > 0);
- modified = false;
+ modified_ = false;
if (selective_update_active)
remove_all_modified_set();
*/
void System::update_variable_bound(Variable* var, double bound)
{
- modified = true;
+ modified_ = true;
var->bound = bound;
if (not var->cnsts.empty())
XBT_IN("(sys=%p, var=%p, weight=%f)", this, var, weight);
- modified = true;
+ modified_ = true;
// Are we enabling this variable?
if (enabling_var) {
void System::update_constraint_bound(Constraint* cnst, double bound)
{
- modified = true;
+ modified_ = true;
update_modified_set(cnst);
cnst->bound = bound;
}
for (Element const& elem : cnst->enabled_element_set) {
Variable* var = elem.variable;
for (Element const& elem2 : var->cnsts) {
- if (var->visited == visited_counter)
+ if (var->visited == visited_counter_)
break;
if (elem2.constraint != cnst && not elem2.constraint->modified_constraint_set_hook.is_linked()) {
modified_constraint_set.push_back(*elem2.constraint);
}
}
// var will be ignored in later visits as long as sys->visited_counter does not move
- var->visited = visited_counter;
+ var->visited = visited_counter_;
}
}
// To be clean, when visited counter has wrapped around, we force these var->visited values so that variables that
// were in the modified a long long time ago are not wrongly skipped here, which would lead to very nasty bugs
// (i.e. not readibily reproducible, and requiring a lot of run time before happening).
- if (++visited_counter == 1) {
+ if (++visited_counter_ == 1) {
/* the counter wrapped around, reset each variable->visited */
for (Variable& var : variable_set)
var.visited = 0;
template <class CnstList> void lmm_solve(CnstList& cnst_list);
public:
- bool modified;
+ bool modified_ = false;
boost::intrusive::list<Variable, boost::intrusive::member_hook<Variable, boost::intrusive::list_member_hook<>,
&Variable::variable_set_hook>>
variable_set;
private:
bool selective_update_active; /* flag to update partially the system only selecting changed portions */
- unsigned visited_counter; /* used by System::update_modified_set() and System::remove_all_modified_set() to
- * cleverly (un-)flag the constraints (more details in these functions) */
+ unsigned visited_counter_ = 1; /* used by System::update_modified_set() and System::remove_all_modified_set() to
+ * cleverly (un-)flag the constraints (more details in these functions) */
boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
&Constraint::constraint_set_hook>>
constraint_set;
boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
&Constraint::modified_constraint_set_hook>>
modified_constraint_set;
- xbt_mallocator_t variable_mallocator;
+ xbt_mallocator_t variable_mallocator_ =
+ xbt_mallocator_new(65536, System::variable_mallocator_new_f, System::variable_mallocator_free_f, nullptr);
+ ;
};
class XBT_PUBLIC FairBottleneck : public System {
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (get_variable())
get_model()->get_maxmin_system()->variable_free(get_variable());
- if (get_model()->getUpdateMechanism() == Model::UpdateAlgo::Lazy) {
- /* remove from heap */
- heapRemove();
- if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
- }
+
+ /* remove from heap on need (ie, if selective update) */
+ heapRemove();
+ if (modified_set_hook_.is_linked())
+ simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
xbt_free(category_);
}
namespace resource {
Model::Model() = default;
+Model::Model(Model::UpdateAlgo algo) : update_mechanism_(algo) {}
Model::~Model()
{
}
/* 2. Calculate resource share at the virtual machine layer. */
- ignoreEmptyVmInPmLMM();
+ ignore_empty_vm_in_pm_LMM();
/* 3. Ready. Get the next occurring event */
return surf_cpu_model_vm->next_occuring_event(now);
class XBT_PRIVATE VMModel : public surf::HostModel {
public:
VMModel();
- void ignoreEmptyVmInPmLMM() override{};
+ void ignore_empty_vm_in_pm_LMM() override{};
double next_occuring_event(double now) override;
void update_actions_state(double /*now*/, double /*delta*/) override{};
* \brief Returns the list of storages attached to an host.
* \return a vector containing all storages attached to the host
*/
+std::vector<const char*> Host::get_attached_storages()
+{
+ return simgrid::simix::kernelImmediate([this] { return this->pimpl_->get_attached_storages(); });
+}
+
void Host::getAttachedStorages(std::vector<const char*>* storages)
{
- simgrid::simix::kernelImmediate([this, storages] {
- this->pimpl_->getAttachedStorageList(storages);
- });
+ std::vector<const char*> local_storages =
+ simgrid::simix::kernelImmediate([this] { return this->pimpl_->get_attached_storages(); });
+ for (auto elm : local_storages)
+ storages->push_back(elm);
}
std::unordered_map<std::string, Storage*> const& Host::getMountedStorages()
}
bool Link::isUsed()
{
- return this->pimpl_->isUsed();
+ return this->pimpl_->is_used();
}
double Link::latency()
if(task->bytes_amount)
std::copy_n(task->bytes_amount, host_nb * host_nb, bytes_amount);
- task->surf_action = surf_host_model->executeParallelTask(host_nb, hosts, flops_amount, bytes_amount, task->rate);
+ task->surf_action = surf_host_model->execute_parallel(host_nb, hosts, flops_amount, bytes_amount, task->rate);
task->surf_action->set_data(task);
}
xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host){
- std::vector<const char*>* storage_vector = new std::vector<const char*>();
xbt_dynar_t storage_dynar = xbt_dynar_new(sizeof(const char*), nullptr);
- host->getAttachedStorages(storage_vector);
- for (auto const& name : *storage_vector)
+ std::vector<const char*> storage_vector = host->get_attached_storages();
+ for (auto const& name : storage_vector)
xbt_dynar_push(storage_dynar, &name);
- delete storage_vector;
return storage_dynar;
}
double sg_host_get_available_speed(sg_host_t host)
{
- return host->pimpl_cpu->getAvailableSpeed();
+ return host->pimpl_cpu->get_available_speed();
}
/** @brief Returns the number of power states for a host.
describe_model(description, descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
xbt_cfg_register_string("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, description);
- describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
- "The optimization modes to use for the CPU");
- xbt_cfg_register_string("cpu/optim", "Lazy", &_sg_cfg_cb__optimization_mode, description);
-
describe_model(description, descsize, surf_storage_model_description, "model", "The model to use for the storage");
xbt_cfg_register_string("storage/model", "default", &_sg_cfg_cb__storage_mode, description);
/* set surf's synchro */
sg_host_t* host_list_cpy = new sg_host_t[host_nb];
std::copy_n(host_list, host_nb, host_list_cpy);
- exec->surfAction_ = surf_host_model->executeParallelTask(host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
+ exec->surfAction_ = surf_host_model->execute_parallel(host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
exec->surfAction_->set_data(exec.get());
if (timeout > 0) {
exec->timeoutDetector = host_list[0]->pimpl_cpu->sleep(timeout);
/* smpi_coll.c -- various optimized routing for collectives */
-/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved. */
/* 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. */
#include "smpi_datatype.hpp"
#include "smpi_op.hpp"
#include "smpi_request.hpp"
+#include "xbt/config.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
#include <string>
#include <vector>
#include <xbt/Extendable.hpp>
-#include <xbt/config.hpp>
namespace simgrid {
namespace smpi {
#ifndef SMPI_PRIVATE_HPP
#define SMPI_PRIVATE_HPP
-#include "include/xbt/config.hpp"
#include "simgrid/msg.h" // msg_bar_t
#include "smpi/smpi.h"
#include "src/instr/instr_smpi.hpp"
-/* Copyright (c) 2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2018. The SimGrid Team. All rights reserved. */
/* 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. */
#include "SmpiHost.hpp"
#include "simgrid/s4u/VirtualMachine.hpp"
#include "smpi_utils.hpp"
+#include "xbt/config.hpp"
#include <string>
#include <vector>
#include "src/internal_config.h"
#include "src/mc/mc_replay.hpp"
#include "src/simix/ActorImpl.hpp"
+#include "xbt/config.hpp"
+
#include <unordered_map>
#ifndef WIN32
#include <cstring>
#include "private.hpp"
+#include "xbt/config.hpp"
+
#include <cerrno>
#include <sys/types.h>
#include "src/kernel/activity/CommImpl.hpp"
#include "src/mc/mc_replay.hpp"
#include "src/simix/ActorImpl.hpp"
+#include "xbt/config.hpp"
#include <algorithm>
/* Each VM has a dummy CPU action on the PM layer. This CPU action works as the constraint (capacity) of the VM in the
* PM layer. If the VM does not have any active task, the dummy CPU action must be deactivated, so that the VM does not
* get any CPU share in the PM layer. */
-void HostModel::ignoreEmptyVmInPmLMM()
+void HostModel::ignore_empty_vm_in_pm_LMM()
{
/* iterate for all virtual machines */
for (s4u::VirtualMachine* const& ws_vm : vm::VirtualMachineImpl::allVms_) {
return -1.0;
}
-kernel::resource::Action* HostModel::executeParallelTask(int host_nb, s4u::Host** host_list, double* flops_amount,
- double* bytes_amount, double rate)
+kernel::resource::Action* HostModel::execute_parallel(int host_nb, s4u::Host** host_list, double* flops_amount,
+ double* bytes_amount, double rate)
{
kernel::resource::Action* action = nullptr;
if ((host_nb == 1) && (has_cost(bytes_amount, 0) <= 0)) {
piface_->pimpl_ = this;
}
-void HostImpl::getAttachedStorageList(std::vector<const char*>* storages)
+std::vector<const char*> HostImpl::get_attached_storages()
{
+ std::vector<const char*> storages;
for (auto const& s : storage_)
if (s.second->getHost() == piface_->getCname())
- storages->push_back(s.second->piface_.getCname());
+ storages.push_back(s.second->piface_.getCname());
+ return storages;
}
}
public:
HostModel() : Model() {}
- virtual void ignoreEmptyVmInPmLMM();
- virtual kernel::resource::Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount,
- double* bytes_amount, double rate);
+ virtual void ignore_empty_vm_in_pm_LMM();
+ virtual kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
+ double* bytes_amount, double rate);
};
/************
virtual ~HostImpl() = default;
/** @brief Get the vector of storages (by names) attached to the Host */
- virtual void getAttachedStorageList(std::vector<const char*>* storages);
+ virtual std::vector<const char*> get_attached_storages();
std::map<std::string, simgrid::surf::StorageImpl*> storage_;
simgrid::s4u::Host* piface_ = nullptr;
storageDestructedCallbacks(this);
}
-bool StorageImpl::isUsed()
+bool StorageImpl::is_used()
{
THROW_UNIMPLEMENTED;
return false;
s4u::Storage piface_;
/** @brief Check if the Storage is used (if an action currently uses its resources) */
- bool isUsed() override;
+ bool is_used() override;
void apply_event(tmgr_trace_event_t event, double value) override;
* @brief StorageAction constructor
*
* @param model The StorageModel associated to this StorageAction
- * @param cost The cost of this NetworkAction in [TODO]
+ * @param cost The cost of this StorageAction in bytes
* @param failed [description]
* @param storage The Storage associated to this StorageAction
* @param type [description]
#include "cpu_ti.hpp"
#include "simgrid/sg_config.hpp"
#include "src/kernel/lmm/maxmin.hpp"
+#include "xbt/config.hpp"
#include "xbt/utility.hpp"
+
#include <algorithm>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU IMPROVED module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU module");
+
+/***********
+ * Options *
+ ***********/
+
+static simgrid::config::Flag<std::string>
+ cpu_optim_opt("cpu/optim", "Optimization algorithm to use for CPU resources. ", "Lazy",
+
+ std::map<std::string, std::string>({
+ {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining)."},
+ {"TI", "Trace integration. Highly optimized mode when using availability traces (only available "
+ "for the Cas01 CPU model for now)."},
+ {"Full", "Full update of remaining and variables. Slow but may be useful when debugging."},
+ }),
+
+ [](std::string const& val) {
+ xbt_assert(_sg_cfg_init_status < 2,
+ "Cannot change the optimization algorithm after the initialization");
+ });
/*********
* Model *
xbt_assert(not surf_cpu_model_pm);
xbt_assert(not surf_cpu_model_vm);
- if (xbt_cfg_get_string("cpu/optim") == "TI") {
+ if (cpu_optim_opt == "TI") {
surf_cpu_model_init_ti();
return;
}
- surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
+ simgrid::kernel::resource::Model::UpdateAlgo algo;
+ if (cpu_optim_opt == "Lazy")
+ algo = simgrid::kernel::resource::Model::UpdateAlgo::Lazy;
+ else
+ algo = simgrid::kernel::resource::Model::UpdateAlgo::Full;
+
+ surf_cpu_model_pm = new simgrid::surf::CpuCas01Model(algo);
all_existing_models->push_back(surf_cpu_model_pm);
- surf_cpu_model_vm = new simgrid::surf::CpuCas01Model();
+ surf_cpu_model_vm = new simgrid::surf::CpuCas01Model(algo);
all_existing_models->push_back(surf_cpu_model_vm);
}
namespace simgrid {
namespace surf {
-CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
+CpuCas01Model::CpuCas01Model(kernel::resource::Model::UpdateAlgo algo) : simgrid::surf::CpuModel(algo)
{
- std::string optim = xbt_cfg_get_string("cpu/optim");
bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");
- if (optim == "Full") {
- setUpdateMechanism(Model::UpdateAlgo::Full);
- } else if (optim == "Lazy") {
+ if (algo == Model::UpdateAlgo::Lazy) {
xbt_assert(select || xbt_cfg_is_default_value("cpu/maxmin-selective-update"),
"You cannot disable cpu selective update when using the lazy update mechanism");
- setUpdateMechanism(Model::UpdateAlgo::Lazy);
select = true;
- } else {
- xbt_die("Unsupported optimization (%s) for this model", optim.c_str());
}
set_maxmin_system(new simgrid::kernel::lmm::System(select));
-
- if (getUpdateMechanism() == Model::UpdateAlgo::Lazy)
- get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
}
CpuCas01Model::~CpuCas01Model()
return &speedPerPstate_;
}
-bool CpuCas01::isUsed()
+bool CpuCas01::is_used()
{
return model()->get_maxmin_system()->constraint_used(constraint());
}
class CpuCas01Model : public simgrid::surf::CpuModel {
public:
- CpuCas01Model();
+ CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
~CpuCas01Model() override;
Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
CpuAction* execution_start(double size, int requestedCore) override;
CpuAction* sleep(double duration) override;
- bool isUsed() override;
+ bool is_used() override;
std::vector<double> * getSpeedPeakList(); // FIXME: killme to hide our internals
return load * speed_.peak;
}
-double Cpu::getAvailableSpeed()
+double Cpu::get_available_speed()
{
/* number between 0 and 1 */
return speed_.scale;
stateEvent_ = future_evt_set->add_trace(trace, this);
}
-void Cpu::setSpeedTrace(tmgr_trace_t trace)
+void Cpu::set_speed_trace(tmgr_trace_t trace)
{
xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", host_->getCname());
*/
class XBT_PUBLIC CpuModel : public kernel::resource::Model {
public:
+ CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
+ CpuModel() : Model() {}
+
/**
* @brief Create a Cpu
*
public:
/** @brief Get the available speed of the current Cpu */
- virtual double getAvailableSpeed();
+ virtual double get_available_speed();
/** @brief Get the current Cpu computational speed */
virtual double getPstateSpeed(int pstate_index);
int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values (0 or 1). */
- virtual void setSpeedTrace(tmgr_trace_t trace); /*< 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); /*< setup the trace file with availability events (peak speed changes due to
+ external load). Trace must contain relative values (ratio between 0 and 1) */
tmgr_trace_event_t stateEvent_ = nullptr;
Metric speed_ = {1.0, 0, nullptr};
double integral = 0;
double time = 0;
int i = 0;
- nbPoints_ = speedTrace->event_list.size() + 1;
- timePoints_ = new double[nbPoints_];
- integral_ = new double[nbPoints_];
+ nb_points_ = speedTrace->event_list.size() + 1;
+ time_points_ = new double[nb_points_];
+ integral_ = new double[nb_points_];
for (auto const& val : speedTrace->event_list) {
- timePoints_[i] = time;
+ time_points_[i] = time;
integral_[i] = integral;
integral += val.date_ * val.value_;
time += val.date_;
i++;
}
- timePoints_[i] = time;
+ time_points_[i] = time;
integral_[i] = integral;
}
CpuTiTrace::~CpuTiTrace()
{
- delete [] timePoints_;
+ delete[] time_points_;
delete [] integral_;
}
return ((b - a) * value_);
}
- if (fabs(ceil(a / lastTime_) - a / lastTime_) < EPSILON)
- a_index = 1 + static_cast<int>(ceil(a / lastTime_));
+ if (fabs(ceil(a / last_time_) - a / last_time_) < EPSILON)
+ a_index = 1 + static_cast<int>(ceil(a / last_time_));
else
- a_index = static_cast<int> (ceil(a / lastTime_));
+ a_index = static_cast<int>(ceil(a / last_time_));
- int b_index = static_cast<int> (floor(b / lastTime_));
+ int b_index = static_cast<int>(floor(b / last_time_));
if (a_index > b_index) { /* Same chunk */
- return trace_->integrateSimple(a - (a_index - 1) * lastTime_, b - (b_index) * lastTime_);
+ return trace_->integrate_simple(a - (a_index - 1) * last_time_, b - (b_index)*last_time_);
}
- double first_chunk = trace_->integrateSimple(a - (a_index - 1) * lastTime_, lastTime_);
+ double first_chunk = trace_->integrate_simple(a - (a_index - 1) * last_time_, last_time_);
double middle_chunk = (b_index - a_index) * total_;
- double last_chunk = trace_->integrateSimple(0.0, b - (b_index) * lastTime_);
+ double last_chunk = trace_->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::integrateSimple(double a, double b)
+double CpuTiTrace::integrate_simple(double a, double b)
{
- return integrateSimplePoint(b) - integrateSimplePoint(a);
+ return integrate_simple_point(b) - integrate_simple_point(a);
}
/**
* \brief Auxiliary function to compute the integral at point a.
* \param a point
*/
-double CpuTiTrace::integrateSimplePoint(double a)
+double CpuTiTrace::integrate_simple_point(double a)
{
double integral = 0;
double a_aux = a;
- int ind = binarySearch(timePoints_, a, 0, nbPoints_ - 1);
+ int ind = binary_search(time_points_, a, 0, nb_points_ - 1);
integral += integral_[ind];
- XBT_DEBUG("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f",
- a, ind, integral, integral_[ind + 1], integral_[ind], timePoints_[ind + 1], timePoints_[ind]);
- double_update(&a_aux, timePoints_[ind], sg_maxmin_precision*sg_surf_precision);
+ XBT_DEBUG("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f", a, ind, integral, integral_[ind + 1],
+ integral_[ind], time_points_[ind + 1], time_points_[ind]);
+ double_update(&a_aux, time_points_[ind], sg_maxmin_precision * sg_surf_precision);
if (a_aux > 0)
- integral += ((integral_[ind + 1] - integral_[ind]) / (timePoints_[ind + 1] - timePoints_[ind])) *
- (a - timePoints_[ind]);
+ integral +=
+ ((integral_[ind + 1] - integral_[ind]) / (time_points_[ind + 1] - time_points_[ind])) * (a - time_points_[ind]);
XBT_DEBUG("Integral a %f = %f", a, integral);
return integral;
/* Reduce the problem to one where amount <= trace_total */
int quotient = static_cast<int>(floor(amount / total_));
double reduced_amount = (total_) * ((amount / total_) - floor(amount / total_));
- double reduced_a = a - (lastTime_) * static_cast<int>(floor(a / lastTime_));
+ double reduced_a = a - (last_time_) * static_cast<int>(floor(a / last_time_));
XBT_DEBUG("Quotient: %d reduced_amount: %f reduced_a: %f", quotient, reduced_amount, reduced_a);
/* Now solve for new_amount which is <= trace_total */
- double reduced_b = solveSomewhatSimple(reduced_a, reduced_amount);
+ double reduced_b;
+ XBT_DEBUG("Solve integral: [%.2f, amount=%.2f]", reduced_a, reduced_amount);
+ double amount_till_end = integrate(reduced_a, last_time_);
-/* Re-map to the original b and amount */
- double b = (lastTime_) * static_cast<int>(floor(a / lastTime_)) + (quotient * lastTime_) + reduced_b;
- return b;
-}
-
-/**
-* \brief Auxiliary function to solve integral
-*
-* Here, amount is <= trace->total
-* and a <=trace->last_time
-*
-*/
-double CpuTiTgmr::solveSomewhatSimple(double a, double amount)
-{
- double b;
-
- XBT_DEBUG("Solve integral: [%.2f, amount=%.2f]", a, amount);
- double amount_till_end = integrate(a, lastTime_);
-
- if (amount_till_end > amount) {
- b = trace_->solveSimple(a, amount);
+ if (amount_till_end > reduced_amount) {
+ reduced_b = trace_->solve_simple(reduced_a, reduced_amount);
} else {
- b = lastTime_ + trace_->solveSimple(0.0, amount - amount_till_end);
+ reduced_b = last_time_ + trace_->solve_simple(0.0, reduced_amount - amount_till_end);
}
- return b;
+
+ /* Re-map to the original b and amount */
+ return (last_time_) * static_cast<int>(floor(a / last_time_)) + (quotient * last_time_) + reduced_b;
}
/**
* \param amount Amount of flops
* \return The date when amount is available.
*/
-double CpuTiTrace::solveSimple(double a, double amount)
+double CpuTiTrace::solve_simple(double a, double amount)
{
- double integral_a = integrateSimplePoint(a);
- int ind = binarySearch(integral_, integral_a + amount, 0, nbPoints_ - 1);
- double time = timePoints_[ind];
+ double integral_a = integrate_simple_point(a);
+ int ind = binary_search(integral_, integral_a + amount, 0, nb_points_ - 1);
+ double time = time_points_[ind];
time += (integral_a + amount - integral_[ind]) /
- ((integral_[ind + 1] - integral_[ind]) / (timePoints_[ind + 1] - timePoints_[ind]));
+ ((integral_[ind + 1] - integral_[ind]) / (time_points_[ind + 1] - time_points_[ind]));
return time;
}
* \param a Time
* \return CPU speed scale
*/
-double CpuTiTgmr::getPowerScale(double a)
+double CpuTiTgmr::get_power_scale(double a)
{
- double reduced_a = a - floor(a / lastTime_) * lastTime_;
- int point = trace_->binarySearch(trace_->timePoints_, reduced_a, 0, trace_->nbPoints_ - 1);
- trace_mgr::DatedValue val = speedTrace_->event_list.at(point);
+ 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);
return val.value_;
}
* \param value Percentage of CPU speed available (useful to fixed tracing)
* \return Integration trace structure
*/
-CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value) :
- speedTrace_(speedTrace)
+CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value) : speed_trace_(speedTrace)
{
double total_time = 0.0;
trace_ = 0;
total_time += val.date_;
trace_ = new CpuTiTrace(speedTrace);
- lastTime_ = total_time;
- total_ = trace_->integrateSimple(0, total_time);
+ last_time_ = total_time;
+ total_ = trace_->integrate_simple(0, total_time);
- XBT_DEBUG("Total integral %f, last_time %f ", total_, lastTime_);
+ 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::binarySearch(double *array, double a, int low, int high)
+int CpuTiTrace::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);
double min_action_duration = -1;
/* iterates over modified cpus to update share resources */
- for (auto it = std::begin(modifiedCpu_); it != std::end(modifiedCpu_);) {
+ for (auto it = std::begin(modified_cpus_); it != std::end(modified_cpus_);) {
CpuTi& ti = *it;
++it; // increment iterator here since the following call to ti.updateActionsFinishTime() may invalidate it
- ti.updateActionsFinishTime(now);
+ ti.update_actions_finish_time(now);
}
/* get the min next event if heap not empty */
XBT_DEBUG("Action %p: finish", action);
action->finish(kernel::resource::Action::State::done);
/* update remaining amount of all actions */
- action->cpu_->updateRemainingAmount(surf_get_clock());
+ action->cpu_->update_remaining_amount(surf_get_clock());
}
}
CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
: Cpu(model, host, speedPerPstate, core)
{
- xbt_assert(core==1,"Multi-core not handled by this model yet");
- coresAmount_ = core;
+ xbt_assert(core == 1, "Multi-core not handled by this model yet");
speed_.peak = speedPerPstate->front();
XBT_DEBUG("CPU create: peak=%f", speed_.peak);
- speedIntegratedTrace_ = new CpuTiTgmr(nullptr, 1/*scale*/);
+ speed_integrated_trace_ = new CpuTiTgmr(nullptr, 1 /*scale*/);
}
CpuTi::~CpuTi()
{
- modified(false);
- delete speedIntegratedTrace_;
+ set_modified(false);
+ delete speed_integrated_trace_;
}
-void CpuTi::setSpeedTrace(tmgr_trace_t trace)
+void CpuTi::set_speed_trace(tmgr_trace_t trace)
{
- if (speedIntegratedTrace_)
- delete speedIntegratedTrace_;
+ if (speed_integrated_trace_)
+ delete speed_integrated_trace_;
- speedIntegratedTrace_ = new CpuTiTgmr(trace, speed_.scale);
+ speed_integrated_trace_ = new CpuTiTgmr(trace, speed_.scale);
/* add a fake trace event if periodicity == 0 */
if (trace && trace->event_list.size() > 1) {
XBT_DEBUG("Finish trace date: value %f", value);
/* update remaining of actions and put in modified cpu list */
- updateRemainingAmount(surf_get_clock());
+ update_remaining_amount(surf_get_clock());
- modified(true);
+ set_modified(true);
- speedTrace = speedIntegratedTrace_->speedTrace_;
+ speedTrace = speed_integrated_trace_->speed_trace_;
trace_mgr::DatedValue val = speedTrace->event_list.back();
- delete speedIntegratedTrace_;
+ delete speed_integrated_trace_;
speed_.scale = val.value_;
trace = new CpuTiTgmr(TRACE_FIXED, val.value_);
XBT_DEBUG("value %f", val.value_);
- speedIntegratedTrace_ = trace;
+ speed_integrated_trace_ = trace;
tmgr_trace_event_unref(&speed_.event);
double date = surf_get_clock();
/* put all action running on cpu to failed */
- for (CpuTiAction& action : actionSet_) {
+ for (CpuTiAction& action : action_set_) {
if (action.get_state() == kernel::resource::Action::State::running ||
action.get_state() == kernel::resource::Action::State::ready ||
action.get_state() == kernel::resource::Action::State::not_in_the_system) {
}
}
-void CpuTi::updateActionsFinishTime(double now)
+/** Update the actions that are running on this CPU (which was modified recently) */
+void CpuTi::update_actions_finish_time(double now)
{
- double sum_priority = 0.0;
- double total_area;
-
/* update remaining amount of actions */
- updateRemainingAmount(now);
+ update_remaining_amount(now);
- for (CpuTiAction const& action : actionSet_) {
+ /* Compute the sum of priorities for the actions running on that CPU */
+ sum_priority_ = 0.0;
+ for (CpuTiAction const& action : action_set_) {
/* action not running, skip it */
if (action.get_state_set() != surf_cpu_model_pm->get_running_action_set())
continue;
if (action.suspended_ != kernel::resource::Action::SuspendStates::not_suspended)
continue;
- sum_priority += 1.0 / action.get_priority();
+ sum_priority_ += 1.0 / action.get_priority();
}
- sumPriority_ = sum_priority;
- for (CpuTiAction& action : actionSet_) {
+ for (CpuTiAction& action : action_set_) {
double min_finish = -1;
/* action not running, skip it */
if (action.get_state_set() != surf_cpu_model_pm->get_running_action_set())
/* verify if the action is really running on cpu */
if (action.suspended_ == kernel::resource::Action::SuspendStates::not_suspended && action.get_priority() > 0) {
/* total area needed to finish the action. Used in trace integration */
- total_area = (action.get_remains()) * sum_priority * action.get_priority();
-
- total_area /= speed_.peak;
+ double total_area = (action.get_remains() * sum_priority_ * action.get_priority()) / speed_.peak;
- action.set_finish_time(speedIntegratedTrace_->solve(now, total_area));
+ action.set_finish_time(speed_integrated_trace_->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
if (action.get_max_duration() > NO_MAX_DURATION &&
action.get_start_time() + action.get_max_duration() < action.get_finish_time())
&action, action.get_start_time(), action.get_finish_time(), action.get_max_duration());
}
/* remove from modified cpu */
- modified(false);
+ set_modified(false);
}
-bool CpuTi::isUsed()
+bool CpuTi::is_used()
{
- return not actionSet_.empty();
+ return not action_set_.empty();
}
-double CpuTi::getAvailableSpeed()
+double CpuTi::get_available_speed()
{
- speed_.scale = speedIntegratedTrace_->getPowerScale(surf_get_clock());
- return Cpu::getAvailableSpeed();
+ speed_.scale = speed_integrated_trace_->get_power_scale(surf_get_clock());
+ return Cpu::get_available_speed();
}
/** @brief Update the remaining amount of actions */
-void CpuTi::updateRemainingAmount(double now)
+void CpuTi::update_remaining_amount(double now)
{
/* already updated */
- if (lastUpdate_ >= now)
+ if (last_update_ >= now)
return;
/* compute the integration area */
- double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak;
- XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
- for (CpuTiAction& action : actionSet_) {
+ double area_total = speed_integrated_trace_->integrate(last_update_, now) * speed_.peak;
+ XBT_DEBUG("Flops total: %f, Last update %f", area_total, last_update_);
+ for (CpuTiAction& action : action_set_) {
/* action not running, skip it */
if (action.get_state_set() != model()->get_running_action_set())
continue;
continue;
/* update remaining */
- action.update_remains(area_total / (sumPriority_ * action.get_priority()));
+ action.update_remains(area_total / (sum_priority_ * action.get_priority()));
XBT_DEBUG("Update remaining action(%p) remaining %f", &action, action.get_remains_no_update());
}
- lastUpdate_ = now;
+ last_update_ = now;
}
CpuAction *CpuTi::execution_start(double size)
XBT_IN("(%s,%g)", getCname(), size);
CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), size, isOff(), this);
- actionSet_.push_back(*action);
+ action_set_.push_back(*action);
XBT_OUT();
return action;
action->get_state_set()->push_back(*action);
}
- actionSet_.push_back(*action);
+ action_set_.push_back(*action);
XBT_OUT();
return action;
}
-void CpuTi::modified(bool modified){
- CpuTiList& modifiedCpu = static_cast<CpuTiModel*>(model())->modifiedCpu_;
+void CpuTi::set_modified(bool modified)
+{
+ CpuTiList& modifiedCpu = static_cast<CpuTiModel*>(model())->modified_cpus_;
if (modified) {
if (not cpu_ti_hook.is_linked()) {
modifiedCpu.push_back(*this);
: CpuAction(model_, cost, failed)
, cpu_(cpu)
{
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
CpuTiAction::~CpuTiAction()
{
/* remove from action_set */
if (action_ti_hook.is_linked())
- simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
+ simgrid::xbt::intrusive_erase(cpu_->action_set_, *this);
/* remove from heap */
heapRemove();
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
void CpuTiAction::set_state(Action::State state)
{
CpuAction::set_state(state);
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
void CpuTiAction::cancel()
{
this->set_state(Action::State::failed);
heapRemove();
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
void CpuTiAction::suspend()
if (suspended_ != Action::SuspendStates::sleeping) {
suspended_ = Action::SuspendStates::suspended;
heapRemove();
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
XBT_OUT();
}
XBT_IN("(%p)", this);
if (suspended_ != Action::SuspendStates::sleeping) {
suspended_ = Action::SuspendStates::not_suspended;
- cpu_->modified(true);
+ cpu_->set_modified(true);
}
XBT_OUT();
}
{
XBT_IN("(%p,%g)", this, priority);
set_priority_no_update(priority);
- cpu_->modified(true);
+ cpu_->set_modified(true);
XBT_OUT();
}
double CpuTiAction::get_remains()
{
XBT_IN("(%p)", this);
- cpu_->updateRemainingAmount(surf_get_clock());
+ cpu_->update_remaining_amount(surf_get_clock());
XBT_OUT();
return get_remains_no_update();
}
/***********
* Classes *
***********/
-class XBT_PRIVATE CpuTiTrace;
-class XBT_PRIVATE CpuTiTgmr;
class XBT_PRIVATE CpuTiModel;
class XBT_PRIVATE CpuTi;
-class XBT_PRIVATE CpuTiAction;
-
-struct tiTag;
/*********
* Trace *
explicit CpuTiTrace(tmgr_trace_t speedTrace);
~CpuTiTrace();
- double integrateSimple(double a, double b);
- double integrateSimplePoint(double a);
- double solveSimple(double a, double amount);
+ double integrate_simple(double a, double b);
+ double integrate_simple_point(double a);
+ double solve_simple(double a, double amount);
- double *timePoints_;
+ double* time_points_;
double *integral_;
- int nbPoints_;
- int binarySearch(double *array, double a, int low, int high);
+ int nb_points_;
+ int binary_search(double* array, double a, int low, int high);
};
enum trace_type {
double integrate(double a, double b);
double solve(double a, double amount);
- double solveSomewhatSimple(double a, double amount);
- double getPowerScale(double a);
+ double get_power_scale(double a);
trace_type type_;
double value_; /*< Percentage of cpu speed available. Value fixed between 0 and 1 */
/* Dynamic */
- double lastTime_ = 0.0; /*< Integral interval last point (discrete time) */
+ 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 speedTrace_ = nullptr;
+ tmgr_trace_t speed_trace_ = nullptr;
};
/**********
************/
class CpuTi : public Cpu {
public:
- CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
+ CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core);
~CpuTi() override;
- void setSpeedTrace(tmgr_trace_t trace) override;
+ void set_speed_trace(tmgr_trace_t trace) override;
void apply_event(tmgr_trace_event_t event, double value) override;
- void updateActionsFinishTime(double now);
- void updateRemainingAmount(double now);
+ void update_actions_finish_time(double now);
+ void update_remaining_amount(double now);
- bool isUsed() override;
+ bool is_used() override;
CpuAction *execution_start(double size) override;
simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) override
{
return nullptr;
}
CpuAction *sleep(double duration) override;
- double getAvailableSpeed() override;
+ double get_available_speed() override;
- void modified(bool modified);
+ void set_modified(bool modified);
- CpuTiTgmr *speedIntegratedTrace_ = nullptr;/*< Structure with data needed to integrate trace file */
- ActionTiList actionSet_; /*< set with all actions running on cpu */
- double sumPriority_ = 0; /*< the sum of actions' priority that are running on cpu */
- double lastUpdate_ = 0; /*< last update of actions' remaining amount done */
+ CpuTiTgmr* speed_integrated_trace_ = nullptr; /*< Structure with data needed to integrate trace file */
+ ActionTiList action_set_; /*< set with all actions running on cpu */
+ double sum_priority_ = 0; /*< the sum of actions' priority that are running on cpu */
+ double last_update_ = 0; /*< last update of actions' remaining amount done */
- double currentFrequency_;
+ double current_frequency_;
boost::intrusive::list_member_hook<> cpu_ti_hook;
};
public:
CpuTiModel() = default;
~CpuTiModel() override;
- Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core) override;
+ Cpu* createCpu(simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core) override;
double next_occuring_event(double now) override;
void update_actions_state(double now, double delta) override;
kernel::resource::Action::StateSet runningActionSetThatDoesNotNeedBeingChecked_;
- CpuTiList modifiedCpu_;
+ CpuTiList modified_cpus_;
};
}
double HostCLM03Model::next_occuring_event(double now)
{
- ignoreEmptyVmInPmLMM();
+ ignore_empty_vm_in_pm_LMM();
double min_by_cpu = surf_cpu_model_pm->next_occuring_event(now);
double min_by_net =
set_maxmin_system(make_new_lmm_system(select));
loopback_ = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
-
- if (getUpdateMechanism() == kernel::resource::Model::UpdateAlgo::Lazy)
- get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
}
LinkImpl* NetworkCm02Model::createLink(const std::string& name, double bandwidth, double latency,
}
}
- bool LinkImpl::isUsed()
+ bool LinkImpl::is_used()
{
return model()->get_maxmin_system()->constraint_used(constraint());
}
virtual int sharingPolicy();
/** @brief Check if the Link is used */
- bool isUsed() override;
+ bool is_used() override;
void turnOn() override;
void turnOff() override;
}
}
-kernel::resource::Action* HostL07Model::executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount,
- double* bytes_amount, double rate)
+kernel::resource::Action* HostL07Model::execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
+ double* bytes_amount, double rate)
{
return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate);
}
host_list[1] = dst;
bytes_amount[1] = size;
- return hostModel_->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate);
+ return hostModel_->execute_parallel(2, host_list, flops_amount, bytes_amount, rate);
}
Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
host_list[0] = getHost();
flops_amount[0] = size;
- return static_cast<CpuL07Model*>(model())->hostModel_->executeParallelTask(1, host_list, flops_amount, nullptr, -1);
+ return static_cast<CpuL07Model*>(model())->hostModel_->execute_parallel(1, host_list, flops_amount, nullptr, -1);
}
kernel::resource::Action* CpuL07::sleep(double duration)
return action;
}
-bool CpuL07::isUsed(){
+bool CpuL07::is_used()
+{
return model()->get_maxmin_system()->constraint_used(constraint());
}
Cpu::onSpeedChange();
}
-
-bool LinkL07::isUsed(){
+bool LinkL07::is_used()
+{
return model()->get_maxmin_system()->constraint_used(constraint());
}
double next_occuring_event(double now) override;
void update_actions_state(double now, double delta) override;
- kernel::resource::Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount,
- double* bytes_amount, double rate) override;
+ kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
+ double* bytes_amount, double rate) override;
};
class CpuL07Model : public CpuModel {
public:
CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> * speedPerPstate, int core);
~CpuL07() override;
- bool isUsed() override;
+ bool is_used() override;
void apply_event(tmgr_trace_event_t event, double value) override;
kernel::resource::Action* execution_start(double size) override;
simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) override
LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
e_surf_link_sharing_policy_t policy);
~LinkL07() override;
- bool isUsed() override;
+ bool is_used() override;
void apply_event(tmgr_trace_event_t event, double value) override;
void setBandwidth(double value) override;
void setLatency(double value) override;
class L07Action : public CpuAction {
friend Action *CpuL07::execution_start(double size);
friend Action *CpuL07::sleep(double duration);
- friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list,
- double *flops_amount, double *bytes_amount, double rate);
+ friend Action* HostL07Model::execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
+ double* bytes_amount, double rate);
+
public:
L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* host_list, double* flops_amount,
double* bytes_amount, double rate);
if (args->state_trace)
host->pimpl_cpu->setStateTrace(args->state_trace);
if (args->speed_trace)
- host->pimpl_cpu->setSpeedTrace(args->speed_trace);
+ host->pimpl_cpu->set_speed_trace(args->speed_trace);
if (args->pstate != 0)
host->pimpl_cpu->setPState(args->pstate);
if (args->coord && strcmp(args->coord, ""))
if (peer->state_trace)
host->pimpl_cpu->setStateTrace(peer->state_trace);
if (peer->speed_trace)
- host->pimpl_cpu->setSpeedTrace(peer->speed_trace);
+ host->pimpl_cpu->set_speed_trace(peer->speed_trace);
}
void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date);
while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
- if (resource->isUsed() || (watched_hosts.find(resource->getCname()) != watched_hosts.end())) {
+ if (resource->is_used() || (watched_hosts.find(resource->getCname()) != watched_hosts.end())) {
time_delta = next_event_date - NOW;
XBT_DEBUG("This event invalidates the next_occuring_event() computation of models. Next event set to %f", time_delta);
}
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)
+ void apply_event(tmgr_trace_event_t event, double value) override
{
XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", thedate, value, event->idx);
tmgr_trace_event_unref(&event);
}
- bool isUsed() { return true; }
+ bool is_used() override { return true; }
};
static void trace2vector(const char* str, std::vector<tmgr::DatedValue>* whereto)
xbt_assert(host, "Host %s undefined", elm.second.c_str());
simgrid::surf::Cpu* cpu = host->pimpl_cpu;
- cpu->setSpeedTrace(trace);
+ cpu->set_speed_trace(trace);
}
for (auto const& elm : trace_connect_list_link_avail) {
enum method_t { MAXMIN, LAGRANGE_RENO, LAGRANGE_VEGAS };
-static lmm::System* new_system(method_t method, bool update)
+static lmm::System* new_system(method_t method)
{
+ /* selective update would need real actions instead of NULL as a first parameter to the variable constructor */
switch (method) {
case MAXMIN:
- return lmm::make_new_maxmin_system(update);
+ return lmm::make_new_maxmin_system(false);
case LAGRANGE_VEGAS:
case LAGRANGE_RENO:
- return lmm::make_new_lagrange_system(update);
+ return lmm::make_new_lagrange_system(false);
default:
xbt_die("Invalid method");
}
else if (method == LAGRANGE_RENO)
lmm::Lagrange::set_default_protocol_function(lmm::func_reno_f, lmm::func_reno_fp, lmm::func_reno_fpi);
- lmm::System* Sys = new_system(method, true);
+ lmm::System* Sys = new_system(method);
lmm::Constraint* L1 = Sys->constraint_new(nullptr, a);
lmm::Constraint* L2 = Sys->constraint_new(nullptr, b);
lmm::Constraint* L3 = Sys->constraint_new(nullptr, a);
if (method == LAGRANGE_RENO)
lmm::Lagrange::set_default_protocol_function(lmm::func_reno_f, lmm::func_reno_fp, lmm::func_reno_fpi);
- lmm::System* Sys = new_system(method, true);
+ lmm::System* Sys = new_system(method);
lmm::Constraint* CPU1 = Sys->constraint_new(nullptr, 200.0);
lmm::Constraint* CPU2 = Sys->constraint_new(nullptr, 100.0);
if (method == LAGRANGE_RENO)
lmm::Lagrange::set_default_protocol_function(lmm::func_reno_f, lmm::func_reno_fp, lmm::func_reno_fpi);
- lmm::System* Sys = new_system(method, true);
+ lmm::System* Sys = new_system(method);
/* Creates the constraints */
lmm::Constraint** tmp_cnst = new lmm::Constraint*[15];
lmm::Variable* var[nb_var];
int used[nb_cnst];
- lmm::System* Sys = new lmm::System(true);
+ /* We cannot activate the selective update as we pass nullptr as an Action when creating the variables */
+ lmm::System* Sys = new lmm::System(false);
for (int i = 0; i < nb_cnst; i++) {
cnst[i] = Sys->constraint_new(NULL, float_random(10.0));
! expect return 0
! output sort
$ $SG_TEST_EXENV ${bindir:=.}/maxmin_bench medium 5 test
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
> [0.000000]: [surf_maxmin/DEBUG] Constraint '98' usage: 13.060939 remaining: 3.166833 concurrency: 7<=8<=10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '80' usage: 12.338661 remaining: 3.766234 concurrency: 7<=8<=16
> [0.000000]: [surf_maxmin/DEBUG] '97'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '98'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '99'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
> [0.000000]: [surf_maxmin/DEBUG] Constraint '111' usage: 16.414585 remaining: 0.229770 concurrency: 9<=9<=9
> [0.000000]: [surf_maxmin/DEBUG] Constraint '112' usage: 12.855644 remaining: 0.239760 concurrency: 7<=8<=40
> [0.000000]: [surf_maxmin/DEBUG] '198'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '199'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '200'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
> [0.000000]: [surf_maxmin/DEBUG] Constraint '285' usage: 14.339161 remaining: 6.593407 concurrency: 7<=8<=24
> [0.000000]: [surf_maxmin/DEBUG] Constraint '249' usage: 17.094905 remaining: 3.656344 concurrency: 9<=9<=9
> [0.000000]: [surf_maxmin/DEBUG] '298'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '299'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '300'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
> [0.000000]: [surf_maxmin/DEBUG] Constraint '325' usage: 22.924076 remaining: 9.700300 concurrency: 11<=12<=40
> [0.000000]: [surf_maxmin/DEBUG] Constraint '400' usage: 10.918082 remaining: 9.520480 concurrency: 7<=7<=16
> [0.000000]: [surf_maxmin/DEBUG] '398'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '399'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '400'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 100
> [0.000000]: [surf_maxmin/DEBUG] Constraint '500' usage: 16.228771 remaining: 6.223776 concurrency: 7<=8<=24
> [0.000000]: [surf_maxmin/DEBUG] Constraint '464' usage: 13.778721 remaining: 2.417582 concurrency: 9<=9<=9
! expect return 0
! output sort
$ $SG_TEST_EXENV ${bindir:=.}/maxmin_bench small 10 test
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '9' usage: 4.703796 remaining: 7.082917 concurrency: 2<=2<=-1
> [0.000000]: [surf_maxmin/DEBUG] Constraint '6' usage: 5.688312 remaining: 9.860140 concurrency: 3<=3<=3
> [0.000000]: [surf_maxmin/DEBUG] '6'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '7'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '8'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '16' usage: 2.596903 remaining: 9.730270 concurrency: 2<=2<=3
> [0.000000]: [surf_maxmin/DEBUG] Constraint '20' usage: 6.927572 remaining: 1.978022 concurrency: 4<=4<=4
> [0.000000]: [surf_maxmin/DEBUG] '11'(1.000000) : 0.316463
> [0.000000]: [surf_maxmin/DEBUG] '16'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '20'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '28' usage: 2.611888 remaining: 2.127872 concurrency: 1<=1<=3
> [0.000000]: [surf_maxmin/DEBUG] Constraint '26' usage: 3.101898 remaining: 6.863137 concurrency: 2<=2<=-1
> [0.000000]: [surf_maxmin/DEBUG] '27'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '29'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '30'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '31' usage: 1.213786 remaining: 9.950050 concurrency: 1<=1<=4
> [0.000000]: [surf_maxmin/DEBUG] Constraint '35' usage: 6.809191 remaining: 3.656344 concurrency: 4<=4<=-1
> [0.000000]: [surf_maxmin/DEBUG] '31'(1.000000) : 0.757364
> [0.000000]: [surf_maxmin/DEBUG] '34'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '37'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '42' usage: 10.002498 remaining: 3.556444 concurrency: 4<=4<=4
> [0.000000]: [surf_maxmin/DEBUG] Constraint '49' usage: 2.623876 remaining: 2.117882 concurrency: 1<=2<=3
> [0.000000]: [surf_maxmin/DEBUG] '45'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '48'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '49'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '54' usage: 5.379620 remaining: 3.456543 concurrency: 3<=3<=-1
> [0.000000]: [surf_maxmin/DEBUG] Constraint '53' usage: 4.633367 remaining: 6.793207 concurrency: 3<=3<=3
> [0.000000]: [surf_maxmin/DEBUG] '51'(1.000000) : 1.219766
> [0.000000]: [surf_maxmin/DEBUG] '55'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '60'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '66' usage: 8.571429 remaining: 7.002997 concurrency: 4<=4<=-1
> [0.000000]: [surf_maxmin/DEBUG] Constraint '65' usage: 4.924076 remaining: 2.937063 concurrency: 2<=3<=4
> [0.000000]: [surf_maxmin/DEBUG] '68'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '69'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '70'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '73' usage: 5.087413 remaining: 7.882118 concurrency: 2<=2<=-1
> [0.000000]: [surf_maxmin/DEBUG] Constraint '72' usage: 4.393606 remaining: 8.511489 concurrency: 2<=2<=3
> [0.000000]: [surf_maxmin/DEBUG] '71'(1.000000) : 0.854701
> [0.000000]: [surf_maxmin/DEBUG] '78'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '79'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '86' usage: 5.734765 remaining: 0.609391 concurrency: 4<=4<=4
> [0.000000]: [surf_maxmin/DEBUG] Constraint '85' usage: 7.075924 remaining: 3.776224 concurrency: 3<=3<=4
> [0.000000]: [surf_maxmin/DEBUG] '86'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '87'(0.000000) : 0.000000
> [0.000000]: [surf_maxmin/DEBUG] '90'(0.000000) : 0.000000
-> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 1
+> [0.000000]: [surf_maxmin/DEBUG] Setting selective_update_active flag to 0
> [0.000000]: [surf_maxmin/DEBUG] Active constraints : 10
> [0.000000]: [surf_maxmin/DEBUG] Constraint '99' usage: 6.451049 remaining: 0.949051 concurrency: 2<=2<=4
> [0.000000]: [surf_maxmin/DEBUG] Constraint '94' usage: 4.122378 remaining: 4.585415 concurrency: 2<=3<=4