From 41dbf302d1807e7259061a79285ee7751d5d9329 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 3 Sep 2019 09:12:15 +0200 Subject: [PATCH] load disk model --- src/simgrid/sg_config.cpp | 19 +++++++++++++++++-- src/surf/sg_platf.cpp | 5 +++++ src/surf/surf_c_bindings.cpp | 3 ++- src/surf/surf_interface.cpp | 4 ++++ src/surf/surf_interface.hpp | 2 ++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 1bf0f9f91c..2acb020ae2 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -171,8 +171,20 @@ static void _sg_cfg_cb__optimization_mode(const std::string& value) find_model_description(surf_optimization_mode_description, value); } +static void _sg_cfg_cb__disk_model(const std::string& value) +{ + xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); + + if (value == "help") { + model_help("disk", surf_disk_model_description); + exit(0); + } + + find_model_description(surf_disk_model_description, value); +} + /* callback of the cpu/model variable */ -static void _sg_cfg_cb__storage_mode(const std::string& value) +static void _sg_cfg_cb__storage_model(const std::string& value) { xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); @@ -243,7 +255,10 @@ void sg_config_init(int *argc, char **argv) declare_model_flag("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, surf_cpu_model_description, "model", "The model to use for the CPU"); - declare_model_flag("storage/model", "default", &_sg_cfg_cb__storage_mode, surf_storage_model_description, "model", + declare_model_flag("disk/model", "default", &_sg_cfg_cb__disk_model, surf_disk_model_description, "model", + "The model to use for the disk"); + + declare_model_flag("storage/model", "default", &_sg_cfg_cb__storage_model, surf_storage_model_description, "model", "The model to use for the storage"); declare_model_flag("network/model", "LV08", &_sg_cfg_cb__network_model, surf_network_model_description, "model", diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 2e211f7789..9df9f386f0 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -513,6 +513,7 @@ static void surf_config_models_setup() std::string host_model_name = simgrid::config::get_value("host/model"); std::string network_model_name = simgrid::config::get_value("network/model"); std::string cpu_model_name = simgrid::config::get_value("cpu/model"); + std::string disk_model_name = simgrid::config::get_value("disk/model"); std::string storage_model_name = simgrid::config::get_value("storage/model"); /* The compound host model is needed when using non-default net/cpu models */ @@ -541,6 +542,10 @@ static void surf_config_models_setup() 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(); diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index b0a82806f6..9e4182ac6e 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -6,6 +6,7 @@ #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" @@ -71,7 +72,7 @@ double surf_solve(double max_date) 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; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index b657ce6380..ea299d7b17 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -111,6 +111,10 @@ const std::vector surf_optimization_mode_description = {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr}, }; +const std::vector surf_disk_model_description = { + {"default", "Simplistic disk model.", &surf_disk_model_init_default}, +}; + const std::vector surf_storage_model_description = { {"default", "Simplistic storage model.", &surf_storage_model_init_default}, }; diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 3497b4e337..da361ca582 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -205,6 +205,8 @@ XBT_PUBLIC_DATA const std::vector surf_optimization_mo XBT_PUBLIC_DATA const std::vector surf_cpu_model_description; /** @brief The list of all network models (pick one with --cfg=network/model) */ XBT_PUBLIC_DATA const std::vector surf_network_model_description; +/** @brief The list of all disk models (pick one with --cfg=disk/model) */ +XBT_PUBLIC_DATA const std::vector surf_disk_model_description; /** @brief The list of all storage models (pick one with --cfg=storage/model) */ XBT_PUBLIC_DATA const std::vector surf_storage_model_description; /** @brief The list of all host models (pick one with --cfg=host/model:) */ -- 2.20.1