From 964924f05516c25accb7be21f22a5aa022a4e985 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 18 Feb 2022 20:53:18 +0100 Subject: [PATCH] Add the MPI tag to the Send/Recv Transitions --- src/kernel/actor/SimcallObserver.cpp | 10 ++++++---- src/kernel/actor/SimcallObserver.hpp | 4 ++++ src/mc/api/TransitionComm.cpp | 4 ++-- src/mc/api/TransitionComm.hpp | 6 ++++++ .../checker/CommunicationDeterminismChecker.cpp | 15 ++++----------- src/smpi/mpi/smpi_request.cpp | 2 ++ 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/kernel/actor/SimcallObserver.cpp b/src/kernel/actor/SimcallObserver.cpp index f869507c92..6da0ea5f98 100644 --- a/src/kernel/actor/SimcallObserver.cpp +++ b/src/kernel/actor/SimcallObserver.cpp @@ -237,15 +237,17 @@ void ActivityWaitanySimcall::prepare(int times_considered) void CommIsendSimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::COMM_SEND << ' '; - stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' ' << src_buff_size_; - XBT_DEBUG("SendObserver comm:%p mbox:%u buff:%p size:%zu", comm_, mbox_->get_id(), src_buff_, src_buff_size_); + stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' ' << src_buff_size_ << ' ' + << tag_; + XBT_DEBUG("SendObserver comm:%p mbox:%u buff:%p size:%zu tag:%d", comm_, mbox_->get_id(), src_buff_, src_buff_size_, + tag_); } void CommIrecvSimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::COMM_RECV << ' '; - stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_; - XBT_DEBUG("RecvObserver comm:%p mbox:%u buff:%p", comm_, mbox_->get_id(), dst_buff_); + stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_ << ' ' << tag_; + XBT_DEBUG("RecvObserver comm:%p mbox:%u buff:%p tag:%d", comm_, mbox_->get_id(), dst_buff_, tag_); } } // namespace actor diff --git a/src/kernel/actor/SimcallObserver.hpp b/src/kernel/actor/SimcallObserver.hpp index df8e2851dd..23086f87a7 100644 --- a/src/kernel/actor/SimcallObserver.hpp +++ b/src/kernel/actor/SimcallObserver.hpp @@ -218,6 +218,7 @@ class CommIsendSimcall : public SimcallObserver { void* payload_; bool detached_; activity::CommImpl* comm_; + int tag_; bool (*match_fun_)(void*, void*, activity::CommImpl*); void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send @@ -252,6 +253,7 @@ public: void* get_payload() const { return payload_; } bool is_detached() const { return detached_; } void set_comm(activity::CommImpl* comm) { comm_ = comm; } + void set_tag(int tag) { tag_ = tag; } auto get_match_fun() const { return match_fun_; } auto get_clean_fun() const { return clean_fun_; } @@ -264,6 +266,7 @@ class CommIrecvSimcall : public SimcallObserver { size_t* dst_buff_size_; void* payload_; double rate_; + int tag_; activity::CommImpl* comm_; bool (*match_fun_)(void*, void*, activity::CommImpl*); @@ -291,6 +294,7 @@ public: 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; } + void set_tag(int tag) { tag_ = tag; } 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 13094fbdf8..cab3f10303 100644 --- a/src/mc/api/TransitionComm.cpp +++ b/src/mc/api/TransitionComm.cpp @@ -103,7 +103,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 >> comm_ >> mbox_ >> rbuff_); + xbt_assert(stream >> comm_ >> mbox_ >> rbuff_ >> tag_); } std::string CommRecvTransition::to_string(bool verbose) const { @@ -152,7 +152,7 @@ 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 >> comm_ >> mbox_ >> sbuff_ >> size_); + xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_ >> tag_); XBT_DEBUG("SendTransition comm:%" PRIxPTR " mbox:%u sbuff:%" PRIxPTR " size:%zu", comm_, mbox_, sbuff_, 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 7b7fbf44f9..2c244f6852 100644 --- a/src/mc/api/TransitionComm.hpp +++ b/src/mc/api/TransitionComm.hpp @@ -90,6 +90,7 @@ class CommRecvTransition : public Transition { uintptr_t comm_; /* Addr of the CommImpl */ unsigned mbox_; uintptr_t rbuff_; + int tag_; public: CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream); @@ -102,6 +103,8 @@ public: unsigned get_mailbox() const { return mbox_; } /** Receiver buffer */ uintptr_t get_rbuff() const { return rbuff_; } + /** If using SMPI, the tag */ + int get_tag() const { return tag_; } }; class CommSendTransition : public Transition { @@ -109,6 +112,7 @@ class CommSendTransition : public Transition { unsigned mbox_; uintptr_t sbuff_; size_t size_; + int tag_; public: CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream); @@ -123,6 +127,8 @@ public: uintptr_t get_sbuff() const { return sbuff_; } /** data size */ size_t get_size() const { return size_; } + /** If using SMPI, the tag */ + int get_tag() const { return tag_; } }; class TestAnyTransition : public Transition { diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 50f2d68dfe..e0d25a5137 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -46,11 +46,10 @@ public: // num? res.comm_addr = this->comm_addr; res.type = this->type; - // src_proc? - // dst_proc? + res.src_proc = this->src_proc; res.dst_proc = this->dst_proc; res.mbox = this->mbox; - // tag? + res.tag = this->tag; res.index = this->index; return res; } @@ -253,10 +252,7 @@ void CommDetExtension::get_comm_pattern(const Transition* transition, bool backt pattern->comm_addr = send->get_comm(); pattern->mbox = send->get_mailbox(); pattern->src_proc = send->aid_; - -#if HAVE_SMPI - pattern->tag = 0; // FIXME: replace it by the real tag from the observer -#endif + pattern->tag = send->get_tag(); #if HAVE_SMPI // auto send_detached = api::get().check_send_request_detached(request); @@ -277,10 +273,7 @@ void CommDetExtension::get_comm_pattern(const Transition* transition, bool backt pattern->type = PatternCommunicationType::receive; pattern->comm_addr = recv->get_comm(); - -#if HAVE_SMPI - pattern->tag = 0; // FIXME: replace it by the real tag from the observer -#endif + pattern->tag = recv->get_tag(); pattern->mbox = recv->get_mailbox(); pattern->dst_proc = recv->aid_; } diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index b690a145a2..e8ab078064 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -519,6 +519,7 @@ void Request::start() : smpi_comm_copy_data_callback, this, -1.0}; + observer.set_tag(tag_); action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::irecv(&observer); }, &observer); @@ -624,6 +625,7 @@ void Request::start() process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, // detach if msg size < eager/rdv switch limit detached_}; + observer.set_tag(tag_); action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::isend(&observer); }, &observer); XBT_DEBUG("send simcall posted"); -- 2.20.1