}
private:
- Host* host_ = nullptr;
- double flops_amount_ = 0.0;
- double priority_ = 1.0;
- double bound_ = 0.0;
- std::string name_ = "";
+ Host* host_ = nullptr;
+ double flops_amount_ = 0.0;
+ double priority_ = 1.0;
+ double bound_ = 0.0;
+ std::string name_ = "";
+ std::string tracing_category_ = "";
std::atomic_int_fast32_t refcount_{0};
}; // class
}
/******************************* Host simcalls ********************************/
#ifdef __cplusplus
-XBT_PUBLIC smx_activity_t simcall_execution_start(std::string name, double flops_amount, double priority, double bound,
- sg_host_t host);
+XBT_PUBLIC smx_activity_t simcall_execution_start(std::string name, std::string category, double flops_amount,
+ double priority, double bound, sg_host_t host);
XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list,
double* flops_amount, double* bytes_amount, double rate,
double timeout);
task->name ?: "", simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
simdata->bytes_parallel_amount, -1.0, timeout));
XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get());
+ if (task->category != nullptr)
+ simcall_set_category(simdata->compute, task->category);
} else {
simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
- simcall_execution_start(task->name ?: "", simdata->flops_amount, simdata->priority, simdata->bound,
- MSG_process_get_host(MSG_process_self())));
+ simcall_execution_start(task->name ?: "", task->category ?: "", simdata->flops_amount, simdata->priority,
+ simdata->bound, MSG_process_get_host(MSG_process_self())));
}
- if (task->category != nullptr)
- simcall_set_category(simdata->compute, task->category);
+
comp_state = simcall_execution_wait(simdata->compute);
simdata->setNotUsed();
Activity* Exec::start()
{
- pimpl_ = simcall_execution_start(name_, flops_amount_, 1. / priority_, bound_, host_);
+ pimpl_ = simcall_execution_start(name_, tracing_category_, flops_amount_, 1. / priority_, bound_, host_);
state_ = State::STARTED;
return this;
}
ExecPtr Exec::set_tracing_category(std::string category)
{
- if (category.empty())
- return this;
-
- simgrid::simix::simcall([this, category] {
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->set_category(category);
- });
+ xbt_assert(state_ == State::INITED, "Cannot change the tracing category of an exec after its start");
+ tracing_category_ = category;
return this;
}
}
void Host::execute(double flops, double priority)
{
- smx_activity_t s = simcall_execution_start("", flops, 1 / priority /*priority*/, 0. /*bound*/, this);
+ smx_activity_t s = simcall_execution_start("", "", flops, 1 / priority /*priority*/, 0. /*bound*/, this);
simcall_execution_wait(s);
}
return nullptr;
} else {
- return SIMIX_execution_start("suspend", 0.0, 1.0, 0.0, this->host_);
+ return SIMIX_execution_start("suspend", "", 0.0, 1.0, 0.0, this->host_);
}
}
* @param host host where the synchro will be executed
* @return A new SIMIX execution synchronization
*/
-smx_activity_t simcall_execution_start(std::string name, double flops_amount, double priority, double bound,
- simgrid::s4u::Host* host)
+smx_activity_t simcall_execution_start(std::string name, std::string category, double flops_amount, double priority,
+ double bound, simgrid::s4u::Host* host)
{
/* checking for infinite values */
xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
xbt_assert(std::isfinite(priority), "priority is not finite!");
- return simgrid::simix::simcall([name, flops_amount, priority, bound, host] {
- return SIMIX_execution_start(name, flops_amount, priority, bound, host);
+ return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
+ return SIMIX_execution_start(name, category, flops_amount, priority, bound, host);
});
}
process_list.clear();
}
-boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
-SIMIX_execution_start(std::string name, double flops_amount, double priority, double bound, sg_host_t host)
+boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> SIMIX_execution_start(std::string name, std::string category,
+ double flops_amount, double priority,
+ double bound, sg_host_t host)
{
/* set surf's action */
simgrid::kernel::resource::Action* surf_action = nullptr;
simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
new simgrid::kernel::activity::ExecImpl(name, surf_action, /*timeout_detector*/ nullptr, host));
+ exec->set_category(name);
XBT_DEBUG("Create execute synchro %p: %s", exec.get(), exec->name_.c_str());
simgrid::kernel::activity::ExecImpl::on_creation(exec);
XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, std::string category);
XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
-SIMIX_execution_start(std::string name, double flops_amount, double priority, double bound, sg_host_t host);
+SIMIX_execution_start(std::string name, std::string category, double flops_amount, double priority, double bound,
+ sg_host_t host);
XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
SIMIX_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list, double* flops_amount,
double* bytes_amount, double rate, double timeout);
void smpi_execute_flops(double flops) {
xbt_assert(flops >= 0, "You're trying to execute a negative amount of flops (%f)!", flops);
XBT_DEBUG("Handle real computation time: %f flops", flops);
- simgrid::s4u::ExecPtr e = simgrid::s4u::this_actor::exec_init(flops)->set_name("computation");
- e->start();
- e->set_tracing_category(TRACE_internal_smpi_get_category());
- e->wait();
+ simgrid::s4u::this_actor::exec_init(flops)
+ ->set_name("computation")
+ ->set_tracing_category(TRACE_internal_smpi_get_category())
+ ->start()
+ ->wait();
smpi_switch_data_segment(simgrid::s4u::Actor::self());
}