host.state_trace = simgrid::kernel::profile::Profile::from_file(filename);
lua_pop(L, 1);
- sg_platf_new_host(&host);
+ sg_platf_new_host_begin(&host);
+ sg_platf_new_host_seal(0);
return 0;
}
************/
DiskImpl* DiskImpl::set_host(s4u::Host* host)
{
+ xbt_assert(host, "Cannot set host, none given");
host_ = host;
return this;
}
Disk* Disk::seal()
{
kernel::actor::simcall([this]{ pimpl_->seal(); });
- get_host()->add_disk(this);
Disk::on_creation(*this);
return this;
}
Disk* Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
{
return kernel::actor::simcall([this, &name, read_bandwidth, write_bandwidth] {
- return this->pimpl_->create_disk(name, read_bandwidth, write_bandwidth);
+ auto* disk = pimpl_->create_disk(name, read_bandwidth, write_bandwidth);
+ pimpl_->add_disk(disk);
+ return disk;
});
}
return disks;
}
-HostImpl* HostImpl::set_disks(const std::vector<kernel::resource::DiskImpl*>& disks)
-{
- disks_ = disks;
- for (auto d : disks_)
- d->set_host(&piface_);
- return this;
-}
-
s4u::Disk* HostImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
{
auto disk = piface_.get_netpoint()->get_englobing_zone()->get_disk_model()->create_disk(name, read_bandwidth,
void destroy(); // Must be called instead of the destructor
std::vector<s4u::Disk*> get_disks() const;
- HostImpl* set_disks(const std::vector<kernel::resource::DiskImpl*>& disks);
s4u::Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
void add_disk(const s4u::Disk* disk);
void remove_disk(const std::string& disk_name);
{
return current_routing;
}
+static simgrid::s4u::Host* current_host = nullptr;
/** Module management function: creates all internal data structures */
void sg_platf_init()
}
/** @brief Add a host to the current NetZone */
-void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
+void sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* args)
{
- simgrid::s4u::Host* host = routing_get_current()
- ->create_host(args->id, args->speed_per_pstate)
- ->set_coordinates(args->coord)
- ->set_properties(args->properties);
-
- host->get_impl()->set_disks(args->disks);
+ current_host = routing_get_current()
+ ->create_host(args->id, args->speed_per_pstate)
+ ->set_coordinates(args->coord)
+ ->set_core_count(args->core_amount)
+ ->set_state_profile(args->state_trace)
+ ->set_speed_profile(args->speed_trace);
+ // host->get_impl()->set_disks(args->disks);
+}
- host->pimpl_cpu->set_core_count(args->core_amount)
- ->set_state_profile(args->state_trace)
- ->set_speed_profile(args->speed_trace);
+void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props)
+{
+ xbt_assert(current_host, "Cannot set properties of the current host: none under construction");
+ current_host->set_properties(props);
+}
- host->seal();
+void sg_platf_new_host_seal(int pstate)
+{
+ xbt_assert(current_host, "Cannot seal the current Host: none under construction");
+ current_host->seal();
/* When energy plugin is activated, changing the pstate requires to already have the HostEnergy extension whose
- * allocation is triggered by the on_creation signal. Then set_pstate must be called after the signal emition */
- if (args->pstate != 0)
- host->set_pstate(args->pstate);
+ * allocation is triggered by the on_creation signal. Then set_pstate must be called after the signal emission */
+
+ if (pstate != 0)
+ current_host->set_pstate(pstate);
+
+ current_host = nullptr;
}
/** @brief Add a "router" to the network element list */
}
}
+void sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
+{
+ simgrid::s4u::Disk* new_disk = routing_get_current()
+ ->create_disk(disk->id, disk->read_bw, disk->write_bw)
+ ->set_host(current_host)
+ ->set_properties(disk->properties)
+ ->seal();
+
+ current_host->add_disk(new_disk);
+}
+
void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster)
{
using simgrid::kernel::routing::ClusterZone;
}
}
-simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
-{
- simgrid::kernel::resource::DiskImpl* pimpl = routing_get_current()
- ->create_disk(disk->id, disk->read_bw, disk->write_bw)
- ->set_properties(disk->properties)
- ->get_impl();
-
- pimpl->seal();
- simgrid::s4u::Disk::on_creation(*pimpl->get_iface());
- return pimpl;
-}
-
void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route)
{
routing_get_current()->add_route(route->src, route->dst, route->gw_src, route->gw_dst, route->link_list,
*/
void sg_platf_new_Zone_seal()
{
- xbt_assert(current_routing, "Cannot seal the current Zone: zone under construction");
+ xbt_assert(current_routing, "Cannot seal the current Zone: none under construction");
current_routing->seal();
simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
current_routing = current_routing->get_parent();
profile::Profile* speed_trace = nullptr;
profile::Profile* state_trace = nullptr;
std::string coord = "";
- std::unordered_map<std::string, std::string> properties;
- std::vector<resource::DiskImpl*> disks;
};
class HostLinkCreationArgs {
XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described
XBT_PUBLIC void
-sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
+sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
+XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map<std::string, std::string>& props);
+XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described
+
XBT_PUBLIC void
sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
XBT_PUBLIC void
sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
XBT_PUBLIC void
+sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
+XBT_PUBLIC void
sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a cluster to the current Zone
XBT_PUBLIC void
XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
-XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
-sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
XBT_PRIVATE void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect);
std::string surf_parsed_filename; // Currently parsed file (for the error messages)
std::vector<simgrid::kernel::resource::LinkImpl*>
parsed_link_list; /* temporary store of current link list of a route */
-std::vector<simgrid::kernel::resource::DiskImpl*> parsed_disk_list; /* temporary store of current disk list of a host */
-/*
- * Helping functions
- */
+
+/* Helping functions */
void surf_parse_assert(bool cond, const std::string& msg)
{
if (not cond)
simgrid::s4u::Engine::on_platform_created();
}
-void STag_surfxml_host(){
- property_sets.push_back(std::unordered_map<std::string, std::string>());
-}
-
void STag_surfxml_prop()
{
property_sets.back().insert({A_surfxml_prop_id, A_surfxml_prop_value});
&(property_sets.back()));
}
-void ETag_surfxml_host() {
+void STag_surfxml_host()
+{
simgrid::kernel::routing::HostCreationArgs host;
-
- host.properties = property_sets.back();
- property_sets.pop_back();
-
+ property_sets.push_back(std::unordered_map<std::string, std::string>());
host.id = A_surfxml_host_id;
host.speed_per_pstate =
host.state_trace = A_surfxml_host_state___file[0]
? simgrid::kernel::profile::Profile::from_file(A_surfxml_host_state___file)
: nullptr;
- host.pstate = surf_parse_get_int(A_surfxml_host_pstate);
host.coord = A_surfxml_host_coordinates;
- host.disks.swap(parsed_disk_list);
- sg_platf_new_host(&host);
+ sg_platf_new_host_begin(&host);
+}
+
+void ETag_surfxml_host()
+{
+ sg_platf_new_host_set_properties(property_sets.back());
+ property_sets.pop_back();
+
+ sg_platf_new_host_seal(surf_parse_get_int(A_surfxml_host_pstate));
}
void STag_surfxml_disk() {
disk.write_bw = xbt_parse_get_bandwidth(surf_parsed_filename, surf_parse_lineno, A_surfxml_disk_write___bw,
"write_bw of disk ", disk.id);
- parsed_disk_list.push_back(sg_platf_new_disk(&disk));
+ sg_platf_new_disk(&disk);
}
void STag_surfxml_host___link(){