X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/989e6d7e4cb105760aff9acce9ac2d26de2f793d..3f9b311ec56db95ec539001a860ae3c838c48312:/src/kernel/actor/CommObserver.cpp diff --git a/src/kernel/actor/CommObserver.cpp b/src/kernel/actor/CommObserver.cpp index 5022bdaae3..a7257d780d 100644 --- a/src/kernel/actor/CommObserver.cpp +++ b/src/kernel/actor/CommObserver.cpp @@ -6,6 +6,7 @@ #include "simgrid/s4u/Host.hpp" #include "src/kernel/activity/CommImpl.hpp" #include "src/kernel/activity/MailboxImpl.hpp" +#include "src/kernel/activity/MessageQueueImpl.hpp" #include "src/kernel/actor/ActorImpl.hpp" #include "src/kernel/actor/SimcallObserver.hpp" #include "src/mc/mc_config.hpp" @@ -17,7 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(obs_comm, mc_observer, "Logging specific to the namespace simgrid::kernel::actor { ActivityTestanySimcall::ActivityTestanySimcall(ActorImpl* actor, const std::vector& activities, - std::string fun_call) + std::string_view fun_call) : ResultingSimcall(actor, -1), activities_(activities), fun_call_(fun_call) { indexes_.clear(); @@ -39,7 +40,8 @@ void ActivityTestanySimcall::prepare(int times_considered) else next_value_ = -1; } -static void serialize_activity_test(const activity::ActivityImpl* act, std::stringstream& stream) +static void serialize_activity_test(const activity::ActivityImpl* act, std::string const& call_location, + std::stringstream& stream) { if (const auto* comm = dynamic_cast(act)) { stream << " " << (short)mc::Transition::Type::COMM_TEST; @@ -47,6 +49,7 @@ static void serialize_activity_test(const activity::ActivityImpl* act, std::stri stream << ' ' << (comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1); stream << ' ' << (comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1); stream << ' ' << comm->get_mailbox_id(); + stream << ' ' << call_location; } else { stream << (short)mc::Transition::Type::UNKNOWN; XBT_CRITICAL("Unknown transition in a test any. Bad things may happen"); @@ -58,16 +61,18 @@ static std::string to_string_activity_test(const activity::ActivityImpl* act) return "CommTest(comm_id:" + std::to_string(comm->get_id()) + " src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) + " dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) + - " mbox:" + std::to_string(comm->get_mailbox_id()); + " mbox:" + std::to_string(comm->get_mailbox_id()) + ")"; } else { return "TestUnknownType()"; } } void ActivityTestanySimcall::serialize(std::stringstream& stream) const { + XBT_DEBUG("Serialize %s", to_string().c_str()); stream << (short)mc::Transition::Type::TESTANY << ' ' << activities_.size() << ' '; for (auto const* act : activities_) { - serialize_activity_test(act, stream); + // fun_call of each activity embedded in the TestAny is not known, so let's use the location of the TestAny itself + serialize_activity_test(act, fun_call_, stream); stream << ' '; } stream << fun_call_; @@ -75,22 +80,28 @@ void ActivityTestanySimcall::serialize(std::stringstream& stream) const std::string ActivityTestanySimcall::to_string() const { std::stringstream buffer("TestAny("); + bool first = true; for (auto const* act : activities_) { + if (first) + first = false; + else + buffer << " | "; buffer << to_string_activity_test(act); } + buffer << ")"; return buffer.str(); } void ActivityTestSimcall::serialize(std::stringstream& stream) const { - serialize_activity_test(activity_, stream); - stream << ' ' << fun_call_; + serialize_activity_test(activity_, fun_call_, stream); } std::string ActivityTestSimcall::to_string() const { return to_string_activity_test(activity_); } -static void serialize_activity_wait(const activity::ActivityImpl* act, bool timeout, std::stringstream& stream) +static void serialize_activity_wait(const activity::ActivityImpl* act, bool timeout, std::string const& call_location, + std::stringstream& stream) { if (const auto* comm = dynamic_cast(act)) { stream << (short)mc::Transition::Type::COMM_WAIT << ' '; @@ -99,6 +110,7 @@ static void serialize_activity_wait(const activity::ActivityImpl* act, bool time stream << ' ' << (comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1); stream << ' ' << (comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1); stream << ' ' << comm->get_mailbox_id(); + stream << ' ' << call_location; } else { stream << (short)mc::Transition::Type::UNKNOWN; } @@ -118,14 +130,15 @@ static std::string to_string_activity_wait(const activity::ActivityImpl* act) void ActivityWaitSimcall::serialize(std::stringstream& stream) const { - serialize_activity_wait(activity_, timeout_ > 0, stream); - stream << ' ' << fun_call_; + serialize_activity_wait(activity_, timeout_ > 0, fun_call_, stream); } void ActivityWaitanySimcall::serialize(std::stringstream& stream) const { + XBT_DEBUG("Serialize %s", to_string().c_str()); stream << (short)mc::Transition::Type::WAITANY << ' ' << activities_.size() << ' '; for (auto const* act : activities_) { - serialize_activity_wait(act, timeout_ > 0, stream); + // fun_call of each activity embedded in the WaitAny is not known, so let's use the location of the WaitAny itself + serialize_activity_wait(act, timeout_ > 0, fun_call_, stream); stream << ' '; } stream << fun_call_; @@ -137,13 +150,19 @@ std::string ActivityWaitSimcall::to_string() const std::string ActivityWaitanySimcall::to_string() const { std::stringstream buffer("WaitAny("); + bool first = true; for (auto const* act : activities_) { - buffer << to_string_activity_wait(act); + if (first) + first = false; + else + buffer << " | "; + buffer << to_string_activity_test(act); } + buffer << ")"; return buffer.str(); } ActivityWaitanySimcall::ActivityWaitanySimcall(ActorImpl* actor, const std::vector& activities, - double timeout, std::string fun_call) + double timeout, std::string_view fun_call) : ResultingSimcall(actor, -1), activities_(activities), timeout_(timeout), fun_call_(fun_call) { // list all the activities that are ready @@ -203,8 +222,8 @@ void CommIsendSimcall::serialize(std::stringstream& stream) const } std::string CommIsendSimcall::to_string() const { - return "CommAsyncSend(comm_id: " + std::to_string(comm_->get_id()) + " mbox:" + std::to_string(mbox_->get_id()) + - " tag: " + std::to_string(tag_) + ")"; + return "CommAsyncSend(comm_id: " + std::to_string(comm_ ? comm_->get_id() : 0) + + " mbox:" + std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; } void CommIrecvSimcall::serialize(std::stringstream& stream) const @@ -215,10 +234,35 @@ void CommIrecvSimcall::serialize(std::stringstream& stream) const XBT_DEBUG("RecvObserver comm:%p mbox:%u tag:%d", comm_, mbox_->get_id(), tag_); stream << ' ' << fun_call_; } + std::string CommIrecvSimcall::to_string() const { - return "CommAsyncRecv(comm_id: " + std::to_string(comm_->get_id()) + " mbox:" + std::to_string(mbox_->get_id()) + - " tag: " + std::to_string(tag_) + ")"; + return "CommAsyncRecv(comm_id: " + std::to_string(comm_ ? comm_->get_id() : 0) + + " mbox:" + std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; +} + +void MessIputSimcall::serialize(std::stringstream& stream) const +{ + stream << mess_ << ' ' << queue_; + XBT_DEBUG("PutObserver mess:%p queue:%p", mess_, queue_); +} + +std::string MessIputSimcall::to_string() const +{ + return "MessAsyncPut(queue:" + queue_->get_name() + ")"; } +void MessIgetSimcall::serialize(std::stringstream& stream) const +{ + stream << mess_ << ' ' << queue_; + XBT_DEBUG("GettObserver mess:%p queue:%p", mess_, queue_); +} + +std::string MessIgetSimcall::to_string() const +{ + return "MessAsyncGet(queue:" + queue_->get_name() + ")"; +} + + + } // namespace simgrid::kernel::actor