resource::NetworkModel* network_model_;
resource::CpuModel* cpu_model_vm_;
resource::CpuModel* cpu_model_pm_;
+ resource::DiskModel* disk_model_;
protected:
explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
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_; }
+ /** @brief Retrieves the disk model associated to this NetZone */
+ resource::DiskModel* get_disk_model() const { return disk_model_; }
const s4u::NetZone* get_iface() const { return &piface_; }
s4u::NetZone* get_iface() { return &piface_; }
/** @brief Make a host within that NetZone */
s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_amount);
+ /** @brief Create a disk with the disk model from this NetZone */
+ s4u::Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
/** @brief Make a link within that NetZone */
virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
s4u::Link::SharingPolicy policy);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_disk, ker_resource, "Disk resources, fuelling I/O activities");
-simgrid::kernel::resource::DiskModel* surf_disk_model = nullptr;
-
namespace simgrid {
namespace kernel {
namespace resource {
DiskModel::~DiskModel()
{
- surf_disk_model = nullptr;
}
/************
void DiskImpl::seal()
{
+ xbt_assert(this->get_model(), "Cannot seal Disk (%s) without setting the model first", this->get_cname());
lmm::System* maxmin_system = get_model()->get_maxmin_system();
this->set_read_constraint(maxmin_system->constraint_new(this, read_bw_))
->set_write_constraint(maxmin_system->constraint_new(this, write_bw_))
* Model *
*********/
-XBT_PUBLIC_DATA simgrid::kernel::resource::DiskModel* surf_disk_model;
-
namespace simgrid {
namespace kernel {
namespace resource {
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
+#include "src/kernel/resource/DiskImpl.hpp"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
#include "src/surf/xml/platf_private.hpp"
}
cpu_model_pm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]);
+ disk_model_ = static_cast<simgrid::kernel::resource::DiskModel*>(
+ models_by_type[simgrid::kernel::resource::Model::Type::DISK][0]);
XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id());
}
return count;
}
+s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
+{
+ auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth);
+
+ return l->get_iface();
+}
+
s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths,
s4u::Link::SharingPolicy policy)
{
Disk* Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
{
- return surf_disk_model->create_disk(name, read_bandwidth, write_bandwidth)->set_host(this)->get_iface();
+ auto disk =
+ this->get_netpoint()->get_englobing_zone()->get_disk_model()->create_disk(name, read_bandwidth, write_bandwidth);
+ return disk->set_host(this)->get_iface();
}
void Host::add_disk(const Disk* disk)
void surf_disk_model_init_default()
{
- surf_disk_model = new simgrid::kernel::resource::DiskS19Model();
+ /* 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 */
+ new simgrid::kernel::resource::DiskS19Model();
}
namespace simgrid {
simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
{
- simgrid::kernel::resource::DiskImpl* pimpl = surf_disk_model->create_disk(disk->id, disk->read_bw, disk->write_bw);
+ simgrid::kernel::resource::DiskImpl* pimpl =
+ routing_get_current()->create_disk(disk->id, disk->read_bw, disk->write_bw)->get_impl();
if (disk->properties) {
pimpl->set_properties(*disk->properties);