#ifndef DOXYGEN
friend Host;
friend Link;
+ friend Disk;
friend Storage;
friend kernel::routing::NetPoint;
friend kernel::routing::NetZoneImpl;
*/
void set_config(const std::string& str);
- private:
- kernel::EngineImpl* const pimpl;
- static Engine* instance_;
- };
+ /** Callback fired when the platform is created (ie, the xml file parsed),
+ * right before the actual simulation starts. */
+ static xbt::signal<void()> on_platform_created;
- /** Callback fired when the platform is created (ie, the xml file parsed),
- * right before the actual simulation starts. */
- extern XBT_PUBLIC xbt::signal<void()> on_platform_created;
+ /** Callback fired when the platform is about to be created
+ * (ie, after any configuration change and just before the resource creation) */
+ static xbt::signal<void()> on_platform_creation;
- /** Callback fired when the platform is about to be created
- * (ie, after any configuration change and just before the resource creation) */
- extern XBT_PUBLIC xbt::signal<void()> on_platform_creation;
+ /** Callback fired when the main simulation loop ends, just before the end of Engine::run() */
+ static xbt::signal<void()> on_simulation_end;
- /** Callback fired when the main simulation loop ends, just before the end of Engine::run() */
- extern XBT_PUBLIC xbt::signal<void()> on_simulation_end;
+ /** Callback fired when the time jumps into the future */
+ static xbt::signal<void(double)> on_time_advance;
- /** Callback fired when the time jumps into the future */
- extern XBT_PUBLIC xbt::signal<void(double)> on_time_advance;
+ /** Callback fired when the time cannot advance because of inter-actors deadlock */
+ static xbt::signal<void(void)> on_deadlock;
- /** Callback fired when the time cannot advance because of inter-actors deadlock */
- extern XBT_PUBLIC xbt::signal<void(void)> on_deadlock;
+ private:
+ kernel::EngineImpl* const pimpl;
+ static Engine* instance_;
+ };
#ifndef DOXYGEN /* Internal use only, no need to expose it */
template <class T> XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
void set_pstate(int pstate_index);
int get_pstate() const;
+ std::vector<Disk*> get_disks() const;
+ void add_disk(Disk* disk);
+ void remove_disk(std::string disk_name);
+
std::vector<const char*> get_attached_storages() const;
/** Get an associative list [mount point]->[Storage] of all local mount points.
} // namespace s4u
} // namespace simgrid
- extern int USER_HOST_LEVEL;
-
#endif /* SIMGRID_S4U_HOST_HPP */
#include "mc/mc.h"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/kernel/routing/NetZoneImpl.hpp"
+#include "simgrid/s4u/Disk.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/Mailbox.hpp"
namespace simgrid {
namespace s4u {
- xbt::signal<void()> on_platform_creation;
- xbt::signal<void()> on_platform_created;
- xbt::signal<void()> on_simulation_end;
- xbt::signal<void(double)> on_time_advance;
- xbt::signal<void(void)> on_deadlock;
+ xbt::signal<void()> Engine::on_platform_creation;
+ xbt::signal<void()> Engine::on_platform_created;
+ xbt::signal<void()> Engine::on_simulation_end;
+ xbt::signal<void(double)> Engine::on_time_advance;
+ xbt::signal<void(void)> Engine::on_deadlock;
Engine* Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U hosts");
XBT_LOG_EXTERNAL_CATEGORY(surf_route);
- int USER_HOST_LEVEL = -1;
-
namespace simgrid {
namespace xbt {
template class Extendable<s4u::Host>;
return this->pimpl_cpu->get_pstate();
}
+std::vector<Disk*> Host::get_disks() const
+{
+ return kernel::actor::simcall([this] { return this->pimpl_->get_disks(); });
+}
+
+void Host::add_disk(Disk* disk)
+{
+ kernel::actor::simcall([this, disk] { this->pimpl_->add_disk(disk); });
+}
+void Host::remove_disk(std::string disk_name)
+{
+ kernel::actor::simcall([this, disk_name] { this->pimpl_->remove_disk(disk_name); });
+}
/**
* @ingroup simix_storage_management
* @brief Returns the list of storages attached to a host.
// ========= Layering madness ==============*
// ========== User data Layer ==========
- void* sg_host_user(sg_host_t host)
+ void* sg_host_data(sg_host_t host)
+ {
+ return host->get_data();
+ }
+ void sg_host_data_set(sg_host_t host, void* userdata)
+ {
+ host->set_data(userdata);
+ }
+ void* sg_host_user(sg_host_t host) // deprecated
{
- return host->extension(USER_HOST_LEVEL);
+ return host->get_data();
}
- void sg_host_user_set(sg_host_t host, void* userdata)
+ void sg_host_user_set(sg_host_t host, void* userdata) // deprecated
{
- host->extension_set(USER_HOST_LEVEL, userdata);
+ host->set_data(userdata);
}
- void sg_host_user_destroy(sg_host_t host)
+ void sg_host_user_destroy(sg_host_t host) // deprecated
{
- host->extension_set(USER_HOST_LEVEL, nullptr);
+ host->set_data(nullptr);
}
// ========= storage related functions ============
#include "src/include/simgrid/sg_config.hpp"
#include "src/include/surf/surf.hpp"
#include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/resource/DiskImpl.hpp"
#include "src/kernel/resource/profile/Profile.hpp"
#include "src/simix/smx_private.hpp"
#include "src/surf/HostImpl.hpp"
/** Module management function: creates all internal data structures */
void sg_platf_init()
{
- simgrid::s4u::on_platform_created.connect(check_disk_attachment);
+ simgrid::s4u::Engine::on_platform_created.connect(check_disk_attachment);
}
/** Module management function: frees all internal data structures */
void sg_platf_exit() {
simgrid::surf::on_cluster.disconnect_slots();
- simgrid::s4u::on_platform_created.disconnect_slots();
+ simgrid::s4u::Engine::on_platform_created.disconnect_slots();
/* make sure that we will reinit the models while loading the platf once reinited */
surf_parse_models_setup_already_called = 0;
host->pimpl_->storage_ = mount_list;
mount_list.clear();
+ host->pimpl_->disks_ = std::move(args->disks);
+ for (auto d : host->pimpl_->disks_)
+ d->set_host(host);
+
/* Change from the defaults */
if (args->state_trace)
host->pimpl_cpu->set_state_profile(args->state_trace);
delete cabinet->radicals;
}
+simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk)
+{
+ simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
+ if (disk->properties) {
+ d->set_properties(*disk->properties);
+ delete disk->properties;
+ }
+ simgrid::s4u::Disk::on_creation(*d->get_iface());
+ return d;
+}
+
void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage)
{
xbt_assert(std::find(known_storages.begin(), known_storages.end(), storage->id) == known_storages.end(),
std::string host_model_name = simgrid::config::get_value<std::string>("host/model");
std::string network_model_name = simgrid::config::get_value<std::string>("network/model");
std::string cpu_model_name = simgrid::config::get_value<std::string>("cpu/model");
+ std::string disk_model_name = simgrid::config::get_value<std::string>("disk/model");
std::string storage_model_name = simgrid::config::get_value<std::string>("storage/model");
/* The compound host model is needed when using non-default net/cpu models */
XBT_DEBUG("Call vm_model_init");
surf_vm_model_init_HL13();
+ XBT_DEBUG("Call disk_model_init");
+ int disk_id = find_model_description(surf_disk_model_description, disk_model_name);
+ surf_disk_model_description[disk_id].model_init_preparse();
+
XBT_DEBUG("Call storage_model_init");
int storage_id = find_model_description(surf_storage_model_description, storage_model_name);
surf_storage_model_description[storage_id].model_init_preparse();
simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
{
if (not surf_parse_models_setup_already_called) {
- simgrid::s4u::on_platform_creation();
+ simgrid::s4u::Engine::on_platform_creation();
/* Initialize the surf models. That must be done after we got all config, and before we need the models.
* That is, after the last <config> tag, if any, and before the first of cluster|peer|zone|trace|trace_connect
#include "simgrid/s4u/Engine.hpp"
#include "src/include/surf/surf.hpp"
#include "src/instr/instr_private.hpp"
+#include "src/kernel/resource/DiskImpl.hpp"
#include "src/kernel/resource/profile/FutureEvtSet.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
for (auto const& model : all_existing_models) {
if (model != surf_host_model && model != surf_vm_model && model != surf_network_model &&
- model != surf_storage_model) {
+ model != surf_storage_model && model != surf_disk_model) {
double next_event_model = model->next_occuring_event(NOW);
if ((time_delta < 0.0 || next_event_model < time_delta) && next_event_model >= 0.0)
time_delta = next_event_model;
for (auto const& model : all_existing_models)
model->update_actions_state(NOW, time_delta);
- simgrid::s4u::on_time_advance(time_delta);
+ simgrid::s4u::Engine::on_time_advance(time_delta);
TRACE_paje_dump_buffer(false);
#include "src/simgrid/version.h"
#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf.hpp"
+ #include "src/xbt_modinter.h" /* whether initialization was already done */
#include "surf/surf.hpp"
#include "xbt/module.h"
{"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
};
+const std::vector<surf_model_description_t> surf_disk_model_description = {
+ {"default", "Simplistic disk model.", &surf_disk_model_init_default},
+};
+
const std::vector<surf_model_description_t> surf_storage_model_description = {
{"default", "Simplistic storage model.", &surf_storage_model_init_default},
};
void surf_init(int *argc, char **argv)
{
- if (USER_HOST_LEVEL != -1) // Already initialized
+ if (xbt_initialized > 0)
return;
- XBT_DEBUG("Create all Libs");
- USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
-
xbt_init(argc, argv);
sg_config_init(argc, argv);
static 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 list link of a route */
-
+ 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
*/
surf_parsed_filename.c_str(), version);
}
void ETag_surfxml_platform(){
- simgrid::s4u::on_platform_created();
+ simgrid::s4u::Engine::on_platform_created();
}
void STag_surfxml_host(){
: 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);
}
void STag_surfxml_disk() {
- THROW_UNIMPLEMENTED;
+ ZONE_TAG = 0;
+ xbt_assert(current_property_set == nullptr,
+ "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
}
+
void ETag_surfxml_disk() {
+ simgrid::kernel::routing::DiskCreationArgs disk;
+ disk.properties = current_property_set;
+ current_property_set = nullptr;
+
+ disk.id = A_surfxml_disk_id;
+ disk.read_bw = surf_parse_get_bandwidth(A_surfxml_disk_read___bw, "read_bw of disk ", disk.id);
+ disk.write_bw = surf_parse_get_bandwidth(A_surfxml_disk_write___bw, "write_bw of disk ", disk.id);
+
+ parsed_disk_list.push_back(sg_platf_new_disk(&disk));
}
void STag_surfxml_host___link(){