From d9966aa66acc63c0417fbeae8e3ff12bccb0cdb0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 11 Mar 2018 21:30:33 +0100 Subject: [PATCH] also change the namespace of kernel/resource/{Action,Model} --- include/simgrid/forward.h | 2 ++ src/include/surf/surf.hpp | 22 ++++---------- src/kernel/activity/CommImpl.cpp | 10 +++---- src/kernel/activity/CommImpl.hpp | 6 ++-- src/kernel/activity/ExecImpl.cpp | 8 ++--- src/kernel/activity/ExecImpl.hpp | 6 ++-- src/kernel/activity/SleepImpl.cpp | 4 +-- src/kernel/activity/SleepImpl.hpp | 2 +- src/kernel/activity/SynchroIo.cpp | 4 +-- src/kernel/activity/SynchroIo.hpp | 2 +- src/kernel/activity/SynchroRaw.cpp | 4 +-- src/kernel/activity/SynchroRaw.hpp | 2 +- src/kernel/lmm/maxmin.cpp | 6 ++-- src/kernel/lmm/maxmin.hpp | 11 +++---- src/kernel/resource/Action.cpp | 10 +++++-- src/kernel/resource/Action.hpp | 20 +++++++------ src/kernel/resource/Model.cpp | 4 ++- src/kernel/resource/Model.hpp | 5 ++-- src/kernel/resource/Resource.cpp | 4 +-- src/kernel/resource/Resource.hpp | 6 ++-- src/plugins/vm/VirtualMachineImpl.hpp | 4 +-- src/simdag/sd_global.cpp | 2 +- src/simdag/simdag_private.hpp | 2 +- src/simix/ActorImpl.cpp | 2 +- src/simix/smx_global.cpp | 2 +- src/simix/smx_network.cpp | 4 +-- src/surf/HostImpl.cpp | 8 ++--- src/surf/HostImpl.hpp | 6 ++-- src/surf/StorageImpl.cpp | 11 +++---- src/surf/StorageImpl.hpp | 22 +++++++------- src/surf/cpu_cas01.cpp | 21 +++++++------ src/surf/cpu_cas01.hpp | 11 +++---- src/surf/cpu_interface.cpp | 17 +++++------ src/surf/cpu_interface.hpp | 27 +++++++++-------- src/surf/cpu_ti.cpp | 22 +++++++------- src/surf/cpu_ti.hpp | 7 ++--- src/surf/network_cm02.cpp | 24 ++++++++------- src/surf/network_cm02.hpp | 6 ++-- src/surf/network_constant.cpp | 8 ++--- src/surf/network_constant.hpp | 5 ++-- src/surf/network_ib.cpp | 2 +- src/surf/network_interface.cpp | 5 ++-- src/surf/network_interface.hpp | 17 ++++++----- src/surf/network_ns3.cpp | 9 +++--- src/surf/network_ns3.hpp | 4 +-- src/surf/plugins/host_energy.cpp | 2 +- src/surf/plugins/host_load.cpp | 2 +- src/surf/ptask_L07.cpp | 33 ++++++++++----------- src/surf/ptask_L07.hpp | 18 ++++++------ src/surf/storage_n11.cpp | 6 ++-- src/surf/storage_n11.hpp | 6 ++-- src/surf/surf_c_bindings.cpp | 15 ++++++---- src/surf/surf_interface.cpp | 4 +-- src/surf/surf_interface.hpp | 2 +- teshsuite/surf/surf_usage/surf_usage.cpp | 34 +++++++++++----------- teshsuite/surf/surf_usage2/surf_usage2.cpp | 4 +-- 56 files changed, 261 insertions(+), 251 deletions(-) diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index b13224ff97..772a50ab5e 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -48,6 +48,8 @@ class ConstraintLight; class System; } namespace resource { +class Action; +class Model; class Resource; } namespace routing { diff --git a/src/include/surf/surf.hpp b/src/include/surf/surf.hpp index 4cd73e299b..84b8c16bd2 100644 --- a/src/include/surf/surf.hpp +++ b/src/include/surf/surf.hpp @@ -20,13 +20,11 @@ namespace simgrid { namespace surf { -class Model; class CpuModel; class HostModel; class NetworkModel; class StorageModel; class NetworkCm02Link; -class Action; } } @@ -36,20 +34,10 @@ class Action; * Generic data structure for a model. The hosts, * the CPUs and the network links are examples of models. */ -typedef simgrid::surf::Model* surf_model_t; typedef simgrid::surf::CpuModel* surf_cpu_model_t; typedef simgrid::surf::HostModel* surf_host_model_t; typedef simgrid::surf::NetworkModel* surf_network_model_t; typedef simgrid::surf::StorageModel* surf_storage_model_t; -/** @ingroup SURF_c_bindings - * \brief Action structure - * - * Never create s_surf_action_t by yourself ! The actions are created - * on the fly when you call execute or communicate on a model. - * - * \see e_surf_action_state_t - */ -typedef simgrid::surf::Action* surf_action_t; SG_BEGIN_DECL() /* Actions and models are highly connected structures... */ @@ -85,7 +73,8 @@ XBT_PUBLIC(void) model_help(const char* category, s_surf_model_description_t* ta * @param model The model from which the action is extracted * @return An action in done state */ -XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model); +XBT_PUBLIC(simgrid::kernel::resource::Action*) +surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model); /** * @brief Pop an action from the failed actions set @@ -93,7 +82,8 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model) * @param model The model from which the action is extracted * @return An action in failed state */ -XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t model); +XBT_PUBLIC(simgrid::kernel::resource::Action*) +surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model); /** * @brief Get the size of the running action set of a model @@ -101,7 +91,7 @@ XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t mode * @param model The model * @return The size of the running action set */ -XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model); +XBT_PUBLIC(int) surf_model_running_action_set_size(simgrid::kernel::resource::Model* model); /** * @brief [brief description] @@ -110,7 +100,7 @@ XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model); * @param action The surf cpu action * @param bound [description] */ -XBT_PUBLIC(void) surf_cpu_action_set_bound(surf_action_t action, double bound); +XBT_PUBLIC(void) surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound); /** @} */ diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 98be4746d6..e811dd1768 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -97,15 +97,15 @@ void simgrid::kernel::activity::CommImpl::cleanupSurf() void simgrid::kernel::activity::CommImpl::post() { /* Update synchro state */ - if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::done) + if (src_timeout && src_timeout->getState() == simgrid::kernel::resource::Action::State::done) state = SIMIX_SRC_TIMEOUT; - else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::done) + else if (dst_timeout && dst_timeout->getState() == simgrid::kernel::resource::Action::State::done) state = SIMIX_DST_TIMEOUT; - else if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::failed) + else if (src_timeout && src_timeout->getState() == simgrid::kernel::resource::Action::State::failed) state = SIMIX_SRC_HOST_FAILURE; - else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::failed) + else if (dst_timeout && dst_timeout->getState() == simgrid::kernel::resource::Action::State::failed) state = SIMIX_DST_HOST_FAILURE; - else if (surfAction_ && surfAction_->getState() == simgrid::surf::Action::State::failed) { + else if (surfAction_ && surfAction_->getState() == simgrid::kernel::resource::Action::State::failed) { state = SIMIX_LINK_FAILURE; } else state = SIMIX_DONE; diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index 842d407d17..86e44d1f72 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -46,9 +46,9 @@ expectations of the other side, too. See */ void (*copy_data_fun)(smx_activity_t, void*, size_t) = nullptr; /* Surf action data */ - surf_action_t surfAction_ = nullptr; /* The Surf communication action encapsulated */ - surf_action_t src_timeout = nullptr; /* Surf's actions to instrument the timeouts */ - surf_action_t dst_timeout = nullptr; /* Surf's actions to instrument the timeouts */ + simgrid::kernel::resource::Action* surfAction_ = nullptr; /* The Surf communication action encapsulated */ + simgrid::kernel::resource::Action* src_timeout = nullptr; /* Surf's actions to instrument the timeouts */ + simgrid::kernel::resource::Action* dst_timeout = nullptr; /* Surf's actions to instrument the timeouts */ smx_actor_t src_proc = nullptr; smx_actor_t dst_proc = nullptr; double rate = 0.0; diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 097947c319..9f2c2057f5 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -75,10 +75,10 @@ void simgrid::kernel::activity::ExecImpl::post() /* If the host running the synchro failed, notice it. This way, the asking * process can be killed if it runs on that host itself */ state = SIMIX_FAILED; - } else if (surfAction_->getState() == simgrid::surf::Action::State::failed) { + } else if (surfAction_->getState() == simgrid::kernel::resource::Action::State::failed) { /* If the host running the synchro didn't fail, then the synchro was canceled */ state = SIMIX_CANCELED; - } else if (timeoutDetector && timeoutDetector->getState() == simgrid::surf::Action::State::done) { + } else if (timeoutDetector && timeoutDetector->getState() == simgrid::kernel::resource::Action::State::done) { state = SIMIX_TIMEOUT; } else { state = SIMIX_DONE; @@ -104,8 +104,8 @@ simgrid::kernel::activity::ExecImpl::migrate(simgrid::s4u::Host* to) { if (not MC_is_active() && not MC_record_replay_is_active()) { - surf_action_t oldAction = this->surfAction_; - surf_action_t newAction = to->pimpl_cpu->execution_start(oldAction->getCost()); + simgrid::kernel::resource::Action* oldAction = this->surfAction_; + simgrid::kernel::resource::Action* newAction = to->pimpl_cpu->execution_start(oldAction->getCost()); newAction->setRemains(oldAction->getRemains()); newAction->setData(this); newAction->setSharingWeight(oldAction->getPriority()); diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 24f8467d66..4b114476be 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -29,8 +29,8 @@ public: /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */ sg_host_t host_ = nullptr; - surf_action_t surfAction_ = nullptr; /* The Surf execution action encapsulated */ - surf::Action* timeoutDetector = nullptr; + kernel::resource::Action* surfAction_ = nullptr; /* The Surf execution action encapsulated */ + kernel::resource::Action* timeoutDetector = nullptr; static simgrid::xbt::signal onCreation; static simgrid::xbt::signal onCompletion; static simgrid::xbt::signal onMigration; diff --git a/src/kernel/activity/SleepImpl.cpp b/src/kernel/activity/SleepImpl.cpp index c4a452b39e..c8f76b3656 100644 --- a/src/kernel/activity/SleepImpl.cpp +++ b/src/kernel/activity/SleepImpl.cpp @@ -33,12 +33,12 @@ void simgrid::kernel::activity::SleepImpl::post() e_smx_state_t result; switch (surf_sleep->getState()) { - case simgrid::surf::Action::State::failed: + case simgrid::kernel::resource::Action::State::failed: simcall->issuer->context->iwannadie = 1; result = SIMIX_SRC_HOST_FAILURE; break; - case simgrid::surf::Action::State::done: + case simgrid::kernel::resource::Action::State::done: result = SIMIX_DONE; break; diff --git a/src/kernel/activity/SleepImpl.hpp b/src/kernel/activity/SleepImpl.hpp index 5441f6145e..38c781f208 100644 --- a/src/kernel/activity/SleepImpl.hpp +++ b/src/kernel/activity/SleepImpl.hpp @@ -21,7 +21,7 @@ public: void post() override; sg_host_t host = nullptr; /* The host that is sleeping */ - surf_action_t surf_sleep = nullptr; /* The Surf sleeping action encapsulated */ + simgrid::kernel::resource::Action* surf_sleep = nullptr; /* The Surf sleeping action encapsulated */ }; } } diff --git a/src/kernel/activity/SynchroIo.cpp b/src/kernel/activity/SynchroIo.cpp index abd8302636..5d7c25d1b4 100644 --- a/src/kernel/activity/SynchroIo.cpp +++ b/src/kernel/activity/SynchroIo.cpp @@ -36,10 +36,10 @@ void simgrid::kernel::activity::IoImpl::post() } switch (surf_io->getState()) { - case simgrid::surf::Action::State::failed: + case simgrid::kernel::resource::Action::State::failed: state = SIMIX_FAILED; break; - case simgrid::surf::Action::State::done: + case simgrid::kernel::resource::Action::State::done: state = SIMIX_DONE; break; default: diff --git a/src/kernel/activity/SynchroIo.hpp b/src/kernel/activity/SynchroIo.hpp index f827ac6017..b7f7e1b2ec 100644 --- a/src/kernel/activity/SynchroIo.hpp +++ b/src/kernel/activity/SynchroIo.hpp @@ -20,7 +20,7 @@ public: void resume() override; void post() override; - surf_action_t surf_io = nullptr; + simgrid::kernel::resource::Action* surf_io = nullptr; }; }}} // namespace simgrid::kernel::activity diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index e6db37c92f..3d60634e0f 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -27,9 +27,9 @@ void simgrid::kernel::activity::RawImpl::resume() void simgrid::kernel::activity::RawImpl::post() { XBT_IN("(%p)",this); - if (sleep->getState() == simgrid::surf::Action::State::failed) + if (sleep->getState() == simgrid::kernel::resource::Action::State::failed) state = SIMIX_FAILED; - else if(sleep->getState() == simgrid::surf::Action::State::done) + else if (sleep->getState() == simgrid::kernel::resource::Action::State::done) state = SIMIX_SRC_TIMEOUT; SIMIX_synchro_finish(this); diff --git a/src/kernel/activity/SynchroRaw.hpp b/src/kernel/activity/SynchroRaw.hpp index d416f90dd0..eaa8e9c8a6 100644 --- a/src/kernel/activity/SynchroRaw.hpp +++ b/src/kernel/activity/SynchroRaw.hpp @@ -22,7 +22,7 @@ public: void resume() override; void post() override; - surf_action_t sleep = nullptr; + simgrid::kernel::resource::Action* sleep = nullptr; }; }}} // namespace simgrid::kernel::activity diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 876d72d480..b9c5b41bee 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -212,7 +212,7 @@ void System::variable_mallocator_free_f(void* var) delete static_cast(var); } -Variable* System::variable_new(simgrid::surf::Action* id, double sharing_weight, double bound, +Variable* System::variable_new(simgrid::kernel::resource::Action* id, double sharing_weight, double bound, int number_of_constraints) { XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", this, id, sharing_weight, bound, number_of_constraints); @@ -535,7 +535,7 @@ template void System::solve(CnstList& cnst_list) cnst.usage = elem.consumption_weight / elem.variable->sharing_weight; elem.make_active(); - simgrid::surf::Action* action = static_cast(elem.variable->id); + simgrid::kernel::resource::Action* action = static_cast(elem.variable->id); if (keep_track && not action->isLinkedModifiedSet()) keep_track->push_back(*action); } @@ -712,7 +712,7 @@ void System::update_variable_bound(Variable* var, double bound) update_modified_set(var->cnsts[0].constraint); } -void Variable::initialize(simgrid::surf::Action* id_value, double sharing_weight_value, double bound_value, +void Variable::initialize(simgrid::kernel::resource::Action* id_value, double sharing_weight_value, double bound_value, int number_of_constraints, unsigned visited_value) { id = id_value; diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index 6c08ad07d6..d0930c0b55 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -337,7 +337,7 @@ private: XBT_PUBLIC_CLASS Variable { public: - void initialize(simgrid::surf::Action* id_value, double sharing_weight_value, double bound_value, + void initialize(simgrid::kernel::resource::Action * id_value, double sharing_weight_value, double bound_value, int number_of_constraints, unsigned visited_value); /** @@ -382,7 +382,7 @@ public: * @brief Get the data associated to a variable * @return The data associated to the variable */ - simgrid::surf::Action* get_id() const { return id; } + simgrid::kernel::resource::Action* get_id() const { return id; } /** * @brief Get the weight of a variable @@ -415,7 +415,7 @@ public: double bound; double value; short int concurrency_share; /* The maximum number of elements that variable will add to a constraint */ - simgrid::surf::Action* id; + simgrid::kernel::resource::Action* id; int id_int; unsigned visited; /* used by System::update_modified_set() */ /* \begin{For Lagrange only} */ @@ -468,7 +468,8 @@ public: * @param bound The maximum value of the variable (-1.0 if no maximum value) * @param number_of_constraints The maximum number of constraint to associate to the variable */ - Variable* variable_new(simgrid::surf::Action * id, double weight_value, double bound, int number_of_constraints); + Variable* variable_new(simgrid::kernel::resource::Action * id, double weight_value, double bound, + int number_of_constraints); /** * @brief Free a variable @@ -604,7 +605,7 @@ public: &Constraint::saturated_constraint_set_hook>> saturated_constraint_set; - simgrid::surf::ActionLmmListPtr keep_track; + simgrid::kernel::resource::ActionLmmListPtr keep_track; void (*solve_fun)(lmm_system_t self); diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 69c372971c..fac7b4a2b3 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -11,11 +11,14 @@ XBT_LOG_NEW_CATEGORY(kernel, "Logging specific to the internals of SimGrid"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(resource, kernel, "Logging specific to the resources"); namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { -Action::Action(simgrid::surf::Model* model, double cost, bool failed) : Action(model, cost, failed, nullptr) {} +Action::Action(simgrid::kernel::resource::Model* model, double cost, bool failed) : Action(model, cost, failed, nullptr) +{ +} -Action::Action(simgrid::surf::Model* model, double cost, bool failed, kernel::lmm::Variable* var) +Action::Action(simgrid::kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var) : remains_(cost), start_(surf_get_clock()), cost_(cost), model_(model), variable_(var) { if (failed) @@ -226,3 +229,4 @@ double Action::getRemains() } // namespace surf } // namespace simgrid +} // namespace simgrid diff --git a/src/kernel/resource/Action.hpp b/src/kernel/resource/Action.hpp index c5595b82af..827fccf4a0 100644 --- a/src/kernel/resource/Action.hpp +++ b/src/kernel/resource/Action.hpp @@ -9,9 +9,10 @@ #include "src/surf/surf_interface.hpp" namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { -typedef std::pair heap_element_type; +typedef std::pair heap_element_type; typedef boost::heap::pairing_heap, boost::heap::stable, boost::heap::compare>> heap_type; @@ -59,7 +60,7 @@ public: * @param cost The cost of the Action * @param failed If the action is impossible (e.g.: execute something on a switched off host) */ - Action(simgrid::surf::Model * model, double cost, bool failed); + Action(simgrid::kernel::resource::Model * model, double cost, bool failed); /** * @brief Action constructor @@ -69,20 +70,20 @@ public: * @param failed If the action is impossible (e.g.: execute something on a switched off host) * @param var The lmm variable associated to this Action if it is part of a LMM component */ - Action(simgrid::surf::Model * model, double cost, bool failed, kernel::lmm::Variable* var); + Action(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var); virtual ~Action(); /** * @brief Mark that the action is now finished * - * @param state the new [state](\ref simgrid::surf::Action::State) of the current Action + * @param state the new [state](\ref simgrid::kernel::resource::Action::State) of the current Action */ void finish(Action::State state); - /** @brief Get the [state](\ref simgrid::surf::Action::State) of the current Action */ + /** @brief Get the [state](\ref simgrid::kernel::resource::Action::State) of the current Action */ Action::State getState() const; /**< get the state*/ - /** @brief Set the [state](\ref simgrid::surf::Action::State) of the current Action */ + /** @brief Set the [state](\ref simgrid::kernel::resource::Action::State) of the current Action */ virtual void setState(Action::State state); /** @brief Get the bound of the current Action */ @@ -161,7 +162,7 @@ public: /** @brief Get the state set in which the action is */ ActionList* getStateSet() const { return stateSet_; }; - simgrid::surf::Model* getModel() const { return model_; } + simgrid::kernel::resource::Model* getModel() const { return model_; } protected: ActionList* stateSet_; @@ -177,7 +178,7 @@ private: -1; /**< finish time : this is modified during the run and fluctuates until the task is completed */ double cost_; - simgrid::surf::Model* model_; + simgrid::kernel::resource::Model* model_; void* data_ = nullptr; /**< for your convenience */ /* LMM */ @@ -210,4 +211,5 @@ typedef Action::ActionLmmList ActionLmmList; typedef Action::ActionLmmList* ActionLmmListPtr; } // namespace surf } // namespace simgrid +} // namespace simgrid #endif diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index ac5f5ecf29..5d518efcb7 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -9,7 +9,8 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(resource); namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { Model::Model() : maxminSystem_(nullptr) { @@ -165,3 +166,4 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/) } // namespace surf } // namespace simgrid +} // namespace simgrid diff --git a/src/kernel/resource/Model.hpp b/src/kernel/resource/Model.hpp index 704febba06..e947ad33a3 100644 --- a/src/kernel/resource/Model.hpp +++ b/src/kernel/resource/Model.hpp @@ -9,7 +9,8 @@ #include "src/kernel/resource/Action.hpp" namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { /** @ingroup SURF_interface * @brief SURF model interface class @@ -96,5 +97,5 @@ private: } // namespace surf } // namespace simgrid - +} // namespace simgrid #endif diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 6016ae4f80..dc462309db 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -11,7 +11,7 @@ namespace simgrid { namespace kernel { namespace resource { -Resource::Resource(surf::Model* model, const std::string& name, lmm::Constraint* constraint) +Resource::Resource(Model* model, const std::string& name, lmm::Constraint* constraint) : name_(name), model_(model), constraint_(constraint) { } @@ -42,7 +42,7 @@ double Resource::getLoad() return constraint_->get_usage(); } -surf::Model* Resource::model() const +Model* Resource::model() const { return model_; } diff --git a/src/kernel/resource/Resource.hpp b/src/kernel/resource/Resource.hpp index 80481fbf24..4c9e6db3b9 100644 --- a/src/kernel/resource/Resource.hpp +++ b/src/kernel/resource/Resource.hpp @@ -26,12 +26,12 @@ public: * @param name The name of the Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(surf::Model * model, const std::string& name, lmm::Constraint* constraint); + Resource(Model * model, const std::string& name, lmm::Constraint* constraint); virtual ~Resource(); /** @brief Get the Model of the current Resource */ - surf::Model* model() const; + Model* model() const; /** @brief Get the name of the current Resource */ const std::string& getName() const; @@ -65,7 +65,7 @@ public: private: std::string name_; - surf::Model* model_; + Model* model_; bool isOn_ = true; public: /* LMM */ diff --git a/src/plugins/vm/VirtualMachineImpl.hpp b/src/plugins/vm/VirtualMachineImpl.hpp index 709ff69224..3ffbfde581 100644 --- a/src/plugins/vm/VirtualMachineImpl.hpp +++ b/src/plugins/vm/VirtualMachineImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -56,7 +56,7 @@ public: virtual void setBound(double bound); /* The vm object of the lower layer */ - surf::Action* action_ = nullptr; + kernel::resource::Action* action_ = nullptr; e_surf_vm_state_t getState(); void setState(e_surf_vm_state_t state); diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index f6eeabc500..da60d2d2f9 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -57,7 +57,7 @@ std::set* simulate(double how_long){ /* let's see which tasks are done */ for (auto const& model : *all_existing_models) { - surf_action_t action = surf_model_extract_done_action_set(model); + simgrid::kernel::resource::Action* action = surf_model_extract_done_action_set(model); while (action != nullptr && action->getData() != nullptr) { SD_task_t task = static_cast(action->getData()); XBT_VERB("Task '%s' done", SD_task_get_name(task)); diff --git a/src/simdag/simdag_private.hpp b/src/simdag/simdag_private.hpp index 13d55f49f4..826b800114 100644 --- a/src/simdag/simdag_private.hpp +++ b/src/simdag/simdag_private.hpp @@ -47,7 +47,7 @@ struct s_SD_task_t { double alpha; /* used by typed parallel tasks */ double start_time; double finish_time; - surf_action_t surf_action; + simgrid::kernel::resource::Action* surf_action; unsigned short watch_points; /* bit field xor()ed with masks */ int marked; /* used to check if the task DAG has some cycle*/ diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index a4a974f63a..d81ec61463 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -670,7 +670,7 @@ smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, doubl [](void*, void* arg) { auto sleep = static_cast(arg); if (sleep->surf_sleep) - sleep->surf_sleep->finish(simgrid::surf::Action::State::done); + sleep->surf_sleep->finish(simgrid::kernel::resource::Action::State::done); intrusive_ptr_release(sleep); return 0; }, diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index e71ae2e9d3..adbd7e9254 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -339,7 +339,7 @@ double SIMIX_get_clock() /** Wake up all processes waiting for a Surf action to finish */ static void SIMIX_wake_processes() { - surf_action_t action; + simgrid::kernel::resource::Action* action; for (auto const& model : *all_existing_models) { XBT_DEBUG("Handling the processes whose action failed (if any)"); diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 8708df0668..45ce0ca2fc 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -322,7 +322,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do SIMIX_comm_finish(synchro); } else { /* we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */ - surf_action_t sleep = simcall->issuer->host->pimpl_cpu->sleep(timeout); + simgrid::kernel::resource::Action* sleep = simcall->issuer->host->pimpl_cpu->sleep(timeout); sleep->setData(synchro.get()); simgrid::kernel::activity::CommImplPtr comm = @@ -468,7 +468,7 @@ static inline void SIMIX_comm_start(simgrid::kernel::activity::CommImplPtr comm) receiver->getCname(), comm->surfAction_); /* If a link is failed, detect it immediately */ - if (comm->surfAction_->getState() == simgrid::surf::Action::State::failed) { + if (comm->surfAction_->getState() == simgrid::kernel::resource::Action::State::failed) { XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->getCname(), receiver->getCname()); comm->state = SIMIX_LINK_FAILURE; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 36bff707f3..6edf250fd2 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -51,10 +51,10 @@ static inline double has_cost(double* array, int pos) return -1.0; } -Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_list, double* flops_amount, - double* bytes_amount, double rate) +kernel::resource::Action* HostModel::executeParallelTask(int host_nb, s4u::Host** host_list, double* flops_amount, + double* bytes_amount, double rate) { - Action* action = nullptr; + kernel::resource::Action* action = nullptr; if ((host_nb == 1) && (has_cost(bytes_amount, 0) <= 0)) { action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]); } else if ((host_nb == 1) && (has_cost(flops_amount, 0) <= 0)) { diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 7ef46c8d1d..632ec37349 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -31,13 +31,13 @@ namespace surf { * @brief SURF Host model interface class * @details A model is an object which handle the interactions between its Resources and its Actions */ -class XBT_PRIVATE HostModel : public Model { +class XBT_PRIVATE HostModel : public kernel::resource::Model { public: HostModel() : Model() {} virtual void ignoreEmptyVmInPmLMM(); - virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, - double rate); + virtual kernel::resource::Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, + double* bytes_amount, double rate); }; /************ diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index db277c6adc..fcfa53445e 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -22,7 +21,8 @@ namespace surf { simgrid::xbt::signal storageCreatedCallbacks; simgrid::xbt::signal storageDestructedCallbacks; simgrid::xbt::signal storageStateChangedCallbacks; // signature: wasOn, isOn -simgrid::xbt::signal storageActionStateChangedCallbacks; +simgrid::xbt::signal + storageActionStateChangedCallbacks; /* List of storages */ std::unordered_map* StorageImpl::storages = @@ -53,8 +53,9 @@ StorageModel::~StorageModel() * Resource * ************/ -StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite, - std::string type_id, std::string content_name, sg_size_t size, std::string attach) +StorageImpl::StorageImpl(kernel::resource::Model* model, std::string name, lmm_system_t maxminSystem, double bread, + double bwrite, std::string type_id, std::string content_name, sg_size_t size, + std::string attach) : Resource(model, name.c_str(), maxminSystem->constraint_new(this, std::max(bread, bwrite))) , piface_(this) , typeId_(type_id) diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index a77c79b3c3..ff0704a3c8 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -52,10 +52,11 @@ XBT_PUBLIC_DATA(simgrid::xbt::signal) storageState /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageAction *action, simgrid::surf::Action::State - * old, simgrid::surf::Action::State current)` + * @details Callback functions have the following signature: `void(StorageAction *action, + * simgrid::kernel::resource::Action::State old, simgrid::kernel::resource::Action::State current)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) +XBT_PUBLIC_DATA( + simgrid::xbt::signal) storageActionStateChangedCallbacks; /********* @@ -65,7 +66,7 @@ storageActionStateChangedCallbacks; * @brief SURF storage model interface class * @details A model is an object which handle the interactions between its Resources and its Actions */ -class StorageModel : public Model { +class StorageModel : public kernel::resource::Model { public: StorageModel(); ~StorageModel(); @@ -86,7 +87,7 @@ public: class StorageImpl : public kernel::resource::Resource, public PropertyHolder { public: /** @brief Storage constructor */ - StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite, + StorageImpl(kernel::resource::Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite, std::string type_id, std::string content_name, sg_size_t size, std::string attach); ~StorageImpl() override; @@ -151,7 +152,7 @@ enum e_surf_action_storage_type_t { /** @ingroup SURF_storage_interface * @brief SURF storage action interface class */ -class StorageAction : public Action { +class StorageAction : public kernel::resource::Action { public: /** * @brief StorageAction constructor @@ -162,7 +163,8 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type) + StorageAction(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, + e_surf_action_storage_type_t type) : Action(model, cost, failed), type_(type), storage_(storage){}; /** @@ -175,11 +177,11 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(Model* model, double cost, bool failed, kernel::lmm::Variable* var, StorageImpl* storage, - e_surf_action_storage_type_t type) + StorageAction(kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var, + StorageImpl* storage, e_surf_action_storage_type_t type) : Action(model, cost, failed, var), type_(type), storage_(storage){}; - void setState(simgrid::surf::Action::State state) override; + void setState(simgrid::kernel::resource::Action::State state) override; e_surf_action_storage_type_t type_; StorageImpl* storage_; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index c6bbc3512d..5c6f2dceb7 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2009-2011, 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -56,7 +55,7 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel() maxminSystem_ = new simgrid::kernel::lmm::System(selectiveUpdate_); if (getUpdateMechanism() == UM_LAZY) { - modifiedSet_ = new ActionLmmList(); + modifiedSet_ = new kernel::resource::ActionLmmList(); maxminSystem_->keep_track = modifiedSet_; } } @@ -138,13 +137,13 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) turnOff(); while ((var = cnst->get_variable(&elem))) { - Action* action = static_cast(var->get_id()); + kernel::resource::Action* action = static_cast(var->get_id()); - if (action->getState() == Action::State::running || - action->getState() == Action::State::ready || - action->getState() == Action::State::not_in_the_system) { + if (action->getState() == kernel::resource::Action::State::running || + action->getState() == kernel::resource::Action::State::ready || + action->getState() == kernel::resource::Action::State::not_in_the_system) { action->setFinishTime(date); - action->setState(Action::State::failed); + action->setState(kernel::resource::Action::State::failed); } } } @@ -176,7 +175,7 @@ CpuAction *CpuCas01::sleep(double duration) // FIXME: sleep variables should not consume 1.0 in System::expand() action->setMaxDuration(duration); - action->suspended_ = Action::SuspendStates::sleeping; + action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; if (duration < 0) { // NO_MAX_DURATION /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ simgrid::xbt::intrusive_erase(*action->getStateSet(), *action); @@ -199,7 +198,7 @@ CpuAction *CpuCas01::sleep(double duration) /********** * Action * **********/ -CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, +CpuCas01Action::CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, kernel::lmm::Constraint* constraint, int requestedCore) : CpuAction(model, cost, failed, model->getMaxminSystem()->variable_new(this, 1.0 / requestedCore, requestedCore * speed, 1)) @@ -212,7 +211,7 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp model->getMaxminSystem()->expand(constraint, getVariable(), 1.0); } -CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, +CpuCas01Action::CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, kernel::lmm::Constraint* constraint) : CpuCas01Action(model, cost, failed, speed, constraint, 1) { diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index b256781e7a..cefa230180 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -28,7 +28,7 @@ public: ~CpuCas01Model() override; Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; - ActionList p_cpuRunningActionSetThatDoesNotNeedBeingChecked; + kernel::resource::ActionList p_cpuRunningActionSetThatDoesNotNeedBeingChecked; }; /************ @@ -59,9 +59,10 @@ class CpuCas01Action: public CpuAction { friend CpuAction *CpuCas01::execution_start(double size); friend CpuAction *CpuCas01::sleep(double duration); public: - CpuCas01Action(Model* model, double cost, bool failed, double speed, kernel::lmm::Constraint* constraint, - int coreAmount); - CpuCas01Action(Model* model, double cost, bool failed, double speed, kernel::lmm::Constraint* constraint); + CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint, int coreAmount); + CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint); ~CpuCas01Action() override; int requestedCore(); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 1fcf505917..a223b686b8 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -33,7 +32,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) action->getLastUpdate(), now - action->getLastUpdate()); } - action->finish(Action::State::done); + action->finish(kernel::resource::Action::State::done); XBT_CDEBUG(surf_kernel, "Action %p finished", action); /* set the remains to 0 due to precision problems when updating the remaining amount */ @@ -43,7 +42,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) //defining the last timestamp that we can safely dump to trace file //without losing the event ascending order (considering all CPU's) double smaller = -1; - for (Action const& action : *getRunningActionSet()) { + for (kernel::resource::Action const& action : *getRunningActionSet()) { if (smaller < 0 || action.getLastUpdate() < smaller) smaller = action.getLastUpdate(); } @@ -72,7 +71,7 @@ void CpuModel::updateActionsStateFull(double now, double delta) if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) || ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) { - action.finish(Action::State::done); + action.finish(kernel::resource::Action::State::done); } } } @@ -80,12 +79,12 @@ void CpuModel::updateActionsStateFull(double now, double delta) /************ * Resource * ************/ -Cpu::Cpu(Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) - : Cpu(model, host, nullptr/*constraint*/, speedPerPstate, core) +Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, std::vector* speedPerPstate, int core) + : Cpu(model, host, nullptr /*constraint*/, speedPerPstate, core) { } -Cpu::Cpu(Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint, +Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint, std::vector* speedPerPstate, int core) : Resource(model, host->getCname(), constraint), coresAmount_(core), host_(host) { @@ -198,7 +197,7 @@ void CpuAction::updateRemainingLazy(double now) setLastValue(getVariable()->get_value()); } -simgrid::xbt::signal CpuAction::onStateChange; +simgrid::xbt::signal CpuAction::onStateChange; void CpuAction::suspend(){ Action::State previous = getState(); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 42e1a48dad..bc04a19294 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -24,7 +24,8 @@ namespace surf { * @brief SURF cpu model interface class * @details A model is an object which handle the interactions between its Resources and its Actions */ -XBT_PUBLIC_CLASS CpuModel : public Model { +XBT_PUBLIC_CLASS CpuModel : public kernel::resource::Model +{ public: /** * @brief Create a Cpu @@ -59,7 +60,7 @@ public: * @param speedPerPstate Processor speed (in flop per second) for each pstate * @param core The number of core of this Cpu */ - Cpu(simgrid::surf::Model * model, simgrid::s4u::Host * host, kernel::lmm::Constraint * constraint, + Cpu(simgrid::kernel::resource::Model * model, simgrid::s4u::Host * host, kernel::lmm::Constraint * constraint, std::vector * speedPerPstate, int core); /** @@ -70,7 +71,8 @@ public: * @param speedPerPstate Processor speed (in flop per second) for each pstate * @param core The number of core of this Cpu */ - Cpu(simgrid::surf::Model* model, simgrid::s4u::Host* host, std::vector* speedPerPstate, int core); + Cpu(simgrid::kernel::resource::Model * model, simgrid::s4u::Host * host, std::vector * speedPerPstate, + int core); ~Cpu(); @@ -80,7 +82,7 @@ public: * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing */ - virtual simgrid::surf::Action *execution_start(double size)=0; + virtual simgrid::kernel::resource::Action* execution_start(double size) = 0; /** * @brief Execute some quantity of computation on more than one core @@ -89,7 +91,7 @@ public: * @param requestedCores The desired amount of cores. Must be >= 1 * @return The CpuAction corresponding to the processing */ - virtual simgrid::surf::Action* execution_start(double size, int requestedCores) + virtual simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) { THROW_UNIMPLEMENTED; return nullptr; @@ -101,7 +103,7 @@ public: * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping */ - virtual simgrid::surf::Action *sleep(double duration)=0; + virtual simgrid::kernel::resource::Action* sleep(double duration) = 0; /** @brief Get the amount of cores */ virtual int coreCount(); @@ -146,26 +148,27 @@ public: /** @ingroup SURF_cpu_interface * @brief A CpuAction represents the execution of code on one or several Cpus */ -XBT_PUBLIC_CLASS CpuAction : public simgrid::surf::Action { +XBT_PUBLIC_CLASS CpuAction : public simgrid::kernel::resource::Action +{ friend XBT_PUBLIC(Cpu*) getActionCpu(CpuAction* action); public: /** @brief Signal emitted when the action state changes (ready/running/done, etc) - * Signature: `void(CpuAction *action, simgrid::surf::Action::State previous)` + * Signature: `void(CpuAction *action, simgrid::kernel::resource::Action::State previous)` */ - static simgrid::xbt::signal onStateChange; + static simgrid::xbt::signal onStateChange; /** @brief Signal emitted when the action share changes (amount of flops it gets) * Signature: `void(CpuAction *action)` */ static simgrid::xbt::signal onShareChange; - CpuAction(simgrid::surf::Model* model, double cost, bool failed) : Action(model, cost, failed) {} - CpuAction(simgrid::surf::Model * model, double cost, bool failed, kernel::lmm::Variable* var) + CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed) : Action(model, cost, failed) {} + CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var) : Action(model, cost, failed, var) { } - void setState(simgrid::surf::Action::State state) override; + void setState(simgrid::kernel::resource::Action::State state) override; void updateRemainingLazy(double now) override; std::list cpus(); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 2ad9288ff4..10e8039636 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -362,7 +361,7 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/) while (not actionHeapIsEmpty() && actionHeapTopDate() <= now) { CpuTiAction* action = static_cast(actionHeapPop()); XBT_DEBUG("Action %p: finish", action); - action->finish(Action::State::done); + action->finish(kernel::resource::Action::State::done); /* set the remains to 0 due to precision problems when updating the remaining amount */ action->setRemains(0); /* update remaining amount of all actions */ @@ -440,10 +439,11 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) /* put all action running on cpu to failed */ for (CpuTiAction& action : actionSet_) { - if (action.getState() == Action::State::running || action.getState() == Action::State::ready || - action.getState() == Action::State::not_in_the_system) { + if (action.getState() == kernel::resource::Action::State::running || + action.getState() == kernel::resource::Action::State::ready || + action.getState() == kernel::resource::Action::State::not_in_the_system) { action.setFinishTime(date); - action.setState(Action::State::failed); + action.setState(kernel::resource::Action::State::failed); action.heapRemove(model()->getActionHeap()); } } @@ -473,7 +473,7 @@ void CpuTi::updateActionsFinishTime(double now) continue; /* action suspended, skip it */ - if (action.suspended_ != Action::SuspendStates::not_suspended) + if (action.suspended_ != kernel::resource::Action::SuspendStates::not_suspended) continue; sum_priority += 1.0 / action.getPriority(); @@ -487,7 +487,7 @@ void CpuTi::updateActionsFinishTime(double now) continue; /* verify if the action is really running on cpu */ - if (action.suspended_ == Action::SuspendStates::not_suspended && action.getPriority() > 0) { + if (action.suspended_ == kernel::resource::Action::SuspendStates::not_suspended && action.getPriority() > 0) { /* total area needed to finish the action. Used in trace integration */ total_area = (action.getRemains()) * sum_priority * action.getPriority(); @@ -507,7 +507,7 @@ void CpuTi::updateActionsFinishTime(double now) } /* add in action heap */ if (min_finish > NO_MAX_DURATION) - action.heapUpdate(model()->getActionHeap(), min_finish, Action::Type::NOTSET); + action.heapUpdate(model()->getActionHeap(), min_finish, kernel::resource::Action::Type::NOTSET); else action.heapRemove(model()->getActionHeap()); @@ -550,7 +550,7 @@ void CpuTi::updateRemainingAmount(double now) continue; /* action suspended, skip it */ - if (action.suspended_ != Action::SuspendStates::not_suspended) + if (action.suspended_ != kernel::resource::Action::SuspendStates::not_suspended) continue; /* action don't need update */ @@ -589,7 +589,7 @@ CpuAction *CpuTi::sleep(double duration) CpuTiAction* action = new CpuTiAction(static_cast(model()), 1.0, isOff(), this); action->setMaxDuration(duration); - action->suspended_ = Action::SuspendStates::sleeping; + action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; if (duration == NO_MAX_DURATION) { /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ simgrid::xbt::intrusive_erase(*action->getStateSet(), *action); diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 609cff94f7..2f29bda284 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -85,7 +84,7 @@ class CpuTiAction: public CpuAction { public: CpuTiAction(CpuTiModel *model, double cost, bool failed, CpuTi *cpu); - void setState(simgrid::surf::Action::State state) override; + void setState(simgrid::kernel::resource::Action::State state) override; int unref() override; void cancel() override; void suspend() override; @@ -147,7 +146,7 @@ public: double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; - ActionList runningActionSetThatDoesNotNeedBeingChecked_; + kernel::resource::ActionList runningActionSetThatDoesNotNeedBeingChecked_; CpuTiList modifiedCpu_; }; diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 6c0ac6efa2..68051c7380 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -156,7 +156,7 @@ NetworkCm02Model::NetworkCm02Model() loopback_ = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE); if (getUpdateMechanism() == UM_LAZY) { - modifiedSet_ = new ActionLmmList(); + modifiedSet_ = new kernel::resource::ActionLmmList(); maxminSystem_->keep_track = modifiedSet_; } } @@ -191,19 +191,20 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) } // if I am wearing a latency hat - if (action->getType() == Action::Type::LATENCY) { + if (action->getType() == kernel::resource::Action::Type::LATENCY) { XBT_DEBUG("Latency paid for action %p. Activating", action); maxminSystem_->update_variable_weight(action->getVariable(), action->weight_); action->heapRemove(getActionHeap()); action->refreshLastUpdate(); // if I am wearing a max_duration or normal hat - } else if (action->getType() == Action::Type::MAX_DURATION || action->getType() == Action::Type::NORMAL) { + } else if (action->getType() == kernel::resource::Action::Type::MAX_DURATION || + action->getType() == kernel::resource::Action::Type::NORMAL) { // no need to communicate anymore // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); action->setRemains(0); - action->finish(Action::State::done); + action->finish(kernel::resource::Action::State::done); action->heapRemove(getActionHeap()); } } @@ -252,12 +253,12 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) || ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) { - action.finish(Action::State::done); + action.finish(kernel::resource::Action::State::done); } } } -Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) +kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { int failed = 0; double latency = 0.0; @@ -313,7 +314,8 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz // add to the heap the event when the latency is payed XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate()); action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), - route.empty() ? Action::Type::NORMAL : Action::Type::LATENCY); + route.empty() ? kernel::resource::Action::Type::NORMAL + : kernel::resource::Action::Type::LATENCY); } } else action->setVariable(maxminSystem_->variable_new(action, 1.0, -1.0, constraints_per_variable)); @@ -386,12 +388,12 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) turnOff(); while ((var = constraint()->get_variable(&elem))) { - Action* action = static_cast(var->get_id()); + kernel::resource::Action* action = static_cast(var->get_id()); - if (action->getState() == Action::State::running || - action->getState() == Action::State::ready) { + if (action->getState() == kernel::resource::Action::State::running || + action->getState() == kernel::resource::Action::State::ready) { action->setFinishTime(now); - action->setState(Action::State::failed); + action->setState(kernel::resource::Action::State::failed); } } } diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 7fd4187441..07486aa6f9 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -42,7 +42,7 @@ public: e_surf_link_sharing_policy_t policy) override; void updateActionsStateLazy(double now, double delta) override; void updateActionsStateFull(double now, double delta) override; - Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; + kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; }; /************ @@ -67,7 +67,7 @@ class NetworkCm02Action : public NetworkAction { friend NetworkSmpiModel; public: - NetworkCm02Action(Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){}; + NetworkCm02Action(kernel::resource::Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){}; virtual ~NetworkCm02Action() = default; void updateRemainingLazy(double now) override; }; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 166d70ef61..a2d9074599 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -32,7 +32,7 @@ LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, d double NetworkConstantModel::nextOccuringEvent(double /*now*/) { double min = -1.0; - for (Action const& action : *getRunningActionSet()) { + for (kernel::resource::Action const& action : *getRunningActionSet()) { const NetworkConstantAction& net_action = static_cast(action); if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) min = net_action.latency_; @@ -58,12 +58,12 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta) if ((action.getRemainsNoUpdate() <= 0) || ((action.getMaxDuration() != NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) { - action.finish(Action::State::done); + action.finish(kernel::resource::Action::State::done); } } } -Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) +kernel::resource::Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { NetworkConstantAction* action = new NetworkConstantAction(this, size, sg_latency_factor); diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 108941ced3..f12715bc4a 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -25,7 +25,8 @@ namespace simgrid { *********/ class NetworkConstantModel : public NetworkModel { public: - Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) override; + kernel::resource::Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, + double rate) override; double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 1dc1b1e5f1..edc43236c5 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -34,7 +34,7 @@ static void IB_action_state_changed_callback(simgrid::surf::NetworkAction* actio using simgrid::surf::NetworkIBModel; using simgrid::surf::IBNode; - if (action->getState() != simgrid::surf::Action::State::done) + if (action->getState() != simgrid::kernel::resource::Action::State::done) return; std::pair pair = ((NetworkIBModel*)surf_network_model)->active_comms[action]; XBT_DEBUG("IB callback - action %p finished", action); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index c53c07dee3..0549d1dda2 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -85,7 +84,7 @@ namespace simgrid { { double minRes = Model::nextOccuringEventFull(now); - for (Action const& action : *getRunningActionSet()) { + for (kernel::resource::Action const& action : *getRunningActionSet()) { const NetworkAction& net_action = static_cast(action); if (net_action.latency_ > 0) minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_); diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 0dd7dacfeb..8863627ba5 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -30,7 +30,7 @@ namespace surf { * @brief SURF network model interface class * @details A model is an object which handles the interactions between its Resources and its Actions */ -class NetworkModel : public Model { +class NetworkModel : public kernel::resource::Model { public: /** @brief Constructor */ NetworkModel() : Model() {} @@ -61,7 +61,7 @@ public: * unlimited. * @return The action representing the communication */ - virtual Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size, double rate) = 0; + virtual kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) = 0; /** @brief Function pointer to the function to use to solve the lmm_system_t * @@ -188,7 +188,7 @@ public: * @brief SURF network action interface class * @details A NetworkAction represents a communication between two [hosts](\ref HostImpl) */ -class NetworkAction : public simgrid::surf::Action { +class NetworkAction : public simgrid::kernel::resource::Action { public: /** @brief Constructor * @@ -196,7 +196,10 @@ public: * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] */ - NetworkAction(simgrid::surf::Model* model, double cost, bool failed) : simgrid::surf::Action(model, cost, failed) {} + NetworkAction(simgrid::kernel::resource::Model* model, double cost, bool failed) + : simgrid::kernel::resource::Action(model, cost, failed) + { + } /** * @brief NetworkAction constructor @@ -206,10 +209,10 @@ public: * @param failed [description] * @param var The lmm variable associated to this Action if it is part of a LMM component */ - NetworkAction(simgrid::surf::Model* model, double cost, bool failed, kernel::lmm::Variable* var) - : simgrid::surf::Action(model, cost, failed, var){}; + NetworkAction(simgrid::kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var) + : simgrid::kernel::resource::Action(model, cost, failed, var){}; - void setState(simgrid::surf::Action::State state) override; + void setState(simgrid::kernel::resource::Action::State state) override; virtual std::list links(); double latency_ = {}; diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 273b564f32..05f1e9c7dd 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -175,7 +175,7 @@ LinkImpl* NetworkNS3Model::createLink(const std::string& name, double bandwidth, return new LinkNS3(this, name, bandwidth, latency); } -Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) +kernel::resource::Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { return new NetworkNS3Action(this, size, src, dst); } @@ -223,8 +223,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) XBT_DEBUG("Processing socket %p (action %p)",sgFlow,action); action->setRemains(action->getCost() - sgFlow->sentBytes_); - if (TRACE_is_enabled() && - action->getState() == Action::State::running){ + if (TRACE_is_enabled() && action->getState() == kernel::resource::Action::State::running) { double data_delta_sent = sgFlow->sentBytes_ - action->lastSent_; std::vector route = std::vector(); @@ -240,7 +239,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) if(sgFlow->finished_){ socket_to_destroy.push_back(ns3Socket); XBT_DEBUG("Destroy socket %p of action %p", ns3Socket.c_str(), action); - action->finish(Action::State::done); + action->finish(kernel::resource::Action::State::done); } else { XBT_DEBUG("Socket %p sent %u bytes out of %u (%u remaining)", ns3Socket.c_str(), sgFlow->sentBytes_, sgFlow->totalBytes_, sgFlow->remaining_); @@ -289,7 +288,7 @@ void LinkNS3::setLatencyTrace(tmgr_trace_t trace) { * Action * **********/ -NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst) +NetworkNS3Action::NetworkNS3Action(kernel::resource::Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst) : NetworkAction(model, totalBytes, false) { XBT_DEBUG("Communicate from %s to %s", src->getCname(), dst->getCname()); diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index ae7f9bdd61..7ed353a5a3 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -19,7 +19,7 @@ public: ~NetworkNS3Model(); LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; - Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; + kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; double nextOccuringEvent(double now) override; bool nextOccuringEventIsIdempotent() override { return false; } void updateActionsState(double now, double delta) override; @@ -45,7 +45,7 @@ public: **********/ class XBT_PRIVATE NetworkNS3Action : public NetworkAction { public: - NetworkNS3Action(Model* model, double cost, s4u::Host* src, s4u::Host* dst); + NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst); bool isSuspended() override; int unref() override; diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index 55236368e7..81b4c9b559 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -389,7 +389,7 @@ static void onCreation(simgrid::s4u::Host& host) host.extension_set(new HostEnergy(&host)); } -static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf::Action::State previous) +static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State previous) { for (simgrid::surf::Cpu* const& cpu : action->cpus()) { simgrid::s4u::Host* host = cpu->getHost(); diff --git a/src/surf/plugins/host_load.cpp b/src/surf/plugins/host_load.cpp index 31ea874530..f30692e307 100644 --- a/src/surf/plugins/host_load.cpp +++ b/src/surf/plugins/host_load.cpp @@ -158,7 +158,7 @@ static void onHostChange(simgrid::s4u::Host& host) } /* This callback is called when an action (computation, idle, ...) terminates */ -static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf::Action::State /*previous*/) +static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/) { for (simgrid::surf::Cpu* const& cpu : action->cpus()) { simgrid::s4u::Host* host = cpu->getHost(); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index d4eb8a24bd..3707a56128 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2007-2010, 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -71,7 +70,7 @@ NetworkL07Model::~NetworkL07Model() double HostL07Model::nextOccuringEvent(double now) { double min = HostModel::nextOccuringEventFull(now); - for (Action const& action : *getRunningActionSet()) { + for (kernel::resource::Action const& action : *getRunningActionSet()) { const L07Action& net_action = static_cast(action); if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) { min = net_action.latency_; @@ -116,7 +115,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) || ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) { - action.finish(Action::State::done); + action.finish(kernel::resource::Action::State::done); } else { /* Need to check that none of the model has failed */ int i = 0; @@ -126,7 +125,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) void* constraint_id = cnst->get_id(); if (static_cast(constraint_id)->isOff()) { XBT_DEBUG("Action (%p) Failed!!", &action); - action.finish(Action::State::failed); + action.finish(kernel::resource::Action::State::failed); break; } cnst = action.getVariable()->get_constraint(i); @@ -135,17 +134,15 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) } } -Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount,double rate) { +kernel::resource::Action* HostL07Model::executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, + double* bytes_amount, double rate) +{ return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate); } -L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount, double rate) - : CpuAction(model, 1, 0) - , computationAmount_(flops_amount) - , communicationAmount_(bytes_amount) - , rate_(rate) +L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* host_list, double* flops_amount, + double* bytes_amount, double rate) + : CpuAction(model, 1, 0), computationAmount_(flops_amount), communicationAmount_(bytes_amount), rate_(rate) { int nb_link = 0; int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */ @@ -214,7 +211,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list, delete[] host_list; } -Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) +kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) { sg_host_t* host_list = new sg_host_t[2](); double* flops_amount = new double[2](); @@ -262,7 +259,7 @@ LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwid s4u::Link::onCreation(this->piface_); } -Action *CpuL07::execution_start(double size) +kernel::resource::Action* CpuL07::execution_start(double size) { sg_host_t* host_list = new sg_host_t[1](); double* flops_amount = new double[1](); @@ -273,11 +270,11 @@ Action *CpuL07::execution_start(double size) return static_cast(model())->hostModel_->executeParallelTask(1, host_list, flops_amount, nullptr, -1); } -Action *CpuL07::sleep(double duration) +kernel::resource::Action* CpuL07::sleep(double duration) { L07Action *action = static_cast(execution_start(1.0)); action->setMaxDuration(duration); - action->suspended_ = Action::SuspendStates::sleeping; + action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0); return action; @@ -294,7 +291,7 @@ void CpuL07::onSpeedChange() { model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale); while ((var = constraint()->get_variable(&elem))) { - Action* action = static_cast(var->get_id()); + kernel::resource::Action* action = static_cast(var->get_id()); model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak); } diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 4ae5bb8dd8..aff79640b7 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -41,8 +40,8 @@ public: double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; - Action *executeParallelTask(int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount, double rate) override; + kernel::resource::Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, + double* bytes_amount, double rate) override; }; class CpuL07Model : public CpuModel { @@ -61,7 +60,7 @@ public: LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; - Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; + kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; HostL07Model *hostModel_; }; @@ -76,8 +75,8 @@ public: ~CpuL07() override; bool isUsed() override; void apply_event(tmgr_trace_event_t event, double value) override; - Action* execution_start(double size) override; - Action* sleep(double duration) override; + kernel::resource::Action* execution_start(double size) override; + kernel::resource::Action* sleep(double duration) override; protected: void onSpeedChange() override; @@ -103,8 +102,9 @@ class L07Action : public CpuAction { friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list, double *flops_amount, double *bytes_amount, double rate); public: - L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate); - ~L07Action(); + L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* host_list, double* flops_amount, + double* bytes_amount, double rate); + ~L07Action(); void updateBound(); diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 9c951540c4..62e7d21192 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -87,7 +87,7 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) if (((action.getRemainsNoUpdate() <= 0) && (action.getVariable()->get_weight() > 0)) || ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) { - action.finish(Action::State::done); + action.finish(kernel::resource::Action::State::done); } } } @@ -118,7 +118,7 @@ StorageAction* StorageN11::write(sg_size_t size) * Action * **********/ -StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, +StorageN11Action::StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type) : StorageAction(model, cost, failed, model->getMaxminSystem()->variable_new(this, 1.0, -1.0, 3), storage, type) { diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index b6d8c4f7ea..9414ac6261 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -53,7 +52,8 @@ public: class StorageN11Action : public StorageAction { public: - StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type); + StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, + e_surf_action_storage_type_t type); void suspend(); int unref(); void cancel(); diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 98b5dd9c1d..659be87a77 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -150,28 +150,31 @@ double surf_solve(double max_date) /********* * MODEL * *********/ -static surf_action_t ActionListExtract(simgrid::surf::ActionList* list) +static simgrid::kernel::resource::Action* ActionListExtract(simgrid::kernel::resource::ActionList* list) { if (list->empty()) return nullptr; - surf_action_t res = &list->front(); + simgrid::kernel::resource::Action* res = &list->front(); list->pop_front(); return res; } -surf_action_t surf_model_extract_done_action_set(surf_model_t model) +simgrid::kernel::resource::Action* surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model) { return ActionListExtract(model->getDoneActionSet()); } -surf_action_t surf_model_extract_failed_action_set(surf_model_t model){ +simgrid::kernel::resource::Action* surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model) +{ return ActionListExtract(model->getFailedActionSet()); } -int surf_model_running_action_set_size(surf_model_t model){ +int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model) +{ return model->getRunningActionSet()->size(); } -void surf_cpu_action_set_bound(surf_action_t action, double bound) { +void surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound) +{ static_cast(action)->setBound(bound); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 222720f6c5..f45907ef1a 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -29,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke * Utils * *********/ -std::vector * all_existing_models = nullptr; /* to destroy models correctly */ +std::vector* all_existing_models = nullptr; /* to destroy models correctly */ simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr; std::vector surf_path; @@ -307,7 +307,7 @@ void surf_init(int *argc, char **argv) xbt_init(argc, argv); if (not all_existing_models) - all_existing_models = new std::vector(); + all_existing_models = new std::vector(); if (not future_evt_set) future_evt_set = new simgrid::trace_mgr::future_evt_set(); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index b8e41a1d8a..385a234718 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -80,6 +80,6 @@ int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path); /** \ingroup SURF_models * \brief List of initialized models */ -XBT_PUBLIC_DATA(std::vector*) all_existing_models; +XBT_PUBLIC_DATA(std::vector*) all_existing_models; #endif /* SURF_MODEL_H_ */ diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index 333ecff1e9..e05c1f5ec9 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -11,18 +11,18 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); -static const char *string_action(simgrid::surf::Action::State state) +static const char* string_action(simgrid::kernel::resource::Action::State state) { switch (state) { - case simgrid::surf::Action::State::ready: + case simgrid::kernel::resource::Action::State::ready: return "SURF_ACTION_READY"; - case simgrid::surf::Action::State::running: + case simgrid::kernel::resource::Action::State::running: return "SURF_ACTION_RUNNING"; - case simgrid::surf::Action::State::failed: + case simgrid::kernel::resource::Action::State::failed: return "SURF_ACTION_FAILED"; - case simgrid::surf::Action::State::done: + case simgrid::kernel::resource::Action::State::done: return "SURF_ACTION_DONE"; - case simgrid::surf::Action::State::not_in_the_system: + case simgrid::kernel::resource::Action::State::not_in_the_system: return "SURF_ACTION_NOT_IN_THE_SYSTEM"; default: return "INVALID STATE"; @@ -44,13 +44,13 @@ int main(int argc, char **argv) simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B"); /* Let's do something on it */ - simgrid::surf::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0); - simgrid::surf::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0); - simgrid::surf::Action* actionC = hostB->pimpl_cpu->sleep(7.32); + simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0); + simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0); + simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32); - simgrid::surf::Action::State stateActionA = actionA->getState(); - simgrid::surf::Action::State stateActionB = actionB->getState(); - simgrid::surf::Action::State stateActionC = actionC->getState(); + simgrid::kernel::resource::Action::State stateActionA = actionA->getState(); + simgrid::kernel::resource::Action::State stateActionB = actionB->getState(); + simgrid::kernel::resource::Action::State stateActionC = actionC->getState(); /* And just look at the state of these tasks */ XBT_INFO("actionA state: %s", string_action(stateActionA)); @@ -66,9 +66,9 @@ int main(int argc, char **argv) XBT_INFO("Next Event : %g", surf_get_clock()); XBT_DEBUG("\t CPU actions"); - simgrid::surf::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet(); + simgrid::kernel::resource::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet(); while (not action_list->empty()) { - simgrid::surf::Action& action = action_list->front(); + simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" CPU Failed action"); XBT_DEBUG("\t * Failed : %p", &action); action.unref(); @@ -76,7 +76,7 @@ int main(int argc, char **argv) action_list = surf_cpu_model_pm->getDoneActionSet(); while (not action_list->empty()) { - simgrid::surf::Action& action = action_list->front(); + simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" CPU Done action"); XBT_DEBUG("\t * Done : %p", &action); action.unref(); @@ -84,7 +84,7 @@ int main(int argc, char **argv) action_list = surf_network_model->getFailedActionSet(); while (not action_list->empty()) { - simgrid::surf::Action& action = action_list->front(); + simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" Network Failed action"); XBT_DEBUG("\t * Failed : %p", &action); action.unref(); @@ -92,7 +92,7 @@ int main(int argc, char **argv) action_list = surf_network_model->getDoneActionSet(); while (not action_list->empty()) { - simgrid::surf::Action& action = action_list->front(); + simgrid::kernel::resource::Action& action = action_list->front(); XBT_INFO(" Network Done action"); XBT_DEBUG("\t * Done : %p", &action); action.unref(); diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index 41e5c971bb..1637939e73 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -1,6 +1,6 @@ /* A few basic tests for the surf library */ -/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -36,7 +36,7 @@ int main(int argc, char **argv) surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */ do { - surf_action_t action = nullptr; + simgrid::kernel::resource::Action* action = nullptr; running = 0; double now = surf_get_clock(); -- 2.20.1