From: Martin Quinson Date: Fri, 18 Feb 2022 00:25:50 +0000 (+0100) Subject: Give the comm to {Send,Recv}Transition, as CommDet needs it X-Git-Tag: v3.31~393 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eeaf1624487cd72c4e08db73e10b82e21fe083b3 Give the comm to {Send,Recv}Transition, as CommDet needs it --- diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 98a52224af..842d669957 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -267,7 +267,7 @@ void CommImpl::copy_data() copied_ = true; } -ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer) +ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer) { auto* mbox = observer->get_mailbox(); XBT_DEBUG("send from mailbox %p", mbox); @@ -301,6 +301,7 @@ ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer) other_comm->set_state(State::READY); } + observer->set_comm(other_comm.get()); if (observer->is_detached()) { other_comm->detach(); @@ -329,7 +330,7 @@ ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer) return (observer->is_detached() ? nullptr : other_comm); } -ActivityImplPtr CommImpl::irecv(const actor::CommIrecvSimcall* observer) +ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer) { CommImplPtr this_synchro(new CommImpl(CommImpl::Type::RECEIVE)); auto* mbox = observer->get_mailbox(); @@ -376,6 +377,7 @@ ActivityImplPtr CommImpl::irecv(const actor::CommIrecvSimcall* observer) } observer->get_issuer()->activities_.emplace_back(other_comm); } + observer->set_comm(other_comm.get()); /* Setup communication synchro */ other_comm->dst_actor_ = observer->get_issuer(); diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index 7141785702..3837b6b28f 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -53,8 +53,8 @@ public: std::vector get_traversed_links() const; void copy_data(); - static ActivityImplPtr isend(const actor::CommIsendSimcall* observer); - static ActivityImplPtr irecv(const actor::CommIrecvSimcall* observer); + static ActivityImplPtr isend(actor::CommIsendSimcall* observer); + static ActivityImplPtr irecv(actor::CommIrecvSimcall* observer); bool test(actor::ActorImpl* issuer) override; void wait_for(actor::ActorImpl* issuer, double timeout) override; diff --git a/src/kernel/actor/SimcallObserver.cpp b/src/kernel/actor/SimcallObserver.cpp index 72043367b8..972777850e 100644 --- a/src/kernel/actor/SimcallObserver.cpp +++ b/src/kernel/actor/SimcallObserver.cpp @@ -237,14 +237,14 @@ void ActivityWaitanySimcall::prepare(int times_considered) void CommIsendSimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::COMM_SEND << ' '; - stream << mbox_->get_id() << ' ' << (void*)src_buff_ << ' ' << src_buff_size_; + stream << (void*)comm_ << ' ' << mbox_->get_id() << ' ' << (void*)src_buff_ << ' ' << src_buff_size_; XBT_DEBUG("SendObserver mbox:%u buff:%p size:%zu", mbox_->get_id(), src_buff_, src_buff_size_); } void CommIrecvSimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::COMM_RECV << ' '; - stream << mbox_->get_id() << ' ' << (void*)dst_buff_; + stream << (void*)comm_ << ' ' << mbox_->get_id() << ' ' << (void*)dst_buff_; } } // namespace actor diff --git a/src/kernel/actor/SimcallObserver.hpp b/src/kernel/actor/SimcallObserver.hpp index 98cada2d2d..df8e2851dd 100644 --- a/src/kernel/actor/SimcallObserver.hpp +++ b/src/kernel/actor/SimcallObserver.hpp @@ -217,6 +217,7 @@ class CommIsendSimcall : public SimcallObserver { size_t src_buff_size_; void* payload_; bool detached_; + activity::CommImpl* comm_; bool (*match_fun_)(void*, void*, activity::CommImpl*); void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send @@ -250,6 +251,7 @@ public: size_t get_src_buff_size() const { return src_buff_size_; } void* get_payload() const { return payload_; } bool is_detached() const { return detached_; } + void set_comm(activity::CommImpl* comm) { comm_ = comm; } auto get_match_fun() const { return match_fun_; } auto get_clean_fun() const { return clean_fun_; } @@ -262,6 +264,7 @@ class CommIrecvSimcall : public SimcallObserver { size_t* dst_buff_size_; void* payload_; double rate_; + activity::CommImpl* comm_; bool (*match_fun_)(void*, void*, activity::CommImpl*); void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one @@ -287,6 +290,7 @@ public: unsigned char* get_dst_buff() const { return dst_buff_; } size_t* get_dst_buff_size() const { return dst_buff_size_; } void* get_payload() const { return payload_; } + void set_comm(activity::CommImpl* comm) { comm_ = comm; } auto get_match_fun() const { return match_fun_; }; auto get_copy_data_fun() const { return copy_data_fun_; } diff --git a/src/mc/api/TransitionComm.cpp b/src/mc/api/TransitionComm.cpp index 616599674e..0a846d633f 100644 --- a/src/mc/api/TransitionComm.cpp +++ b/src/mc/api/TransitionComm.cpp @@ -101,7 +101,7 @@ bool CommTestTransition::depends(const Transition* other) const CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_RECV, issuer, times_considered) { - xbt_assert(stream >> mbox_ >> dst_buff_); + xbt_assert(stream >> comm_ >> mbox_ >> dst_buff_); } std::string CommRecvTransition::to_string(bool verbose) const { @@ -150,8 +150,8 @@ bool CommRecvTransition::depends(const Transition* other) const CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_SEND, issuer, times_considered) { - xbt_assert(stream >> mbox_ >> src_buff_ >> size_); - XBT_DEBUG("SendTransition mbox:%u buff:%p size:%zu", mbox_, src_buff_, size_); + xbt_assert(stream >> comm_ >> mbox_ >> src_buff_ >> size_); + XBT_DEBUG("SendTransition comm:%p mbox:%u buff:%p size:%zu", comm_, mbox_, src_buff_, size_); } std::string CommSendTransition::to_string(bool verbose = false) const { diff --git a/src/mc/api/TransitionComm.hpp b/src/mc/api/TransitionComm.hpp index 6f8a7c9ed6..9d4a7481e8 100644 --- a/src/mc/api/TransitionComm.hpp +++ b/src/mc/api/TransitionComm.hpp @@ -56,6 +56,7 @@ public: }; class CommRecvTransition : public Transition { + void* comm_; /* Addr of the CommImpl */ unsigned mbox_; void* dst_buff_; @@ -66,6 +67,7 @@ public: }; class CommSendTransition : public Transition { + void* comm_; /* Addr of the CommImpl */ unsigned mbox_; void* src_buff_; size_t size_;