typedef s4u_Semaphore* sg_sem_t;
typedef s4u_NetZone* sg_netzone_t;
typedef s4u_Host* sg_host_t;
+typedef const s4u_Host* const_sg_host_t;
typedef s4u_Link* sg_link_t;
+typedef const s4u_Link* const_sg_link_t;
typedef s4u_Disk* sg_disk_t;
+typedef const s4u_Disk* const_sg_disk_t;
typedef s4u_Storage* sg_storage_t;
+typedef const s4u_Storage* const_sg_storage_t;
typedef s4u_File* sg_file_t;
+typedef const s4u_File* const_sg_file_t;
typedef s4u_VM* sg_vm_t;
+typedef const s4u_VM* const_sg_vm_t;
typedef s4u_Actor* sg_actor_t;
typedef const s4u_Actor* const_sg_actor_t;
XBT_PUBLIC void sg_host_energy_plugin_init();
XBT_PUBLIC void sg_host_energy_update_all();
-XBT_PUBLIC double sg_host_get_consumed_energy(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmin_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmax_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_power_range_slope_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_current_consumption(sg_host_t host);
+XBT_PUBLIC double sg_host_get_consumed_energy(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmin_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmax_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_current_consumption(const_sg_host_t host);
XBT_PUBLIC void sg_link_energy_plugin_init();
-XBT_PUBLIC double sg_link_get_consumed_energy(sg_link_t link);
+XBT_PUBLIC double sg_link_get_consumed_energy(const_sg_link_t link);
XBT_PUBLIC int sg_link_energy_is_inited();
XBT_PUBLIC sg_file_t sg_file_open(const char* fullpath, void* data);
XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size);
XBT_PUBLIC sg_size_t sg_file_write(sg_file_t fd, sg_size_t size);
-XBT_PUBLIC void sg_file_close(sg_file_t fd);
+XBT_PUBLIC void sg_file_close(const_sg_file_t fd);
XBT_PUBLIC const char* sg_file_get_name(sg_file_t fd);
XBT_PUBLIC sg_size_t sg_file_get_size(sg_file_t fd);
XBT_PUBLIC void sg_file_dump(sg_file_t fd);
-XBT_PUBLIC void* sg_file_get_data(sg_file_t fd);
+XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd);
XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data);
XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin);
XBT_PUBLIC sg_size_t sg_file_tell(sg_file_t fd);
XBT_PUBLIC int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath);
XBT_PUBLIC int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath);
-XBT_PUBLIC sg_size_t sg_disk_get_size_free(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size_used(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size(sg_disk_t d);
-XBT_PUBLIC const char* sg_disk_get_mount_point(sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_free(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_used(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size(const_sg_disk_t d);
+XBT_PUBLIC const char* sg_disk_get_mount_point(const_sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_storage_get_size_free(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size_used(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size(sg_storage_t st);
-XBT_PUBLIC xbt_dict_t sg_storage_get_content(sg_storage_t storage);
+XBT_PUBLIC sg_size_t sg_storage_get_size_free(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size_used(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size(const_sg_storage_t st);
+XBT_PUBLIC xbt_dict_t sg_storage_get_content(const_sg_storage_t storage);
XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host);
sg_size_t current_position_ = SEEK_SET;
Storage* find_local_storage_on(Host* host);
- Disk* find_local_disk_on(Host* host);
+ Disk* find_local_disk_on(const Host* host);
sg_size_t write_on_storage(sg_size_t size, bool write_inside);
sg_size_t write_on_disk(sg_size_t size, bool write_inside);
class XBT_PUBLIC FileSystemDiskExt {
public:
static simgrid::xbt::Extension<Disk, FileSystemDiskExt> EXTENSION_ID;
- explicit FileSystemDiskExt(Disk* ptr);
+ explicit FileSystemDiskExt(const Disk* ptr);
FileSystemDiskExt(const FileSystemDiskExt&) = delete;
FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete;
std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
class XBT_PUBLIC FileSystemStorageExt {
public:
static simgrid::xbt::Extension<Storage, FileSystemStorageExt> EXTENSION_ID;
- explicit FileSystemStorageExt(Storage* ptr);
+ explicit FileSystemStorageExt(const Storage* ptr);
FileSystemStorageExt(const FileSystemStorageExt&) = delete;
FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete;
std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
XBT_PUBLIC void sg_vm_live_migration_plugin_init();
XBT_PRIVATE void sg_vm_dirty_page_tracking_init();
-XBT_PUBLIC void sg_vm_start_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_lookup_computed_flops(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_lookup_computed_flops(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_migrate(sg_vm_t vm, sg_host_t dst_pm);
-XBT_PUBLIC void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity);
-XBT_PUBLIC double sg_vm_get_dirty_page_intensity(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size);
-XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_migration_speed(sg_vm_t vm, double speed);
-XBT_PUBLIC double sg_vm_get_migration_speed(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_get_max_downtime(sg_vm_t vm);
-XBT_PUBLIC int sg_vm_is_migrating(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity);
+XBT_PUBLIC double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size);
+XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed);
+XBT_PUBLIC double sg_vm_get_migration_speed(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_get_max_downtime(const_sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_migrating(const_sg_vm_t vm);
XBT_PUBLIC sg_vm_t sg_vm_create_migratable(sg_host_t pm, const char* name, int coreAmount, int ramsize,
int mig_netspeed, int dp_intensity);
SG_BEGIN_DECL
XBT_PUBLIC void sg_host_load_plugin_init();
-XBT_PUBLIC double sg_host_get_current_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_avg_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_total_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_computed_flops(sg_host_t host);
-XBT_PUBLIC void sg_host_load_reset(sg_host_t host);
+XBT_PUBLIC double sg_host_get_current_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_avg_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_total_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_computed_flops(const_sg_host_t host);
+XBT_PUBLIC void sg_host_load_reset(const_sg_host_t host);
#define MSG_host_load_plugin_init() sg_host_load_plugin_init()
/** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
XBT_PUBLIC int sg_vm_is_running(sg_vm_t vm);
XBT_PUBLIC int sg_vm_is_suspended(sg_vm_t vm);
-XBT_PUBLIC const char* sg_vm_get_name(sg_vm_t vm);
+XBT_PUBLIC const char* sg_vm_get_name(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_set_ramsize(sg_vm_t vm, size_t size);
XBT_PUBLIC size_t sg_vm_get_ramsize(sg_vm_t vm);
XBT_PUBLIC void sg_vm_set_bound(sg_vm_t vm, double bound);
}
}
-void sg_vm_start_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->start_tracking();
}
-void sg_vm_stop_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->stop_tracking();
}
-double sg_vm_lookup_computed_flops(sg_vm_t vm)
+double sg_vm_lookup_computed_flops(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->computed_flops_lookup();
}
-void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity)
+void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_intensity(intensity);
}
-double sg_vm_get_dirty_page_intensity(sg_vm_t vm)
+double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_intensity();
}
-void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size)
+void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_working_set_memory(size);
}
-sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm)
+sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_working_set_memory();
}
-void sg_vm_set_migration_speed(sg_vm_t vm, double speed)
+void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_migration_speed(speed);
}
-double sg_vm_get_migration_speed(sg_vm_t vm)
+double sg_vm_get_migration_speed(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_migration_speed();
}
-double sg_vm_get_max_downtime(sg_vm_t vm)
+double sg_vm_get_max_downtime(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_max_downtime();
}
return st;
}
-Disk* File::find_local_disk_on(Host* host)
+Disk* File::find_local_disk_on(const Host* host)
{
Disk* d = nullptr;
size_t longest_prefix_length = 0;
return res;
}
-FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
+FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
{
const char* size_str = ptr->get_property("size");
if (size_str)
content_.reset(parse_content(content_str));
}
-FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr) : size_(ptr->get_impl()->size_)
+FileSystemStorageExt::FileSystemStorageExt(const Storage* ptr) : size_(ptr->get_impl()->size_)
{
content_.reset(parse_content(ptr->get_impl()->content_name_));
}
return fd->write(size);
}
-void sg_file_close(sg_file_t fd)
+void sg_file_close(const_sg_file_t fd)
{
delete fd;
}
/** Retrieves the user data associated with the file
* @ingroup plugin_filesystem
*/
-void* sg_file_get_data(sg_file_t fd)
+void* sg_file_get_data(const_sg_file_t fd)
{
return fd->get_data();
}
return file->remote_move(host, fullpath);
}
-sg_size_t sg_disk_get_size_free(sg_disk_t d)
+sg_size_t sg_disk_get_size_free(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size() - d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size_used(sg_disk_t d)
+sg_size_t sg_disk_get_size_used(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size(sg_disk_t d)
+sg_size_t sg_disk_get_size(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size();
}
-const char* sg_disk_get_mount_point(sg_disk_t d)
+const char* sg_disk_get_mount_point(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_mount_point();
}
-sg_size_t sg_storage_get_size_free(sg_storage_t st)
+sg_size_t sg_storage_get_size_free(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size() - st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size_used(sg_storage_t st)
+sg_size_t sg_storage_get_size_used(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size(sg_storage_t st)
+sg_size_t sg_storage_get_size(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size();
}
-xbt_dict_t sg_storage_get_content(sg_storage_t storage)
+xbt_dict_t sg_storage_get_content(const_sg_storage_t storage)
{
const std::map<std::string, sg_size_t>* content =
storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
// FIXME I think that this fires at the same time for all hosts, so when the src sends something,
// the dst will be notified even though it didn't even arrive at the recv yet
simgrid::s4u::Link::on_communicate.connect(
- [this](kernel::resource::NetworkAction const&, s4u::Host* src, s4u::Host* dst) {
+ [this](const kernel::resource::NetworkAction&, const s4u::Host* src, const s4u::Host* dst) {
if ((get_host() == src || get_host() == dst) && iteration_running) {
post_task();
}
* The result is that the actor requesting this value will be interrupted,
* the value will be updated in kernel mode before returning the control to the requesting actor.
*/
-double sg_host_get_consumed_energy(sg_host_t host)
+double sg_host_get_consumed_energy(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_consumed_energy();
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated when the host is idling
*/
-double sg_host_get_idle_consumption(sg_host_t host)
+double sg_host_get_idle_consumption(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(0);
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated at the given pstate when the host is idling
*/
-double sg_host_get_idle_consumption_at(sg_host_t host, int pstate)
+double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(pstate);
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated at the given pstate when the host is at 0 or epsilon% CPU usage.
*/
-double sg_host_get_wattmin_at(sg_host_t host, int pstate)
+double sg_host_get_wattmin_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_min_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
*/
-double sg_host_get_wattmax_at(sg_host_t host, int pstate)
+double sg_host_get_wattmax_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_max_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the power slope at the given pstate
*/
-double sg_host_get_power_range_slope_at(sg_host_t host, int pstate)
+double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_power_range_slope_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the current consumption of the host
*/
-double sg_host_get_current_consumption(sg_host_t host)
+double sg_host_get_current_consumption(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_current_watts_value();
/** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
* @ingroup plugin_host_load
*/
-double sg_host_get_current_load(sg_host_t host)
+double sg_host_get_current_load(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the current load of that host
* @ingroup plugin_host_load
*/
-double sg_host_get_avg_load(sg_host_t host)
+double sg_host_get_avg_load(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the time this host was idle since the last reset
* @ingroup plugin_host_load
*/
-double sg_host_get_idle_time(sg_host_t host)
+double sg_host_get_idle_time(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the time this host was idle since the beginning of the simulation
* @ingroup plugin_host_load
*/
-double sg_host_get_total_idle_time(sg_host_t host)
+double sg_host_get_total_idle_time(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the amount of flops computed by that host since the last reset
* @ingroup plugin_host_load
*/
-double sg_host_get_computed_flops(sg_host_t host)
+double sg_host_get_computed_flops(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Resets the idle time and flops amount of that host
* @ingroup plugin_host_load
*/
-void sg_host_load_reset(sg_host_t host)
+void sg_host_load_reset(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
using simgrid::plugin::LinkEnergy;
/* **************************** events callback *************************** */
-static void on_communicate(simgrid::kernel::resource::NetworkAction const& action, simgrid::s4u::Host*,
- simgrid::s4u::Host*)
+static void on_communicate(const simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host*,
+ const simgrid::s4u::Host*)
{
XBT_DEBUG("onCommunicate is called");
for (simgrid::kernel::resource::LinkImpl* link : action.links()) {
* The result is that the actor requesting this value will be interrupted,
* the value will be updated in kernel mode before returning the control to the requesting actor.
*/
-double sg_link_get_consumed_energy(sg_link_t link)
+double sg_link_get_consumed_energy(const_sg_link_t link)
{
if (not LinkEnergy::EXTENSION_ID.valid())
throw simgrid::xbt::InitializationError("The Energy plugin is not active. Please call sg_link_energy_plugin_init() "
return vm;
}
-int sg_vm_is_migrating(simgrid::s4u::VirtualMachine* vm)
+int sg_vm_is_migrating(const simgrid::s4u::VirtualMachine* vm)
{
return vm->get_impl()->is_migrating_;
}
return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
}
-const char* sg_vm_get_name(sg_vm_t vm)
+const char* sg_vm_get_name(const_sg_vm_t vm)
{
return vm->get_cname();
}