class System;
}
namespace resource {
+class Action;
+class Model;
class Resource;
}
namespace routing {
namespace simgrid {
namespace surf {
-class Model;
class CpuModel;
class HostModel;
class NetworkModel;
class StorageModel;
class NetworkCm02Link;
-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... */
* @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
* @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
* @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]
* @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);
/** @} */
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;
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;
/* 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;
{
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());
-/* 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. */
/* 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<void(kernel::activity::ExecImplPtr)> onCreation;
static simgrid::xbt::signal<void(kernel::activity::ExecImplPtr)> onCompletion;
static simgrid::xbt::signal<void(simgrid::kernel::activity::ExecImplPtr, simgrid::s4u::Host*)> onMigration;
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;
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 */
};
}
}
}
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:
void resume() override;
void post() override;
- surf_action_t surf_io = nullptr;
+ simgrid::kernel::resource::Action* surf_io = nullptr;
};
}}} // namespace simgrid::kernel::activity
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);
void resume() override;
void post() override;
- surf_action_t sleep = nullptr;
+ simgrid::kernel::resource::Action* sleep = nullptr;
};
}}} // namespace simgrid::kernel::activity
delete static_cast<Variable*>(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);
cnst.usage = elem.consumption_weight / elem.variable->sharing_weight;
elem.make_active();
- simgrid::surf::Action* action = static_cast<simgrid::surf::Action*>(elem.variable->id);
+ simgrid::kernel::resource::Action* action = static_cast<simgrid::kernel::resource::Action*>(elem.variable->id);
if (keep_track && not action->isLinkedModifiedSet())
keep_track->push_back(*action);
}
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;
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);
/**
* @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
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} */
* @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
&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);
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)
} // namespace surf
} // namespace simgrid
+} // namespace simgrid
#include "src/surf/surf_interface.hpp"
namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
-typedef std::pair<double, simgrid::surf::Action*> heap_element_type;
+typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
typedef boost::heap::pairing_heap<heap_element_type, boost::heap::constant_time_size<false>, boost::heap::stable<true>,
boost::heap::compare<simgrid::xbt::HeapComparator<heap_element_type>>>
heap_type;
* @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
* @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 */
/** @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_;
-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 */
typedef Action::ActionLmmList* ActionLmmListPtr;
} // namespace surf
} // namespace simgrid
+} // namespace simgrid
#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(resource);
namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
Model::Model() : maxminSystem_(nullptr)
{
} // namespace surf
} // namespace simgrid
+} // namespace simgrid
#include "src/kernel/resource/Action.hpp"
namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
/** @ingroup SURF_interface
* @brief SURF model interface class
} // namespace surf
} // namespace simgrid
-
+} // namespace simgrid
#endif
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)
{
}
return constraint_->get_usage();
}
-surf::Model* Resource::model() const
+Model* Resource::model() const
{
return model_;
}
* @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;
private:
std::string name_;
- surf::Model* model_;
+ Model* model_;
bool isOn_ = true;
public: /* LMM */
-/* 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. */
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);
/* 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<SD_task_t>(action->getData());
XBT_VERB("Task '%s' done", SD_task_get_name(task));
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*/
[](void*, void* arg) {
auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(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;
},
/** 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)");
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 =
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;
-/* 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. */
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)) {
* @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);
};
/************
-/* 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. */
simgrid::xbt::signal<void(StorageImpl*)> storageCreatedCallbacks;
simgrid::xbt::signal<void(StorageImpl*)> storageDestructedCallbacks;
simgrid::xbt::signal<void(StorageImpl*, int, int)> storageStateChangedCallbacks; // signature: wasOn, isOn
-simgrid::xbt::signal<void(StorageAction*, Action::State, Action::State)> storageActionStateChangedCallbacks;
+simgrid::xbt::signal<void(StorageAction*, kernel::resource::Action::State, kernel::resource::Action::State)>
+ storageActionStateChangedCallbacks;
/* List of storages */
std::unordered_map<std::string, StorageImpl*>* StorageImpl::storages =
* 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)
/** @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<void(StorageAction*, Action::State, Action::State)>)
+XBT_PUBLIC_DATA(
+ simgrid::xbt::signal<void(StorageAction*, kernel::resource::Action::State, kernel::resource::Action::State)>)
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();
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;
/** @ingroup SURF_storage_interface
* @brief SURF storage action interface class
*/
-class StorageAction : public Action {
+class StorageAction : public kernel::resource::Action {
public:
/**
* @brief StorageAction constructor
* @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){};
/**
* @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_;
-/* 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. */
maxminSystem_ = new simgrid::kernel::lmm::System(selectiveUpdate_);
if (getUpdateMechanism() == UM_LAZY) {
- modifiedSet_ = new ActionLmmList();
+ modifiedSet_ = new kernel::resource::ActionLmmList();
maxminSystem_->keep_track = modifiedSet_;
}
}
turnOff();
while ((var = cnst->get_variable(&elem))) {
- Action* action = static_cast<Action*>(var->get_id());
+ kernel::resource::Action* action = static_cast<kernel::resource::Action*>(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);
}
}
}
// 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);
/**********
* 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))
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)
{
-/* 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. */
~CpuCas01Model() override;
Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
- ActionList p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
+ kernel::resource::ActionList p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
};
/************
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();
-/* 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. */
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 */
//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();
}
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);
}
}
}
/************
* Resource *
************/
-Cpu::Cpu(Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
- : Cpu(model, host, nullptr/*constraint*/, speedPerPstate, core)
+Cpu::Cpu(kernel::resource::Model* model, simgrid::s4u::Host* host, std::vector<double>* 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<double>* speedPerPstate, int core)
: Resource(model, host->getCname(), constraint), coresAmount_(core), host_(host)
{
setLastValue(getVariable()->get_value());
}
-simgrid::xbt::signal<void(simgrid::surf::CpuAction*, Action::State)> CpuAction::onStateChange;
+simgrid::xbt::signal<void(simgrid::surf::CpuAction*, kernel::resource::Action::State)> CpuAction::onStateChange;
void CpuAction::suspend(){
Action::State previous = getState();
* @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
* @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<double> * speedPerPstate, int core);
/**
* @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<double>* speedPerPstate, int core);
+ Cpu(simgrid::kernel::resource::Model * model, simgrid::s4u::Host * host, std::vector<double> * speedPerPstate,
+ int core);
~Cpu();
* @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
* @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;
* @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();
/** @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<void(simgrid::surf::CpuAction*, simgrid::surf::Action::State)> onStateChange;
+ static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, simgrid::kernel::resource::Action::State)> onStateChange;
/** @brief Signal emitted when the action share changes (amount of flops it gets)
* Signature: `void(CpuAction *action)`
*/
static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> 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<Cpu*> cpus();
-/* 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. */
while (not actionHeapIsEmpty() && actionHeapTopDate() <= now) {
CpuTiAction* action = static_cast<CpuTiAction*>(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 */
/* 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());
}
}
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();
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();
}
/* 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());
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 */
CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(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);
-/* 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. */
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;
double nextOccuringEvent(double now) override;
void updateActionsState(double now, double delta) override;
- ActionList runningActionSetThatDoesNotNeedBeingChecked_;
+ kernel::resource::ActionList runningActionSetThatDoesNotNeedBeingChecked_;
CpuTiList modifiedCpu_;
};
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_;
}
}
}
// 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());
}
}
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;
// 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));
turnOff();
while ((var = constraint()->get_variable(&elem))) {
- Action* action = static_cast<Action*>(var->get_id());
+ kernel::resource::Action* action = static_cast<kernel::resource::Action*>(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);
}
}
}
-/* 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. */
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;
};
/************
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;
};
-/* 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. */
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<const NetworkConstantAction&>(action);
if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min))
min = net_action.latency_;
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);
-/* 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. */
*********/
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;
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<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
XBT_DEBUG("IB callback - action %p finished", action);
-/* 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. */
{
double minRes = Model::nextOccuringEventFull(now);
- for (Action const& action : *getRunningActionSet()) {
+ for (kernel::resource::Action const& action : *getRunningActionSet()) {
const NetworkAction& net_action = static_cast<const NetworkAction&>(action);
if (net_action.latency_ > 0)
minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_);
* @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() {}
* 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
*
* @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
*
* @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
* @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<LinkImpl*> links();
double latency_ = {};
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);
}
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<LinkImpl*> route = std::vector<LinkImpl*>();
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_);
* 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());
~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;
**********/
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;
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();
}
/* 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();
-/* 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. */
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<const L07Action&>(action);
if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
min = net_action.latency_;
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;
void* constraint_id = cnst->get_id();
if (static_cast<simgrid::kernel::resource::Resource*>(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);
}
}
-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) */
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]();
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]();
return static_cast<CpuL07Model*>(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<L07Action*>(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;
model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale);
while ((var = constraint()->get_variable(&elem))) {
- Action* action = static_cast<Action*>(var->get_id());
+ kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
}
-/* 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. */
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 {
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_;
};
~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;
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();
-/* 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. */
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);
}
}
}
* 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)
{
-/* 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. */
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();
/*********
* 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<simgrid::surf::CpuAction*>(action)->setBound(bound);
}
* Utils *
*********/
-std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
+std::vector<simgrid::kernel::resource::Model*>* all_existing_models = nullptr; /* to destroy models correctly */
simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
std::vector<std::string> surf_path;
xbt_init(argc, argv);
if (not all_existing_models)
- all_existing_models = new std::vector<simgrid::surf::Model*>();
+ all_existing_models = new std::vector<simgrid::kernel::resource::Model*>();
if (not future_evt_set)
future_evt_set = new simgrid::trace_mgr::future_evt_set();
/** \ingroup SURF_models
* \brief List of initialized models
*/
-XBT_PUBLIC_DATA(std::vector<surf_model_t>*) all_existing_models;
+XBT_PUBLIC_DATA(std::vector<simgrid::kernel::resource::Model*>*) all_existing_models;
#endif /* SURF_MODEL_H_ */
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";
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));
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();
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();
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();
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();
/* 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. */
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();