From 982d2df4bf2b7506782681394ab0fb1a89d50fad Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Sat, 21 Jul 2018 15:25:17 +0200 Subject: [PATCH] allow to set a tracing category for an Exec --- include/simgrid/s4u/Exec.hpp | 1 + src/kernel/activity/ExecImpl.cpp | 6 ++++++ src/kernel/activity/ExecImpl.hpp | 1 + src/s4u/s4u_Exec.cpp | 12 ++++++++++++ 4 files changed, 20 insertions(+) diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 6d647ffaad..d4411efd5e 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -32,6 +32,7 @@ public: ExecPtr set_bound(double bound); ExecPtr set_host(Host* host); ExecPtr set_name(std::string name); + ExecPtr set_tracing_category(std::string category); Host* get_host(); double get_remaining() override; diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index dc7dad509e..ea4995d995 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -86,6 +86,12 @@ void simgrid::kernel::activity::ExecImpl::set_priority(double priority) surf_action_->set_priority(priority); } +void simgrid::kernel::activity::ExecImpl::set_category(std::string category) +{ + if (surf_action_) + surf_action_->set_category(category); +} + void simgrid::kernel::activity::ExecImpl::post() { if (host_ && host_->is_off()) { /* FIXME: handle resource failure for parallel tasks too */ diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index 453d4f1bc3..fb5248e682 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -27,6 +27,7 @@ public: double get_remaining_ratio(); void set_bound(double bound); void set_priority(double priority); + void set_category(std::string category); 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) */ diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index d956b76c19..a61217da96 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -96,6 +96,18 @@ ExecPtr Exec::set_name(std::string name) return this; } +ExecPtr Exec::set_tracing_category(std::string category) +{ + xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start"); + if (category.empty()) + return this; + + simgrid::simix::simcall([this, category] { + boost::static_pointer_cast(pimpl_)->set_category(category); + }); + return this; +} + /** @brief Retrieve the host on which this activity takes place. */ Host* Exec::get_host() { -- 2.20.1