cpu_plop.hpp and cpu_plop_cpp which contains classes CpuPlopModel, CpuPlop and
CpuPlopAction implementing respectively the interfaces CpuModel, Cpu and
CpuAction. You also need to define an initializing function like this:
+FIXME[donassolo]: update doc
~~~~
void surf_cpu_model_init_plop()
You should not do something like that. Please work instead to make XML
avoidable, ie to make the C++ interface nice and usable.
-*/
\ No newline at end of file
+*/
routing::NetPoint* netpoint_ = nullptr; // Our representative in the father NetZone
resource::NetworkModel* network_model_;
resource::CpuModel* cpu_model_vm_;
+ resource::CpuModel* cpu_model_pm_;
protected:
explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
/* FIXME: protect the following fields once the construction madness is sorted out */
RoutingMode hierarchy_ = RoutingMode::unset;
+ /** @brief Retrieves the network model associated to this NetZone */
resource::NetworkModel* get_network_model() const { return network_model_; }
+ /** @brief Retrieves the CPU model for virtual machines associated to this NetZone */
resource::CpuModel* get_cpu_vm_model() const { return cpu_model_vm_; }
+ /** @brief Retrieves the CPU model for physical machines associated to this NetZone */
+ resource::CpuModel* get_cpu_pm_model() const { return cpu_model_pm_; }
+
const s4u::NetZone* get_iface() const { return &piface_; }
s4u::NetZone* get_iface() { return &piface_; }
unsigned int get_table_size() const { return vertices_.size(); }
#include "simgrid/forward.h"
-/** @ingroup SURF_models
- * @brief The CPU model object for the physical machine layer
- */
-XBT_PUBLIC_DATA simgrid::kernel::resource::CpuModel* surf_cpu_model_pm;
-
/** @ingroup SURF_models
* @brief The host model
*
cpu_model_vm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM][0]);
}
+ cpu_model_pm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
+ models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]);
XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id());
}
auto* res = new s4u::Host(name);
res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
- surf_cpu_model_pm->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal();
+ cpu_model_pm_->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal();
return res;
}
*********/
void surf_cpu_model_init_Cas01()
{
- xbt_assert(surf_cpu_model_pm == nullptr, "CPU model already initialized. This should not happen.");
-
if (cpu_optim_opt == "TI") {
simgrid::kernel::resource::CpuTiModel::create_pm_vm_models();
return;
else
algo = simgrid::kernel::resource::Model::UpdateAlgo::FULL;
- surf_cpu_model_pm = new simgrid::kernel::resource::CpuCas01Model(algo);
- models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(surf_cpu_model_pm);
+ auto cpu_model_pm = new simgrid::kernel::resource::CpuCas01Model(algo);
+ models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm);
auto cpu_model_vm = new simgrid::kernel::resource::CpuCas01Model(algo);
models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].push_back(cpu_model_vm);
}
CpuCas01Model::~CpuCas01Model()
{
- surf_cpu_model_pm = nullptr;
}
Cpu* CpuCas01Model::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_cpu, ker_resource, "CPU resource, fueling execution activites");
-simgrid::kernel::resource::CpuModel* surf_cpu_model_pm;
-
namespace simgrid {
namespace kernel {
namespace resource {
void CpuTiModel::create_pm_vm_models()
{
- xbt_assert(surf_cpu_model_pm == nullptr, "CPU model already initialized. This should not happen.");
-
- surf_cpu_model_pm = new CpuTiModel();
- models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(surf_cpu_model_pm);
+ auto cpu_model_pm = new CpuTiModel();
+ models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm);
auto cpu_model_vm = new CpuTiModel();
models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].push_back(cpu_model_vm);
}
CpuTiModel::~CpuTiModel()
{
- surf_cpu_model_pm = nullptr;
}
Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate)
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_started_action_set())
+ if (action.get_state_set() != get_model()->get_started_action_set())
continue;
/* bogus priority, skip it */
for (CpuTiAction& action : action_set_) {
double min_finish = -1;
/* action not running, skip it */
- if (action.get_state_set() != surf_cpu_model_pm->get_started_action_set())
+ if (action.get_state_set() != get_model()->get_started_action_set())
continue;
/* verify if the action is really running on cpu */
void surf_host_model_init_compound()
{
- xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
/* FIXME[donassolo]: this smells bad, but works
* (the constructor saves its pointer in all_existing_models and models_by_type :O).
* We need a manager for these models */
void surf_host_model_init_ptask_L07()
{
XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks.");
- xbt_assert(not surf_cpu_model_pm, "Cannot switch to ptasks: CPU model already defined");
surf_host_model = new simgrid::surf::HostL07Model();
all_existing_models.push_back(surf_host_model);
network_model_ = std::make_unique<NetworkL07Model>(this, maxmin_system);
models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(network_model_.get());
cpu_model_pm_ = std::make_unique<CpuL07Model>(this, maxmin_system);
- surf_cpu_model_pm = cpu_model_pm_.get();
+ models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM].push_back(cpu_model_pm_.get());
}
HostL07Model::~HostL07Model() {}
sg_netzone_t as_zone = sg_zone_get_by_name("AS0");
simgrid::kernel::resource::NetworkModel* net_model = as_zone->get_impl()->get_network_model();
+ simgrid::kernel::resource::CpuModel* cpu_model_pm = as_zone->get_impl()->get_cpu_pm_model();
- XBT_DEBUG("CPU model: %p", surf_cpu_model_pm);
+ XBT_DEBUG("CPU model: %p", cpu_model_pm);
XBT_DEBUG("Network model: %p", net_model);
simgrid::s4u::Host* hostA = sg_host_by_name("Cpu A");
simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
XBT_INFO("Next Event : %g", surf_get_clock());
XBT_DEBUG("\t CPU actions");
- simgrid::kernel::resource::Action::StateSet* action_list = surf_cpu_model_pm->get_failed_action_set();
+ simgrid::kernel::resource::Action::StateSet* action_list = cpu_model_pm->get_failed_action_set();
while (not action_list->empty()) {
simgrid::kernel::resource::Action& action = action_list->front();
XBT_INFO(" CPU Failed action");
action.unref();
}
- action_list = surf_cpu_model_pm->get_finished_action_set();
+ action_list = cpu_model_pm->get_finished_action_set();
while (not action_list->empty()) {
simgrid::kernel::resource::Action& action = action_list->front();
XBT_INFO(" CPU Done action");
XBT_DEBUG("\t * Done : %p", &action);
action.unref();
}
- } while ((net_model->get_started_action_set()->size() || surf_cpu_model_pm->get_started_action_set()->size()) &&
+ } while ((net_model->get_started_action_set()->size() || cpu_model_pm->get_started_action_set()->size()) &&
surf_solve(-1.0) >= 0.0);
XBT_DEBUG("Simulation Terminated");