From: Bruno Donassolo Date: Thu, 4 Mar 2021 16:49:25 +0000 (+0100) Subject: Say goodbye to last global: surf_host_model X-Git-Tag: v3.27~201^2~1 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/df308bdc5212ab9944427c118fdf6a9cd84221ed Say goodbye to last global: surf_host_model - By now, add the host_model in netZone too - Probably need some check when running parallel_execute in a list of hosts (all belongs to same model/netzone?) --- diff --git a/doc/doxygen/module-surf.doc b/doc/doxygen/module-surf.doc index 9dc285ede3..fdb4e47050 100644 --- a/doc/doxygen/module-surf.doc +++ b/doc/doxygen/module-surf.doc @@ -43,6 +43,7 @@ - the CPU resource, - the timer resource. + FIXME[donassolo]: fix doc The implementation of these resources depends on the platform models you choose. You can select your model by calling #surf_host_model_init_current_default() (which will give you a diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index eed458f362..ffbf67b93c 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -74,6 +74,7 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder { resource::CpuModel* cpu_model_vm_; resource::CpuModel* cpu_model_pm_; resource::DiskModel* disk_model_; + simgrid::surf::HostModel* host_model_; protected: explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model); @@ -113,6 +114,9 @@ public: 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_; } + /** @brief Retrieves the host model associated to this NetZone */ + // FIXME[donassolo]: why HostModel isn't in resource namespace? + simgrid::surf::HostModel* get_host_model() const { return host_model_; } const s4u::NetZone* get_iface() const { return &piface_; } s4u::NetZone* get_iface() { return &piface_; } diff --git a/src/include/surf/surf.hpp b/src/include/surf/surf.hpp index 9f55cd817a..d5d1645a72 100644 --- a/src/include/surf/surf.hpp +++ b/src/include/surf/surf.hpp @@ -8,15 +8,6 @@ #include "simgrid/forward.h" -/** @ingroup SURF_models - * @brief The host model - * - * Note that when you create an API on top of SURF, the host model should be the only one you use - * because depending on the platform model, the network model and the CPU model may not exist. - */ -XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model; - - /*** SURF Globals **************************/ /** @ingroup SURF_simulation diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index f306e90389..40b9f95160 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -5,6 +5,7 @@ #include "src/kernel/activity/ExecImpl.hpp" #include "simgrid/Exception.hpp" +#include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/modelchecker.h" #include "simgrid/s4u/Exec.hpp" #include "src/mc/mc_replay.hpp" @@ -120,7 +121,9 @@ ExecImpl* ExecImpl::start() surf_action_->set_user_bound(bound_); } } else { - surf_action_ = surf_host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1); + // FIXME[donassolo]: verify if all hosts belongs to the same netZone? + auto host_model = hosts_.front()->get_netpoint()->get_englobing_zone()->get_host_model(); + surf_action_ = host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1); } surf_action_->set_activity(this); } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index b9046bef9b..11f4c0d255 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -8,6 +8,7 @@ #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "src/kernel/resource/DiskImpl.hpp" +#include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/xml/platf_private.hpp" @@ -34,6 +35,9 @@ NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource: models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]); disk_model_ = static_cast( models_by_type[simgrid::kernel::resource::Model::Type::DISK][0]); + // FIXME[donassolo]: we probably need some validation of the coherence among + // the different models in each netZone + host_model_ = static_cast(models_by_type[simgrid::kernel::resource::Model::Type::HOST][0]); XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id()); } diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index 89b78db1b4..1c78fa2698 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simdag_private.hpp" +#include "simgrid/kernel/routing/NetPoint.hpp" #include "src/surf/HostImpl.hpp" #include "src/surf/surf_interface.hpp" #include @@ -801,8 +802,10 @@ void SD_task_run(SD_task_t task) XBT_VERB("Executing task '%s'", task->name); /* Beware! The scheduling data are now used by the surf action directly! no copy was done */ + // FIXME[donassolo]: verify if all hosts belongs to the same netZone? + auto host_model = (*task->allocation).front()->get_netpoint()->get_englobing_zone()->get_host_model(); task->surf_action = - surf_host_model->execute_parallel(*task->allocation, task->flops_amount, task->bytes_amount, task->rate); + host_model->execute_parallel(*task->allocation, task->flops_amount, task->bytes_amount, task->rate); task->surf_action->set_data(task); diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index fc804315c0..d6547d5c81 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -10,8 +10,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_host, ker_resource, "Host resources agregate CPU, networking and I/O features"); -simgrid::surf::HostModel *surf_host_model = nullptr; - /************* * Callbacks *t *************/ diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index dfe6045299..b7e70d6716 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -81,6 +81,4 @@ public: } } -XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model; - #endif /* SURF_HOST_INTERFACE_HPP */ diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index e22365b7c8..db3a9953d4 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -12,7 +12,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host); void surf_host_model_init_current_default() { - surf_host_model = new simgrid::surf::HostCLM03Model(); + /* 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::surf::HostCLM03Model(); simgrid::config::set_default("network/crosstraffic", true); surf_cpu_model_init_Cas01(); surf_network_model_init_LegrandVelho(); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 6961a27869..570e3aacea 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -20,9 +20,9 @@ void surf_host_model_init_ptask_L07() { XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks."); - surf_host_model = new simgrid::surf::HostL07Model(); - all_existing_models.push_back(surf_host_model); - models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(surf_host_model); + auto host_model = new simgrid::surf::HostL07Model(); + all_existing_models.push_back(host_model); + models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(host_model); } namespace simgrid {