From: Frederic Suter Date: Wed, 25 Jul 2018 14:00:38 +0000 (+0200) Subject: changing the way the tracing category is passed to ExecImpl X-Git-Tag: v3_21~355^2~29 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4713af90ef9c023d84da321abc1f387d195b8d48 changing the way the tracing category is passed to ExecImpl the former version implied to set the category AFTER the start() because the ExecImpl had to exist. It was against the idea of "do all the sets and then starts". Now, the category is set at user level and then passed to the Impl within the start simcall. Setting a category after the start is now forbidden. --- diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index d4411efd5e..9616bfe2c5 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -57,11 +57,12 @@ public: } 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 } diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index ea767d0a40..4f5047b54c 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -191,8 +191,8 @@ XBT_PUBLIC void SIMIX_comm_finish(smx_activity_t synchro); /******************************* 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); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 62bed03094..84d1c06fc2 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -65,13 +65,14 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo 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( - 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(); diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 4d6ec06a6d..dc9c7a91aa 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -15,7 +15,7 @@ namespace s4u { 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; } @@ -98,12 +98,8 @@ ExecPtr Exec::set_name(std::string name) ExecPtr Exec::set_tracing_category(std::string category) { - if (category.empty()) - return this; - - simgrid::simix::simcall([this, category] { - boost::static_pointer_cast(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; } diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index ceed115d6a..77ab45f7a5 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -289,7 +289,7 @@ void Host::execute(double flops) } 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); } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 2970aa7b08..6aa8dfa211 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -202,7 +202,7 @@ smx_activity_t ActorImpl::suspend(ActorImpl* issuer) 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_); } } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index cab0bf8335..51b08fa8fc 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -38,15 +38,15 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); * @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); }); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index f9bbc488a8..91da469fe9 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -60,8 +60,9 @@ void SIMIX_host_autorestart(sg_host_t host) process_list.clear(); } -boost::intrusive_ptr -SIMIX_execution_start(std::string name, double flops_amount, double priority, double bound, sg_host_t host) +boost::intrusive_ptr 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; @@ -75,6 +76,7 @@ SIMIX_execution_start(std::string name, double flops_amount, double priority, do 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); diff --git a/src/simix/smx_host_private.hpp b/src/simix/smx_host_private.hpp index 91f84ab04a..22aec6d730 100644 --- a/src/simix/smx_host_private.hpp +++ b/src/simix/smx_host_private.hpp @@ -18,7 +18,8 @@ XBT_PRIVATE void SIMIX_execution_finish(smx_activity_t synchro); XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, std::string category); XBT_PRIVATE boost::intrusive_ptr -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 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); diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index bc55483695..85191c7329 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -49,10 +49,11 @@ void smpi_execute_(double *duration) 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()); }