void ActivityImpl::clean_action()
{
- if (surf_action_) {
- surf_action_->unref();
- surf_action_ = nullptr;
+ if (model_action_) {
+ model_action_->unref();
+ model_action_ = nullptr;
}
}
double ActivityImpl::get_remaining() const
{
- return surf_action_ ? surf_action_->get_remains() : 0;
+ return model_action_ ? model_action_->get_remains() : 0;
}
const char* ActivityImpl::get_state_str() const
void ActivityImpl::suspend()
{
- if (surf_action_ == nullptr)
+ if (model_action_ == nullptr)
return;
- XBT_VERB("This activity is suspended (remain: %f)", surf_action_->get_remains());
- surf_action_->suspend();
+ XBT_VERB("This activity is suspended (remain: %f)", model_action_->get_remains());
+ model_action_->suspend();
s4u::Activity::on_suspended(*get_iface());
}
void ActivityImpl::resume()
{
- if (surf_action_ == nullptr)
+ if (model_action_ == nullptr)
return;
- XBT_VERB("This activity is resumed (remain: %f)", surf_action_->get_remains());
- surf_action_->resume();
+ XBT_VERB("This activity is resumed (remain: %f)", model_action_->get_remains());
+ model_action_->resume();
s4u::Activity::on_resumed(*get_iface());
}
void ActivityImpl::cancel()
{
XBT_VERB("Activity %p is canceled", this);
- if (surf_action_ != nullptr)
- surf_action_->cancel();
+ if (model_action_ != nullptr)
+ model_action_->cancel();
state_ = State::CANCELED;
}
virtual ~ActivityImpl();
ActivityImpl() = default;
std::list<actor::Simcall*> simcalls_; /* List of simcalls waiting for this activity */
- s4u::Activity* piface_ = nullptr;
- resource::Action* surf_action_ = nullptr;
+ s4u::Activity* piface_ = nullptr;
+ resource::Action* model_action_ = nullptr; /* The resource consumption in the used model */
protected:
void inline set_name(std::string_view name)
bool test(actor::ActorImpl* issuer = nullptr) override;
void wait_for(actor::ActorImpl* issuer, double timeout) override;
void post() override
- { /*no surf action*/
+ { /* no model action */
}
void finish() override;
void set_exception(actor::ActorImpl* issuer) override
/* Getting the network_model from the origin host
* Valid while we have a single network model, otherwise we would need to change this function to first get the
- * routes and later create the respective surf actions */
+ * routes and later create the respective model actions */
auto net_model = from_->get_netpoint()->get_englobing_zone()->get_network_model();
- surf_action_ = net_model->communicate(from_, to_, size_, rate_, false);
- surf_action_->set_activity(this);
- surf_action_->set_category(get_tracing_category());
- set_start_time(surf_action_->get_start_time());
+ model_action_ = net_model->communicate(from_, to_, size_, rate_, false);
+ model_action_->set_activity(this);
+ model_action_->set_category(get_tracing_category());
+ set_start_time(model_action_->get_start_time());
set_state(State::RUNNING);
on_start(*this);
- XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p; state: %s)", this, from_->get_cname(),
- to_->get_cname(), surf_action_, get_state_str());
+ XBT_DEBUG("Starting communication %p from '%s' to '%s' (model action: %p; state: %s)", this, from_->get_cname(),
+ to_->get_cname(), model_action_, get_state_str());
/* If a link is failed, detect it immediately */
- if (surf_action_->get_state() == resource::Action::State::FAILED) {
+ if (model_action_->get_state() == resource::Action::State::FAILED) {
XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", from_->get_cname(),
to_->get_cname());
set_state(State::LINK_FAILURE);
"communication",
dst_actor_->get_cname(), dst_actor_->get_host()->get_cname());
- surf_action_->suspend();
+ model_action_->suspend();
}
}
// find a match in the list of already received comms
other_comm = mbox->find_matching_comm(CommImplType::SEND, observer->get_match_fun(), observer->get_payload(),
this_synchro, /*done*/ true, /*remove_matching*/ true);
- if (other_comm && other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) {
+ if (other_comm && other_comm->model_action_ && other_comm->get_remaining() < 1e-12) {
XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
other_comm->set_state(State::DONE);
other_comm->set_mailbox(nullptr);
void CommImpl::suspend()
{
/* FIXME: shall we suspend also the timeout synchro? */
- if (surf_action_)
- surf_action_->suspend();
+ if (model_action_)
+ model_action_->suspend();
/* if not created yet, the action will be suspended on creation, in CommImpl::start() */
}
void CommImpl::resume()
{
/*FIXME: check what happen with the timeouts */
- if (surf_action_)
- surf_action_->resume();
+ if (model_action_)
+ model_action_->resume();
/* in the other case, the synchro were not really suspended yet, see CommImpl::suspend() and CommImpl::start() */
}
mbox_->remove(this);
set_state(State::CANCELED);
}
- } else if (not MC_is_active() /* when running the MC there are no surf actions */
+ } else if (not MC_is_active() /* when running the MC there are no model actions */
&& not MC_record_replay_is_active() && (get_state() == State::READY || get_state() == State::RUNNING)) {
- surf_action_->cancel();
+ model_action_->cancel();
}
}
set_state(State::SRC_HOST_FAILURE);
else if ((to_ && not to_->is_on()) || (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FAILED))
set_state(State::DST_HOST_FAILURE);
- else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) {
+ else if (model_action_ && model_action_->get_state() == resource::Action::State::FAILED) {
set_state(State::LINK_FAILURE);
} else if (get_state() == State::RUNNING) {
xbt_assert(from_ && from_->is_on());
XBT_DEBUG("CommImpl::post(): comm %p, state %s, src_proc %p, dst_proc %p, detached: %d", this, get_state_str(),
src_actor_.get(), dst_actor_.get(), detached_);
- /* destroy the surf actions associated with the Simix communication */
+ /* destroy the model actions associated with the communication activity */
cleanup_surf();
/* Answer all simcalls associated with the synchro */
if (not MC_is_active() && not MC_record_replay_is_active()) {
if (get_hosts().size() == 1) {
if (thread_count_ == 1) {
- surf_action_ = get_host()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
- surf_action_->set_sharing_penalty(sharing_penalty_);
+ model_action_ = get_host()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
+ model_action_->set_sharing_penalty(sharing_penalty_);
} else {
auto host_model = get_host()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_thread(get_host(), flops_amounts_.front(), thread_count_);
+ model_action_ = host_model->execute_thread(get_host(), flops_amounts_.front(), thread_count_);
}
- surf_action_->set_category(get_tracing_category());
+ model_action_->set_category(get_tracing_category());
} else {
// get the model from first host since we have only 1 by now
auto host_model = get_host()->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->execute_parallel(get_hosts(), flops_amounts_.data(), bytes_amounts_.data(), -1);
+ model_action_ = host_model->execute_parallel(get_hosts(), flops_amounts_.data(), bytes_amounts_.data(), -1);
}
- surf_action_->set_activity(this);
- set_start_time(surf_action_->get_start_time());
+ model_action_->set_activity(this);
+ set_start_time(model_action_->get_start_time());
}
XBT_DEBUG("Create execute synchro %p: %s", this, get_cname());
{
if (get_state() == State::WAITING)
return 1;
- return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains() / surf_action_->get_cost();
+ return (model_action_ == nullptr) ? 0 : model_action_->get_remains() / model_action_->get_cost();
}
double ExecImpl::get_par_remaining_ratio()
// parallel task: their remain is already between 0 and 1
if (get_state() == State::WAITING)
return 1;
- return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains();
+ return (model_action_ == nullptr) ? 0 : model_action_->get_remains();
}
ExecImpl& ExecImpl::set_bound(double bound)
ExecImpl& ExecImpl::update_sharing_penalty(double sharing_penalty)
{
sharing_penalty_ = sharing_penalty;
- surf_action_->set_sharing_penalty(sharing_penalty);
+ model_action_->set_sharing_penalty(sharing_penalty);
return *this;
}
void ExecImpl::post()
{
- xbt_assert(surf_action_ != nullptr);
+ xbt_assert(model_action_ != nullptr);
if (auto const& hosts = get_hosts();
std::any_of(hosts.begin(), hosts.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
/* If one of the hosts running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
set_state(State::FAILED);
- } else if (surf_action_->get_state() == resource::Action::State::FAILED) {
+ } else if (model_action_->get_state() == resource::Action::State::FAILED) {
/* If all the hosts are running the synchro didn't fail, then the synchro was canceled */
set_state(State::CANCELED);
} else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED &&
- surf_action_->get_remains() > 0.0) {
- surf_action_->set_state(resource::Action::State::FAILED);
+ model_action_->get_remains() > 0.0) {
+ model_action_->set_state(resource::Action::State::FAILED);
set_state(State::TIMEOUT);
} else {
set_state(State::DONE);
ActivityImpl* ExecImpl::migrate(s4u::Host* to)
{
if (not MC_is_active() && not MC_record_replay_is_active()) {
- resource::Action* old_action = this->surf_action_;
+ resource::Action* old_action = this->model_action_;
resource::Action* new_action = to->get_cpu()->execution_start(old_action->get_cost(), old_action->get_user_bound());
new_action->set_remains(old_action->get_remains());
new_action->set_activity(this);
old_action->set_activity(nullptr);
old_action->cancel();
old_action->unref();
- this->surf_action_ = new_action;
+ this->model_action_ = new_action;
}
on_migration(*this, to);
IoImpl& IoImpl::update_sharing_penalty(double sharing_penalty)
{
sharing_penalty_ = sharing_penalty;
- surf_action_->set_sharing_penalty(sharing_penalty);
+ model_action_->set_sharing_penalty(sharing_penalty);
return *this;
}
set_state(State::RUNNING);
if (dst_host_ == nullptr) {
XBT_DEBUG("Starting regular I/O");
- surf_action_ = disk_->io_start(size_, type_);
- surf_action_->set_sharing_penalty(sharing_penalty_);
+ model_action_ = disk_->io_start(size_, type_);
+ model_action_->set_sharing_penalty(sharing_penalty_);
} else {
XBT_DEBUG("Starting streaming I/O");
auto host_model = dst_host_->get_netpoint()->get_englobing_zone()->get_host_model();
- surf_action_ = host_model->io_stream(host_, disk_, dst_host_, dst_disk_, size_);
+ model_action_ = host_model->io_stream(host_, disk_, dst_host_, dst_disk_, size_);
}
- surf_action_->set_activity(this);
- set_start_time(surf_action_->get_start_time());
+ model_action_->set_activity(this);
+ set_start_time(model_action_->get_start_time());
XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
void IoImpl::post()
{
- performed_ioops_ = surf_action_->get_cost();
- if (surf_action_->get_state() == resource::Action::State::FAILED) {
+ performed_ioops_ = model_action_->get_cost();
+ if (model_action_->get_state() == resource::Action::State::FAILED) {
if (host_ && dst_host_) { // this is an I/O stream
if (not host_->is_on())
set_state(State::SRC_HOST_FAILURE);
else
set_state(State::CANCELED);
} else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED &&
- surf_action_->get_remains() > 0.0) {
- surf_action_->set_state(resource::Action::State::FAILED);
+ model_action_->get_remains() > 0.0) {
+ model_action_->set_state(resource::Action::State::FAILED);
set_state(State::TIMEOUT);
} else {
set_state(State::DONE);
bool test(actor::ActorImpl* issuer = nullptr) override;
void wait_for(actor::ActorImpl* issuer, double timeout) override;
void post() override
- { /*no surf action*/
+ { /* no model action */
}
void finish() override;
void set_exception(actor::ActorImpl* issuer) override
if (granted_) {
post();
} else if (timeout > 0) {
- surf_action_ = get_issuer()->get_host()->get_cpu()->sleep(timeout);
- surf_action_->set_activity(this);
+ model_action_ = get_issuer()->get_host()->get_cpu()->sleep(timeout);
+ model_action_->set_activity(this);
} else {
// Already in the queue
actor::Simcall* simcall = simcalls_.front();
simcalls_.pop_front();
- if (surf_action_ != nullptr) { // A timeout was declared
- if (surf_action_->get_state() == resource::Action::State::FINISHED) { // The timeout elapsed
+ if (model_action_ != nullptr) { // A timeout was declared
+ if (model_action_->get_state() == resource::Action::State::FINISHED) { // The timeout elapsed
if (granted_) { // but we got the semaphore, just in time!
set_state(State::DONE);
observer->set_result(true);
}
}
- surf_action_->unref();
- surf_action_ = nullptr;
+ model_action_->unref();
+ model_action_ = nullptr;
}
simcall->issuer_->waiting_synchro_ = nullptr;
SleepImpl* SleepImpl::start()
{
- surf_action_ = host_->get_cpu()->sleep(duration_);
- surf_action_->set_activity(this);
+ model_action_ = host_->get_cpu()->sleep(duration_);
+ model_action_->set_activity(this);
XBT_DEBUG("Create sleep synchronization %p", this);
return this;
}
void SleepImpl::post()
{
- if (surf_action_->get_state() == resource::Action::State::FAILED) {
+ if (model_action_->get_state() == resource::Action::State::FAILED) {
if (host_ && not host_->is_on())
set_state(State::SRC_HOST_FAILURE);
else
set_state(State::CANCELED);
- } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
+ } else if (model_action_->get_state() == resource::Action::State::FINISHED) {
set_state(State::DONE);
}
SynchroImpl* SynchroImpl::start()
{
- surf_action_ = host_->get_cpu()->sleep(timeout_);
- surf_action_->set_activity(this);
+ model_action_ = host_->get_cpu()->sleep(timeout_);
+ model_action_->set_activity(this);
return this;
}
void SynchroImpl::post()
{
- if (surf_action_->get_state() == resource::Action::State::FAILED)
+ if (model_action_->get_state() == resource::Action::State::FAILED)
set_state(State::FAILED);
- else if (surf_action_->get_state() == resource::Action::State::FINISHED)
+ else if (model_action_->get_state() == resource::Action::State::FINISHED)
set_state(State::SRC_TIMEOUT);
clean_action();
{
activity::ActivityImplPtr sleep_activity = this->sleep(timeout);
if (actor->wannadie() || actor->to_be_freed()) {
- if (sleep_activity->surf_action_)
- sleep_activity->surf_action_->finish(resource::Action::State::FINISHED);
+ if (sleep_activity->model_action_)
+ sleep_activity->model_action_->finish(resource::Action::State::FINISHED);
} else {
actor->on_exit->emplace_back([sleep_activity](bool) {
- if (sleep_activity->surf_action_)
- sleep_activity->surf_action_->finish(resource::Action::State::FINISHED);
+ if (sleep_activity->model_action_)
+ sleep_activity->model_action_->finish(resource::Action::State::FINISHED);
});
}
return sleep_activity;
void WifiLinkImpl::update_bw_comm_start(const kernel::activity::CommImpl& comm)
{
- auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(comm.surf_action_);
+ auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(comm.model_action_);
if (actionWifi == nullptr)
return;
void NetworkIBModel::IB_comm_start_callback(const activity::CommImpl& comm)
{
- auto* action = static_cast<NetworkAction*>(comm.surf_action_);
+ auto* action = static_cast<NetworkAction*>(comm.model_action_);
auto* ibModel = static_cast<NetworkIBModel*>(action->get_model());
auto* act_src = &ibModel->active_nodes.at(action->get_src().get_name());
auto* act_dst = &ibModel->active_nodes.at(action->get_dst().get_name());
// FIXME I think that this fires at the same time for all hosts, so when the src sends something,
// the dst will be notified even though it didn't even arrive at the recv yet
kernel::activity::CommImpl::on_start.connect([this](const kernel::activity::CommImpl& comm) {
- const auto* act = static_cast<kernel::resource::NetworkAction*>(comm.surf_action_);
+ const auto* act = static_cast<kernel::resource::NetworkAction*>(comm.model_action_);
if ((get_host() == &act->get_src() || get_host() == &act->get_dst()) && iteration_running) {
post_task();
}
while (iter != end(current_activities)) {
auto& activity = iter->first; // Just an alias
auto& remaining_cost_after_last_update = iter->second; // Just an alias
- auto& action = activity->surf_action_;
+ auto& action = activity->model_action_;
auto current_iter = iter;
++iter;
double Exec::get_cost() const
{
- return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_cost();
+ return (pimpl_->model_action_ == nullptr) ? -1 : pimpl_->model_action_->get_cost();
}
double Exec::get_remaining() const