{
while (not activity->test()) {
XBT_INFO("activity remaining duration: %g (%.0f%%)", activity->get_remaining(),
- 100 * activity->getRemainingRatio());
+ 100 * activity->get_remaining_ratio());
simgrid::s4u::this_actor::sleep_for(5);
}
XBT_INFO("My task is over.");
Host* get_host();
double get_remaining() override;
- double getRemainingRatio();
+ double get_remaining_ratio();
//////////////// Deprecated functions
XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_priority()") ExecPtr setPriority(double priority)
XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_bound()") ExecPtr setBound(double bound) { return set_bound(bound); }
XBT_ATTRIB_DEPRECATED_v323("Please use Exec::set_host()") ExecPtr setHost(Host* host) { return set_host(host); }
XBT_ATTRIB_DEPRECATED_v323("Please use Exec::get_host()") Host* getHost() { return get_host(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Exec::get_remaining_ratio()") double getRemainingRatio()
+ {
+ return get_remaining_ratio();
+ }
private:
Host* host_ = nullptr;
surfAction_->resume();
}
-double simgrid::kernel::activity::ExecImpl::remains()
+double simgrid::kernel::activity::ExecImpl::get_remaining()
{
xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
"We would need to return a vector instead of a scalar. "
return surfAction_ ? surfAction_->get_remains() : 0;
}
-double simgrid::kernel::activity::ExecImpl::remainingRatio()
+double simgrid::kernel::activity::ExecImpl::get_remaining_ratio()
{
if (host_ == nullptr) // parallel task: their remain is already between 0 and 1 (see comment in ExecImpl::remains())
return surfAction_->get_remains();
return surfAction_->get_remains() / surfAction_->get_cost();
}
-void simgrid::kernel::activity::ExecImpl::setBound(double bound)
+void simgrid::kernel::activity::ExecImpl::set_bound(double bound)
{
if (surfAction_)
surfAction_->set_bound(bound);
void suspend() override;
void resume() override;
void post() override;
- double remains();
- double remainingRatio();
- void setBound(double bound);
+ double get_remaining();
+ double get_remaining_ratio();
+ void set_bound(double bound);
virtual ActivityImpl* migrate(s4u::Host* to);
/* 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;
- kernel::resource::Action* surfAction_ = nullptr; /* The Surf execution action encapsulated */
- kernel::resource::Action* timeoutDetector = nullptr;
+ s4u::Host* host_ = nullptr;
+ resource::Action* surfAction_ = nullptr; /* The Surf execution action encapsulated */
+ 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;
xbt_assert((task != nullptr), "Cannot get information from a nullptr task");
if (task->simdata->compute) {
// Task in progress
- return task->simdata->compute->remainingRatio();
+ return task->simdata->compute->get_remaining_ratio();
} else {
// Task not started (flops_amount is > 0.0) or finished (flops_amount is set to 0.0)
return task->simdata->flops_amount > 0.0 ? 1.0 : 0.0;
*/
double MSG_task_get_flops_amount(msg_task_t task) {
if (task->simdata->compute != nullptr) {
- return task->simdata->compute->remains();
+ return task->simdata->compute->get_remaining();
} else {
// Not started or already done.
// - Before starting, flops_amount is initially the task cost
Activity* Exec::start()
{
pimpl_ = simcall_execution_start(nullptr, flops_amount_, 1. / priority_, 0., host_);
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->setBound(bound_);
+ boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->set_bound(bound_);
state_ = State::started;
return this;
}
return host_;
}
+/** @brief Returns the amount of flops that remain to be done */
double Exec::get_remaining()
{
return simgrid::simix::kernelImmediate(
- [this]() { return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->remains(); });
+ [this]() { return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
}
-double Exec::getRemainingRatio()
+
+/** @brief Returns the ratio of elements that are still to do
+ *
+ * The returned value is between 0 (completely done) and 1 (nothing done yet).
+ */
+double Exec::get_remaining_ratio()
{
- return simgrid::simix::kernelImmediate(
- [this]() { return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->remainingRatio(); });
+ return simgrid::simix::kernelImmediate([this]() {
+ return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_remaining_ratio();
+ });
}
void intrusive_ptr_release(simgrid::s4u::Exec* e)
{
dp_tracking = true;
for (auto const& elm : dp_objs)
- dp_objs[elm.first] = elm.first->remains();
+ dp_objs[elm.first] = elm.first->get_remaining();
}
double VmDirtyPageTrackingExt::computed_flops_lookup()
double total = 0;
for (auto const& elm : dp_objs) {
- total += elm.second - elm.first->remains();
- dp_objs[elm.first] = elm.first->remains();
+ total += elm.second - elm.first->get_remaining();
+ dp_objs[elm.first] = elm.first->get_remaining();
}
total += dp_updated_by_deleted_tasks;
return;
if (vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->is_tracking()) {
- vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->track(exec, exec->remains());
+ vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->track(exec, exec->get_remaining());
} else {
vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->track(exec, 0.0);
}
/* If we are in the middle of dirty page tracking, we record how much computation has been done until now, and keep
* the information for the lookup_() function that will called soon. */
if (vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->is_tracking()) {
- double delta =
- vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->get_stored_remains(exec) - exec->remains();
+ double delta = vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->get_stored_remains(exec) -
+ exec->get_remaining();
vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->update_dirty_page_count(delta);
}
vm->getImpl()->extension<simgrid::vm::VmDirtyPageTrackingExt>()->untrack(exec);