namespace kernel {
namespace activity {
-ExecImpl::ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, s4u::Host* host)
- : ActivityImpl(std::move(name)), host_(host), timeout_detector_(timeout_detector)
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host)
+ : ActivityImpl(std::move(name)), host_(host)
{
this->state_ = SIMIX_RUNNING;
this->set_category(std::move(tracing_category));
- if (timeout_detector != nullptr)
- timeout_detector_->set_data(this);
+ XBT_DEBUG("Create exec %p", this);
+}
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout)
+ : ExecImpl(std::move(name), std::move(tracing_category), nullptr)
+{
+ if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
+ timeout_detector_ = host->pimpl_cpu->sleep(timeout);
+ timeout_detector_->set_data(this);
+ }
XBT_DEBUG("Create exec %p", this);
}
~ExecImpl() override;
public:
- explicit ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector,
- s4u::Host* host);
+ explicit ExecImpl(std::string name, std::string tracing_category, s4u::Host* host);
+ explicit ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout);
ExecImpl* start(double flops_amount, double priority, double bound);
void cancel();
void post() override;
sg_host_t host = MSG_process_get_host(MSG_process_self());
simdata->compute = simgrid::simix::simcall([task, host] {
return simgrid::kernel::activity::ExecImplPtr(
- new simgrid::kernel::activity::ExecImpl(task->name ?: "", task->category ?: "",
- /*timeout_detector*/ nullptr, host));
+ new simgrid::kernel::activity::ExecImpl(task->name ?: "", task->category ?: "", host));
});
/* checking for infinite values */
xbt_assert(std::isfinite(simdata->flops_amount), "flops_amount is not finite!");
{
Activity::set_remaining(flops_amount_);
pimpl_ = simix::simcall([this] {
- return kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl(name_, tracing_category_,
- /*timeout_detector*/ nullptr, host_));
+ return kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl(name_, tracing_category_, host_));
});
}
return nullptr;
} else {
- return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", nullptr, this->host_))->start(0.0, 1.0, 0.0);
+ return activity::ExecImplPtr(new activity::ExecImpl("suspend", "", this->host_))->start(0.0, 1.0, 0.0);
}
}
const double* flops_amount, const double* bytes_amount, double rate,
double timeout)
{
+ /* Check that we are not mixing VMs and PMs in the parallel task */
+ bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[0]));
+ for (int i = 1; i < host_nb; i++) {
+ bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[i]));
+ xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
+ }
+
/* checking for infinite values */
for (int i = 0 ; i < host_nb ; ++i) {
if (flops_amount != nullptr)
{
return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
return simgrid::kernel::activity::ExecImplPtr(
- new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category), nullptr, host))
+ new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category), host))
->start(flops_amount, priority, bound);
});
}
SIMIX_execution_parallel_start(std::string name, int host_nb, const sg_host_t* host_list, const double* flops_amount,
const double* bytes_amount, double rate, double timeout)
{
-
- /* Check that we are not mixing VMs and PMs in the parallel task */
- bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[0]));
- for (int i = 1; i < host_nb; i++) {
- bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[i]));
- xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
- }
+ simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
+ new simgrid::kernel::activity::ExecImpl(std::move(name), "", host_list[0], timeout));
/* set surf's synchro */
- simgrid::kernel::resource::Action* surf_action = nullptr;
- simgrid::kernel::resource::Action* timeout_detector = nullptr;
if (not MC_is_active() && not MC_record_replay_is_active()) {
- surf_action = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate);
- if (timeout > 0) {
- timeout_detector = host_list[0]->pimpl_cpu->sleep(timeout);
+ exec->surf_action_ = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate);
+ if (exec->surf_action_ != nullptr) {
+ exec->surf_action_->set_data(exec.get());
}
}
- simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
- new simgrid::kernel::activity::ExecImpl(std::move(name), "", timeout_detector, nullptr));
- if (surf_action != nullptr) {
- exec->surf_action_ = surf_action;
- exec->surf_action_->set_data(exec.get());
- }
XBT_DEBUG("Create parallel execute synchro %p", exec.get());
return exec;